summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CodeGenTBAA.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r--lib/CodeGen/CodeGenTBAA.cpp36
1 files changed, 7 insertions, 29 deletions
diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp
index 9ee3f1d2e6..34f91e1621 100644
--- a/lib/CodeGen/CodeGenTBAA.cpp
+++ b/lib/CodeGen/CodeGenTBAA.cpp
@@ -28,7 +28,7 @@ using namespace CodeGen;
CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext& VMContext,
const LangOptions &Features, MangleContext &MContext)
: Context(Ctx), VMContext(VMContext), Features(Features), MContext(MContext),
- Root(0), Char(0) {
+ MDHelper(VMContext), Root(0), Char(0) {
}
CodeGenTBAA::~CodeGenTBAA() {
@@ -40,7 +40,7 @@ llvm::MDNode *CodeGenTBAA::getRoot() {
// (or a different version of this front-end), their TBAA trees will
// remain distinct, and the optimizer will treat them conservatively.
if (!Root)
- Root = getTBAAInfoForNamedType("Simple C/C++ TBAA", 0);
+ Root = MDHelper.CreateTBAARoot("Simple C/C++ TBAA");
return Root;
}
@@ -51,33 +51,11 @@ llvm::MDNode *CodeGenTBAA::getChar() {
// these special powers only cover user-accessible memory, and doesn't
// include things like vtables.
if (!Char)
- Char = getTBAAInfoForNamedType("omnipotent char", getRoot());
+ Char = MDHelper.CreateTBAANode("omnipotent char", getRoot());
return Char;
}
-/// getTBAAInfoForNamedType - Create a TBAA tree node with the given string
-/// as its identifier, and the given Parent node as its tree parent.
-llvm::MDNode *CodeGenTBAA::getTBAAInfoForNamedType(StringRef NameStr,
- llvm::MDNode *Parent,
- bool Readonly) {
- // Currently there is only one flag defined - the readonly flag.
- llvm::Value *Flags = 0;
- if (Readonly)
- Flags = llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), true);
-
- // Set up the mdnode operand list.
- llvm::Value *Ops[] = {
- llvm::MDString::get(VMContext, NameStr),
- Parent,
- Flags
- };
-
- // Create the mdnode.
- unsigned Len = llvm::array_lengthof(Ops) - !Flags;
- return llvm::MDNode::get(VMContext, llvm::makeArrayRef(Ops, Len));
-}
-
static bool TypeHasMayAlias(QualType QTy) {
// Tagged types have declarations, and therefore may have attributes.
if (const TagType *TTy = dyn_cast<TagType>(QTy))
@@ -137,7 +115,7 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
// "underlying types".
default:
return MetadataCache[Ty] =
- getTBAAInfoForNamedType(BTy->getName(Features), getChar());
+ MDHelper.CreateTBAANode(BTy->getName(Features), getChar());
}
}
@@ -145,7 +123,7 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
// TODO: Implement C++'s type "similarity" and consider dis-"similar"
// pointers distinct.
if (Ty->isPointerType())
- return MetadataCache[Ty] = getTBAAInfoForNamedType("any pointer",
+ return MetadataCache[Ty] = MDHelper.CreateTBAANode("any pointer",
getChar());
// Enum types are distinct types. In C++ they have "underlying types",
@@ -173,7 +151,7 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
llvm::raw_svector_ostream Out(OutName);
MContext.mangleCXXRTTIName(QualType(ETy, 0), Out);
Out.flush();
- return MetadataCache[Ty] = getTBAAInfoForNamedType(OutName, getChar());
+ return MetadataCache[Ty] = MDHelper.CreateTBAANode(OutName, getChar());
}
// For now, handle any other kind of type conservatively.
@@ -181,5 +159,5 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
}
llvm::MDNode *CodeGenTBAA::getTBAAInfoForVTablePtr() {
- return getTBAAInfoForNamedType("vtable pointer", getRoot());
+ return MDHelper.CreateTBAANode("vtable pointer", getRoot());
}