[PATCH] D64888: Use the MachineBasicBlock symbol for a callbr target

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 16:23:58 PDT 2019


void updated this revision to Diff 210453.
void added a comment.

Use for-each loop.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64888/new/

https://reviews.llvm.org/D64888

Files:
  lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  test/CodeGen/X86/callbr-asm-obj-file.ll


Index: test/CodeGen/X86/callbr-asm-obj-file.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/callbr-asm-obj-file.ll
@@ -0,0 +1,19 @@
+; RUN: llc < %s -mtriple=x86_64-pc-linux -filetype=obj -o - \
+; RUN:  | llvm-objdump -triple x86_64-pc-linux -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
+}
Index: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -430,8 +430,13 @@
           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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64888.210453.patch
Type: text/x-patch
Size: 1796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190717/d6734ec3/attachment.bin>


More information about the llvm-commits mailing list