[llvm] r366523 - Use the MachineBasicBlock symbol for a callbr target
Bill Wendling via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 18:10:28 PDT 2019
Author: void
Date: Thu Jul 18 18:10:28 2019
New Revision: 366523
URL: http://llvm.org/viewvc/llvm-project?rev=366523&view=rev
Log:
Use the MachineBasicBlock symbol for a callbr target
Summary:
Inline asm doesn't use labels when compiled as an object file. Therefore, we
shouldn't create one for the (potential) callbr destination. Instead, use the
symbol for the MachineBasicBlock.
Reviewers: nickdesaulniers, craig.topper
Reviewed By: nickdesaulniers
Subscribers: xbolva00, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D64888
Added:
llvm/trunk/test/CodeGen/X86/callbr-asm-obj-file.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/trunk/test/CodeGen/X86/callbr-asm.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp?rev=366523&r1=366522&r2=366523&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp Thu Jul 18 18:10:28 2019
@@ -430,8 +430,13 @@ static void EmitGCCInlineAsmStr(const ch
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);
+ const BasicBlock *BB = BA->getBasicBlock();
+ const MachineFunction *MF = MI->getParent()->getParent();
+ for (const MachineBasicBlock &MBB : *MF)
+ if (BB == MBB.getBasicBlock()) {
+ MBB.getSymbol()->print(OS, AP->MAI);
+ break;
+ }
} else if (MI->getOperand(OpNo).isMBB()) {
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
Sym->print(OS, AP->MAI);
Added: llvm/trunk/test/CodeGen/X86/callbr-asm-obj-file.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/callbr-asm-obj-file.ll?rev=366523&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/callbr-asm-obj-file.ll (added)
+++ llvm/trunk/test/CodeGen/X86/callbr-asm-obj-file.ll Thu Jul 18 18:10:28 2019
@@ -0,0 +1,19 @@
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -filetype=obj -o - \
+; RUN: | llvm-objdump -triple x86_64-linux-gnu -d - \
+; RUN: | FileCheck %s
+
+; CHECK: 0000000000000000 test1:
+; CHECK-NEXT: 0: 74 00 je 0 <test1+0x2>
+; CHECK-NEXT: 2: c3 retq
+
+define void @test1() {
+entry:
+ callbr void asm sideeffect "je ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test1, %a.b.normal.jump))
+ to label %asm.fallthrough [label %a.b.normal.jump]
+
+asm.fallthrough:
+ ret void
+
+a.b.normal.jump:
+ ret void
+}
Modified: llvm/trunk/test/CodeGen/X86/callbr-asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/callbr-asm.ll?rev=366523&r1=366522&r2=366523&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/callbr-asm.ll (original)
+++ llvm/trunk/test/CodeGen/X86/callbr-asm.ll Thu Jul 18 18:10:28 2019
@@ -12,7 +12,7 @@ define i32 @test1(i32 %a) {
; CHECK-NEXT: addl $4, %eax
; CHECK-NEXT: #APP
; CHECK-NEXT: xorl %eax, %eax
-; CHECK-NEXT: jmp .Ltmp00
+; CHECK-NEXT: jmp .LBB0_2
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: .LBB0_1: # %normal
; CHECK-NEXT: xorl %eax, %eax
@@ -87,17 +87,17 @@ define dso_local i32 @test3(i32 %a) {
; CHECK-NEXT: # Parent Loop BB2_3 Depth=3
; CHECK-NEXT: # => This Inner Loop Header: Depth=4
; CHECK-NEXT: #APP
-; CHECK-NEXT: jmp .Ltmp10
-; CHECK-NEXT: jmp .Ltmp20
-; CHECK-NEXT: jmp .Ltmp30
+; CHECK-NEXT: jmp .LBB2_1
+; CHECK-NEXT: jmp .LBB2_2
+; CHECK-NEXT: jmp .LBB2_3
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: .LBB2_5: # %normal0
; CHECK-NEXT: # in Loop: Header=BB2_4 Depth=4
; CHECK-NEXT: #APP
-; CHECK-NEXT: jmp .Ltmp10
-; CHECK-NEXT: jmp .Ltmp20
-; CHECK-NEXT: jmp .Ltmp30
-; CHECK-NEXT: jmp .Ltmp40
+; CHECK-NEXT: jmp .LBB2_1
+; CHECK-NEXT: jmp .LBB2_2
+; CHECK-NEXT: jmp .LBB2_3
+; CHECK-NEXT: jmp .LBB2_4
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: .LBB2_6: # %normal1
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
More information about the llvm-commits
mailing list