-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assembly comments affect generated code. #3298
Comments
This is a known issue. However, the assembly comments are not generated unless you run with |
The problem is that the technique we use to inject comments is to insert an assembly block, which LLVM assumes could have arbitrary side-effects. There should be another way to do that...but I'm not sure what it is. |
The other problem is that a compiler is, more generally, not unreasonable in deleting operations which have no outputs that aren't unused and no effects on memory or other state. One is warned about this in the GCC asm statement documentation, for example (and in GCC's case, for extra confusion, a non-volatile asm with no outputs at all appears to be implicitly made volatile early in compilation, presumably under the assumption that unconditionally removing it was not the intended result). Clearly there's some way of tracking which parts of the (Edited for what I hope is clarity.) |
The defaults have been changed. We never generate assembly comments without -Z asm-comments. I am leaving the bug open because it'd be good to find a better way to inject debugging comments. |
This is still an issue. |
Some searching yield two threads (1, 2) which suggest that one can attach a metadata string to the LLVM instruction and get the |
accepted for P-low. |
This option no longer exists, so closing. |
Use the same rule between function and macro
Given this program:
compiling with
-S -O
yields an assembly file containing this, which is what's left of theuint::range
loop (as output bygrep -C2 inc
):But compiling with
-c -O
and disassembling shows a file where the loop has been entirely removed. However, compiling with-S -Zno-asm-comments -O
is faithful to the-c
output; and with--save-temps
we can see that the bitcode is identical between-c
and-S -Zno-asm-comments
and nontrivially different (more than just the comments) for-S
.So there's something about the asm comments that makes LLVM think they have effects.
The text was updated successfully, but these errors were encountered: