[llvm] r243954 - Introduce enum value for previously defined metadata -- make.implicit

Chen Li meloli87 at gmail.com
Mon Aug 3 21:41:35 PDT 2015


Author: chenli
Date: Mon Aug  3 23:41:34 2015
New Revision: 243954

URL: http://llvm.org/viewvc/llvm-project?rev=243954&view=rev
Log:
Introduce enum value for previously defined metadata -- make.implicit 

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

Modified:
    llvm/trunk/include/llvm/IR/LLVMContext.h
    llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
    llvm/trunk/lib/IR/LLVMContext.cpp

Modified: llvm/trunk/include/llvm/IR/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LLVMContext.h?rev=243954&r1=243953&r2=243954&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/IR/LLVMContext.h Mon Aug  3 23:41:34 2015
@@ -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.

Modified: llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp?rev=243954&r1=243953&r2=243954&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp (original)
+++ llvm/trunk/lib/CodeGen/ImplicitNullChecks.cpp Mon Aug  3 23:41:34 2015
@@ -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::analyzeBlockFor
 
   MDNode *BranchMD =
       MBB.getBasicBlock()
-          ? MBB.getBasicBlock()->getTerminator()->getMetadata("make.implicit")
+          ? MBB.getBasicBlock()->getTerminator()->getMetadata(LLVMContext::MD_make_implicit)
           : nullptr;
   if (!BranchMD)
     return false;

Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=243954&r1=243953&r2=243954&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Mon Aug  3 23:41:34 2015
@@ -104,6 +104,12 @@ LLVMContext::LLVMContext() : pImpl(new L
   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; }
 





More information about the llvm-commits mailing list