Add isConstant argument to MDBuilder::createTBAAStructTagNode
authorArtur Pilipenko <apilipenko@azulsystems.com>
Mon, 1 Jun 2015 14:53:55 +0000 (14:53 +0000)
committerArtur Pilipenko <apilipenko@azulsystems.com>
Mon, 1 Jun 2015 14:53:55 +0000 (14:53 +0000)
According to the TBAA description struct-path tag node can have an optional IsConstant field. Add corresponding argument to MDBuilder::createTBAAStructTagNode.

Reviewed By: hfinkel

Differential Revision: http://reviews.llvm.org/D10160

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238749 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/MDBuilder.h
lib/IR/MDBuilder.cpp

index ba14457f71855ee5a55a01271971161696bde7f6..ceb1c736e5c79e7c71dd93e7937cc0b56ef1cec0 100644 (file)
@@ -153,7 +153,7 @@ public:
   /// \brief Return metadata for a TBAA tag node with the given
   /// base type, access type and offset relative to the base type.
   MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
   /// \brief Return metadata for a TBAA tag node with the given
   /// base type, access type and offset relative to the base type.
   MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
-                                  uint64_t Offset);
+                                  uint64_t Offset, bool IsConstant = false);
 };
 
 } // end namespace llvm
 };
 
 } // end namespace llvm
index 354592df4c96750a7022d77d81908659b82788f5..b4c5ca7c6a12043c8de3ccd4eb7f4a170ff46c9f 100644 (file)
@@ -168,9 +168,16 @@ MDNode *MDBuilder::createTBAAScalarTypeNode(StringRef Name, MDNode *Parent,
 /// \brief Return metadata for a TBAA tag node with the given
 /// base type, access type and offset relative to the base type.
 MDNode *MDBuilder::createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
 /// \brief Return metadata for a TBAA tag node with the given
 /// base type, access type and offset relative to the base type.
 MDNode *MDBuilder::createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
-                                           uint64_t Offset) {
+                                           uint64_t Offset, bool IsConstant) {
   Type *Int64 = Type::getInt64Ty(Context);
   Type *Int64 = Type::getInt64Ty(Context);
-  Metadata *Ops[3] = {BaseType, AccessType,
-                      createConstant(ConstantInt::get(Int64, Offset))};
-  return MDNode::get(Context, Ops);
+  if (IsConstant) {
+    Metadata *Ops[4] = {BaseType, AccessType,
+                        createConstant(ConstantInt::get(Int64, Offset)),
+                        createConstant(ConstantInt::get(Int64, 1))};
+    return MDNode::get(Context, Ops);
+  } else {
+    Metadata *Ops[3] = {BaseType, AccessType,
+                        createConstant(ConstantInt::get(Int64, Offset))};
+    return MDNode::get(Context, Ops);
+  }
 }
 }