Skip to content

Commit ffa0edc

Browse files
committed
CodeGenTBAA: getAnyPtr: further extend description in comment based on suggestion
1 parent 8068c5b commit ffa0edc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

clang/lib/CodeGen/CodeGenTBAA.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ llvm::MDNode *CodeGenTBAA::getAnyPtr(unsigned PtrDepth) {
8686
// Populate at least PtrDepth elements in AnyPtrs. These are the type nodes
8787
// for "any" pointers of increasing pointer depth, and are organized in the
8888
// hierarchy: any pointer <- any p2 pointer <- any p3 pointer <- ...
89+
//
90+
// Note that AnyPtrs[Idx] is actually the node for pointer depth (Idx+1),
91+
// since there is no node for pointer depth 0.
92+
//
93+
// These "any" pointer type nodes are used in pointer TBAA. The type node of
94+
// a concrete pointer type has the "any" pointer type node of appropriate
95+
// pointer depth as its parent. The "any" pointer type nodes are also used
96+
// directly for accesses to void pointers, or to specific pointers that we
97+
// conservatively do not distinguish in pointer TBAA (e.g. pointers to
98+
// members). Essentially, this establishes that e.g. void** can alias with
99+
// any type that can unify with T**, ignoring things like qualifiers. Here, T
100+
// is a variable that represents an arbitrary type, including pointer types.
101+
// As such, each depth is naturally a subtype of the previous depth, and thus
102+
// transitively of all previous depths.
89103
if (AnyPtrs.size() < PtrDepth) {
90104
AnyPtrs.reserve(PtrDepth);
91105
auto Size = Module.getDataLayout().getPointerSize();

0 commit comments

Comments
 (0)