aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 6d14298..bf0a38b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -946,14 +946,20 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO()))
return true;
+ const auto &CGOpts = CGM.getCodeGenOpts();
+ llvm::Reloc::Model RM = CGOpts.RelocationModel;
+ const auto &LOpts = CGM.getLangOpts();
+
+ if (TT.isOSBinFormatMachO()) {
+ if (RM == llvm::Reloc::Static)
+ return true;
+ return GV->isStrongDefinitionForLinker();
+ }
+
// Only handle COFF and ELF for now.
if (!TT.isOSBinFormatELF())
return false;
- // If this is not an executable, don't assume anything is local.
- const auto &CGOpts = CGM.getCodeGenOpts();
- llvm::Reloc::Model RM = CGOpts.RelocationModel;
- const auto &LOpts = CGM.getLangOpts();
if (RM != llvm::Reloc::Static && !LOpts.PIE) {
// On ELF, if -fno-semantic-interposition is specified, we can set dso_local
// if using a local alias is preferable (can avoid GOT indirection).