File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
206206 if (!CodeGenOpts.PointerTBAA )
207207 return AnyPtr;
208208 // Compute the depth of the pointer and generate a tag of the form "p<depth>
209- // <base type tag>".
209+ // <base type tag>". Look through pointer and array types to determine the
210+ // base type.
210211 unsigned PtrDepth = 0 ;
211212 do {
212213 PtrDepth++;
213- Ty = Ty->getPointeeType ().getTypePtr ();
214- } while (Ty->isPointerType ());
214+ Ty = Ty->isPointerType () ? Ty->getPointeeType ().getTypePtr ()
215+ : Ty->getArrayElementTypeNoTypeQual ();
216+ } while (Ty->isPointerType () || Ty->isArrayType ());
215217 Ty = Context.getBaseElementType (QualType (Ty, 0 )).getTypePtr ();
216218 assert (!isa<VariableArrayType>(Ty));
217219 // When the underlying type is a builtin type, we compute the pointee type
@@ -230,10 +232,9 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
230232 ->getString ();
231233 TyName = Name;
232234 } else {
233- // Be conservative if the type isn't a record type. Handling other types
234- // may require stripping const-qualifiers inside the type, e.g.
235- // MemberPointerType.
236- if (!Ty->isRecordType ())
235+ // Be conservative if the type a MemberPointerType. Those would require
236+ // stripping const-qualifiers inside the type.
237+ if (Ty->isMemberPointerType ())
237238 return AnyPtr;
238239
239240 // For non-builtin types use the mangled name of the canonical type.
Original file line number Diff line number Diff line change @@ -39,4 +39,4 @@ const int * h(const int * (*p)[10], int *(*q)[9]) {
3939}
4040
4141// POINTER-TBAA: [[PTRARRAY_TBAA]] = !{[[PTRARRAY_TY:!.+]], [[PTRARRAY_TY]], i64 0}
42- // POINTER-TBAA: [[PTRARRAY_TY:!.+ ]] = !{!"p1 _ZTSPi ", !4, i64 0}
42+ // POINTER-TBAA: [[PTRARRAY_TY]] = !{!"p3 int ", !4, i64 0}
You can’t perform that action at this time.
0 commit comments