The SSAUpdater should avoid recursive traversals of the CFG, since that may

blow out the stack for really big functions.  Start by fixing an easy case.

llvm-svn: 100126
This commit is contained in:
Bob Wilson 2010-04-01 18:46:59 +00:00
parent b242683d99
commit 38fc88ee5d
2 changed files with 24 additions and 16 deletions

View File

@ -111,7 +111,7 @@ private:
void FindExistingPHI(BasicBlock *BB, BBInfo *Info);
bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val);
void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
void ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
void ClearPHITags(PHINode *PHI);
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT

View File

@ -427,7 +427,7 @@ void SSAUpdater::FindExistingPHI(BasicBlock *BB, BBInfo *Info) {
RecordMatchingPHI(BB, Info, SomePHI);
break;
}
ClearPHITags(BB, Info, SomePHI);
ClearPHITags(SomePHI);
}
}
@ -490,20 +490,28 @@ void SSAUpdater::RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
}
/// ClearPHITags - When one of the existing PHI nodes fails to match, clear
/// the PHITag values stored in the BBMap while checking to see if it matched.
void SSAUpdater::ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
/// the PHITag values that were stored in the BBMap when checking to see if
/// it matched.
void SSAUpdater::ClearPHITags(PHINode *PHI) {
BBMapTy *BBMap = getBBMap(BM);
SmallVector<PHINode*, 20> WorkList;
WorkList.push_back(PHI);
while (!WorkList.empty()) {
PHI = WorkList.pop_back_val();
BasicBlock *BB = PHI->getParent();
BBInfo *Info = (*BBMap)[BB];
if (!Info || Info->AvailableVal || !Info->PHITag)
return;
continue;
// Clear the tag.
Info->PHITag = 0;
// Iterate through the predecessors.
BBMapTy *BBMap = getBBMap(BM);
// Iterate through the PHI's incoming values.
for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
PHINode *PHIVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
if (!PHIVal) continue;
BasicBlock *Pred = PHIVal->getParent();
ClearPHITags(Pred, (*BBMap)[Pred], PHIVal);
PHINode *IncomingVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
if (!IncomingVal) continue;
WorkList.push_back(IncomingVal);
}
}
}