mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50265 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -161,7 +161,6 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
|
||||
while (isa<PHINode>(SplitIt))
|
||||
++SplitIt;
|
||||
BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split");
|
||||
New->setUnwindDest(Old->getUnwindDest());
|
||||
|
||||
// The new block lives in whichever loop the old one did.
|
||||
if (Loop *L = LI.getLoopFor(Old))
|
||||
@@ -210,12 +209,8 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
|
||||
BranchInst *BI = BranchInst::Create(BB, NewBB);
|
||||
|
||||
// Move the edges from Preds to point to NewBB instead of BB.
|
||||
for (unsigned i = 0; i != NumPreds; ++i) {
|
||||
for (unsigned i = 0; i != NumPreds; ++i)
|
||||
Preds[i]->getTerminator()->replaceUsesOfWith(BB, NewBB);
|
||||
|
||||
if (Preds[i]->getUnwindDest() == BB)
|
||||
Preds[i]->setUnwindDest(NewBB);
|
||||
}
|
||||
|
||||
// Update dominator tree and dominator frontier if available.
|
||||
DominatorTree *DT = P ? P->getAnalysisToUpdate<DominatorTree>() : 0;
|
||||
|
@@ -34,7 +34,6 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
|
||||
ClonedCodeInfo *CodeInfo) {
|
||||
BasicBlock *NewBB = BasicBlock::Create("", F);
|
||||
if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
|
||||
NewBB->setUnwindDest(const_cast<BasicBlock*>(BB->getUnwindDest()));
|
||||
|
||||
bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
|
||||
|
||||
@@ -108,15 +107,10 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
||||
// references as we go. This uses ValueMap to do all the hard work.
|
||||
//
|
||||
for (Function::iterator BB = cast<BasicBlock>(ValueMap[OldFunc->begin()]),
|
||||
BE = NewFunc->end(); BB != BE; ++BB) {
|
||||
// Fix up the unwind destination.
|
||||
if (BasicBlock *UnwindDest = BB->getUnwindDest())
|
||||
BB->setUnwindDest(cast<BasicBlock>(ValueMap[UnwindDest]));
|
||||
|
||||
BE = NewFunc->end(); BB != BE; ++BB)
|
||||
// Loop over all instructions, fixing each one as we find it...
|
||||
for (BasicBlock::iterator II = BB->begin(); II != BB->end(); ++II)
|
||||
RemapInstruction(II, ValueMap);
|
||||
}
|
||||
}
|
||||
|
||||
/// CloneFunction - Return a copy of the specified function, but without
|
||||
|
@@ -130,10 +130,6 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI,
|
||||
for(SmallVector<BasicBlock *, 16>::iterator NBItr = NewBlocks.begin(),
|
||||
NBE = NewBlocks.end(); NBItr != NBE; ++NBItr) {
|
||||
BasicBlock *NB = *NBItr;
|
||||
|
||||
if (BasicBlock *UnwindDest = NB->getUnwindDest())
|
||||
NB->setUnwindDest(cast<BasicBlock>(ValueMap[UnwindDest]));
|
||||
|
||||
for(BasicBlock::iterator BI = NB->begin(), BE = NB->end();
|
||||
BI != BE; ++BI) {
|
||||
Instruction *Insn = BI;
|
||||
|
@@ -68,11 +68,6 @@ llvm::CloneTrace(const std::vector<BasicBlock*> &origTrace) {
|
||||
//Second loop to do the remapping
|
||||
for (std::vector<BasicBlock *>::const_iterator BB = clonedTrace.begin(),
|
||||
BE = clonedTrace.end(); BB != BE; ++BB) {
|
||||
|
||||
//Remap the unwind destination
|
||||
if (BasicBlock *UnwindDest = (*BB)->getUnwindDest())
|
||||
(*BB)->setUnwindDest(cast<BasicBlock>(ValueMap[UnwindDest]));
|
||||
|
||||
for (BasicBlock::iterator I = (*BB)->begin(); I != (*BB)->end(); ++I) {
|
||||
//Loop over all the operands of the instruction
|
||||
for (unsigned op=0, E = I->getNumOperands(); op != E; ++op) {
|
||||
|
@@ -203,7 +203,6 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
||||
|
||||
BasicBlock *OrigBB = TheCall->getParent();
|
||||
Function *Caller = OrigBB->getParent();
|
||||
BasicBlock *UnwindBB = OrigBB->getUnwindDest();
|
||||
|
||||
// GC poses two hazards to inlining, which only occur when the callee has GC:
|
||||
// 1. If the caller has no GC, then the callee's GC must be propagated to the
|
||||
@@ -419,18 +418,6 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we are inlining a function that unwinds into a BB with an unwind dest,
|
||||
// turn the inlined unwinds into branches to the unwind dest.
|
||||
if (InlinedFunctionInfo.ContainsUnwinds && UnwindBB && isa<CallInst>(TheCall))
|
||||
for (Function::iterator BB = FirstNewBlock, E = Caller->end();
|
||||
BB != E; ++BB) {
|
||||
TerminatorInst *Term = BB->getTerminator();
|
||||
if (isa<UnwindInst>(Term)) {
|
||||
BranchInst::Create(UnwindBB, Term);
|
||||
BB->getInstList().erase(Term);
|
||||
}
|
||||
}
|
||||
|
||||
// If we are inlining for an invoke instruction, we must make sure to rewrite
|
||||
// any inlined 'unwind' instructions into branches to the invoke exception
|
||||
// destination, and call instructions into invoke instructions.
|
||||
|
@@ -125,17 +125,18 @@ bool LoopSimplify::runOnFunction(Function &F) {
|
||||
if (LI->getLoopFor(BB)) continue;
|
||||
|
||||
bool BlockUnreachable = false;
|
||||
TerminatorInst *TI = BB->getTerminator();
|
||||
|
||||
// Check to see if any successors of this block are non-loop-header loops
|
||||
// that are not the header.
|
||||
for (succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I) {
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
|
||||
// If this successor is not in a loop, BB is clearly ok.
|
||||
Loop *L = LI->getLoopFor(*I);
|
||||
Loop *L = LI->getLoopFor(TI->getSuccessor(i));
|
||||
if (!L) continue;
|
||||
|
||||
// If the succ is the loop header, and if L is a top-level loop, then this
|
||||
// is an entrance into a loop through the header, which is also ok.
|
||||
if (L->getHeader() == *I && L->getParentLoop() == 0)
|
||||
if (L->getHeader() == TI->getSuccessor(i) && L->getParentLoop() == 0)
|
||||
continue;
|
||||
|
||||
// Otherwise, this is an entrance into a loop from some place invalid.
|
||||
@@ -153,11 +154,10 @@ bool LoopSimplify::runOnFunction(Function &F) {
|
||||
// loop by replacing the terminator.
|
||||
|
||||
// Remove PHI entries from the successors.
|
||||
for (succ_iterator I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
|
||||
(*I)->removePredecessor(BB);
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||
TI->getSuccessor(i)->removePredecessor(BB);
|
||||
|
||||
// Add a new unreachable instruction before the old terminator.
|
||||
TerminatorInst *TI = BB->getTerminator();
|
||||
new UnreachableInst(TI);
|
||||
|
||||
// Delete the dead terminator.
|
||||
@@ -576,15 +576,12 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
|
||||
}
|
||||
|
||||
// Now that all of the PHI nodes have been inserted and adjusted, modify the
|
||||
// backedge blocks to branch to the BEBlock instead of the header.
|
||||
// backedge blocks to just to the BEBlock instead of the header.
|
||||
for (unsigned i = 0, e = BackedgeBlocks.size(); i != e; ++i) {
|
||||
TerminatorInst *TI = BackedgeBlocks[i]->getTerminator();
|
||||
for (unsigned Op = 0, e = TI->getNumSuccessors(); Op != e; ++Op)
|
||||
if (TI->getSuccessor(Op) == Header)
|
||||
TI->setSuccessor(Op, BEBlock);
|
||||
|
||||
if (BackedgeBlocks[i]->getUnwindDest() == Header)
|
||||
BackedgeBlocks[i]->setUnwindDest(BEBlock);
|
||||
}
|
||||
|
||||
//===--- Update all analyses which we must preserve now -----------------===//
|
||||
|
@@ -1342,8 +1342,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
SmallVector<BasicBlock*, 8> UncondBranchPreds;
|
||||
SmallVector<BranchInst*, 8> CondBranchPreds;
|
||||
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
|
||||
if ((*PI)->getUnwindDest() == BB) continue;
|
||||
|
||||
TerminatorInst *PTI = (*PI)->getTerminator();
|
||||
if (BranchInst *BI = dyn_cast<BranchInst>(PTI)) {
|
||||
if (BI->isUnconditional())
|
||||
@@ -1408,14 +1406,8 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
SmallVector<BasicBlock*, 8> Preds(pred_begin(BB), pred_end(BB));
|
||||
while (!Preds.empty()) {
|
||||
BasicBlock *Pred = Preds.back();
|
||||
|
||||
if (Pred->getUnwindDest() == BB) {
|
||||
Pred->setUnwindDest(NULL);
|
||||
Changed = true;
|
||||
}
|
||||
|
||||
if (BranchInst *BI = dyn_cast<BranchInst>(Pred->getTerminator())) {
|
||||
if (BI->isUnconditional() && BI->getSuccessor(0) == BB) {
|
||||
if (BI->isUnconditional()) {
|
||||
Pred->getInstList().pop_back(); // nuke uncond branch
|
||||
new UnwindInst(Pred); // Use unwind.
|
||||
Changed = true;
|
||||
@@ -1840,7 +1832,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
|
||||
BasicBlock *OnlySucc = 0;
|
||||
if (OnlyPred && OnlyPred != BB && // Don't break self loops
|
||||
OnlyPred->getUnwindDest() != BB &&
|
||||
OnlyPred->getTerminator()->getOpcode() != Instruction::Invoke) {
|
||||
// Check to see if there is only one distinct successor...
|
||||
succ_iterator SI(succ_begin(OnlyPred)), SE(succ_end(OnlyPred));
|
||||
@@ -1852,8 +1843,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
}
|
||||
}
|
||||
|
||||
if (OnlySucc && (BB->getUnwindDest() == OnlyPred->getUnwindDest() ||
|
||||
!BB->getUnwindDest() || !OnlyPred->getUnwindDest())) {
|
||||
if (OnlySucc) {
|
||||
DOUT << "Merging: " << *BB << "into: " << *OnlyPred;
|
||||
|
||||
// Resolve any PHI nodes at the start of the block. They are all
|
||||
@@ -1873,10 +1863,6 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
// Move all definitions in the successor to the predecessor.
|
||||
OnlyPred->getInstList().splice(OnlyPred->end(), BB->getInstList());
|
||||
|
||||
// Move the unwind destination block
|
||||
if (!OnlyPred->getUnwindDest() && BB->getUnwindDest())
|
||||
OnlyPred->setUnwindDest(BB->getUnwindDest());
|
||||
|
||||
// Make all PHI nodes that referred to BB now refer to Pred as their
|
||||
// source.
|
||||
BB->replaceAllUsesWith(OnlyPred);
|
||||
|
Reference in New Issue
Block a user