From dc2c4db5981f3362c0c413cdf445f15d9810696a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 25 Oct 2010 23:51:23 +0000 Subject: Add infrastructure for emitting TBAA metadata with the "constant" flag. llvm-svn: 117328 --- clang/lib/CodeGen/CodeGenTBAA.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenTBAA.cpp') diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index d8618f0d3ad..d4d71a75574 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/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 * -- cgit v1.2.3