[PATCH] D101872: [AArch64][ELF] Prefer to lower MC_GlobalAddress operands to .Lfoo$local
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 17:50:39 PDT 2021
efriedma added a comment.
In D101872#2740867 <https://reviews.llvm.org/D101872#2740867>, @MaskRay wrote:
> If D101873 <https://reviews.llvm.org/D101873> is enabled without this patch, clang 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 in ELF, gv0 (STV_DEFAULT STB_GLOBAL) is by default preemptible and direct access relocations referencing a preemptible symbol cannot be used in -shared mode.
So this is basically a bugfix for dso_local handling? Okay.
================
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);
----------------
MaskRay wrote:
> 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.
>
Do you mean this code is unreachable for non-aarch64 targets? Or that getSymbolPreferLocal() does the same thing as getSymbol() on other targets? Or that clang won't emit IR that's impacted by this change?
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