This is the mail archive of the
mailing list for the GCC project.
Re: Can shrink-wrapping ever move prologue past an ASM statement?
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Josh Poimboeuf <jpoimboe at redhat dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>, Vojtech Pavlik <vojtech at suse dot cz>
- Date: Wed, 8 Jul 2015 16:14:20 -0500
- Subject: Re: Can shrink-wrapping ever move prologue past an ASM statement?
- Authentication-results: sourceware.org; auth=none
- References: <20150707175349 dot GA2325 at virgil dot suse dot cz> <20150707184415 dot GB13004 at gate dot crashing dot org> <20150708092309 dot GB2325 at virgil dot suse dot cz> <20150708103631 dot GA23975 at gate dot crashing dot org> <20150708162234 dot GB4687 at treble dot redhat dot com> <20150708205111 dot GD4687 at treble dot redhat dot com>
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).