Skip to content

Commit

Permalink
[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol
Browse files Browse the repository at this point in the history
This allows relaxing some relocations to symbol+offset instead of emitting
a relocation against a symbol.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D131433
  • Loading branch information
arichardson committed Aug 26, 2022
1 parent 0483b00 commit df00dac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/ARMAsmPrinter.cpp
Expand Up @@ -891,7 +891,7 @@ MCSymbol *ARMAsmPrinter::GetARMGVSymbol(const GlobalValue *GV,

return MCSym;
} else if (Subtarget->isTargetELF()) {
return getSymbol(GV);
return getSymbolPreferLocal(*GV);
}
llvm_unreachable("unexpected target");
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/dso-local-func.ll
Expand Up @@ -24,7 +24,7 @@ define dso_local ptr @dsolocal_func() nounwind {
; PIC-NEXT: .p2align 2
; PIC-NEXT: @ %bb.1:
; PIC-NEXT: .LCPI0_0:
; PIC-NEXT: .long dsolocal_func-(.LPC0_0+8)
; PIC-NEXT: .long .Ldsolocal_func$local-(.LPC0_0+8)
; CHECK-NEXT: .Lfunc_end0:
; CHECK-NEXT: .size dsolocal_func, .Lfunc_end0-dsolocal_func
; PIC-NEXT: .size .Ldsolocal_func$local, .Lfunc_end0-dsolocal_func
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/ARM/elf-preemption.ll
Expand Up @@ -43,7 +43,7 @@ define ptr @get_dsolocal_var() nounwind {
; PIC-NEXT: .p2align 2
; PIC-NEXT: @ %bb.1:
; PIC-NEXT: .LCPI1_0:
; PIC-NEXT: .long dsolocal_var-(.LPC1_0+8)
; PIC-NEXT: .long .Ldsolocal_var$local-(.LPC1_0+8)
ret ptr @dsolocal_var
}

Expand Down Expand Up @@ -147,7 +147,7 @@ define dso_local ptr @dsolocal_func() nounwind {
; PIC-NEXT: .p2align 2
; PIC-NEXT: @ %bb.1:
; PIC-NEXT: .LCPI6_0:
; PIC-NEXT: .long dsolocal_func-(.LPC6_0+8)
; PIC-NEXT: .long .Ldsolocal_func$local-(.LPC6_0+8)
ret ptr @dsolocal_func
}

Expand Down Expand Up @@ -185,7 +185,7 @@ define dso_local void @call_dsolocal_func() nounwind {
; PIC: @ %bb.0:
; PIC-NEXT: .save {r11, lr}
; PIC-NEXT: push {r11, lr}
; PIC-NEXT: bl dsolocal_func
; PIC-NEXT: bl .Ldsolocal_func$local
; PIC-NEXT: pop {r11, pc}
call ptr @dsolocal_func()
ret void
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll
Expand Up @@ -17,10 +17,10 @@
; 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
; RELOCS-NEXT: 0xC R_ARM_ABS32 .L_ZdlPv$local
; RELOCS-NEXT: 0x10 R_ARM_ABS32 .L_ZdlPv$local
; 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
Expand Down Expand Up @@ -67,7 +67,7 @@ define ptr @test(ptr %ptr) nounwind {
; 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
Expand All @@ -83,7 +83,7 @@ define ptr @test(ptr %ptr) nounwind {
; 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(ptr %ptr)
; This inline assembly is needed to highlight the missing Thumb LSB since
Expand Down

0 comments on commit df00dac

Please sign in to comment.