| Issue |
179944
|
| Summary |
mlir-opt crash in WhileConditionTruth pattern during --remove-dead-values
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
compilerStudyer
|
**Bug Op**: scf.while
**Bug Pass**: --remove-dead-values
**Commenting out does not trigger the crash**: smt.solver
**Detailed Description**: The pass crashes when rewriting nested scf.while loops that return vector types. The issue is located in the WhileConditionTruth pattern. The crash is only reproducible when the loop results are "live" (e.g., used by an smt.solver op); otherwise, DCE removes the loops and avoids the buggy code path.
```mlir
module {
func.func @main() {
%0 = gpu.dynamic_shared_memory : memref<?xi8, #gpu.address_space<workgroup>>
%1 = vector.step : vector<1xindex>
%2 = scf.while (%arg0 = %1) : (vector<1xindex>) -> vector<1xindex> {
%cond = arith.constant true
scf.condition(%cond) %arg0 : vector<1xindex>
} do {
^bb0(%arg0: vector<1xindex>):
scf.yield %arg0 : vector<1xindex>
}
%3 = scf.while (%arg0 = %2) : (vector<1xindex>) -> vector<1xindex> {
%cond = arith.constant true
scf.condition(%cond) %arg0 : vector<1xindex>
} do {
^bb0(%arg0: vector<1xindex>):
scf.yield %arg0 : vector<1xindex>
}
smt.solver(%3) : (vector<1xindex>) -> () {
^bb0(%arg0: vector<1xindex>):
smt.yield
}
return
}
}
```
```
mlir-opt --remove-dead-values temp.mlir
```
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: llvmorg-22.1.0-install/bin/mlir-opt --remove-dead-values temp.mlir
#0 0x000055bea1e34e32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
#1 0x000055bea1e315af llvm::sys::RunSignalHandlers() (llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
#2 0x000055bea1e316fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000751474845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000055bea91b9b73 (anonymous namespace)::WhileConditionTruth::matchAndRewrite(mlir::scf::WhileOp, mlir::PatternRewriter&) const SCF.cpp:0:0
#5 0x000055bea965fe03 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#6 0x000055bea96613af mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (llvmorg-22.1.0-install/bin/mlir-opt+0x9d5c3af)
#7 0x000055bea96263c0 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#8 0x000055bea962911e mlir::applyOpPatternsGreedily(llvm::ArrayRef<mlir::Operation*>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*, bool*) (llvmorg-22.1.0-install/bin/mlir-opt+0x9d2411e)
#9 0x000055bea95ad690 (anonymous namespace)::RemoveDeadValues::runOnOperation() RemoveDeadValues.cpp:0:0
#10 0x000055bea96d4756 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (llvmorg-22.1.0-install/bin/mlir-opt+0x9dcf756)
#11 0x000055bea96d4a8e mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (llvmorg-22.1.0-install/bin/mlir-opt+0x9dcfa8e)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs