LLVM IPSCCP doesn't respect optimize(none) #138272
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
F-optimize_attribute
`#![feature(optimize_attribute)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I compiled this code with
-Copt-level=3
:I expected
foo()
to callsquare(3)
, and use its return value. Intuitively, sincesquare
is marked asoptimize(none)
, the optimizer shouldn't be allowed to look at its contents or optimize it.Instead, I got this assembly (which doesn't make a ton of sense to me, especially since
square
seems to also be optimized):It appears that IPSCCPPass in LLVM is doing this optimization. Godbolt
I'm unsure if this is a bug, since optimize() seems to only be a hint.
CC tracking issue of optimize_attribute: #54882
Meta
Reproduced on Godbolt with full compiler version:
The text was updated successfully, but these errors were encountered: