hfinkel added a comment.

In http://reviews.llvm.org/D10546#202612, @ahatanak wrote:

> Do the inline-asm statements you are thinking of use clobber register list to 
> represent the dependency between the first and second statement? If they are 
> using input and output operands or the volatile keyword, clang will know they 
> can't be reordered, so I was guessing they were using the clobber list?


I take back what I said, mostly. GCC's documentation says that, "GCC's 
optimizers sometimes discard asm statements if they determine there is no need 
for the output variables. Also, the optimizers may move code out of loops if 
they believe that the code will always return the same result (i.e. none of its 
input values change between calls). Using the volatile qualifier disables these 
optimizations. asm statements that have no output operands, including asm goto 
statements, are implicitly volatile."

So we're okay here, such inline asm statements need to be marked volatile, or 
have no output registers, so we can check for that.

I don't think, however, you can ever mark the inline asm call as 'readnone', 
because you have no way of knowing that it does not load anything. Any of its 
inputs could be an address, or used to construct an address, to something. The 
programmer might also know that the address is always dereferenceable, and thus 
won't produce any side effects other than its result (and, thus, not mark the 
statement as volatile).

We could parse the assembly using the integrated assembler to figure this out, 
but that's another story.


http://reviews.llvm.org/D10546




_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to