jyu2 added a comment.

>>> I don't find any document about GCC and ICC's behavior and the generated

code doesn't make much sense to me. Besides, if we change "=rm" to "=r"
or "=m", GCC and ICC will report error differently. Which gives me an
impression that the use of constraint is undefined behavior.

Here is gcc document: 
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands

To me it is defined behavior.  Or I may missing some thing here.

constraint:
A string constant specifying constraints on the placement of the operand; See 
Constraints, for details.

Output constraints must begin with either ‘=’ (a variable overwriting an 
existing value) or ‘+’ (when reading and writing). When using ‘=’, do not 
assume the location contains the existing value on entry to the asm, except 
when the operand is tied to an input; see Input Operands.

After the prefix, there must be one or more additional constraints (see 
Constraints) that describe where the value resides. Common constraints include 
‘r’ for register and ‘m’ for memory. When you list more than one possible 
location (for example, "=rm"), the compiler chooses the most efficient one 
based on the current context. If you list as many alternates as the asm 
statement allows, you permit the optimizers to produce the best possible code. 
If you must use a specific register, but your Machine Constraints do not 
provide sufficient control to select the specific register you want, local 
register variables may provide a solution (see Local Register Variables).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107141/new/

https://reviews.llvm.org/D107141

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to