-
Notifications
You must be signed in to change notification settings - Fork 15k
Description
LLVM generally treats the contents of inline-asm as a black box -- not optimizing based on what's in the asm-string, just the constraints.
There is an exception, however: a hack, "ExpandInlineAsm", dating back to 2011 to translate bswap assembly into a bswap intrinsic.
That entire mechanism should just be deleted now.
Not only is it crufty in general, it also causes a violation of Rust's documentation, per @programmerjake on https://discourse.llvm.org/t/rfc-constant-time-coding-support/87781/41?u=jyknight:
it has a important theoretical impact on Rust, since Rust specifies that all inline asm is a blackbox and the program is allowed to overwrite inline asm with arbitrary code at runtime and that isn’t UB as long as the modified code wouldn’t be UB inside that inline asm call. LLVM optimizing based on the contents of what that inline asm was at compile time introduces UB whenever the program overwrites it at runtime.