mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-22 18:35:45 +00:00
Fix PR306: Loop simplify incorrectly updates dominator information
Testcase: LoopSimplify/2004-04-01-IncorrectDomUpdate.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12592 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
afd5e2fdec
commit
4f303bd4a5
@ -530,9 +530,19 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB,
|
|||||||
BasicBlock *NewBBSucc = *succ_begin(NewBB);
|
BasicBlock *NewBBSucc = *succ_begin(NewBB);
|
||||||
DominatorSet &DS = getAnalysis<DominatorSet>();
|
DominatorSet &DS = getAnalysis<DominatorSet>();
|
||||||
|
|
||||||
|
// Update dominator information... The blocks that dominate NewBB are the
|
||||||
|
// intersection of the dominators of predecessors, plus the block itself.
|
||||||
|
//
|
||||||
|
DominatorSet::DomSetType NewBBDomSet = DS.getDominators(PredBlocks[0]);
|
||||||
|
for (unsigned i = 1, e = PredBlocks.size(); i != e; ++i)
|
||||||
|
set_intersect(NewBBDomSet, DS.getDominators(PredBlocks[i]));
|
||||||
|
NewBBDomSet.insert(NewBB); // All blocks dominate themselves...
|
||||||
|
DS.addBasicBlock(NewBB, NewBBDomSet);
|
||||||
|
|
||||||
// The newly inserted basic block will dominate existing basic blocks iff the
|
// The newly inserted basic block will dominate existing basic blocks iff the
|
||||||
// PredBlocks dominate all of the non-pred blocks. If all predblocks dominate
|
// PredBlocks dominate all of the non-pred blocks. If all predblocks dominate
|
||||||
// the non-pred blocks, then they all must be the same block!
|
// the non-pred blocks, then they all must be the same block!
|
||||||
|
//
|
||||||
bool NewBBDominatesNewBBSucc = true;
|
bool NewBBDominatesNewBBSucc = true;
|
||||||
{
|
{
|
||||||
BasicBlock *OnePred = PredBlocks[0];
|
BasicBlock *OnePred = PredBlocks[0];
|
||||||
@ -551,15 +561,18 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update dominator information... The blocks that dominate NewBB are the
|
// The other scenario where the new block can dominate its successors are when
|
||||||
// intersection of the dominators of predecessors, plus the block itself.
|
// all predecessors of NewBBSucc that are not NewBB are dominated by NewBBSucc
|
||||||
// The newly created basic block does not dominate anything except itself.
|
// already.
|
||||||
//
|
if (!NewBBDominatesNewBBSucc) {
|
||||||
DominatorSet::DomSetType NewBBDomSet = DS.getDominators(PredBlocks[0]);
|
NewBBDominatesNewBBSucc = true;
|
||||||
for (unsigned i = 1, e = PredBlocks.size(); i != e; ++i)
|
for (pred_iterator PI = pred_begin(NewBBSucc), E = pred_end(NewBBSucc);
|
||||||
set_intersect(NewBBDomSet, DS.getDominators(PredBlocks[i]));
|
PI != E; ++PI)
|
||||||
NewBBDomSet.insert(NewBB); // All blocks dominate themselves...
|
if (*PI != NewBB && !DS.dominates(NewBBSucc, *PI)) {
|
||||||
DS.addBasicBlock(NewBB, NewBBDomSet);
|
NewBBDominatesNewBBSucc = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If NewBB dominates some blocks, then it will dominate all blocks that
|
// If NewBB dominates some blocks, then it will dominate all blocks that
|
||||||
// NewBBSucc does.
|
// NewBBSucc does.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user