aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp64
1 files changed, 27 insertions, 37 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp b/contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp
index 0a655a82b889..390457dbb2bc 100644
--- a/contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/TargetMachine.cpp
@@ -101,46 +101,41 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
// dso_preemptable. At this point in time, the various IR producers
// have not been transitioned to always produce a dso_local when it
// is possible to do so.
- // In the case of ExternalSymbolSDNode, GV is null and we should just return
- // false. However, COFF currently relies on this to be true
//
// As a result we still have some logic in here to improve the quality of the
// generated code.
- // FIXME: Add a module level metadata for whether intrinsics should be assumed
- // local.
if (!GV)
- return TT.isOSBinFormatCOFF();
+ return false;
// If the IR producer requested that this GV be treated as dso local, obey.
if (GV->isDSOLocal())
return true;
- // DLLImport explicitly marks the GV as external.
- if (GV->hasDLLImportStorageClass())
- return false;
-
- // On MinGW, variables that haven't been declared with DLLImport may still
- // end up automatically imported by the linker. To make this feasible,
- // don't assume the variables to be DSO local unless we actually know
- // that for sure. This only has to be done for variables; for functions
- // the linker can insert thunks for calling functions from another DLL.
- if (TT.isWindowsGNUEnvironment() && TT.isOSBinFormatCOFF() &&
- GV->isDeclarationForLinker() && isa<GlobalVariable>(GV))
- return false;
-
- // On COFF, don't mark 'extern_weak' symbols as DSO local. If these symbols
- // remain unresolved in the link, they can be resolved to zero, which is
- // outside the current DSO.
- if (TT.isOSBinFormatCOFF() && GV->hasExternalWeakLinkage())
- return false;
+ if (TT.isOSBinFormatCOFF()) {
+ // DLLImport explicitly marks the GV as external.
+ if (GV->hasDLLImportStorageClass())
+ return false;
+
+ // On MinGW, variables that haven't been declared with DLLImport may still
+ // end up automatically imported by the linker. To make this feasible,
+ // don't assume the variables to be DSO local unless we actually know
+ // that for sure. This only has to be done for variables; for functions
+ // the linker can insert thunks for calling functions from another DLL.
+ if (TT.isWindowsGNUEnvironment() && GV->isDeclarationForLinker() &&
+ isa<GlobalVariable>(GV))
+ return false;
+
+ // Don't mark 'extern_weak' symbols as DSO local. If these symbols remain
+ // unresolved in the link, they can be resolved to zero, which is outside
+ // the current DSO.
+ if (GV->hasExternalWeakLinkage())
+ return false;
+
+ // Every other GV is local on COFF.
+ return true;
+ }
- // Every other GV is local on COFF.
- // Make an exception for windows OS in the triple: Some firmware builds use
- // *-win32-macho triples. This (accidentally?) produced windows relocations
- // without GOT tables in older clang versions; Keep this behaviour.
- // Some JIT users use *-win32-elf triples; these shouldn't use GOT tables
- // either.
- if (TT.isOSBinFormatCOFF() || TT.isOSWindows())
+ if (TT.isOSBinFormatGOFF())
return true;
if (TT.isOSBinFormatMachO()) {
@@ -149,13 +144,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
return GV->isStrongDefinitionForLinker();
}
- // Due to the AIX linkage model, any global with default visibility is
- // considered non-local.
- if (TT.isOSBinFormatXCOFF())
- return false;
-
- assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm());
- assert(RM != Reloc::DynamicNoPIC);
+ assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm() ||
+ TT.isOSBinFormatXCOFF());
return false;
}