[llvm] r264371 - IR: Reserve an MDKind for !llvm.loop; NFC

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 17:35:38 PDT 2016


Author: dexonsmith
Date: Thu Mar 24 19:35:38 2016
New Revision: 264371

URL: http://llvm.org/viewvc/llvm-project?rev=264371&view=rev
Log:
IR: Reserve an MDKind for !llvm.loop; NFC

This reserves an MDKind for !llvm.loop, which allows callers to avoid a
string-based lookup.  I'm not sure why it was missing.

There should be no functionality change here, just a small compile-time
speedup.

Modified:
    llvm/trunk/include/llvm/IR/LLVMContext.h
    llvm/trunk/lib/Analysis/LoopInfo.cpp
    llvm/trunk/lib/IR/LLVMContext.cpp
    llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Modified: llvm/trunk/include/llvm/IR/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LLVMContext.h?rev=264371&r1=264370&r2=264371&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/IR/LLVMContext.h Thu Mar 24 19:35:38 2016
@@ -46,24 +46,25 @@ public:
   // Pinned metadata names, which always have the same value.  This is a
   // compile-time performance optimization, not a correctness optimization.
   enum {
-    MD_dbg = 0,  // "dbg"
-    MD_tbaa = 1, // "tbaa"
-    MD_prof = 2,  // "prof"
-    MD_fpmath = 3,  // "fpmath"
-    MD_range = 4, // "range"
-    MD_tbaa_struct = 5, // "tbaa.struct"
-    MD_invariant_load = 6, // "invariant.load"
-    MD_alias_scope = 7, // "alias.scope"
-    MD_noalias = 8, // "noalias",
-    MD_nontemporal = 9, // "nontemporal"
+    MD_dbg = 0,                       // "dbg"
+    MD_tbaa = 1,                      // "tbaa"
+    MD_prof = 2,                      // "prof"
+    MD_fpmath = 3,                    // "fpmath"
+    MD_range = 4,                     // "range"
+    MD_tbaa_struct = 5,               // "tbaa.struct"
+    MD_invariant_load = 6,            // "invariant.load"
+    MD_alias_scope = 7,               // "alias.scope"
+    MD_noalias = 8,                   // "noalias",
+    MD_nontemporal = 9,               // "nontemporal"
     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_make_implicit = 14, // "make.implicit"
-    MD_unpredictable = 15, // "unpredictable"
-    MD_invariant_group = 16, // "invariant.group"
-    MD_align = 17 // "align"
+    MD_nonnull = 11,                  // "nonnull"
+    MD_dereferenceable = 12,          // "dereferenceable"
+    MD_dereferenceable_or_null = 13,  // "dereferenceable_or_null"
+    MD_make_implicit = 14,            // "make.implicit"
+    MD_unpredictable = 15,            // "unpredictable"
+    MD_invariant_group = 16,          // "invariant.group"
+    MD_align = 17,                    // "align"
+    MD_loop = 18,                     // "llvm.loop"
   };
 
   /// Known operand bundle tag IDs, which always have the same value.  All

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=264371&r1=264370&r2=264371&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Thu Mar 24 19:35:38 2016
@@ -47,9 +47,6 @@ static cl::opt<bool,true>
 VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
                 cl::desc("Verify loop info (time consuming)"));
 
-// Loop identifier metadata name.
-static const char *const LoopMDName = "llvm.loop";
-
 //===----------------------------------------------------------------------===//
 // Loop implementation
 //
@@ -222,7 +219,7 @@ bool Loop::isSafeToClone() const {
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
   if (isLoopSimplifyForm()) {
-    LoopID = getLoopLatch()->getTerminator()->getMetadata(LoopMDName);
+    LoopID = getLoopLatch()->getTerminator()->getMetadata(LLVMContext::MD_loop);
   } else {
     // Go through each predecessor of the loop header and check the
     // terminator for the metadata.
@@ -234,7 +231,7 @@ MDNode *Loop::getLoopID() const {
       // Check if this terminator branches to the loop header.
       for (BasicBlock *Successor : TI->successors()) {
         if (Successor == H) {
-          MD = TI->getMetadata(LoopMDName);
+          MD = TI->getMetadata(LLVMContext::MD_loop);
           break;
         }
       }
@@ -259,7 +256,7 @@ void Loop::setLoopID(MDNode *LoopID) con
   assert(LoopID->getOperand(0) == LoopID && "Loop ID should refer to itself");
 
   if (isLoopSimplifyForm()) {
-    getLoopLatch()->getTerminator()->setMetadata(LoopMDName, LoopID);
+    getLoopLatch()->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
     return;
   }
 
@@ -268,7 +265,7 @@ void Loop::setLoopID(MDNode *LoopID) con
     TerminatorInst *TI = BB->getTerminator();
     for (BasicBlock *Successor : TI->successors()) {
       if (Successor == H)
-        TI->setMetadata(LoopMDName, LoopID);
+        TI->setMetadata(LLVMContext::MD_loop, LoopID);
     }
   }
 }

Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=264371&r1=264370&r2=264371&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Thu Mar 24 19:35:38 2016
@@ -128,6 +128,11 @@ LLVMContext::LLVMContext() : pImpl(new L
   assert(AlignID == MD_align && "align kind id drifted");
   (void)AlignID;
 
+  // Create the 'llvm.loop' metadata kind.
+  unsigned LoopID = getMDKindID("llvm.loop");
+  assert(LoopID == MD_loop && "llvm.loop kind id drifted");
+  (void)LoopID;
+
   auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt");
   assert(DeoptEntry->second == LLVMContext::OB_deopt &&
          "deopt operand bundle id drifted!");

Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=264371&r1=264370&r2=264371&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Thu Mar 24 19:35:38 2016
@@ -432,7 +432,8 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUn
       continue;
     }
     if (const BasicBlock *PBB = PMBB->getBasicBlock()) {
-      if (MDNode *LoopID = PBB->getTerminator()->getMetadata("llvm.loop")) {
+      if (MDNode *LoopID =
+              PBB->getTerminator()->getMetadata(LLVMContext::MD_loop)) {
         if (GetUnrollMetadata(LoopID, "llvm.loop.unroll.disable"))
           return true;
       }




More information about the llvm-commits mailing list