[PATCH] D74751: [ThinLTO] Drop dso_local if a GlobalVariable satisfies isDeclarationForLinker()
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 18:42:36 PST 2020
MaskRay created this revision.
MaskRay added reviewers: evgeny777, pcc, tejohnson.
Herald added subscribers: llvm-commits, dang, arphaman, dexonsmith, steven_wu, hiraditya, inglorion.
Herald added a project: LLVM.
dso_local leads to direct access even if the definition is not within this compilation unit (it is
still in the same linkage unit). On ELF, such a relocation (e.g. R_X86_64_PC32) referencing a
STB_GLOBAL STV_DEFAULT object can cause a linker error in a -shared link.
If the linkage is changed to available_externally, the dso_local flag should be dropped, so that no
direct access will be generated.
The current behavior is benign, because -fpic does not assume dso_local
(clang/lib/CodeGen/CodeGenModule.cpp:shouldAssumeDSOLocal).
If we do that for -fno-semantic-interposition, there will be an
R_X86_64_PC32 linker error without this patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74751
Files:
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/include/llvm/Transforms/Utils/FunctionImportUtils.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
llvm/test/LTO/Resolution/X86/local-def-dllimport.ll
llvm/test/ThinLTO/X86/funcimport_alwaysinline.ll
llvm/test/ThinLTO/X86/index-const-prop-alias.ll
llvm/test/ThinLTO/X86/index-const-prop-comdat.ll
llvm/test/ThinLTO/X86/index-const-prop-dead.ll
llvm/test/ThinLTO/X86/index-const-prop-full-lto.ll
llvm/test/ThinLTO/X86/index-const-prop-gvref-pie.ll
llvm/test/ThinLTO/X86/index-const-prop-gvref.ll
llvm/test/ThinLTO/X86/index-const-prop-ldst.ll
llvm/test/ThinLTO/X86/index-const-prop-linkage.ll
llvm/test/ThinLTO/X86/index-const-prop2.ll
llvm/tools/llvm-link/llvm-link.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74751.245066.patch
Type: text/x-patch
Size: 17884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200218/eea1d09b/attachment.bin>
More information about the llvm-commits
mailing list