Skip to content

Commit 6db15a8

Browse files
committed
[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol
This allows relaxing some relocations to STT_SECTION symbol+offset instead of emitting a relocation against a symbol. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D131433
1 parent fa210dd commit 6db15a8

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

llvm/lib/Target/ARM/ARMAsmPrinter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,
891891

892892
return MCSym;
893893
} else if (Subtarget->isTargetELF()) {
894-
return getSymbol(GV);
894+
return getSymbolPreferLocal(*GV);
895895
}
896896
llvm_unreachable("unexpected target");
897897
}

llvm/test/CodeGen/ARM/dso-local-func.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ define dso_local ptr @dsolocal_func() nounwind {
2323
; PIC-NEXT: .p2align 2
2424
; PIC-NEXT: @ %bb.1:
2525
; PIC-NEXT: .LCPI0_0:
26-
; PIC-NEXT: .long dsolocal_func-(.LPC0_0+8)
26+
; PIC-NEXT: .long .Ldsolocal_func$local-(.LPC0_0+8)
2727
; CHECK-NEXT: .Lfunc_end0:
2828
; CHECK-NEXT: .size dsolocal_func, .Lfunc_end0-dsolocal_func
2929
; CHECK-NEXT: .cantunwind

llvm/test/CodeGen/ARM/elf-preemption.ll

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ define ptr @get_dsolocal_var() nounwind {
4343
; PIC-NEXT: .p2align 2
4444
; PIC-NEXT: @ %bb.1:
4545
; PIC-NEXT: .LCPI1_0:
46-
; PIC-NEXT: .long dsolocal_var-(.LPC1_0+8)
46+
; PIC-NEXT: .long .Ldsolocal_var$local-(.LPC1_0+8)
4747
ret ptr @dsolocal_var
4848
}
4949

@@ -147,7 +147,7 @@ define dso_local ptr @dsolocal_func() nounwind {
147147
; PIC-NEXT: .p2align 2
148148
; PIC-NEXT: @ %bb.1:
149149
; PIC-NEXT: .LCPI6_0:
150-
; PIC-NEXT: .long dsolocal_func-(.LPC6_0+8)
150+
; PIC-NEXT: .long .Ldsolocal_func$local-(.LPC6_0+8)
151151
ret ptr @dsolocal_func
152152
}
153153

@@ -185,7 +185,7 @@ define dso_local void @call_dsolocal_func() nounwind {
185185
; PIC: @ %bb.0:
186186
; PIC-NEXT: .save {r11, lr}
187187
; PIC-NEXT: push {r11, lr}
188-
; PIC-NEXT: bl dsolocal_func
188+
; PIC-NEXT: bl .Ldsolocal_func$local
189189
; PIC-NEXT: pop {r11, pc}
190190
call ptr @dsolocal_func()
191191
ret void

llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
; RELOCS-NEXT: 0x0 R_ARM_PREL31 .text._ZdlPv
1818
; RELOCS-NEXT: }
1919
; RELOCS-NEXT: Section (7) .rel.text.test {
20-
; RELOCS-NEXT: 0x4 R_ARM_CALL _ZdlPv
20+
; RELOCS-NEXT: 0x4 R_ARM_CALL .L_ZdlPv$local
2121
; FIXME: these two relocation should not be against the section!
2222
; RELOCS-NEXT: 0xC R_ARM_ABS32 .text._ZdlPv
2323
; RELOCS-NEXT: 0x10 R_ARM_ABS32 .text._ZdlPv
24-
; RELOCS-NEXT: 0x1C R_ARM_REL32 _ZdlPv
24+
; RELOCS-NEXT: 0x1C R_ARM_REL32 .L_ZdlPv$local
2525
; RELOCS-NEXT: }
2626
; RELOCS-NEXT: Section (9) .rel.ARM.exidx.text.test {
2727
; RELOCS-NEXT: 0x0 R_ARM_PREL31 .text.test
@@ -32,17 +32,18 @@
3232
; RELOCS-NEXT: ]
3333

3434
; RELOCS-LABEL: Symbols [
35-
; RELOCS: Symbol {
36-
; FIXME: we should include the symbol in the symbol table!
37-
; RELOCS-NOT: Name: .L_ZdlPv$local
38-
; RELOCS-TODO: Name: .L_ZdlPv$local
35+
; RELOCS: Symbol {
36+
; RELOCS: Name: .L_ZdlPv$local
3937
; RELOCS-TODO: Value: 0x1
38+
; RELOCS-NEXT: Value: 0x0
4039
; RELOCS-TODO: Size: 2
41-
; RELOCS-TODO: Binding: Local (0x0)
40+
; RELOCS-NEXT: Size: 0
41+
; RELOCS-NEXT: Binding: Local (0x0)
4242
; RELOCS-TODO: Type: Function (0x2)
43-
; RELOCS-TODO: Other: 0
44-
; RELOCS-TODO: Section: .text._ZdlPv (
45-
; RELOCS-TODO: }
43+
; RELOCS-NEXT: Type: None (0x0)
44+
; RELOCS-NEXT: Other: 0
45+
; RELOCS-NEXT: Section: .text._ZdlPv (
46+
; RELOCS-NEXT: }
4647

4748
define dso_local void @_ZdlPv(ptr %ptr) local_unnamed_addr nounwind "target-features"="+armv7-a,+thumb-mode" {
4849
; CHECK-LABEL: .section .text._ZdlPv,"ax",%progbits
@@ -68,7 +69,7 @@ define ptr @test(ptr %ptr) nounwind {
6869
; CHECK: @ %bb.0: @ %entry
6970
; CHECK-NEXT: .save {r11, lr}
7071
; CHECK-NEXT: push {r11, lr}
71-
; CHECK-NEXT: bl _ZdlPv{{$}}
72+
; CHECK-NEXT: bl .L_ZdlPv$local
7273
; CHECK-NEXT: ldr r0, .LCPI1_0
7374
; CHECK-NEXT: @APP
7475
; CHECK-NEXT: .long .L_ZdlPv$local
@@ -84,7 +85,7 @@ define ptr @test(ptr %ptr) nounwind {
8485
; CHECK-NEXT: .p2align 2
8586
; CHECK-NEXT: @ %bb.1:
8687
; CHECK-NEXT: .LCPI1_0:
87-
; CHECK-NEXT: .long _ZdlPv-(.LPC1_0+8)
88+
; CHECK-NEXT: .long .L_ZdlPv$local-(.LPC1_0+8)
8889
entry:
8990
call void @_ZdlPv(ptr %ptr)
9091
; This inline assembly is needed to highlight the missing Thumb LSB since

0 commit comments

Comments
 (0)