On Thu, Aug 31, 2017 at 5:21 PM, Josh Poimboeuf <jpoim...@redhat.com> wrote: > On Thu, Aug 31, 2017 at 04:50:41PM +0200, Peter Zijlstra wrote: >> On Thu, Aug 31, 2017 at 09:11:20AM -0500, Josh Poimboeuf wrote: >> > Inline asm statements which have call instructions can be problematic. >> > GCC doesn't know about the call instructions, so in some cases it can >> > insert the asm before setting up the frame pointer. This can result in >> > bad stack traces when unwinding from the called function. >> > >> > Previously we worked around this issue by listing the stack pointer as >> > an input/output constraint for the inline asm. That works for GCC, but >> > unfortunately it doesn't work for Clang. In fact, it causes Clang to >> > corrupt the stack pointer. >> >> Sounds like it ought to get fixed regardless and then it might as well >> do the right thing ;-) > > There was some disagreement about what the "right thing" is because it's > an undocumented and unintuitive interface. > > And I use the term "interface" loosely. It was apparently a side effect > which was mentioned to me on the GCC mailing list.
Yes, as far as I understand, there is just no defined semantics for this. Passing sp as is when asm block asks to pass in sp looks like a perfectly reasonable thing to do (also faster code). We could use something like asm("..." ::: "frame"), but we don't have this in compilers.