[Mlir-commits] [mlir] Allow SymbolUserOpInterface operators to be used in RemoveDeadValues Pass (PR #117405)

M. Zeeshan Siddiqui llvmlistbot at llvm.org
Sat Nov 23 09:27:45 PST 2024


================
@@ -577,10 +577,8 @@ void RemoveDeadValues::runOnOperation() {
   WalkResult acceptableIR = module->walk([&](Operation *op) {
     if (op == module)
       return WalkResult::advance();
-    if (isa<BranchOpInterface>(op) ||
-        (isa<SymbolUserOpInterface>(op) && !isa<CallOpInterface>(op))) {
-      op->emitError() << "cannot optimize an IR with "
-                         "non-call symbol user ops or branch ops\n";
+    if (isa<BranchOpInterface>(op)) {
----------------
codemzs wrote:

@parsifal-47 It appears that the pass does not consider values used as block arguments in branch operations as "live" uses. I realized this after I dropped the condition and then I got the below error:

`error: unexpected error: null operand found`
`cf.cond_br %arg0, ^bb1(%non_live : i32), ^bb2(%non_live : i32)`

Here, `%non_live` is passed as a block argument to both `^bb1` and `^bb2`, because the `RemoveDeadValues` pass doesn't recognize values used as block arguments in branch operations as "live", it incorrectly removes `%non_live`. This leads to a `null` operand error when `cf.cond_br` still references `%non_live`, which no longer exists.

I believe we may need to restructure this pass to handle this scenario, therefore I am inclined to not do as part of this change but was curious if this is something you could handle in a separate change? What are your thoughts?

https://github.com/llvm/llvm-project/pull/117405


More information about the Mlir-commits mailing list