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

2015-07-10 Thread Richard Earnshaw
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,

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

2015-07-10 Thread Segher Boessenkool
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

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

2015-07-10 Thread Richard Earnshaw
On 10/07/15 16:00, pins...@gmail.com wrote: On Jul 10, 2015, at 7:13 AM, Richard Earnshaw richard.earns...@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

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

2015-07-10 Thread Richard Earnshaw
On 10/07/15 16:16, Richard Earnshaw wrote: On 10/07/15 16:00, pins...@gmail.com wrote: On Jul 10, 2015, at 7:13 AM, Richard Earnshaw richard.earns...@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

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

2015-07-10 Thread Richard Earnshaw
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

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

2015-07-10 Thread pinskia
On Jul 10, 2015, at 7:13 AM, Richard Earnshaw richard.earns...@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

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

2015-07-08 Thread Martin Jambor
Hi, On Tue, Jul 07, 2015 at 01:44:15PM -0500, Segher Boessenkool wrote: On Tue, Jul 07, 2015 at 07:53:49PM +0200, Martin Jambor wrote: I've been asked to look into the item one of http://permalink.gmane.org/gmane.linux.kernel/1990397 and found out that at least shrink-wrapping happily

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

2015-07-08 Thread Segher Boessenkool
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)); snip Well, I only have had a quick look at where things go wrong and have not spent much time thinking about

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

2015-07-08 Thread Martin Jambor
On Tue, Jul 07, 2015 at 02:25:34PM -0600, Jeff Law wrote: On 07/07/2015 11:53 AM, Martin Jambor wrote: Hi, I've been asked to look into the item one of http://permalink.gmane.org/gmane.linux.kernel/1990397 and found out that at least shrink-wrapping happily moves prologue past an asm

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

2015-07-08 Thread Josh Poimboeuf
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)); snip Well, I only have had a quick look

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

2015-07-08 Thread Segher Boessenkool
On Wed, Jul 08, 2015 at 11:22:34AM -0500, Josh Poimboeuf wrote: Writing the asm with a clobber of the stack pointer causes all stack accesses to go via the frame pointer, which causes pretty horrible code. As far as I can tell, most (but not all) kernel stack accesses already occur via

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

2015-07-08 Thread Josh Poimboeuf
On Wed, Jul 08, 2015 at 11:37:35AM -0500, Segher Boessenkool wrote: On Wed, Jul 08, 2015 at 11:22:34AM -0500, Josh Poimboeuf wrote: Writing the asm with a clobber of the stack pointer causes all stack accesses to go via the frame pointer, which causes pretty horrible code. As far as

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

2015-07-08 Thread Josh Poimboeuf
On Wed, Jul 08, 2015 at 04:14:20PM -0500, Segher Boessenkool wrote: On Wed, Jul 08, 2015 at 03:51:12PM -0500, Josh Poimboeuf 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

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

2015-07-08 Thread Josh Poimboeuf
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);

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

2015-07-08 Thread Segher Boessenkool
On Wed, Jul 08, 2015 at 03:51:12PM -0500, Josh Poimboeuf 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

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

2015-07-08 Thread Jeff Law
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

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

2015-07-08 Thread Segher Boessenkool
On Wed, Jul 08, 2015 at 03:15:12PM -0600, Jeff Law 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

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

2015-07-07 Thread Martin Jambor
Hi, I've been asked to look into the item one of http://permalink.gmane.org/gmane.linux.kernel/1990397 and found out that at least shrink-wrapping happily moves prologue past an asm statement which can be bad if the asm statement contains a call instruction. Am I right concluding that this is a

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

2015-07-07 Thread Segher Boessenkool
On Tue, Jul 07, 2015 at 07:53:49PM +0200, Martin Jambor wrote: I've been asked to look into the item one of http://permalink.gmane.org/gmane.linux.kernel/1990397 and found out that at least shrink-wrapping happily moves prologue past an asm statement which can be bad if the asm statement

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

2015-07-07 Thread Jeff Law
On 07/07/2015 11:53 AM, Martin Jambor wrote: Hi, I've been asked to look into the item one of http://permalink.gmane.org/gmane.linux.kernel/1990397 and found out that at least shrink-wrapping happily moves prologue past an asm statement which can be bad if the asm statement contains a call