mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Revert "[C++11] Add predecessors(BasicBlock *) / successors(BasicBlock *) iterator ranges."
This reverts commit r213474 (and r213475), which causes a miscompile on a stage2 LTO build. I'll reply on the list in a moment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213562 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -114,7 +114,9 @@ BasicBlock *llvm::InsertPreheaderForLoop(Loop *L, Pass *PP) {
|
||||
|
||||
// Compute the set of predecessors of the loop that are not in the loop.
|
||||
SmallVector<BasicBlock*, 8> OutsideBlocks;
|
||||
for (BasicBlock *P : predecessors(Header)) {
|
||||
for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header);
|
||||
PI != PE; ++PI) {
|
||||
BasicBlock *P = *PI;
|
||||
if (!L->contains(P)) { // Coming in from outside the loop?
|
||||
// If the loop is branched to from an indirect branch, we won't
|
||||
// be able to fully transform the loop, because it prohibits
|
||||
@ -156,7 +158,8 @@ BasicBlock *llvm::InsertPreheaderForLoop(Loop *L, Pass *PP) {
|
||||
/// the loop.
|
||||
static BasicBlock *rewriteLoopExitBlock(Loop *L, BasicBlock *Exit, Pass *PP) {
|
||||
SmallVector<BasicBlock*, 8> LoopBlocks;
|
||||
for (BasicBlock *P : predecessors(Exit)) {
|
||||
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I) {
|
||||
BasicBlock *P = *I;
|
||||
if (L->contains(P)) {
|
||||
// Don't do this if the loop is exited via an indirect branch.
|
||||
if (isa<IndirectBrInst>(P->getTerminator())) return nullptr;
|
||||
@ -196,8 +199,10 @@ static void addBlockAndPredsToSet(BasicBlock *InputBB, BasicBlock *StopBlock,
|
||||
if (Blocks.insert(BB).second && BB != StopBlock)
|
||||
// If BB is not already processed and it is not a stop block then
|
||||
// insert its predecessor in the work list
|
||||
for (BasicBlock *WBB : predecessors(BB))
|
||||
for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
|
||||
BasicBlock *WBB = *I;
|
||||
Worklist.push_back(WBB);
|
||||
}
|
||||
} while (!Worklist.empty());
|
||||
}
|
||||
|
||||
@ -311,7 +316,8 @@ static Loop *separateNestedLoop(Loop *L, BasicBlock *Preheader,
|
||||
// Determine which blocks should stay in L and which should be moved out to
|
||||
// the Outer loop now.
|
||||
std::set<BasicBlock*> BlocksInL;
|
||||
for (BasicBlock *P : predecessors(Header)) {
|
||||
for (pred_iterator PI=pred_begin(Header), E = pred_end(Header); PI!=E; ++PI) {
|
||||
BasicBlock *P = *PI;
|
||||
if (DT->dominates(Header, P))
|
||||
addBlockAndPredsToSet(P, Header, BlocksInL);
|
||||
}
|
||||
@ -365,7 +371,9 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader,
|
||||
|
||||
// Figure out which basic blocks contain back-edges to the loop header.
|
||||
std::vector<BasicBlock*> BackedgeBlocks;
|
||||
for (BasicBlock *P : predecessors(Header)) {
|
||||
for (pred_iterator I = pred_begin(Header), E = pred_end(Header); I != E; ++I){
|
||||
BasicBlock *P = *I;
|
||||
|
||||
// Indirectbr edges cannot be split, so we must fail if we find one.
|
||||
if (isa<IndirectBrInst>(P->getTerminator()))
|
||||
return nullptr;
|
||||
@ -480,7 +488,9 @@ ReprocessLoop:
|
||||
if (*BB == L->getHeader()) continue;
|
||||
|
||||
SmallPtrSet<BasicBlock*, 4> BadPreds;
|
||||
for (BasicBlock *P : predecessors(*BB)) {
|
||||
for (pred_iterator PI = pred_begin(*BB),
|
||||
PE = pred_end(*BB); PI != PE; ++PI) {
|
||||
BasicBlock *P = *PI;
|
||||
if (!L->contains(P))
|
||||
BadPreds.insert(P);
|
||||
}
|
||||
@ -493,8 +503,8 @@ ReprocessLoop:
|
||||
<< (*I)->getName() << "\n");
|
||||
|
||||
// Inform each successor of each dead pred.
|
||||
for (BasicBlock *Succ : successors(*I))
|
||||
Succ->removePredecessor(*I);
|
||||
for (succ_iterator SI = succ_begin(*I), SE = succ_end(*I); SI != SE; ++SI)
|
||||
(*SI)->removePredecessor(*I);
|
||||
// Zap the dead pred's terminator and replace it with unreachable.
|
||||
TerminatorInst *TI = (*I)->getTerminator();
|
||||
TI->replaceAllUsesWith(UndefValue::get(TI->getType()));
|
||||
@ -551,10 +561,11 @@ ReprocessLoop:
|
||||
for (SmallSetVector<BasicBlock *, 8>::iterator I = ExitBlockSet.begin(),
|
||||
E = ExitBlockSet.end(); I != E; ++I) {
|
||||
BasicBlock *ExitBlock = *I;
|
||||
for (BasicBlock *Pred : predecessors(ExitBlock))
|
||||
for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock);
|
||||
PI != PE; ++PI)
|
||||
// Must be exactly this loop: no subloops, parent loops, or non-loop preds
|
||||
// allowed.
|
||||
if (!L->contains(Pred)) {
|
||||
if (!L->contains(*PI)) {
|
||||
if (rewriteLoopExitBlock(L, ExitBlock, PP)) {
|
||||
++NumInserted;
|
||||
Changed = true;
|
||||
|
Reference in New Issue
Block a user