[llvm] [LangRef] inline asm: the instructions are treated opaquely (PR #157080)
Jacob Lifshay via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 04:29:32 PDT 2025
programmerjake wrote:
> @RalfJung how about this: `The compiler may analyze the contents of the inline asm string in order to optimize surrounding code, but the compiler will always emit the inline asm string verbatim. Additionally, the compiler will not use any analysis of the inline asm string to optimize the code in violation of any flags, operand constraints or attributes placed on the inline asm call.`
I don't think that's sufficient, since from how I read that it allows LLVM to assume `asm("" : "+r"(v))` doesn't modify `v`, but exactly that kind of thing is commonly used as an optimization barrier. Similarly for code like so:
```rust
pub fn f(mut v: u64) -> u64 {
unsafe {
asm!(
".balign 16",
".nop 8", // this can be atomically replaced with an 8-byte call instruction
inout("rdi") v,
clobber_abi("C"),
);
}
v
}
```
https://github.com/llvm/llvm-project/pull/157080
More information about the llvm-commits
mailing list