1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

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.

llvm-svn: 264371
This commit is contained in:
Duncan P. N. Exon Smith 2016-03-25 00:35:38 +00:00
parent 866cc7fa60
commit f60239c0f1
4 changed files with 29 additions and 25 deletions

View File

@ -46,24 +46,25 @@ public:
// Pinned metadata names, which always have the same value. This is a // Pinned metadata names, which always have the same value. This is a
// compile-time performance optimization, not a correctness optimization. // compile-time performance optimization, not a correctness optimization.
enum { enum {
MD_dbg = 0, // "dbg" MD_dbg = 0, // "dbg"
MD_tbaa = 1, // "tbaa" MD_tbaa = 1, // "tbaa"
MD_prof = 2, // "prof" MD_prof = 2, // "prof"
MD_fpmath = 3, // "fpmath" MD_fpmath = 3, // "fpmath"
MD_range = 4, // "range" MD_range = 4, // "range"
MD_tbaa_struct = 5, // "tbaa.struct" MD_tbaa_struct = 5, // "tbaa.struct"
MD_invariant_load = 6, // "invariant.load" MD_invariant_load = 6, // "invariant.load"
MD_alias_scope = 7, // "alias.scope" MD_alias_scope = 7, // "alias.scope"
MD_noalias = 8, // "noalias", MD_noalias = 8, // "noalias",
MD_nontemporal = 9, // "nontemporal" MD_nontemporal = 9, // "nontemporal"
MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access" MD_mem_parallel_loop_access = 10, // "llvm.mem.parallel_loop_access"
MD_nonnull = 11, // "nonnull" MD_nonnull = 11, // "nonnull"
MD_dereferenceable = 12, // "dereferenceable" 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" MD_make_implicit = 14, // "make.implicit"
MD_unpredictable = 15, // "unpredictable" MD_unpredictable = 15, // "unpredictable"
MD_invariant_group = 16, // "invariant.group" MD_invariant_group = 16, // "invariant.group"
MD_align = 17 // "align" MD_align = 17, // "align"
MD_loop = 18, // "llvm.loop"
}; };
/// Known operand bundle tag IDs, which always have the same value. All /// Known operand bundle tag IDs, which always have the same value. All

View File

@ -47,9 +47,6 @@ static cl::opt<bool,true>
VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo), VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
cl::desc("Verify loop info (time consuming)")); cl::desc("Verify loop info (time consuming)"));
// Loop identifier metadata name.
static const char *const LoopMDName = "llvm.loop";
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Loop implementation // Loop implementation
// //
@ -222,7 +219,7 @@ bool Loop::isSafeToClone() const {
MDNode *Loop::getLoopID() const { MDNode *Loop::getLoopID() const {
MDNode *LoopID = nullptr; MDNode *LoopID = nullptr;
if (isLoopSimplifyForm()) { if (isLoopSimplifyForm()) {
LoopID = getLoopLatch()->getTerminator()->getMetadata(LoopMDName); LoopID = getLoopLatch()->getTerminator()->getMetadata(LLVMContext::MD_loop);
} else { } else {
// Go through each predecessor of the loop header and check the // Go through each predecessor of the loop header and check the
// terminator for the metadata. // terminator for the metadata.
@ -234,7 +231,7 @@ MDNode *Loop::getLoopID() const {
// Check if this terminator branches to the loop header. // Check if this terminator branches to the loop header.
for (BasicBlock *Successor : TI->successors()) { for (BasicBlock *Successor : TI->successors()) {
if (Successor == H) { if (Successor == H) {
MD = TI->getMetadata(LoopMDName); MD = TI->getMetadata(LLVMContext::MD_loop);
break; break;
} }
} }
@ -259,7 +256,7 @@ void Loop::setLoopID(MDNode *LoopID) const {
assert(LoopID->getOperand(0) == LoopID && "Loop ID should refer to itself"); assert(LoopID->getOperand(0) == LoopID && "Loop ID should refer to itself");
if (isLoopSimplifyForm()) { if (isLoopSimplifyForm()) {
getLoopLatch()->getTerminator()->setMetadata(LoopMDName, LoopID); getLoopLatch()->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
return; return;
} }
@ -268,7 +265,7 @@ void Loop::setLoopID(MDNode *LoopID) const {
TerminatorInst *TI = BB->getTerminator(); TerminatorInst *TI = BB->getTerminator();
for (BasicBlock *Successor : TI->successors()) { for (BasicBlock *Successor : TI->successors()) {
if (Successor == H) if (Successor == H)
TI->setMetadata(LoopMDName, LoopID); TI->setMetadata(LLVMContext::MD_loop, LoopID);
} }
} }
} }

View File

@ -128,6 +128,11 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
assert(AlignID == MD_align && "align kind id drifted"); assert(AlignID == MD_align && "align kind id drifted");
(void)AlignID; (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"); auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt");
assert(DeoptEntry->second == LLVMContext::OB_deopt && assert(DeoptEntry->second == LLVMContext::OB_deopt &&
"deopt operand bundle id drifted!"); "deopt operand bundle id drifted!");

View File

@ -432,7 +432,8 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
continue; continue;
} }
if (const BasicBlock *PBB = PMBB->getBasicBlock()) { 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")) if (GetUnrollMetadata(LoopID, "llvm.loop.unroll.disable"))
return true; return true;
} }