diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-25 23:51:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-25 23:51:23 +0000 |
commit | 455553b7e5d5233acf48967874c43b4a5d7e24d1 (patch) | |
tree | e86b3675ab27b254791f16746a9d857e7fb576f5 /lib/CodeGen/CodeGenTBAA.cpp | |
parent | e946fc833d8592aa2890bfd9839f1ad839b3d284 (diff) |
Add infrastructure for emitting TBAA metadata with the "constant" flag.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117328 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTBAA.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp index d8618f0d3a..d4d71a7557 100644 --- a/lib/CodeGen/CodeGenTBAA.cpp +++ b/lib/CodeGen/CodeGenTBAA.cpp @@ -20,6 +20,8 @@ #include "clang/AST/ASTContext.h" #include "llvm/LLVMContext.h" #include "llvm/Metadata.h" +#include "llvm/Constants.h" +#include "llvm/Type.h" using namespace clang; using namespace CodeGen; @@ -57,13 +59,22 @@ llvm::MDNode *CodeGenTBAA::getChar() { /// 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(llvm::StringRef NameStr, - llvm::MDNode *Parent) { + 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 + Parent, + Flags }; - return llvm::MDNode::get(VMContext, Ops, llvm::array_lengthof(Ops)); + // Create the mdnode. + return llvm::MDNode::get(VMContext, Ops, llvm::array_lengthof(Ops) - !Flags); } llvm::MDNode * |