This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can shrink-wrapping ever move prologue past an ASM statement?

On 08/07/15 22:15, Jeff Law wrote:
> On 07/08/2015 02:51 PM, Josh Poimboeuf wrote:
>> On Wed, Jul 08, 2015 at 11:22:34AM -0500, Josh Poimboeuf wrote:
>>> On Wed, Jul 08, 2015 at 05:36:31AM -0500, Segher Boessenkool wrote:
>>>> On Wed, Jul 08, 2015 at 11:23:09AM +0200, Martin Jambor wrote:
>>>>>> For other archs, e.g. x86-64, you can do
>>>>>>     register void *sp asm("%sp");
>>>>>>     asm volatile("call func" : "+r"(sp));
>> I've found that putting "sp" in the clobber list also seems to work:
>>    asm volatile("call func" : : : "sp");
>> This syntax is nicer because it doesn't need a local variable associated
>> with the register.  Do you see any issues with this approach?
> Given that SP isn't subject to register allocation, I'd expect it's
> fine.  Note that some folks have (loudly) requested that GCC issue an
> error if an asm tries to clobber sp.
> The call doesn't actually clobber the stack pointer does it?  ISTM that
> a use of sp makes more sense and is better "future proof'd" than
> clobbering sp.
> Jeff

This isn't going to reliably work for ARM or AArch64.  If the only call
within a leaf function is via the ASM the compiler doesn't guarantee to
ensure the stack is aligned to the ABI requirements.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]