Index: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -435,6 +435,7 @@ for (const MachineBasicBlock &MBB : *MF) if (BB == MBB.getBasicBlock()) { MBB.getSymbol()->print(OS, AP->MAI); + const_cast(MBB).setLabelMustBeEmitted(); break; } } else if (MI->getOperand(OpNo).isMBB()) { Index: test/CodeGen/X86/callbr-asm-label-addr.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/callbr-asm-label-addr.ll @@ -0,0 +1,28 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s + +; CHECK-LABEL: test1: +; CHECK: .quad .LBB0_2 +; CHECK-NEXT: .quad .LBB0_1 +; CHECK-LABEL: .LBB0_1: +; CHECK-LABEL: .LBB0_2: + +define i32 @test1(i32 %x) { +entry: + callbr void asm sideeffect ".quad ${0:l}\0A\09.quad ${1:l}", "i,X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test1, %baz), i8* blockaddress(@test1, %bar)) + to label %asm.fallthrough [label %bar] + +asm.fallthrough: + br label %bar + +bar: + %call = tail call i32 @foo(i32 %x) #2 + br label %baz + +baz: + %call1 = tail call i32 @mux(i32 %call) #2 + ret i32 %call1 +} + +declare dso_local i32 @foo(i32) local_unnamed_addr #1 + +declare dso_local i32 @mux(i32) local_unnamed_addr #1 Index: test/CodeGen/X86/callbr-asm.ll =================================================================== --- test/CodeGen/X86/callbr-asm.ll +++ test/CodeGen/X86/callbr-asm.ll @@ -19,6 +19,7 @@ ; CHECK-NEXT: retl ; CHECK-NEXT: .Ltmp0: # Block address taken ; CHECK-NEXT: .LBB0_2: # %fail +; CHECK-NEXT: # Label of block must be emitted ; CHECK-NEXT: movl $1, %eax ; CHECK-NEXT: retl entry: