mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
Fix SSAUpdaterImpl's RecordMatchingPHI to record exactly the
PHI nodes which were matched, rather than climbing up the original PHI node's operands to rediscover PHI nodes for recording, since the PHI nodes found that are not necessarily part of the matched set. This fixes rdar://10589171. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149654 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -380,7 +380,7 @@ public:
|
||||
if (!SomePHI)
|
||||
break;
|
||||
if (CheckIfPHIMatches(SomePHI)) {
|
||||
RecordMatchingPHI(SomePHI);
|
||||
RecordMatchingPHIs(BlockList);
|
||||
break;
|
||||
}
|
||||
// Match failed: clear all the PHITag values.
|
||||
@ -437,38 +437,17 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/// RecordMatchingPHI - For a PHI node that matches, record it and its input
|
||||
/// PHIs in both the BBMap and the AvailableVals mapping.
|
||||
void RecordMatchingPHI(PhiT *PHI) {
|
||||
SmallVector<PhiT*, 20> WorkList;
|
||||
WorkList.push_back(PHI);
|
||||
|
||||
// Record this PHI.
|
||||
BlkT *BB = PHI->getParent();
|
||||
ValT PHIVal = Traits::GetPHIValue(PHI);
|
||||
(*AvailableVals)[BB] = PHIVal;
|
||||
BBMap[BB]->AvailableVal = PHIVal;
|
||||
|
||||
while (!WorkList.empty()) {
|
||||
PHI = WorkList.pop_back_val();
|
||||
|
||||
// Iterate through the PHI's incoming values.
|
||||
for (typename Traits::PHI_iterator I = Traits::PHI_begin(PHI),
|
||||
E = Traits::PHI_end(PHI); I != E; ++I) {
|
||||
ValT IncomingVal = I.getIncomingValue();
|
||||
PhiT *IncomingPHI = Traits::ValueIsPHI(IncomingVal, Updater);
|
||||
if (!IncomingPHI) continue;
|
||||
BB = IncomingPHI->getParent();
|
||||
BBInfo *Info = BBMap[BB];
|
||||
if (!Info || Info->AvailableVal)
|
||||
continue;
|
||||
|
||||
// Record the PHI and add it to the worklist.
|
||||
(*AvailableVals)[BB] = IncomingVal;
|
||||
Info->AvailableVal = IncomingVal;
|
||||
WorkList.push_back(IncomingPHI);
|
||||
/// RecordMatchingPHIs - For each PHI node that matches, record it in both
|
||||
/// the BBMap and the AvailableVals mapping.
|
||||
void RecordMatchingPHIs(BlockListTy *BlockList) {
|
||||
for (typename BlockListTy::iterator I = BlockList->begin(),
|
||||
E = BlockList->end(); I != E; ++I)
|
||||
if (PhiT *PHI = (*I)->PHITag) {
|
||||
BlkT *BB = PHI->getParent();
|
||||
ValT PHIVal = Traits::GetPHIValue(PHI);
|
||||
(*AvailableVals)[BB] = PHIVal;
|
||||
BBMap[BB]->AvailableVal = PHIVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user