[llvm] c5ee312 - [TargetMachine] Simplify shouldAssumeDSOLocal. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 21 12:37:38 PDT 2021
Author: Fangrui Song
Date: 2021-08-21T12:37:29-07:00
New Revision: c5ee3123685ca5d555f80ed6e1bb8eeefca3dfbf
URL: https://github.com/llvm/llvm-project/commit/c5ee3123685ca5d555f80ed6e1bb8eeefca3dfbf
DIFF: https://github.com/llvm/llvm-project/commit/c5ee3123685ca5d555f80ed6e1bb8eeefca3dfbf.diff
LOG: [TargetMachine] Simplify shouldAssumeDSOLocal. NFC
Added:
Modified:
llvm/lib/Target/TargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 0a655a82b889..86cb30d4eb8f 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -115,47 +115,44 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
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;
-
- // 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.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;
+ }
if (TT.isOSBinFormatMachO()) {
+ // 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.
+ if (TT.isOSWindows())
+ return true;
+
if (RM == Reloc::Static)
return true;
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;
}
More information about the llvm-commits
mailing list