[llvm-branch-commits] [clang] [SSAF][PointerFlow] A pointer assignment may yield more than one edge (PR #218207)

Balázs Benics via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 28 05:22:01 PDT 2026


================
@@ -111,15 +94,45 @@ PointerFlowMatcher::addEdges(Expected<EntityPointerLevelSet> &&LHS,
     return RHS.takeError();
   if (RHS->empty())
     return llvm::Error::success();
-  for (auto L : *LHS)
-    Results[L].insert(RHS->begin(), RHS->end());
+
+  std::vector<DeclPointerLevels> LVecs, RVecs;
+
+  for (const auto &L : *LHS)
+    LVecs.push_back(elaborateHigherDeclPointerLevels(L));
+  for (const auto &R : *RHS)
+    RVecs.push_back(elaborateHigherDeclPointerLevels(R));
+
+  // Imagine an assignment from pointer q to p: 'p = q'.  It encodes that if 'p'
+  // has some property, so must 'q'; moreover, if '*p/p[i]' has some property,
+  // so must '*q/q[i]' and so on.  Therefore, for each edge '(a, n) -> (b, m)'
+  // that represents an explicitly spelled place in the source code, we also add
+  // '(a, n + 1) -> (b, m + 1)',
+  // '(a, n + 2) -> (b, m + 2)', ... continuing until either 'a' or 'b' reaches
+  // its maximum pointer level, whichever happens first.
+  //
+  // Note that type checking ensures that 'p' and 'q' have
+  // identical pointer levels, but '(a, n)' and '(b, m)' may have different
+  // upper bounds on their pointer levels, when, for example, 'q' is a
+  // cast-expression.
+
+  for (const DeclPointerLevels &L : LVecs)
+    for (const DeclPointerLevels &R : RVecs)
----------------
steakhal wrote:

Its a pity llvm doesn't have a product algorithm for `LVecs x RVecs`

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


More information about the llvm-branch-commits mailing list