diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-08-02 04:47:05 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-08-02 04:47:05 +0000 |
| commit | d7cb625a9eb2e0f4e1bba2078637df9410d774dc (patch) | |
| tree | 44cf734492071426333dc93f457832d4f5b2c77c /llvm/lib/Transforms/Scalar/CondPropagate.cpp | |
| parent | 6a340b43518950ef735467bebc019daaf6eb0144 (diff) | |
| download | bcm5719-llvm-d7cb625a9eb2e0f4e1bba2078637df9410d774dc.tar.gz bcm5719-llvm-d7cb625a9eb2e0f4e1bba2078637df9410d774dc.zip | |
Fix PR1575 and test/Transforms/CondProp/2007-08-01-InvalidRead.ll
llvm-svn: 40720
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CondPropagate.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/CondPropagate.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/CondPropagate.cpp b/llvm/lib/Transforms/Scalar/CondPropagate.cpp index 80f6973d994..6fc27d4aa64 100644 --- a/llvm/lib/Transforms/Scalar/CondPropagate.cpp +++ b/llvm/lib/Transforms/Scalar/CondPropagate.cpp @@ -142,14 +142,15 @@ void CondProp::SimplifyPredecessors(BranchInst *BI) { if (ConstantInt *CB = dyn_cast<ConstantInt>(PN->getIncomingValue(i-1))) { // If we have a constant, forward the edge from its current to its // ultimate destination. - bool PHIGone = PN->getNumIncomingValues() == 2; RevectorBlockTo(PN->getIncomingBlock(i-1), BI->getSuccessor(CB->isZero())); ++NumBrThread; - // If there were two predecessors before this simplification, the PHI node - // will be deleted. Don't iterate through it the last time. - if (PHIGone) return; + // If there were two predecessors before this simplification, or if the + // PHI node contained all the same value except for the one we just + // substituted, the PHI node may be deleted. Don't iterate through it the + // last time. + if (BI->getCondition() != PN) return; } } @@ -177,16 +178,17 @@ void CondProp::SimplifyPredecessors(SwitchInst *SI) { if (ConstantInt *CI = dyn_cast<ConstantInt>(PN->getIncomingValue(i-1))) { // If we have a constant, forward the edge from its current to its // ultimate destination. - bool PHIGone = PN->getNumIncomingValues() == 2; unsigned DestCase = SI->findCaseValue(CI); RevectorBlockTo(PN->getIncomingBlock(i-1), SI->getSuccessor(DestCase)); ++NumSwThread; RemovedPreds = true; - // If there were two predecessors before this simplification, the PHI node - // will be deleted. Don't iterate through it the last time. - if (PHIGone) return; + // If there were two predecessors before this simplification, or if the + // PHI node contained all the same value except for the one we just + // substituted, the PHI node may be deleted. Don't iterate through it the + // last time. + if (SI->getCondition() != PN) return; } } |

