mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
SplitBlockPredecessors uses ArrayRef instead of Data and Size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146277 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -453,9 +453,8 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
|
||||
/// of the edges being split is an exit of a loop with other exits).
|
||||
///
|
||||
BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
|
||||
BasicBlock *const *Preds,
|
||||
unsigned NumPreds, const char *Suffix,
|
||||
Pass *P) {
|
||||
ArrayRef<BasicBlock*> Preds,
|
||||
const char *Suffix, Pass *P) {
|
||||
// Create new basic block, insert right before the original block.
|
||||
BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), BB->getName()+Suffix,
|
||||
BB->getParent(), BB);
|
||||
@@ -464,7 +463,7 @@ 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, e = Preds.size(); i != e; ++i) {
|
||||
// This is slightly more strict than necessary; the minimum requirement
|
||||
// is that there be no more than one indirectbr branching to BB. And
|
||||
// all BlockAddress uses would need to be updated.
|
||||
@@ -477,7 +476,7 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
|
||||
// node becomes an incoming value for BB's phi node. However, if the Preds
|
||||
// list is empty, we need to insert dummy entries into the PHI nodes in BB to
|
||||
// account for the newly created predecessor.
|
||||
if (NumPreds == 0) {
|
||||
if (Preds.size() == 0) {
|
||||
// Insert dummy values as the incoming value.
|
||||
for (BasicBlock::iterator I = BB->begin(); isa<PHINode>(I); ++I)
|
||||
cast<PHINode>(I)->addIncoming(UndefValue::get(I->getType()), NewBB);
|
||||
@@ -486,12 +485,10 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
|
||||
|
||||
// Update DominatorTree, LoopInfo, and LCCSA analysis information.
|
||||
bool HasLoopExit = false;
|
||||
UpdateAnalysisInformation(BB, NewBB, ArrayRef<BasicBlock*>(Preds, NumPreds),
|
||||
P, HasLoopExit);
|
||||
UpdateAnalysisInformation(BB, NewBB, Preds, P, HasLoopExit);
|
||||
|
||||
// Update the PHI nodes in BB with the values coming from NewBB.
|
||||
UpdatePHINodes(BB, NewBB, ArrayRef<BasicBlock*>(Preds, NumPreds), BI,
|
||||
P, HasLoopExit);
|
||||
UpdatePHINodes(BB, NewBB, Preds, BI, P, HasLoopExit);
|
||||
return NewBB;
|
||||
}
|
||||
|
||||
|
@@ -372,8 +372,7 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum,
|
||||
// form, which we're in the process of restoring!
|
||||
if (!Preds.empty() && HasPredOutsideOfLoop) {
|
||||
BasicBlock *NewExitBB =
|
||||
SplitBlockPredecessors(Exit, Preds.data(), Preds.size(),
|
||||
"split", P);
|
||||
SplitBlockPredecessors(Exit, Preds, "split", P);
|
||||
if (P->mustPreserveAnalysisID(LCSSAID))
|
||||
CreatePHIsForSplitLoopExit(Preds, NewExitBB, Exit);
|
||||
}
|
||||
|
@@ -380,8 +380,7 @@ BasicBlock *LoopSimplify::InsertPreheaderForLoop(Loop *L) {
|
||||
|
||||
// Split out the loop pre-header.
|
||||
BasicBlock *NewBB =
|
||||
SplitBlockPredecessors(Header, &OutsideBlocks[0], OutsideBlocks.size(),
|
||||
".preheader", this);
|
||||
SplitBlockPredecessors(Header, OutsideBlocks, ".preheader", this);
|
||||
|
||||
NewBB->getTerminator()->setDebugLoc(Header->getFirstNonPHI()->getDebugLoc());
|
||||
DEBUG(dbgs() << "LoopSimplify: Creating pre-header " << NewBB->getName()
|
||||
@@ -420,9 +419,7 @@ BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
|
||||
this, NewBBs);
|
||||
NewExitBB = NewBBs[0];
|
||||
} else {
|
||||
NewExitBB = SplitBlockPredecessors(Exit, &LoopBlocks[0],
|
||||
LoopBlocks.size(), ".loopexit",
|
||||
this);
|
||||
NewExitBB = SplitBlockPredecessors(Exit, LoopBlocks, ".loopexit", this);
|
||||
}
|
||||
|
||||
DEBUG(dbgs() << "LoopSimplify: Creating dedicated exit block "
|
||||
@@ -556,9 +553,8 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L, LPPassManager &LPM) {
|
||||
SE->forgetLoop(L);
|
||||
|
||||
BasicBlock *Header = L->getHeader();
|
||||
BasicBlock *NewBB = SplitBlockPredecessors(Header, &OuterLoopPreds[0],
|
||||
OuterLoopPreds.size(),
|
||||
".outer", this);
|
||||
BasicBlock *NewBB =
|
||||
SplitBlockPredecessors(Header, OuterLoopPreds, ".outer", this);
|
||||
|
||||
// Make sure that NewBB is put someplace intelligent, which doesn't mess up
|
||||
// code layout too horribly.
|
||||
|
@@ -114,8 +114,7 @@ static void ConnectProlog(Loop *L, Value *TripCount, unsigned Count,
|
||||
// Split the exit to maintain loop canonicalization guarantees
|
||||
SmallVector<BasicBlock*, 4> Preds(pred_begin(Exit), pred_end(Exit));
|
||||
if (!Exit->isLandingPad()) {
|
||||
SplitBlockPredecessors(Exit, Preds.data(), Preds.size(),
|
||||
".unr-lcssa", P);
|
||||
SplitBlockPredecessors(Exit, Preds, ".unr-lcssa", P);
|
||||
} else {
|
||||
SmallVector<BasicBlock*, 2> NewBBs;
|
||||
SplitLandingPadPredecessors(Exit, Preds, ".unr1-lcssa", ".unr2-lcssa",
|
||||
|
Reference in New Issue
Block a user