[clang] [TBAA] Refine pointer-tbaa for void pointers by pointer depth (PR #126047)

Bruno De Fraine via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 02:51:05 PST 2025


================
@@ -80,6 +80,28 @@ llvm::MDNode *CodeGenTBAA::getChar() {
   return Char;
 }
 
+llvm::MDNode *CodeGenTBAA::getAnyPtr(unsigned PtrDepth) {
+  assert(PtrDepth >= 1 && "Pointer must have some depth");
+
+  // Populate at least PtrDepth elements in AnyPtrs. These are the type nodes
+  // for "any" pointers of increasing pointer depth, and are organized in the
+  // hierarchy: any pointer <- any p2 pointer <- any p3 pointer <- ...
----------------
brunodf-snps wrote:

I've extended the comment based on your suggestion, let me know what you think!

> I'm suggesting `>` here rather than arrows because I think it expresses the subtype relationship more clearly, but I might be abnormally comfortable with subtyping lattices, so let me know what you think.

Yeah, I did not find this very clear. I used arrows to express the parent relationships. I don't think it is common to describe TBAA type nodes with subtyping, whereas "parent" is the term used in the documentation and API? I can still adapt this if you or others prefer[^1].

[^1]: I will say that I'm more used to the symbol `<:` for the subtype relationship, e.g.:
![image](https://github.com/user-attachments/assets/1202957b-133a-4656-a515-97a718792aaa)



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


More information about the cfe-commits mailing list