diff options
| author | Matthias Braun <matze@braunis.de> | 2015-08-26 20:46:49 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2015-08-26 20:46:49 +0000 |
| commit | 4816b18d863f351542fa5564ac4d0068985d7bff (patch) | |
| tree | 53e0639a458a77176263a15ccdbd54da3b596734 | |
| parent | af083d4cf9827d363647ac5214e27dc591a4ee35 (diff) | |
| download | bcm5719-llvm-4816b18d863f351542fa5564ac4d0068985d7bff.tar.gz bcm5719-llvm-4816b18d863f351542fa5564ac4d0068985d7bff.zip | |
FastISel: Avoid adding a successor block twice for degenerate IR.
This fixes http://llvm.org/PR24581
Differential Revision: http://reviews.llvm.org/D12350
llvm-svn: 246074
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/fast-isel-cmp-branch.ll | 17 |
2 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index d5011d2d62d..13b097cfc60 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1415,7 +1415,11 @@ void FastISel::finishCondBranch(const BasicBlock *BranchBB, if (FuncInfo.BPI) BranchWeight = FuncInfo.BPI->getEdgeWeight(BranchBB, TrueMBB->getBasicBlock()); - FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); + // Add TrueMBB as successor unless it is equal to the FalseMBB: This can + // happen in degenerate IR and MachineIR forbids to have a block twice in the + // successor/predecessor lists. + if (TrueMBB != FalseMBB) + FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight); fastEmitBranch(FalseMBB, DbgLoc); } diff --git a/llvm/test/CodeGen/X86/fast-isel-cmp-branch.ll b/llvm/test/CodeGen/X86/fast-isel-cmp-branch.ll index d7b64ed3a5b..e262448468e 100644 --- a/llvm/test/CodeGen/X86/fast-isel-cmp-branch.ll +++ b/llvm/test/CodeGen/X86/fast-isel-cmp-branch.ll @@ -1,5 +1,18 @@ -; RUN: llc -O0 -mtriple=x86_64-linux -asm-verbose=false < %s | FileCheck %s -; RUN: llc -O0 -mtriple=x86_64-windows-itanium -asm-verbose=false < %s | FileCheck %s +; RUN: llc -O0 -mtriple=x86_64-linux -asm-verbose=false -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -O0 -mtriple=x86_64-windows-itanium -asm-verbose=false -verify-machineinstrs < %s | FileCheck %s + +; Fast-isel mustn't add a block to the MBB successor/predecessor list twice. +; The machine verifier will catch and complain about this case. +; CHECK-LABEL: baz +; CHECK: retq +define void @baz() { +entry: + br i1 undef, label %exit, label %exit + +exit: + ret void +} + ; rdar://8337108 ; Fast-isel shouldn't try to look through the compare because it's in a |

