Can shrink-wrapping ever move prologue past an ASM statement?
Richard Earnshaw
Richard.Earnshaw@foss.arm.com
Fri Jul 10 15:17:00 GMT 2015
On 10/07/15 16:16, Richard Earnshaw wrote:
> On 10/07/15 16:00, pinskia@gmail.com wrote:
>>
>>
>>
>>
>>> On Jul 10, 2015, at 7:13 AM, Richard Earnshaw <Richard.Earnshaw@foss.arm.com> wrote:
>>>
>>>> On 10/07/15 13:18, Segher Boessenkool wrote:
>>>>> On Fri, Jul 10, 2015 at 10:02:06AM +0100, Richard Earnshaw wrote:
>>>>> 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.
>>>>
>>>> Those archs have a link register, which is clobbered by the call, so
>>>> asm doing a call should have the link register in its clobber list,
>>>> which is enough to prevent shrink-wrapping the asm. Does that also
>>>> help aligning the stack (as a side effect?)
>>>
>>> No. Currently there's no safe way to guarantee that the stack will be
>>> correctly aligned for a call from within an ASM block since the compiler
>>> has no way of detecting that this is necessary.
>>
>> Note aarch64 is not really affected as the architecture also prevents the unaligned stack from happening in that you will get an interrupt if it is unaligned.
>>
>
> Not quite. You'll get an interrupt if SP is used for a *memory
> dereference* while it is unaligned.
>
Oh, and I believe this is a configurable option on at least some cores...
R.
> R.
>
>> Thanks,
>> Andrew
>>
>>
>>>
>>>> The problem you mention is not target-specific, and would also happen
>>>> without shrink-wrapping. Maybe forcing a frame pointer (which they
>>>> do in the reported case) helps? But there certainly could exist ABIs
>>>> where it does not. This is arch-dependent code by nature, but still.
>>>>
>>>> Nastiness :-)
>>>>
>>>>
>>>> Segher
>>>
>
More information about the Gcc
mailing list