diff options
author | Fangrui Song <i@maskray.me> | 2021-05-11 11:38:32 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-05-11 11:38:32 -0700 |
commit | 2075f2b296b0fa90cb7597f0f318232940d29e95 (patch) | |
tree | f967bc3f06605e88320cf0ab1df495049d6bf5f9 /llvm/tools/llvm-cov/CodeCoverage.cpp | |
parent | b2f227c6c87c16fa593e643a487efd9326249066 (diff) | |
download | llvm-2075f2b296b0fa90cb7597f0f318232940d29e95.zip llvm-2075f2b296b0fa90cb7597f0f318232940d29e95.tar.gz llvm-2075f2b296b0fa90cb7597f0f318232940d29e95.tar.bz2 |
[clang] Support -fpic -fno-semantic-interposition for RISCV
-fno-semantic-interposition (only effective with -fpic) can optimize default
visibility external linkage (non-ifunc-non-COMDAT) variable access and function
calls to avoid GOT/PLT, by using local aliases, e.g.
```
int var;
__attribute__((optnone)) int fun(int x) { return x * x; }
int test() { return fun(var); }
```
-fpic (var and fun are dso_preemptable)
```
test:
.LBB1_1:
auipc a0, %got_pcrel_hi(var)
ld a0, %pcrel_lo(.LBB1_1)(a0)
lw a0, 0(a0)
// fun is preemptible by default in ld -shared mode. ld will create a PLT.
tail fun@plt
```
vs -fpic -fno-semantic-interposition (var and fun are dso_local)
```
test:
.Ltest$local:
.LBB1_1:
auipc a0, %pcrel_hi(.Lvar$local)
addi a0, a0, %pcrel_lo(.LBB1_1)
lw a0, 0(a0)
// The assembler either resolves .Lfun$local at assembly time (-mno-relax
// -fno-function-sections), or produces a relocation referencing a non-preemptible
// local symbol (which can avoid PLT).
tail .Lfun$local
```
Note: Clang's default -fpic is more aggressive than GCC -fpic: interprocedural
optimizations (including inlining) are available but local aliases are not used.
-fpic -fsemantic-interposition can disable interprocedural optimizations.
Depends on D101875
Reviewed By: luismarques
Differential Revision: https://reviews.llvm.org/D101876
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
0 files changed, 0 insertions, 0 deletions