[all-commits] [llvm/llvm-project] 8903e6: [AsmPrinter][ELF] Define local aliases (.Lfoo$loca...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Jan 29 10:58:55 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 8903e61b66112941513449e32e65a7ea85ea31fc
https://github.com/llvm/llvm-project/commit/8903e61b66112941513449e32e65a7ea85ea31fc
Author: Fangrui Song <maskray at google.com>
Date: 2020-01-29 (Wed, 29 Jan 2020)
Changed paths:
M llvm/include/llvm/CodeGen/AsmPrinter.h
M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
M llvm/test/CodeGen/AArch64/emutls.ll
M llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-sp-mod.ll
M llvm/test/CodeGen/ARM/emutls.ll
M llvm/test/CodeGen/X86/emutls.ll
M llvm/test/CodeGen/X86/linux-preemption.ll
Log Message:
-----------
[AsmPrinter][ELF] Define local aliases (.Lfoo$local) for GlobalObjects
For `MC_GlobalAddress` operands referencing **certain** GlobalObjects,
we can lower them to STB_LOCAL aliases to avoid costs brought by
assembler/linker's conservative decisions about symbol interposition:
* An assembler conservatively assumes a global default visibility symbol interposable (ELF
semantics). So relocations in object files are needed even if the code generator assumed
the definition exact and non-interposable.
* The relocations can cause the creation of PLT entries on some targets for -shared links.
A linker conservatively assumes a global default visibility symbol interposable (if not
otherwise constrained by -Bsymbolic/--dynamic-list/VER_NDX_LOCAL/etc).
"certain" refers to GlobalObjects in the intersection of
`hasExactDefinition() and !isInterposable()`: `external`, `appending`, `internal`, `private`.
Local linkages (`internal` and `private`) cannot be interposed. `appending` is for very
few objects LLVM interpret specially. So the set just includes `external`.
This patch emits STB_LOCAL aliases (.Lfoo$local) for such GlobalObjects, so that targets can lower
MC_GlobalAddress operands to STB_LOCAL aliases if applicable.
We may extend the scope and include GlobalAlias in the future.
LLVM's existing -fno-semantic-interposition behaviors give us license to do such optimizations:
* Various optimizations (ipconstprop, inliner, sccp, sroa, etc) treat normal ExternalLinkage
GlobalObjects as non-interposable.
* Before D72197, MC resolved a PC-relative VK_None fixup to a non-local symbol at assembly time (no
outstanding relocation), if the target is defined in the same section. Put it simply, even if IR
optimizations failed to optimize and allowed interposition for the function call in
`void foo() {} void bar() { foo(); }`, the assembler would disallow it.
This patch sets up AsmPrinter infrastructure to make -fno-semantic-interposition more so.
With and without the patch, the object file output should be identical:
`.Lfoo$local` does not take a symbol table entry.
Reviewed By: sfertile
Differential Revision: https://reviews.llvm.org/D73228
More information about the All-commits
mailing list