[clang] [TBAA] Extend pointer TBAA to pointers of non-builtin types. (PR #110569)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 15 13:05:17 PDT 2024
================
@@ -221,21 +221,27 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
PtrDepth++;
Ty = Ty->getPointeeType().getTypePtr();
} while (Ty->isPointerType());
- // TODO: Implement C++'s type "similarity" and consider dis-"similar"
- // pointers distinct for non-builtin types.
+
+ SmallString<256> TyName;
if (isa<BuiltinType>(Ty)) {
llvm::MDNode *ScalarMD = getTypeInfoHelper(Ty);
StringRef Name =
cast<llvm::MDString>(
ScalarMD->getOperand(CodeGenOpts.NewStructPathTBAA ? 2 : 0))
->getString();
+ TyName = Name;
+ } else if (!isa<VariableArrayType>(Ty)) {
+ // For non-builtin types use the mangled name of the canonical type.
+ llvm::raw_svector_ostream TyOut(TyName);
+ Context.createMangleContext()->mangleCanonicalTypeName(QualType(Ty, 0),
----------------
rjmccall wrote:
Hmm. Maybe we should specifically force the use of Itanium mangling for this, just so we're guaranteed a certain amount of consistency between language modes?
https://github.com/llvm/llvm-project/pull/110569
More information about the cfe-commits
mailing list