diff options
| author | Dale Johannesen <dalej@apple.com> | 2007-05-24 17:39:32 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2007-05-24 17:39:32 +0000 |
| commit | 1af8c870c74f4a2bf49dfbec220a9e0040f87825 (patch) | |
| tree | d06c5548eeefe5f0e1abb41931d1db4424e443cf /llvm/lib/CodeGen/BranchFolding.cpp | |
| parent | 8ff9ff7975f5645b6639c53fb44f5f2a020b017d (diff) | |
| download | bcm5719-llvm-1af8c870c74f4a2bf49dfbec220a9e0040f87825.tar.gz bcm5719-llvm-1af8c870c74f4a2bf49dfbec220a9e0040f87825.zip | |
Fix for PR1444: do not create two successors to the same block.
Temporarily, this breaks CodeGen/Generic/2006-02-12-InsertLibraryCall.ll
by exposing an unrelated latent problem; working on that.
llvm-svn: 37323
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index afaaf519524..6c632c2aee3 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -717,12 +717,20 @@ static void ReplaceUsesOfBlockWith(MachineBasicBlock *BB, I->getOperand(i).setMachineBasicBlock(New); } - // Update the successor information. + // Update the successor information. If New was already a successor, just + // remove the link to Old instead of creating another one. PR 1444. + bool HadSuccessorNew = false; std::vector<MachineBasicBlock*> Succs(BB->succ_begin(), BB->succ_end()); for (int i = Succs.size()-1; i >= 0; --i) + if (Succs[i] == New) { + HadSuccessorNew = true; + break; + } + for (int i = Succs.size()-1; i >= 0; --i) if (Succs[i] == Old) { BB->removeSuccessor(Old); - BB->addSuccessor(New); + if (!HadSuccessorNew) + BB->addSuccessor(New); } } |

