<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77862>77862</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR][Analysis][Dataflow] `cf.br`'s target is dead in `DeadCodeAnalysis`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SchrodingerZhu
</td>
</tr>
</table>
<pre>
```c++
const std::string_view SIMPLE_TEST = R"(
module {
func.func @test(%a : i32) -> i32 {
cf.br ^start(%a : i32)
^start(%b : i32):
return %b : i32
}
}
)";
TEST(Basic, Test) {
auto context = defaultContext();
auto module = parseSourceString(SIMPLE_TEST, context.get());
ScopedDiagnosticHandler error_handler(context.get());
DataFlowSolver solver;
solver.load<dataflow::DeadCodeAnalysis>();
auto func = &*module.get()->getRegions().front().getOps().begin();
ASSERT_TRUE(solver.initializeAndRun(func).succeeded());
auto funcOp = dyn_cast<func::FuncOp>(func);
auto ®ion = funcOp.getBody();
for (Block &block : region) {
auto executable = solver.lookupState<dataflow::Executable>(&block);
block.dump();
if (executable) {
llvm::outs() << " - executable: " << executable->isLive() << "\n";
}
}
}
```
The above program gives out:
```mlir
^bb0(%arg0: i32):
cf.br ^bb1(%arg0 : i32)
- executable: 1
^bb1(%0: i32): // pred: ^bb0
func.return %0 : i32
- executable: 0
```
I wonder why `^bb1` is dead?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVVuP6jgM_jXmxRoUEsrlgQegoB1pjs4KZl_2ZZQ2pmRPaVCSMof99aukpVylRRVNHPvz50tc6ZwuKqIZJAtI0p6s_d7Y2TbfW6N0VZD9e1_3MqPOMxix5smBL8LDUmDz3FTOo_MKxBzE3Hmrq-LrpOkbt-8__vxYfX2utp8IIsUNcA580tghHoyqS0IYLy4SxF1d5f3whzBknpwP-jyRCGKOWnDgU3wDsQrre8vwy3f9zC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