[clang] 4633c02 - [clang][dataflow] Allow disabling built-in transfer functions for CFG terminators

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 08:11:24 PDT 2022


Author: Yitzhak Mandelbaum
Date: 2022-03-15T15:10:32Z
New Revision: 4633c02eb0013ed38319b3fd708f59251bcd2aaf

URL: https://github.com/llvm/llvm-project/commit/4633c02eb0013ed38319b3fd708f59251bcd2aaf
DIFF: https://github.com/llvm/llvm-project/commit/4633c02eb0013ed38319b3fd708f59251bcd2aaf.diff

LOG: [clang][dataflow] Allow disabling built-in transfer functions for CFG terminators

Terminators are handled specially in the transfer functions so we need an
additional check on whether the analysis has disabled built-in transfer
functions.

Differential Revision: https://reviews.llvm.org/D121694

Added: 
    

Modified: 
    clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 058922afd4838..6baf1a7fd42d6 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -170,6 +170,8 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
   }
 
   llvm::Optional<TypeErasedDataflowAnalysisState> MaybeState;
+  bool ApplyBuiltinTransfer = Analysis.applyBuiltinTransfer();
+
   for (const CFGBlock *Pred : Preds) {
     // Skip if the `Block` is unreachable or control flow cannot get past it.
     if (!Pred || Pred->hasNoReturnElement())
@@ -183,11 +185,13 @@ static TypeErasedDataflowAnalysisState computeBlockInputState(
       continue;
 
     TypeErasedDataflowAnalysisState PredState = MaybePredState.getValue();
-    if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
-      const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
-      TerminatorVisitor(StmtToEnv, PredState.Env,
-                        blockIndexInPredecessor(*Pred, Block))
-          .Visit(PredTerminatorStmt);
+    if (ApplyBuiltinTransfer) {
+      if (const Stmt *PredTerminatorStmt = Pred->getTerminatorStmt()) {
+        const StmtToEnvMapImpl StmtToEnv(CFCtx, BlockStates);
+        TerminatorVisitor(StmtToEnv, PredState.Env,
+                          blockIndexInPredecessor(*Pred, Block))
+            .Visit(PredTerminatorStmt);
+      }
     }
 
     if (MaybeState.hasValue()) {


        


More information about the cfe-commits mailing list