[llvm] 3b42245 - [IPO] AAFunctionReachabilityFunction.updateImpl - reduce AAReachability scope. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 25 06:42:59 PST 2022


Author: Simon Pilgrim
Date: 2022-02-25T14:42:31Z
New Revision: 3b422455ddeb424e6c771de822889c3c352bd2ac

URL: https://github.com/llvm/llvm-project/commit/3b422455ddeb424e6c771de822889c3c352bd2ac
DIFF: https://github.com/llvm/llvm-project/commit/3b422455ddeb424e6c771de822889c3c352bd2ac.diff

LOG: [IPO] AAFunctionReachabilityFunction.updateImpl - reduce AAReachability scope. NFCI.

We already have a check for !InstQueries.empty(), so move the for-range over InstQueries inside to avoid the AAReachability uninitialized variable static analysis warnings.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index ba986a65e0201..40b2162e7d8cb 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -9849,22 +9849,21 @@ struct AAFunctionReachabilityFunction : public AAFunctionReachability {
     }
 
     // Update the Instruction queries.
-    const AAReachability *Reachability;
     if (!InstQueries.empty()) {
-      Reachability = &A.getAAFor<AAReachability>(
+      const AAReachability *Reachability = &A.getAAFor<AAReachability>(
           *this, IRPosition::function(*getAssociatedFunction()),
           DepClassTy::REQUIRED);
-    }
 
-    // Check for local callbases first.
-    for (auto &InstPair : InstQueries) {
-      SmallVector<const AACallEdges *> CallEdges;
-      bool AllKnown =
-          getReachableCallEdges(A, *Reachability, *InstPair.first, CallEdges);
-      // Update will return change if we this effects any queries.
-      if (!AllKnown)
-        InstPair.second.CanReachUnknownCallee = true;
-      Change |= InstPair.second.update(A, *this, CallEdges);
+      // Check for local callbases first.
+      for (auto &InstPair : InstQueries) {
+        SmallVector<const AACallEdges *> CallEdges;
+        bool AllKnown =
+            getReachableCallEdges(A, *Reachability, *InstPair.first, CallEdges);
+        // Update will return change if we this effects any queries.
+        if (!AllKnown)
+          InstPair.second.CanReachUnknownCallee = true;
+        Change |= InstPair.second.update(A, *this, CallEdges);
+      }
     }
 
     return Change;


        


More information about the llvm-commits mailing list