================
@@ -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());
+ }
----------------
joker-eph wrote:
```suggestion
// When erasing a terminator, insert an unreachable op in its place.
if (op->hasTrait<OpTrait::IsTerminator>())
ub::UnreachableOp::create(OpBuilder{op}, op->getLoc());
```
Nit: simplifying a bit.
https://github.com/llvm/llvm-project/pull/169269
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits