Introduce enum value for previously defined metadata -- make.implicit
authorChen Li <meloli87@gmail.com>
Tue, 4 Aug 2015 04:41:34 +0000 (04:41 +0000)
committerChen Li <meloli87@gmail.com>
Tue, 4 Aug 2015 04:41:34 +0000 (04:41 +0000)
Summary: This patch adds enum value for an existing metadata type -- make.implicit. Using preassigned enum will be helpful to get compile time type checking and avoid string construction and comparison. The patch also changes uses of make.implicit from string metadata to enum metadata. There is no functionality change.

Reviewers: reames

Subscribers: llvm-commits

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

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

include/llvm/IR/LLVMContext.h
lib/CodeGen/ImplicitNullChecks.cpp
lib/IR/LLVMContext.cpp

index e6c22090ab6d8044dd57e93c5d5b86d3765d0789..e58f2a9b01ee122b85d6039370b47c7819e4cd8d 100644 (file)
@@ -60,7 +60,8 @@ public:
     MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access"
     MD_nonnull = 11, // "nonnull"
     MD_dereferenceable = 12, // "dereferenceable"
-    MD_dereferenceable_or_null = 13 // "dereferenceable_or_null"
+    MD_dereferenceable_or_null = 13, // "dereferenceable_or_null"
+    MD_make_implicit = 14 // "make.implicit"
   };
 
   /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
index fbe057791c541a5a1507938d81fcd4d9c9b8295c..26e536cae2f2127a203fdb777bd8a0c51c640d5a 100644 (file)
@@ -38,6 +38,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Instruction.h"
+#include "llvm/IR/LLVMContext.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
@@ -134,7 +135,7 @@ bool ImplicitNullChecks::analyzeBlockForNullChecks(
 
   MDNode *BranchMD =
       MBB.getBasicBlock()
-          ? MBB.getBasicBlock()->getTerminator()->getMetadata("make.implicit")
+          ? MBB.getBasicBlock()->getTerminator()->getMetadata(LLVMContext::MD_make_implicit)
           : nullptr;
   if (!BranchMD)
     return false;
index 6d799e4b96505a5d722df6892e92a622bb205057..59680f5eef5ac1533302b99ee619bb9d938171f2 100644 (file)
@@ -104,6 +104,12 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
   assert(DereferenceableOrNullID == MD_dereferenceable_or_null && 
          "dereferenceable_or_null kind id drifted");
   (void)DereferenceableOrNullID;
+
+  // Create the 'make.implicit' metadata kind.
+  unsigned MakeImplicitID = getMDKindID("make.implicit");
+  assert(MakeImplicitID == MD_make_implicit &&
+         "make.implicit kind id drifted");
+  (void)MakeImplicitID;
 }
 LLVMContext::~LLVMContext() { delete pImpl; }