[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:00 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.
----------------
steakhal wrote:
This isn't any cast expr. This is reinterpret casts, casting away one or more levels of indirection.
https://github.com/llvm/llvm-project/pull/218207
More information about the llvm-branch-commits
mailing list