[clang] [TBAA] Emit distinct TBAA tags for pointers with different depths,types. (PR #76612)

Florian Hahn via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 14:09:43 PDT 2024


================
@@ -185,10 +185,56 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
     return getChar();
 
   // Handle pointers and references.
-  // TODO: Implement C++'s type "similarity" and consider dis-"similar"
-  // pointers distinct.
-  if (Ty->isPointerType() || Ty->isReferenceType())
-    return createScalarTypeNode("any pointer", getChar(), Size);
+  //
+  // C has a very strict rule for pointer aliasing. C23 6.7.6.1p2:
+  //     For two pointer types to be compatible, both shall be identically
+  //     qualified and both shall be pointers to compatible types.
+  //
+  // This rule is impractically strict; we want to at least ignore CVR
----------------
fhahn wrote:

Sounds good!

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


More information about the cfe-commits mailing list