[clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 30 12:23:44 PDT 2025
================
@@ -867,29 +868,30 @@ class DataflowAnalysis {
std::conditional_t<Dir == Direction::Forward, ForwardDataflowWorklist,
BackwardDataflowWorklist>;
Worklist W(Cfg, AC);
+ llvm::SmallBitVector Seen(Cfg.getNumBlockIDs() + 1);
const CFGBlock *Start = isForward() ? &Cfg.getEntry() : &Cfg.getExit();
InStates[Start] = D.getInitialState();
+ Seen.set(Start->getBlockID());
W.enqueueBlock(Start);
- llvm::SmallBitVector Visited(Cfg.getNumBlockIDs() + 1);
-
while (const CFGBlock *B = W.dequeue()) {
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);
+ bool SeeingFirstTime = !Seen.test(AdjacentB->getBlockID());
----------------
ymand wrote:
Why not use optionals? like `std::optional<Lattice> OldInState`?
https://github.com/llvm/llvm-project/pull/159991
More information about the cfe-commits
mailing list