mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-05 01:31:05 +00:00
Resurrect the assertion removed by r227717
Summary: MSVC can compile "LoopID->getOperand(0) == LoopID" when LoopID is MDNode*. Test Plan: no regression Reviewers: mkuper Subscribers: jholewinski, llvm-commits Differential Revision: http://reviews.llvm.org/D7327 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
48da191fb3
commit
62d535ff3c
include/llvm/Transforms/Utils
lib
@ -34,7 +34,7 @@ bool UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool AllowRuntime,
|
||||
bool UnrollRuntimeLoopProlog(Loop *L, unsigned Count, LoopInfo *LI,
|
||||
LPPassManager* LPM);
|
||||
|
||||
const MDNode *GetUnrollMetadata(const MDNode *LoopID, StringRef Name);
|
||||
MDNode *GetUnrollMetadata(MDNode *LoopID, StringRef Name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -442,8 +442,7 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
|
||||
continue;
|
||||
}
|
||||
if (const BasicBlock *PBB = PMBB->getBasicBlock()) {
|
||||
if (const MDNode *LoopID =
|
||||
PBB->getTerminator()->getMetadata("llvm.loop")) {
|
||||
if (MDNode *LoopID = PBB->getTerminator()->getMetadata("llvm.loop")) {
|
||||
if (GetUnrollMetadata(LoopID, "llvm.loop.unroll.disable"))
|
||||
return true;
|
||||
}
|
||||
|
@ -231,11 +231,10 @@ static unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls,
|
||||
// Returns the loop hint metadata node with the given name (for example,
|
||||
// "llvm.loop.unroll.count"). If no such metadata node exists, then nullptr is
|
||||
// returned.
|
||||
static const MDNode *GetUnrollMetadataForLoop(const Loop *L, StringRef Name) {
|
||||
MDNode *LoopID = L->getLoopID();
|
||||
if (!LoopID)
|
||||
return nullptr;
|
||||
return GetUnrollMetadata(LoopID, Name);
|
||||
static MDNode *GetUnrollMetadataForLoop(const Loop *L, StringRef Name) {
|
||||
if (MDNode *LoopID = L->getLoopID())
|
||||
return GetUnrollMetadata(LoopID, Name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Returns true if the loop has an unroll(full) pragma.
|
||||
@ -251,7 +250,7 @@ static bool HasUnrollDisablePragma(const Loop *L) {
|
||||
// If loop has an unroll_count pragma return the (necessarily
|
||||
// positive) value from the pragma. Otherwise return 0.
|
||||
static unsigned UnrollCountPragmaValue(const Loop *L) {
|
||||
const MDNode *MD = GetUnrollMetadataForLoop(L, "llvm.loop.unroll.count");
|
||||
MDNode *MD = GetUnrollMetadataForLoop(L, "llvm.loop.unroll.count");
|
||||
if (MD) {
|
||||
assert(MD->getNumOperands() == 2 &&
|
||||
"Unroll count hint metadata should have two operands.");
|
||||
|
@ -553,16 +553,17 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
|
||||
/// Given an llvm.loop loop id metadata node, returns the loop hint metadata
|
||||
/// node with the given name (for example, "llvm.loop.unroll.count"). If no
|
||||
/// such metadata node exists, then nullptr is returned.
|
||||
const MDNode *llvm::GetUnrollMetadata(const MDNode *LoopID, StringRef Name) {
|
||||
MDNode *llvm::GetUnrollMetadata(MDNode *LoopID, StringRef Name) {
|
||||
// First operand should refer to the loop id itself.
|
||||
assert(LoopID->getNumOperands() > 0 && "requires at least one operand");
|
||||
assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
|
||||
|
||||
for (unsigned i = 1, e = LoopID->getNumOperands(); i < e; ++i) {
|
||||
const MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
|
||||
MDNode *MD = dyn_cast<MDNode>(LoopID->getOperand(i));
|
||||
if (!MD)
|
||||
continue;
|
||||
|
||||
const MDString *S = dyn_cast<MDString>(MD->getOperand(0));
|
||||
MDString *S = dyn_cast<MDString>(MD->getOperand(0));
|
||||
if (!S)
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user