[llvm-branch-commits] [clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)

Gábor Horváth via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 24 02:07:14 PDT 2025


================
@@ -873,19 +874,26 @@ class DataflowAnalysis {
     llvm::SmallBitVector Visited(Cfg.getNumBlockIDs() + 1);
 
     while (const CFGBlock *B = W.dequeue()) {
-      Lattice StateIn = getInState(B);
+      Lattice StateIn = *getInState(B);
       Lattice StateOut = transferBlock(B, StateIn);
       OutStates[B] = StateOut;
-      Visited.set(B->getBlockID());
       for (const CFGBlock *AdjacentB : isForward() ? B->succs() : B->preds()) {
         if (!AdjacentB)
           continue;
-        Lattice OldInState = getInState(AdjacentB);
-        Lattice NewInState = D.join(OldInState, StateOut);
+        Lattice OldInState;
+        bool SawFirstTime = false;
+        Lattice NewInState;
+        if (const Lattice *In = getInState(AdjacentB)) {
----------------
Xazax-hun wrote:

Wouldn't it be simpler if `getInState` always returned a valid state? Just defaulted to `D.getInitialState` when the lookup fail. 

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


More information about the llvm-branch-commits mailing list