[PATCH] D102583: -fno-semantic-interposition: Don't set dso_local on GlobalVariable
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 16 12:23:52 PDT 2021
MaskRay created this revision.
MaskRay added reviewers: foutrelis, rnk, serge-sans-paille, xbolva00.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
`clang -fpic -fno-semantic-interposition` may set dso_local on variables for -fpic.
GCC folks consider there are 'address interposition' and 'semantic interposition',
and 'disabling semantic interposition' can optimize function calls but
cannot change variable references to use local aliases
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100483).
This patch removes dso_local for variables in
`clang -fpic -fno-semantic-interposition` mode so that the built shared objects can
work with copy relocations.
Example:
// a.c
int var;
int *addr() { return var; }
// old: cannot be interposed
movslq .Lvar$local(%rip), %rax
// new: can be interposed
movq var at GOTPCREL(%rip), %rax
movslq (%rax), %rax
The local alias lowering for `GlobalVariable`s is kept in case there is a
future option allowing local aliases.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102583
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/semantic-interposition.c
clang/test/CodeGenCUDA/device-stub.cu
clang/test/CodeGenCUDA/device-var-linkage.cu
clang/test/CodeGenCUDA/managed-var.cu
clang/test/CodeGenCUDA/static-device-var-rdc.cu
clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102583.345721.patch
Type: text/x-patch
Size: 14618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210516/94f53456/attachment-0001.bin>
More information about the cfe-commits
mailing list