This is the mail archive of the gcc@gcc.gnu.org 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 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" : : : "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?

Like I said, that forces the function to have a frame pointer.  That might
not matter for x86 and your application (because you already have a frame
pointer for other reasons).

Clobbering sp in inline asm isn't a terribly sane thing to do (and neither
is writing to it, as in my code above), of course; we don't *actually*
clobber it here (that is, write an unspecified value to it), but still.
Just reading it would be better for your sanity, and is also enough to
prevent shrink-wrapping the asm.

I do believe it should work though, I see no issues with it _that_ way.
You'll have to test and see (it works fine in trivial tests).


Segher


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