[clang] [TBAA] Only emit pointer tbaa metedata for record types. (PR #116991)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 20 15:38:20 PST 2024


================
@@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
     if (!CodeGenOpts.PointerTBAA)
       return AnyPtr;
     // Compute the depth of the pointer and generate a tag of the form "p<depth>
-    // <base type tag>".
+    // <base type tag>". Look through pointer and array types to determine the
+    // base type.
     unsigned PtrDepth = 0;
     do {
       PtrDepth++;
-      Ty = Ty->getPointeeType().getTypePtr();
-    } while (Ty->isPointerType());
+      Ty = Ty->isPointerType() ? Ty->getPointeeType().getTypePtr()
+                               : Ty->getArrayElementTypeNoTypeQual();
+    } while (Ty->isPointerType() || Ty->isArrayType());
     Ty = Context.getBaseElementType(QualType(Ty, 0)).getTypePtr();
----------------
rjmccall wrote:

You can drop this now.

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


More information about the cfe-commits mailing list