diff options
-rw-r--r-- | llvm/include/llvm/IR/LLVMContext.h | 35 | ||||
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 3 |
4 files changed, 29 insertions, 25 deletions
diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 54d08cf8e54..cd7fcfb7c17 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -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 diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 47a313a8f3a..e3e1a281a6c 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -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) const { 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) const { TerminatorInst *TI = BB->getTerminator(); for (BasicBlock *Successor : TI->successors()) { if (Successor == H) - TI->setMetadata(LoopMDName, LoopID); + TI->setMetadata(LLVMContext::MD_loop, LoopID); } } } diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index 77cefd038d8..151c2055813 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -128,6 +128,11 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { 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!"); diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 8a76896215b..c084b48fdc4 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -432,7 +432,8 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll( 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; } |