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