Issue |
151047
|
Summary |
[CodeGen] Assertion failure in MachineInstr::setDebugValueUndef during BranchFolder optimization
|
Labels |
new issue
|
Assignees |
|
Reporter |
krystophny
|
## Summary
Clang crashes with an assertion failure when building LLVM's Polly component in a self-hosted build configuration. The crash occurs during the Control Flow Optimizer pass in the BranchFolder's `HoistCommonCodeInSuccs` function.
## Bug Classification
Compiler crash bug - Backend code generator crash
## Assertion Details
```
Assertion failed: (isDebugValue() && "Must be a debug value instruction."), function setDebugValueUndef, file MachineInstr.h, line 2004.
```
## Stack Trace
```
Stack dump:
0. Program arguments: clang [compiler flags]
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'polly/lib/External/isl/isl_transitive_closure.c'.
4. Running pass 'Control Flow Optimizer' on function '@has_spurious_elements'
#8 (anonymous namespace)::BranchRelaxation::run(llvm::MachineFunction&) (.cold.9)
#9 llvm::MachineInstr::setDebugValueUndef()
#10 llvm::BranchFolder::HoistCommonCodeInSuccs(llvm::MachineBasicBlock*)::::operator()
#11 llvm::BranchFolder::HoistCommonCodeInSuccs(llvm::MachineBasicBlock*)
#12 llvm::BranchFolder::OptimizeFunction(...)
```
## Reproduction Steps
1. Configure LLVM build with self-hosted clang
2. Run `ninja` in build directory
3. Crash occurs when compiling `polly/lib/External/isl/isl_transitive_closure.c`
4. Also reproduces with `polly/lib/External/isl/isl_scheduler.c`
## Build Configuration
- **Host System:** macOS (Darwin 24.5.0, arm64)
- **Compiler:** clang version 22.0.0git
- **Target:** arm64-apple-darwin24.5.0
- **Build Type:** Self-hosted build (clang building LLVM)
- **Optimization:** `-O2 -g -DNDEBUG`
- **Assertions:** Enabled (`+assertions`)
## Analysis
The assertion failure occurs when `setDebugValueUndef()` is called on a `MachineInstr` that fails the `isDebugValue()` check. This suggests that:
1. The BranchFolder optimization is incorrectly identifying a non-debug instruction as a debug instruction
2. There may be corruption in the debug metadata during the optimization pass
3. The debug instruction handling in `HoistCommonCodeInSuccs` has a logic error
This appears related to recent changes in debug instruction handling during branch folding, as there were recent reverts of patches modifying this code (commits 654c0d8 and 8d4fde5).
## Affected Files
- Files that trigger the crash: `polly/lib/External/isl/isl_transitive_closure.c`, `polly/lib/External/isl/isl_scheduler.c`
- Code location: `MachineInstr.h:2004` (`setDebugValueUndef` function)
- Optimization pass: `BranchFolder::HoistCommonCodeInSuccs`
## Workarounds
- Building with `-O1` or `-O0` may avoid the crash
- Disabling debug info (`-g`) may prevent the issue
- Excluding Polly from the build avoids the crash
## Additional Context
This crash prevents successful self-hosted LLVM builds and appears to be a regression in the debug instruction handling during backend optimization passes.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs