mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Change another SSAUpdater function to avoid recursion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100131 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9bdb8f0717
commit
33f22e8c66
@ -110,7 +110,7 @@ private:
|
|||||||
void FindAvailableVal(BasicBlock *BB, BBInfo *Info, unsigned Counter);
|
void FindAvailableVal(BasicBlock *BB, BBInfo *Info, unsigned Counter);
|
||||||
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(PHINode *PHI);
|
||||||
void ClearPHITags(PHINode *PHI);
|
void ClearPHITags(PHINode *PHI);
|
||||||
|
|
||||||
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
|
void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
|
||||||
|
@ -406,7 +406,7 @@ void SSAUpdater::FindExistingPHI(BasicBlock *BB, BBInfo *Info) {
|
|||||||
for (BasicBlock::iterator It = BB->begin();
|
for (BasicBlock::iterator It = BB->begin();
|
||||||
(SomePHI = dyn_cast<PHINode>(It)); ++It) {
|
(SomePHI = dyn_cast<PHINode>(It)); ++It) {
|
||||||
if (CheckIfPHIMatches(BB, Info, SomePHI)) {
|
if (CheckIfPHIMatches(BB, Info, SomePHI)) {
|
||||||
RecordMatchingPHI(BB, Info, SomePHI);
|
RecordMatchingPHI(SomePHI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ClearPHITags(SomePHI);
|
ClearPHITags(SomePHI);
|
||||||
@ -449,25 +449,31 @@ bool SSAUpdater::CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val) {
|
|||||||
return IsMatch;
|
return IsMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RecordMatchingPHI - For a PHI node that matches, record it in both the
|
/// RecordMatchingPHI - For a PHI node that matches, record it and its input
|
||||||
/// BBMap and the AvailableVals mapping. Recursively record its input PHIs
|
/// PHIs in both the BBMap and the AvailableVals mapping.
|
||||||
/// as well.
|
void SSAUpdater::RecordMatchingPHI(PHINode *PHI) {
|
||||||
void SSAUpdater::RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
|
BBMapTy *BBMap = getBBMap(BM);
|
||||||
|
AvailableValsTy &AvailableVals = getAvailableVals(AV);
|
||||||
|
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)
|
if (!Info || Info->AvailableVal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Record the PHI.
|
// Record the PHI.
|
||||||
AvailableValsTy &AvailableVals = getAvailableVals(AV);
|
|
||||||
AvailableVals[BB] = PHI;
|
AvailableVals[BB] = PHI;
|
||||||
Info->AvailableVal = PHI;
|
Info->AvailableVal = PHI;
|
||||||
|
|
||||||
// Iterate through the predecessors.
|
// Iterate through the PHI's incoming values.
|
||||||
BBMapTy *BBMap = getBBMap(BM);
|
|
||||||
for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
|
for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
|
||||||
PHINode *PHIVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
|
PHINode *IncomingVal = dyn_cast<PHINode>(PHI->getIncomingValue(i));
|
||||||
if (!PHIVal) continue;
|
if (!IncomingVal) continue;
|
||||||
BasicBlock *Pred = PHIVal->getParent();
|
WorkList.push_back(IncomingVal);
|
||||||
RecordMatchingPHI(Pred, (*BBMap)[Pred], PHIVal);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user