mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100126 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -111,7 +111,7 @@ private:
|
|||||||
void FindExistingPHI(BasicBlock *BB, BBInfo *Info);
|
void FindExistingPHI(BasicBlock *BB, BBInfo *Info);
|
||||||
bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val);
|
bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val);
|
||||||
void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
|
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
|
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
|
||||||
SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT
|
SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT
|
||||||
|
@ -427,7 +427,7 @@ void SSAUpdater::FindExistingPHI(BasicBlock *BB, BBInfo *Info) {
|
|||||||
RecordMatchingPHI(BB, Info, SomePHI);
|
RecordMatchingPHI(BB, Info, SomePHI);
|
||||||
break;
|
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
|
/// 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.
|
/// the PHITag values that were stored in the BBMap when checking to see if
|
||||||
void SSAUpdater::ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
|
/// it matched.
|
||||||
if (!Info || Info->AvailableVal || !Info->PHITag)
|
void SSAUpdater::ClearPHITags(PHINode *PHI) {
|
||||||
return;
|
|
||||||
|
|
||||||
// Clear the tag.
|
|
||||||
Info->PHITag = 0;
|
|
||||||
|
|
||||||
// Iterate through the predecessors.
|
|
||||||
BBMapTy *BBMap = getBBMap(BM);
|
BBMapTy *BBMap = getBBMap(BM);
|
||||||
for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
|
SmallVector<PHINode*, 20> WorkList;
|
||||||
PHINode *PHIVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
|
WorkList.push_back(PHI);
|
||||||
if (!PHIVal) continue;
|
|
||||||
BasicBlock *Pred = PHIVal->getParent();
|
while (!WorkList.empty()) {
|
||||||
ClearPHITags(Pred, (*BBMap)[Pred], PHIVal);
|
PHI = WorkList.pop_back_val();
|
||||||
|
BasicBlock *BB = PHI->getParent();
|
||||||
|
BBInfo *Info = (*BBMap)[BB];
|
||||||
|
if (!Info || Info->AvailableVal || !Info->PHITag)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Clear the tag.
|
||||||
|
Info->PHITag = 0;
|
||||||
|
|
||||||
|
// Iterate through the PHI's incoming values.
|
||||||
|
for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
|
||||||
|
PHINode *IncomingVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
|
||||||
|
if (!IncomingVal) continue;
|
||||||
|
WorkList.push_back(IncomingVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user