[PATCH] D131433: [ARM] Use getSymbolPreferLocal() in GetARMGVSymbol

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 13:27:05 PDT 2022


arichardson created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
arichardson added a reviewer: MaskRay.
Herald added a subscriber: StephenFan.
arichardson published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This allows relaxing some relocations to symbol+offset instead of emitting
a relocation against a symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131433

Files:
  llvm/lib/Target/ARM/ARMAsmPrinter.cpp
  llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll


Index: llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll
===================================================================
--- llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll
+++ llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll
@@ -17,11 +17,11 @@
 ; RELOCS-NEXT:     0x0 R_ARM_PREL31 .text._ZdlPv
 ; RELOCS-NEXT:   }
 ; RELOCS-NEXT:   Section (7) .rel.text.test {
-; RELOCS-NEXT:     0x4 R_ARM_CALL _ZdlPv
+; RELOCS-NEXT:     0x4 R_ARM_CALL .L_ZdlPv$local
 ; FIXME: these two relocation should not be against the section!
 ; RELOCS-NEXT:     0xC R_ARM_ABS32 .text._ZdlPv
 ; RELOCS-NEXT:     0x10 R_ARM_ABS32 .text._ZdlPv
-; RELOCS-NEXT:     0x1C R_ARM_REL32 _ZdlPv
+; RELOCS-NEXT:     0x1C R_ARM_REL32 .L_ZdlPv$local
 ; RELOCS-NEXT:   }
 ; RELOCS-NEXT:   Section (9) .rel.ARM.exidx.text.test {
 ; RELOCS-NEXT:     0x0 R_ARM_PREL31 .text.test
@@ -32,17 +32,18 @@
 ; RELOCS-NEXT: ]
 
 ; RELOCS-LABEL: Symbols [
-; RELOCS: Symbol {
-; FIXME: we should include the symbol in the symbol table!
-; RELOCS-NOT:    Name: .L_ZdlPv$local
-; RELOCS-TODO:   Name: .L_ZdlPv$local
+; RELOCS:      Symbol {
+; RELOCS:        Name: .L_ZdlPv$local
 ; RELOCS-TODO:   Value: 0x1
+; RELOCS-NEXT:   Value: 0x0
 ; RELOCS-TODO:   Size: 4
-; RELOCS-TODO:   Binding: Local (0x0)
+; RELOCS-NEXT:   Size: 0
+; RELOCS-NEXT:   Binding: Local (0x0)
 ; RELOCS-TODO:   Type: Function (0x2)
-; RELOCS-TODO:   Other: 0
-; RELOCS-TODO:   Section: .text._ZdlPv (
-; RELOCS-TODO: }
+; RELOCS-NEXT:   Type: None (0x0)
+; RELOCS-NEXT:   Other: 0
+; RELOCS-NEXT:   Section: .text._ZdlPv (
+; RELOCS-NEXT: }
 
 ; RELOCS-LABEL: Hex dump of section '.text.test':
 ; RELOCS-NEXT: 0x00000000 00482de9 feffffeb 0c009fe5 00000000 .H-.............
@@ -72,7 +73,7 @@
 ; CHECK:       @ %bb.0: @ %entry
 ; CHECK-NEXT:    .save {r11, lr}
 ; CHECK-NEXT:    push {r11, lr}
-; CHECK-NEXT:    bl _ZdlPv{{$}}
+; CHECK-NEXT:    bl .L_ZdlPv$local
 ; CHECK-NEXT:    ldr r0, .LCPI1_0
 ; CHECK-NEXT:    @APP
 ; CHECK-NEXT:    .long .L_ZdlPv$local
@@ -88,7 +89,7 @@
 ; CHECK-NEXT:    .p2align 2
 ; CHECK-NEXT:  @ %bb.1:
 ; CHECK-NEXT:  .LCPI1_0:
-; CHECK-NEXT:    .long _ZdlPv-(.LPC1_0+8)
+; CHECK-NEXT:    .long .L_ZdlPv$local-(.LPC1_0+8)
 entry:
   call void @_ZdlPv(i8* %ptr)
   ; This inline assembly is needed to highlight the missing Thumb LSB since
Index: llvm/lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -891,7 +891,7 @@
 
     return MCSym;
   } else if (Subtarget->isTargetELF()) {
-    return getSymbol(GV);
+    return getSymbolPreferLocal(*GV);
   }
   llvm_unreachable("unexpected target");
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131433.450920.patch
Type: text/x-patch
Size: 2707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220808/54b21bb5/attachment.bin>


More information about the llvm-commits mailing list