diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-01 18:48:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-01 18:48:38 +0000 |
commit | 8e8eda78cc5f06e4b19f2c374189a25017085286 (patch) | |
tree | f27c03273c48c4eefe8d82335c721bd9578018d6 /lib/Transforms/Utils/CloneFunction.cpp | |
parent | 6f46e59d2a0e66f3646db9677258876960477f87 (diff) |
Fix bugs in the inliner having to do with single-entry phi nodes and valuemap
updating. These were exposed by Devang's recent passmgr changes (with
non-default passorderings) because now the inliner can be interleved with
the LCSSA pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/CloneFunction.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 74cc66210e..2dd8ec0697 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -431,18 +431,12 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, PN->eraseFromParent(); ++OldI; } - } else if (PN->getNumIncomingValues() == 1) { - BasicBlock::iterator I = NewBB->begin(); - BasicBlock::const_iterator OldI = OldBB->begin(); - while ((PN = dyn_cast<PHINode>(I++))) { - Value *NV = PN->getIncomingValue(0); - PN->replaceAllUsesWith(NV); - assert(ValueMap[OldI] == PN && "ValueMap mismatch"); - ValueMap[OldI] = NV; - PN->eraseFromParent(); - ++OldI; - } } + // NOTE: We cannot eliminate single entry phi nodes here, because of + // ValueMap. Single entry phi nodes can have multiple ValueMap entries + // pointing at them. Thus, deleting one would require scanning the ValueMap + // to update any entries in it that would require that. This would be + // really slow. } // Now that the inlined function body has been fully constructed, go through @@ -454,8 +448,14 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, BranchInst *BI = dyn_cast<BranchInst>(I->getTerminator()); if (!BI || BI->isConditional()) { ++I; continue; } + // Note that we can't eliminate uncond branches if the destination has + // single-entry PHI nodes. Eliminating the single-entry phi nodes would + // require scanning the ValueMap to update any entries that point to the phi + // node. BasicBlock *Dest = BI->getSuccessor(0); - if (!Dest->getSinglePredecessor()) { ++I; continue; } + if (!Dest->getSinglePredecessor() || isa<PHINode>(Dest->begin())) { + ++I; continue; + } // We know all single-entry PHI nodes in the inlined function have been // removed, so we just need to splice the blocks. |