[Mlir-commits] [mlir] [mlir] Enable remove-dead-values to delete unused private function (PR #161471)

lonely eagle llvmlistbot at llvm.org
Wed Oct 1 09:52:02 PDT 2025


linuxlonelyeagle wrote:

> That does not really explain the crash though: why wasn't the cond_branch also dead and removed?

```
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: cf.cond_br with 1 operands and 0 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: arith.cmpi with 2 operands and 1 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: arith.constant with 0 operands and 1 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: func.return with 1 operands and 0 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: arith.constant with 0 operands and 1 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: func.return with 1 operands and 0 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[dataflow SparseAnalysis.cpp:431 1] Visiting operation: arith.constant with 0 operands and 1 results
[dataflow SparseAnalysis.cpp:439 1] Operation is in dead block, bailing out
[liveness-analysis LivenessAnalysis.cpp:299 1] RunLivenessAnalysis initialized for op: builtin.module check on unreachable code now:
[liveness-analysis LivenessAnalysis.cpp:307 1] Result: 0 of %c0_i64 = arith.constant 0 : i64 has no liveness info (unreachable), mark dead
[liveness-analysis LivenessAnalysis.cpp:307 1] Result: 0 of %0 = arith.cmpi eq, %arg0, %c0_i64 : i64 has no liveness info (unreachable), mark dead
[liveness-analysis LivenessAnalysis.cpp:307 1] Result: 0 of %c1_i64 = arith.constant 1 : i64 has no liveness info (unreachable), mark dead
[liveness-analysis LivenessAnalysis.cpp:307 1] Result: 0 of %c3_i64 = arith.constant 3 : i64 has no liveness info (unreachable), mark dead
[liveness-analysis LivenessAnalysis.cpp:317 1] Block argument: 0 of func.func private @test(%arg0: i64) -> i64 {...} has no liveness info, mark dead
[pass-manager Pass.cpp:1102 2] PassManager run completed with result: success
test_tag: cf:
 operand #0: not live
module {
  func.func private @test(%arg0: i64) -> i64 {
    %c0_i64 = arith.constant 0 : i64
    %0 = arith.cmpi eq, %arg0, %c0_i64 : i64
    cf.cond_br %0, ^bb1, ^bb2 {tag = "cf"}
  ^bb1:  // pred: ^bb0
    %c1_i64 = arith.constant 1 : i64
    return %c1_i64 : i64
  ^bb2:  // pred: ^bb0
    %c3_i64 = arith.constant 3 : i64
    return %c3_i64 : i64
  }
}
```
https://github.com/llvm/llvm-project/blob/a9b8dfe7b5f224e2d442352979cf2e0c1c0b539b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp#L317
The liveness lattice will by default set the SSA values without a liveness lattice to dead.
Why isn't the br.cond op explicitly set to dead? 
Because its operand, which is the result of arith.cmpi, is explicitly set to dead. In fact, it is dead.



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


More information about the Mlir-commits mailing list