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

@ -63,7 +63,8 @@ public:
MD_make_implicit = 14, // "make.implicit"
MD_unpredictable = 15, // "unpredictable"
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

View File

@ -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);
}
}
}

View File

@ -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!");

View File

@ -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;
}