-fno-semantic-interposition 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: // @test
adrp x8, :got:var
ldr x8, [x8, :got_lo12:var]
ldr w0, [x8]
// fun is preemptible by default in ld -shared mode. ld will create a PLT.
b funvs -fpic -fno-semantic-interposition (var and fun are dso_local)
test: // @test
.Ltest$local:
adrp x8, .Lvar$local
ldr w0, [x8, :lo12:.Lvar$local]
// The assembler either resolves .Lfun$local at assembly time, or produces a
// relocation referencing a non-preemptible section symbol (which can avoid PLT).
b .Lfun$localNote: 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 D101872