[llvm] [Analysis] Ignore convergence tokens in dead branches in `CodeMetrics` (PR #193590)

Joshua Batista via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 11:58:51 PDT 2026


================
@@ -112,13 +113,39 @@ void CodeMetrics::collectEphemeralValues(
   completeEphemeralValues(Visited, Worklist, EphValues);
 }
 
+/// Check if a block was previously marked dead by setting the terminator to
+/// `unreachable` and the condiational branch to the block is statically
+/// evaluated. This is done for instance within the unroll pass, between
+/// unrolling inner/outer loops.
+static bool isBlockMarkedDead(const BasicBlock *BB) {
+  if (!isa<UnreachableInst>(BB->getTerminator()))
+    return false;
+  for (const BasicBlock *Pred : predecessors(BB)) {
+    auto *CondBr = dyn_cast<CondBrInst>(Pred->getTerminator());
+    if (!CondBr)
+      return false;
----------------
bob80905 wrote:

Are there other types of control flow instructions, other than condBrInst, that we care about that could switch control flow to this block? 

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


More information about the llvm-commits mailing list