diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-25 18:32:02 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-25 18:32:02 +0000 |
commit | 2a3443c7c5eb314aba8bce2f38d8846ecb815f85 (patch) | |
tree | 1974cde24ccc4db78336692283eb5447149d8c61 /llvm/lib | |
parent | d21e5c6684642a4e17b0f6d7802d55b0a32c5837 (diff) | |
download | bcm5719-llvm-2a3443c7c5eb314aba8bce2f38d8846ecb815f85.tar.gz bcm5719-llvm-2a3443c7c5eb314aba8bce2f38d8846ecb815f85.zip |
GVN: If a branch has two identical successors, we cannot declare either dead.
This previously caused miscompilations as a result of phi nodes receiving
undef incoming values from blocks dominated by such successors.
Differential Revision: http://reviews.llvm.org/D10726
llvm-svn: 240670
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index e93833c32f4..60903c8b4aa 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -2804,6 +2804,10 @@ bool GVN::processFoldableCondBr(BranchInst *BI) { if (!BI || BI->isUnconditional()) return false; + // If a branch has two identical successors, we cannot declare either dead. + if (BI->getSuccessor(0) == BI->getSuccessor(1)) + return false; + ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition()); if (!Cond) return false; |