[clang] [clang][dataflow] Discard unneeded `ExprToLoc` and `ExprToVal` entries. (PR #72850)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 21 08:43:27 PST 2023


================
@@ -311,7 +318,10 @@ computeBlockInputState(const CFGBlock &Block, AnalysisContext &AC) {
     }
   }
 
-  JoinedStateBuilder Builder(AC);
+  // When performing the join, only retain state for those expressions that are
+  // consumed by this block. This avoids performing joins and potentially
+  // extending the flow condition for expressions that we won't need anyway.
+  JoinedStateBuilder Builder(AC, AC.CFCtx.getExprConsumedByBlock(&Block));
----------------
Xazax-hun wrote:

Thanks! I think my main concerns are around convergence and `ExprToLoc`. Consider a simple loop like:
```
B1 ---> B2
^       |
 \______/
```

We have getStableStorageLocation that will first look up an expression in `ExprToLoc` and it will try to reuse the some location. In case we clear `ExprToLoc` along the back edge, in the second iteration through processing `B2` we would create new locations for the expressions.

Is this the intended effect here? 


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


More information about the cfe-commits mailing list