mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Revert "Revert r241570, it caused PR24053"
This reverts commit r241602. We had a latent bug in SCCP where we would make a basic block empty and then proceed to ask questions about it's terminator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241616 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a77796487b
commit
0148a4c854
@ -163,47 +163,40 @@ CallInst *BasicBlock::getTerminatingMustTailCall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Instruction* BasicBlock::getFirstNonPHI() {
|
Instruction* BasicBlock::getFirstNonPHI() {
|
||||||
BasicBlock::iterator i = begin();
|
for (Instruction &I : *this)
|
||||||
// All valid basic blocks should have a terminator,
|
if (!isa<PHINode>(I))
|
||||||
// which is not a PHINode. If we have an invalid basic
|
return &I;
|
||||||
// block we'll get an assertion failure when dereferencing
|
return nullptr;
|
||||||
// a past-the-end iterator.
|
|
||||||
while (isa<PHINode>(i)) ++i;
|
|
||||||
return &*i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction* BasicBlock::getFirstNonPHIOrDbg() {
|
Instruction* BasicBlock::getFirstNonPHIOrDbg() {
|
||||||
BasicBlock::iterator i = begin();
|
for (Instruction &I : *this)
|
||||||
// All valid basic blocks should have a terminator,
|
if (!isa<PHINode>(I) && !isa<DbgInfoIntrinsic>(I))
|
||||||
// which is not a PHINode. If we have an invalid basic
|
return &I;
|
||||||
// block we'll get an assertion failure when dereferencing
|
return nullptr;
|
||||||
// a past-the-end iterator.
|
|
||||||
while (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i)) ++i;
|
|
||||||
return &*i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
|
Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
|
||||||
// All valid basic blocks should have a terminator,
|
for (Instruction &I : *this) {
|
||||||
// which is not a PHINode. If we have an invalid basic
|
if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
|
||||||
// block we'll get an assertion failure when dereferencing
|
|
||||||
// a past-the-end iterator.
|
|
||||||
BasicBlock::iterator i = begin();
|
|
||||||
for (;; ++i) {
|
|
||||||
if (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(i);
|
if (auto *II = dyn_cast<IntrinsicInst>(&I))
|
||||||
if (!II)
|
if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
|
||||||
break;
|
II->getIntrinsicID() == Intrinsic::lifetime_end)
|
||||||
if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
|
continue;
|
||||||
II->getIntrinsicID() != Intrinsic::lifetime_end)
|
|
||||||
break;
|
return &I;
|
||||||
}
|
}
|
||||||
return &*i;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
|
BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
|
||||||
iterator InsertPt = getFirstNonPHI();
|
Instruction *FirstNonPHI = getFirstNonPHI();
|
||||||
|
if (!FirstNonPHI)
|
||||||
|
return end();
|
||||||
|
|
||||||
|
iterator InsertPt = FirstNonPHI;
|
||||||
if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
|
if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
|
||||||
return InsertPt;
|
return InsertPt;
|
||||||
}
|
}
|
||||||
|
@ -1799,11 +1799,10 @@ bool IPSCCP::runOnModule(Module &M) {
|
|||||||
if (!TI->use_empty())
|
if (!TI->use_empty())
|
||||||
TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
|
TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
|
||||||
TI->eraseFromParent();
|
TI->eraseFromParent();
|
||||||
|
new UnreachableInst(M.getContext(), BB);
|
||||||
|
|
||||||
if (&*BB != &F->front())
|
if (&*BB != &F->front())
|
||||||
BlocksToErase.push_back(BB);
|
BlocksToErase.push_back(BB);
|
||||||
else
|
|
||||||
new UnreachableInst(M.getContext(), BB);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user