summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTBAA.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r--lib/CodeGen/CodeGenTBAA.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp
index f394ea288d46..ad473032db17 100644
--- a/lib/CodeGen/CodeGenTBAA.cpp
+++ b/lib/CodeGen/CodeGenTBAA.cpp
@@ -59,7 +59,10 @@ llvm::MDNode *CodeGenTBAA::getRoot() {
llvm::MDNode *CodeGenTBAA::createScalarTypeNode(StringRef Name,
llvm::MDNode *Parent,
uint64_t Size) {
- (void)Size; // TODO: Support generation of size-aware type nodes.
+ if (CodeGenOpts.NewStructPathTBAA) {
+ llvm::Metadata *Id = MDHelper.createString(Name);
+ return MDHelper.createTBAATypeNode(Parent, Size, Id);
+ }
return MDHelper.createTBAAScalarTypeNode(Name, Parent);
}
@@ -158,6 +161,10 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
if (Ty->isPointerType() || Ty->isReferenceType())
return createScalarTypeNode("any pointer", getChar(), Size);
+ // Accesses to arrays are accesses to objects of their element types.
+ if (CodeGenOpts.NewStructPathTBAA && Ty->isArrayType())
+ return getTypeInfo(cast<ArrayType>(Ty)->getElementType());
+
// Enum types are distinct types. In C++ they have "underlying types",
// however they aren't related for TBAA.
if (const EnumType *ETy = dyn_cast<EnumType>(Ty)) {
@@ -300,8 +307,12 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type *Ty) {
OutName = RD->getName();
}
- // TODO: Support size-aware type nodes and create one here for the
- // given aggregate type.
+ if (CodeGenOpts.NewStructPathTBAA) {
+ llvm::MDNode *Parent = getChar();
+ uint64_t Size = Context.getTypeSizeInChars(Ty).getQuantity();
+ llvm::Metadata *Id = MDHelper.createString(OutName);
+ return MDHelper.createTBAATypeNode(Parent, Size, Id, Fields);
+ }
// Create the struct type node with a vector of pairs (offset, type).
SmallVector<std::pair<llvm::MDNode*, uint64_t>, 4> OffsetsAndTypes;
@@ -348,6 +359,10 @@ llvm::MDNode *CodeGenTBAA::getAccessTagInfo(TBAAAccessInfo Info) {
Info.BaseType = Info.AccessType;
assert(!Info.Offset && "Nonzero offset for an access with no base type!");
}
+ if (CodeGenOpts.NewStructPathTBAA) {
+ return N = MDHelper.createTBAAAccessTag(Info.BaseType, Info.AccessType,
+ Info.Offset, Info.Size);
+ }
return N = MDHelper.createTBAAStructTagNode(Info.BaseType, Info.AccessType,
Info.Offset);
}