[TargetMachine] Don't imply dso_local on global variable declarations in Reloc::Stati...
authorFangrui Song <i@maskray.me>
Sat, 5 Dec 2020 03:03:40 +0000 (19:03 -0800)
committerFangrui Song <i@maskray.me>
Sat, 5 Dec 2020 03:03:41 +0000 (19:03 -0800)
commit961f31d8ad14c66829991522d73e14b5a96ff6d4
tree2c6c6c38257eefd2f6d9683c091a89095cb0ce0b
parentfd32639823e4d74eadbca5b0a9610a87d69b25c8
[TargetMachine] Don't imply dso_local on global variable declarations in Reloc::Static model

clang/lib/CodeGen/CodeGenModule sets dso_local on applicable global variables,
we don't need to duplicate the work in TargetMachine:shouldAssumeDSOLocal.
(Actually the long-term goal (started by r324535) is to remove as much
additional implied dso_local in TargetMachine:shouldAssumeDSOLocal as possible.)

By not implying dso_local, we will respect dso_local/dso_preemptable specifiers
set by the frontend. This allows the proposed -fno-direct-access-external-data
option to work with -fno-pic and prevent copy relocations.

This patch should be NFC in terms of the Clang behavior because the case we
don't set dso_local is a case Clang sets dso_local. However, some tests don't
set dso_local on some `external global` and expose some differences. Most tests
have been fixed to be more robust in previous commits.
13 files changed:
llvm/lib/Target/TargetMachine.cpp
llvm/test/CodeGen/AArch64/extern-weak.ll
llvm/test/CodeGen/AArch64/tiny_model.ll
llvm/test/CodeGen/X86/abi-isel.ll
llvm/test/CodeGen/X86/br-fold.ll
llvm/test/CodeGen/X86/code-model-elf.ll
llvm/test/CodeGen/X86/emutls.ll
llvm/test/CodeGen/X86/linux-preemption.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/tail-dup-merge-loop-headers.ll
llvm/test/CodeGen/X86/x86-64-mem.ll
llvm/test/CodeGen/X86/x86-store-gv-addr.ll
llvm/test/CodeGen/XCore/threads.ll