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:
parent
866cc7fa60
commit
f60239c0f1
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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!");
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user