[RISCV] Prefer to lower MC_GlobalAddress operands to .Lfoo$local
authorFangrui Song <i@maskray.me>
Tue, 11 May 2021 18:29:45 +0000 (11:29 -0700)
committerFangrui Song <i@maskray.me>
Tue, 11 May 2021 18:29:45 +0000 (11:29 -0700)
commitec27c5f170441ab54295830aa9f7d376406c6a0f
tree8dd87abf46bd3ad109b7445d451d0a2e16aae121
parent61cbbba7a645a1d87db9a80867c84a788ab2ea9c
[RISCV] Prefer to lower MC_GlobalAddress operands to .Lfoo$local

Similar to X86 D73230 and AArch64 D101872

With this change, we can set dso_local in clang's -fpic -fno-semantic-interposition mode,
for default visibility external linkage non-ifunc-non-COMDAT definitions.

For such dso_local definitions, variable access/taking the address of a
function/calling a function will go through a local alias to avoid GOT/PLT.

Reviewed By: jrtc27, luismarques

Differential Revision: https://reviews.llvm.org/D101875
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
llvm/test/CodeGen/RISCV/elf-preemption.ll [new file with mode: 0644]