[Mlir-commits] [mlir] [mlir][Transforms] Fix crash in `-remove-dead-values` on private functions (PR #169269)
Matthias Springer
llvmlistbot at llvm.org
Fri Nov 28 03:41:42 PST 2025
================
@@ -786,9 +824,14 @@ static void cleanUpDeadVals(RDVFinalCleanupList &list) {
// 3. Operations
LDBG() << "Cleaning up " << list.operations.size() << " operations";
- for (auto &op : list.operations) {
+ for (Operation *op : list.operations) {
LDBG() << "Erasing operation: "
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
+ if (op->hasTrait<OpTrait::IsTerminator>()) {
+ // When erasing a terminator, insert an unreachable op in its place.
+ OpBuilder b(op);
+ ub::UnreachableOp::create(b, op->getLoc());
+ }
----------------
matthias-springer wrote:
This is giving me a compilation error:
```
llvm-project/mlir/lib/Transforms/RemoveDeadValues.cpp:832:7: error: no matching function for call to 'create'
832 | ub::UnreachableOp::create(OpBuilder{op}, op->getLoc());
| ^~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/build/tools/mlir/include/mlir/Dialect/UB/IR/UBOps.h.inc:377:24: note: candidate function not viable: expects an lvalue for 1st argument
377 | static UnreachableOp create(::mlir::OpBuilder &builder, ::mlir::Location location);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
```
https://github.com/llvm/llvm-project/pull/169269
More information about the Mlir-commits
mailing list