[PATCH] D101872: [AArch64][ELF] Prefer to lower MC_GlobalAddress operands to .Lfoo$local
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 17:37:19 PDT 2021
MaskRay added a comment.
In D101872#2740815 <https://reviews.llvm.org/D101872#2740815>, @efriedma wrote:
> I'm not sure I understand the practical effect of this. I mean, I get the immediate effect on the object file, but I'm not sure I understand how this impacts linking. Without this patch, will we end up with runtime relocations in some cases? If so, which cases?
Currently -fpic -fno-semantic-interposition is a no-op on non-x86.
On x86, -fpic -fno-semantic-interposition sets dso_local on default visibility external linkage definitions.
This change by itself does not affect clang behavior. With D101873 <https://reviews.llvm.org/D101873>, -fpic -fno-semantic-interposition will be effective on aarch64.
If D101873 <https://reviews.llvm.org/D101873> is enabled without this patch, we may produce assembly like
; CHECK-NEXT: adrp x0, gv0 # instead of .Lgv0$local
; CHECK-NEXT: ldr w0, [x0, :lo12:gv0]
This will be rejected by `{ld.bfd,gold,ld.lld} -shared` because gv0 (STV_DEFAULT STB_GLOBAL) is by default preemptible and direct access relocations referencing a preemptible symbol cannot be used in -shared mode.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp:592
assert(MO.isGlobal() && "caller should check MO.isGlobal");
- getSymbol(MO.getGlobal())->print(OS, MAI);
+ getSymbolPreferLocal(*MO.getGlobal())->print(OS, MAI);
printOffset(MO.getOffset(), OS);
----------------
efriedma wrote:
> This is target-independent code; what targets does it affect?
Only aarch64. No-op for others.
With D101873, aarch64 will behave like x86: -fpic -fno-semantic-interposition will set dso_local on default visibility external linkage definitions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101872/new/
https://reviews.llvm.org/D101872
More information about the llvm-commits
mailing list