[llvm] [LLVM][Transforms][Attributor] - Improvements in AAIntraFnReachability::isReachableImpl (PR #189132)

Jan Leyonberg via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 07:13:33 PDT 2026


================
@@ -3697,15 +3697,48 @@ struct AAIntraFnReachabilityFunction final
                             IsTemporaryRQI);
     }
 
-    SmallPtrSet<const BasicBlock *, 16> Visited;
+    // Optimization: Use DT DFS numbers for visited set if available.
+    // This avoids SmallPtrSet allocation and hashing overhead.
+    if (DT) {
+      if (VisitedMap.empty()) {
+        // Resize once.
+        if (auto *Root = DT->getRootNode())
+          VisitedMap.resize(Root->getDFSNumOut() + 1, 0);
+      }
+      // Increment query ID.
+      CurrentQueryID++;
+      if (CurrentQueryID == 0) {
----------------
jsjodin wrote:

If CurrentQueryID is initialized to 0 and is incremented above wouldn't this condition always be false?

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


More information about the llvm-commits mailing list