[Bug inline-asm/94522] Enhancement request: asm goto with outputs

torvalds@linux-foundation.org gcc-bugzilla@gcc.gnu.org
Wed Apr 8 20:30:44 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94522

Linus Torvalds <torvalds@linux-foundation.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |torvalds@linux-foundation.o
                   |                            |rg

--- Comment #4 from Linus Torvalds <torvalds@linux-foundation.org> ---
(In reply to Andrew Pinski from comment #1)
> Take:
> asm goto ("" : "=r"(*m) :....);
> 
> Where does the store to *m happen?  Do you replicate it on to the label side
> too?
> 
> What are the semantics for the above case on clang?  My bet is it is not
> well defined and really broken.

The outputs are defined to have values only in the fallthrough case.

On the label side, the outputs (whether memory or register) are explicitly
undefined. 

The outputs may obviously not even be in scope except in the fallthrough.

Now, with memory ops, it's obviously quite possible that the programmer then
knows that they wrote an inline asm that did the write to memory before it did
the goto. 

But that's no different from a _non_output_ "asm goto" that you pass a memory
pointer to, so I don't think that's something that is new to this situation.

As to whether this is simple or not to do in gcc - the clang implementation has
been buggy so far, altough it's good enough for testing ;)


More information about the Gcc-bugs mailing list