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 @@ -798,6 +798,8 @@ return false; if (!PredCond.empty()) return false; + if (TailBB->isInlineAsmBrIndirectTarget()) + return false; return true; } diff --git a/llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll b/llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll --- a/llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll +++ b/llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll @@ -72,7 +72,7 @@ ; CHECK-LABEL: : ; CHECK-LABEL: <$d.9>: ; CHECK-LABEL: <$x.10>: -; CHECK-NEXT: b {{.*}} +; CHECK-NEXT: b {{.*}} <$x.12+0x4> ; CHECK-LABEL: <$x.12>: ; CHECK-NEXT: mov w0, wzr ; CHECK-NEXT: ldr x30, [sp], #16 diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs.ll --- a/llvm/test/CodeGen/X86/callbr-asm-outputs.ll +++ b/llvm/test/CodeGen/X86/callbr-asm-outputs.ll @@ -178,15 +178,15 @@ ; CHECK-NEXT: # %bb.2: # %asm.fallthrough2 ; CHECK-NEXT: addl %edx, %ecx ; CHECK-NEXT: movl %ecx, %eax +; CHECK-NEXT: .LBB3_4: # Block address taken +; CHECK-NEXT: # %return +; CHECK-NEXT: # Label of block must be emitted ; CHECK-NEXT: retl ; CHECK-NEXT: .LBB3_3: # Block address taken ; CHECK-NEXT: # %label_true ; CHECK-NEXT: # Label of block must be emitted ; CHECK-NEXT: movl $-2, %eax -; CHECK-NEXT: .LBB3_4: # Block address taken -; CHECK-NEXT: # %return -; CHECK-NEXT: # Label of block must be emitted -; CHECK-NEXT: retl +; CHECK-NEXT: jmp .LBB3_4 entry: %0 = callbr { i32, i32 } asm sideeffect "testl $0, $0; testl $1, $2; jne ${3:l}", "=r,=r,r,!i,!i,~{dirflag},~{fpsr},~{flags}"(i32 %out1) to label %asm.fallthrough [label %label_true, label %return] diff --git a/llvm/test/CodeGen/X86/tail-dup-asm-goto.ll b/llvm/test/CodeGen/X86/tail-dup-asm-goto.ll --- a/llvm/test/CodeGen/X86/tail-dup-asm-goto.ll +++ b/llvm/test/CodeGen/X86/tail-dup-asm-goto.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py -; RUN: llc -mtriple=x86_64-linux -stop-after=early-tailduplication < %s | FileCheck %s +; RUN: llc -mtriple=x86_64-linux -stop-after=early-tailduplication \ +; RUN: -verify-machineinstrs < %s | FileCheck %s ; Ensure that we don't duplicate a block with an "INLINEASM_BR" instruction ; during code gen. @@ -74,7 +75,6 @@ ; BOTH the fallthrough/direct target and the indirect target are the same basic ; block. We might one day permit tail duplication here, but we need to ensure ; that we don't crash or run afoul of any MachineVerifier checks. -; FIXME: enable -verify-machineinstrs for this test! define void @ceph_con_v2_try_read(i32 %__trans_tmp_3.sroa.0.0.copyload, i1 %tobool.not.i.i) nounwind { ; CHECK-LABEL: name: ceph_con_v2_try_read ; CHECK: bb.0.entry: @@ -108,11 +108,10 @@ ; CHECK-NEXT: JMP_1 %bb.3 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.3.if.else.i.i: - ; CHECK-NEXT: successors: %bb.1(0x80000000) + ; CHECK-NEXT: successors: %bb.5(0x80000000) ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: INLINEASM_BR &"", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.5 - ; CHECK-NEXT: LIFETIME_END %stack.0.skip.i.i - ; CHECK-NEXT: JMP_1 %bb.1 + ; CHECK-NEXT: JMP_1 %bb.5 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.4.process_message_header.exit.i: ; CHECK-NEXT: successors: %bb.1(0x80000000)