diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -791,7 +791,7 @@ bool TailDuplicator::canTailDuplicate(MachineBasicBlock *TailBB, MachineBasicBlock *PredBB) { // EH edges are ignored by analyzeBranch. - if (PredBB->succ_size() > 1) + if (PredBB->succ_size() > 1 && !PredBB->mayHaveInlineAsmBr()) return false; MachineBasicBlock *PredTBB = nullptr, *PredFBB = nullptr; @@ -896,7 +896,7 @@ // Update the CFG. PredBB->removeSuccessor(PredBB->succ_begin()); - assert(PredBB->succ_empty() && + assert((PredBB->succ_empty() || PredBB->mayHaveInlineAsmBr()) && "TailDuplicate called on block with multiple successors!"); for (MachineBasicBlock *Succ : TailBB->successors()) PredBB->addSuccessor(Succ, MBPI->getEdgeProbability(TailBB, Succ)); diff --git a/llvm/test/CodeGen/X86/callbr-asm-sink.ll b/llvm/test/CodeGen/X86/callbr-asm-sink.ll --- a/llvm/test/CodeGen/X86/callbr-asm-sink.ll +++ b/llvm/test/CodeGen/X86/callbr-asm-sink.ll @@ -14,7 +14,6 @@ ; CHECK-NEXT: #APP ; CHECK-NEXT: # 8(%rdi) .LBB0_1 ; CHECK-NEXT: #NO_APP -; CHECK-NEXT: # %bb.2: ; CHECK-NEXT: retq ; CHECK-NEXT: .LBB0_1: # Block address taken ; CHECK-NEXT: # Label of block must be emitted diff --git a/llvm/test/CodeGen/X86/callbr-asm.ll b/llvm/test/CodeGen/X86/callbr-asm.ll --- a/llvm/test/CodeGen/X86/callbr-asm.ll +++ b/llvm/test/CodeGen/X86/callbr-asm.ll @@ -171,13 +171,14 @@ ; CHECK-LABEL: test4: ; CHECK: # %bb.0: # %entry ; CHECK-NEXT: #APP -; CHECK-NEXT: ja .LBB4_3 +; CHECK-NEXT: ja .LBB4_2 ; CHECK-NEXT: #NO_APP ; CHECK-NEXT: # %bb.1: # %asm.fallthrough ; CHECK-NEXT: #APP -; CHECK-NEXT: ja .LBB4_3 +; CHECK-NEXT: ja .LBB4_2 ; CHECK-NEXT: #NO_APP -; CHECK-NEXT: .LBB4_3: # Block address taken +; CHECK-NEXT: retl +; CHECK-NEXT: .LBB4_2: # Block address taken ; CHECK-NEXT: # %quux ; CHECK-NEXT: # Label of block must be emitted ; CHECK-NEXT: retl diff --git a/llvm/test/CodeGen/X86/inline-asm-pic.ll b/llvm/test/CodeGen/X86/inline-asm-pic.ll --- a/llvm/test/CodeGen/X86/inline-asm-pic.ll +++ b/llvm/test/CodeGen/X86/inline-asm-pic.ll @@ -29,7 +29,6 @@ ; CHECK-NEXT: ## LBB1_1 ; CHECK-EMPTY: ; CHECK-NEXT: ## InlineAsm End -; CHECK-NEXT: ## %bb.2: ## %return ; CHECK-NEXT: retl ; CHECK-NEXT: Ltmp0: ## Block address taken ; CHECK-NEXT: LBB1_1: ## %overflow