[Mlir-commits] [mlir] [mlir][Transforms] `remove-dead-values`: Rely on canonicalizer for region simplification (PR #173505)
Ivan Butygin
llvmlistbot at llvm.org
Fri Jan 2 04:31:30 PST 2026
================
@@ -751,11 +517,44 @@ static void processBranchOp(BranchOpInterface branchOp, RunLivenessAnalysis &la,
}
}
+/// Create ub.poison ops for the given values. If a value has no uses, return
+/// an "empty" value.
+static SmallVector<Value> createPoisonedValues(OpBuilder &b,
+ ValueRange values) {
+ return llvm::map_to_vector(values, [&](Value value) {
+ if (value.use_empty())
+ return Value();
+ return ub::PoisonOp::create(b, value.getLoc(), value.getType()).getResult();
+ });
+}
+
+namespace {
+/// A listener that keeps track of ub.poison ops.
+struct TrackingListener : public RewriterBase::Listener {
+ void notifyOperationErased(Operation *op) override {
+ if (auto poisonOp = dyn_cast<ub::PoisonOp>(op))
+ poisonOps.erase(poisonOp);
+ }
+ void notifyOperationInserted(Operation *op,
+ OpBuilder::InsertPoint previous) override {
+ if (auto poisonOp = dyn_cast<ub::PoisonOp>(op))
+ poisonOps.insert(poisonOp);
+ }
+ DenseSet<ub::PoisonOp> poisonOps;
----------------
Hardcode84 wrote:
`SmallDenseSet` as well
https://github.com/llvm/llvm-project/pull/173505
More information about the Mlir-commits
mailing list