[cfe-commits] r117328 - in /cfe/trunk/lib/CodeGen: CodeGenTBAA.cpp CodeGenTBAA.h

Dan Gohman gohman at apple.com
Mon Oct 25 16:51:23 PDT 2010


Author: djg
Date: Mon Oct 25 18:51:23 2010
New Revision: 117328

URL: http://llvm.org/viewvc/llvm-project?rev=117328&view=rev
Log:
Add infrastructure for emitting TBAA metadata with the "constant" flag.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
    cfe/trunk/lib/CodeGen/CodeGenTBAA.h

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=117328&r1=117327&r2=117328&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Mon Oct 25 18:51:23 2010
@@ -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 @@
 /// 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 *

Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.h?rev=117328&r1=117327&r2=117328&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTBAA.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTBAA.h Mon Oct 25 18:51:23 2010
@@ -56,7 +56,8 @@
   llvm::MDNode *getChar();
 
   llvm::MDNode *getTBAAInfoForNamedType(llvm::StringRef NameStr,
-                                        llvm::MDNode *Parent);
+                                        llvm::MDNode *Parent,
+                                        bool Readonly = false);
 
 public:
   CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,





More information about the cfe-commits mailing list