| Issue |
242905
|
| Summary |
[InstCombine] Constant-folding a musttail libcall (sin/cos) replaces its returned value and produces invalid IR
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
arie2026
|
InstCombine constant-folds a `musttail` call to a math libcall with a constant argument and replaces the
returned value with the constant, but keeps the `musttail` call. The verifier then rejects the module because
the result of a `musttail` call must be returned.
Reproducer (`opt -passes=instcombine`, no target flags needed):
```llvm
declare double @sin(double)
define double @f(double %x) {
%r = musttail call double @sin(double 0.0)
ret double %r
}
```
```
$ opt -passes=instcombine -disable-output test.ll
musttail call result must be returned
ret double 0.000000e+00
LLVM ERROR: Broken module found, compilation aborted!
```
Output with `-disable-verify`:
```llvm
define double @f(double %x) {
%r = musttail call double @sin(double 0.000000e+00)
ret double 0.000000e+00
}
```
Expected: valid IR — either leave a `musttail` call (and its `ret`) alone, or drop the call together with the
`musttail` marker.
Notes: same with `@cos` and with `sin(1.0)`; `@llvm.sin.f64`, `-passes=instsimplify`, `early-cse`, `sccp` and `gvn`
are fine, so it looks specific to InstCombine's libcall folding path. Also reproduces on a 2026-11-05 trunk.
Found with a mutation-based IR fuzzer. Triage, test-case minimization and parts of this write-up were
assisted by an LLM; verified the reproducer on b23814056.
Assisted-by: Claude (Anthropic)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs