diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-28 00:19:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-28 00:19:07 +0000 |
commit | b2718272256fd023bbbe3e8e9616f315def43072 (patch) | |
tree | 73b75cf1d859d2bc0427aea03e85a993bccd1791 /lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 86a23b1e5396cfd06c56027a5fb43ccb3605d7bc (diff) | |
download | external_llvm-b2718272256fd023bbbe3e8e9616f315def43072.zip external_llvm-b2718272256fd023bbbe3e8e9616f315def43072.tar.gz external_llvm-b2718272256fd023bbbe3e8e9616f315def43072.tar.bz2 |
Fix PR2256, yet another miscompilation in simplifycfg of i
multiple return values.
Bill, please pull this into Tak.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 7f37b45..b584e13 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1365,10 +1365,11 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { // If the return instruction returns a value, and if the value was a // PHI node in "BB", propagate the right value into the return. - if (NewRet->getNumOperands() == 1) - if (PHINode *PN = dyn_cast<PHINode>(NewRet->getOperand(0))) + for (unsigned i = 0, e = NewRet->getNumOperands(); i != e; ++i) + if (PHINode *PN = dyn_cast<PHINode>(NewRet->getOperand(i))) if (PN->getParent() == BB) - NewRet->setOperand(0, PN->getIncomingValueForBlock(Pred)); + NewRet->setOperand(i, PN->getIncomingValueForBlock(Pred)); + // Update any PHI nodes in the returning block to realize that we no // longer branch to them. BB->removePredecessor(Pred); |