diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -456,26 +456,23 @@ // FIXME: Shouldn't arch-independent output template handling go into // PrintAsmOperand? - if (Modifier[0] == 'l') { // Labels are target independent. - if (MI->getOperand(OpNo).isBlockAddress()) { - const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress(); - MCSymbol *Sym = AP->GetBlockAddressSymbol(BA); - Sym->print(OS, AP->MAI); - MMI->getContext().registerInlineAsmLabel(Sym); - } else if (MI->getOperand(OpNo).isMBB()) { - const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol(); - Sym->print(OS, AP->MAI); - } else { - Error = true; - } + // Labels are target independent. + if (MI->getOperand(OpNo).isBlockAddress()) { + const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress(); + MCSymbol *Sym = AP->GetBlockAddressSymbol(BA); + Sym->print(OS, AP->MAI); + MMI->getContext().registerInlineAsmLabel(Sym); + } else if (MI->getOperand(OpNo).isMBB()) { + const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol(); + Sym->print(OS, AP->MAI); + } else if (Modifier[0] == 'l') { + Error = true; + } else if (InlineAsm::isMemKind(OpFlags)) { + Error = AP->PrintAsmMemoryOperand( + MI, OpNo, Modifier[0] ? Modifier : nullptr, OS); } else { - if (InlineAsm::isMemKind(OpFlags)) { - Error = AP->PrintAsmMemoryOperand( - MI, OpNo, Modifier[0] ? Modifier : nullptr, OS); - } else { - Error = AP->PrintAsmOperand(MI, OpNo, - Modifier[0] ? Modifier : nullptr, OS); - } + Error = AP->PrintAsmOperand(MI, OpNo, + Modifier[0] ? Modifier : nullptr, OS); } } if (Error) { 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 @@ -53,7 +53,6 @@ ret i32 1 } - ; Test 3 - asm-goto implements a loop. The loop gets recognized, but many loop ; transforms fail due to canonicalization having callbr exceptions. Trivial ; blocks at labels 1 and 3 also don't get simplified due to callbr. @@ -131,3 +130,32 @@ %1 = load i32, i32* %a.addr, align 4 ret i32 %1 } + +; Test 4 - asm-goto referenced with the 'l' (ell) modifier and not. +define void @test4() { +; CHECK-LABEL: test4: +; CHECK: # %bb.0: +; CHECK-NEXT: #APP +; CHECK-NOT: ja .Ltmp50 +; CHECK-NEXT: ja .Ltmp5 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: .LBB3_1: +; CHECK-NEXT: #APP +; CHECK-NOT: ja .Ltmp50 +; CHECK-NEXT: ja .Ltmp5 +; CHECK-NEXT: #NO_APP +; CHECK-NEXT: jmp .LBB3_3 +entry: + callbr void asm sideeffect "ja $0", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux)) + to label %asm.fallthrough [label %quux] + +asm.fallthrough: ; preds = %entry + callbr void asm sideeffect "ja ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux)) + to label %cleanup [label %quux] + +quux: ; preds = %asm.fallthrough, %entry + br label %cleanup + +cleanup: ; preds = %asm.fallthrough, %quux + ret void +}