1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Use this fantzy ArrayRef thing to pass in the list of predecessors.

llvm-svn: 137978
This commit is contained in:
Bill Wendling 2011-08-18 20:39:32 +00:00
parent 1876aadea7
commit dec05a3784

View File

@ -317,9 +317,8 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) {
/// UpdateAnalysisInformation - Update DominatorTree, LoopInfo, and LCCSA /// UpdateAnalysisInformation - Update DominatorTree, LoopInfo, and LCCSA
/// analysis information. /// analysis information.
static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB, static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
BasicBlock *const *Preds, ArrayRef<BasicBlock *> Preds,
unsigned NumPreds, Pass *P, Pass *P, bool &HasLoopExit) {
bool &HasLoopExit) {
if (!P) return; if (!P) return;
LoopInfo *LI = P->getAnalysisIfAvailable<LoopInfo>(); LoopInfo *LI = P->getAnalysisIfAvailable<LoopInfo>();
@ -331,18 +330,20 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
bool IsLoopEntry = !!L; bool IsLoopEntry = !!L;
bool SplitMakesNewLoopHeader = false; bool SplitMakesNewLoopHeader = false;
if (LI) { if (LI) {
for (unsigned i = 0; i != NumPreds; ++i) { for (ArrayRef<BasicBlock*>::iterator
i = Preds.begin(), e = Preds.end(); i != e; ++i) {
BasicBlock *Pred = *i;
// If we need to preserve LCSSA, determine if any of the preds is a loop // If we need to preserve LCSSA, determine if any of the preds is a loop
// exit. // exit.
if (PreserveLCSSA) if (PreserveLCSSA)
if (Loop *PL = LI->getLoopFor(Preds[i])) if (Loop *PL = LI->getLoopFor(Pred))
if (!PL->contains(OldBB)) if (!PL->contains(OldBB))
HasLoopExit = true; HasLoopExit = true;
// If we need to preserve LoopInfo, note whether any of the preds crosses // If we need to preserve LoopInfo, note whether any of the preds crosses
// an interesting loop boundary. // an interesting loop boundary.
if (!L) continue; if (!L) continue;
if (L->contains(Preds[i])) if (L->contains(Pred))
IsLoopEntry = false; IsLoopEntry = false;
else else
SplitMakesNewLoopHeader = true; SplitMakesNewLoopHeader = true;
@ -362,8 +363,10 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
// loops enclose them, and select the most-nested loop which contains the // loops enclose them, and select the most-nested loop which contains the
// loop containing the block being split. // loop containing the block being split.
Loop *InnermostPredLoop = 0; Loop *InnermostPredLoop = 0;
for (unsigned i = 0; i != NumPreds; ++i) for (ArrayRef<BasicBlock*>::iterator
if (Loop *PredLoop = LI->getLoopFor(Preds[i])) { i = Preds.begin(), e = Preds.end(); i != e; ++i) {
BasicBlock *Pred = *i;
if (Loop *PredLoop = LI->getLoopFor(Pred)) {
// Seek a loop which actually contains the block being split (to avoid // Seek a loop which actually contains the block being split (to avoid
// adjacent loops). // adjacent loops).
while (PredLoop && !PredLoop->contains(OldBB)) while (PredLoop && !PredLoop->contains(OldBB))
@ -375,6 +378,7 @@ static void UpdateAnalysisInformation(BasicBlock *OldBB, BasicBlock *NewBB,
InnermostPredLoop->getLoopDepth() < PredLoop->getLoopDepth())) InnermostPredLoop->getLoopDepth() < PredLoop->getLoopDepth()))
InnermostPredLoop = PredLoop; InnermostPredLoop = PredLoop;
} }
}
if (InnermostPredLoop) if (InnermostPredLoop)
InnermostPredLoop->addBasicBlockToLoop(NewBB, LI->getBase()); InnermostPredLoop->addBasicBlockToLoop(NewBB, LI->getBase());
@ -430,7 +434,8 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
// Update DominatorTree, LoopInfo, and LCCSA analysis information. // Update DominatorTree, LoopInfo, and LCCSA analysis information.
bool HasLoopExit = false; bool HasLoopExit = false;
UpdateAnalysisInformation(BB, NewBB, Preds, NumPreds, P, HasLoopExit); UpdateAnalysisInformation(BB, NewBB, ArrayRef<BasicBlock*>(Preds, NumPreds),
P, HasLoopExit);
// Otherwise, create a new PHI node in NewBB for each PHI node in BB. // Otherwise, create a new PHI node in NewBB for each PHI node in BB.
AliasAnalysis *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : 0; AliasAnalysis *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : 0;