summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/TargetMachine.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 76ec541f8b6..ee5b010ecf2 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -137,27 +137,20 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO()))
return true;
- // If GV is null we know that this is a call to an intrinsic. For ELF and
- // MachO we don't need to assume those are local since the liker can trivially
- // convert a call to a PLT to a direct call if the target (in the runtime
- // library) turns out to be local.
- if (!GV)
- return false;
-
// Most PIC code sequences that assume that a symbol is local cannot
// produce a 0 if it turns out the symbol is undefined. While this
// is ABI and relocation depended, it seems worth it to handle it
// here.
- if (isPositionIndependent() && GV->hasExternalWeakLinkage())
+ if (GV && isPositionIndependent() && GV->hasExternalWeakLinkage())
return false;
- if (!GV->hasDefaultVisibility())
+ if (GV && !GV->hasDefaultVisibility())
return true;
if (TT.isOSBinFormatMachO()) {
if (RM == Reloc::Static)
return true;
- return GV->isStrongDefinitionForLinker();
+ return GV && GV->isStrongDefinitionForLinker();
}
assert(TT.isOSBinFormatELF());
@@ -167,19 +160,19 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
RM == Reloc::Static || M.getPIELevel() != PIELevel::Default;
if (IsExecutable) {
// If the symbol is defined, it cannot be preempted.
- if (!GV->isDeclarationForLinker())
+ if (GV && !GV->isDeclarationForLinker())
return true;
// A symbol marked nonlazybind should not be accessed with a plt. If the
// symbol turns out to be external, the linker will convert a direct
// access to an access via the plt, so don't assume it is local.
- const Function *F = dyn_cast<Function>(GV);
+ const Function *F = dyn_cast_or_null<Function>(GV);
if (F && F->hasFnAttribute(Attribute::NonLazyBind))
return false;
- bool IsTLS = GV->isThreadLocal();
+ bool IsTLS = GV && GV->isThreadLocal();
bool IsAccessViaCopyRelocs =
- Options.MCOptions.MCPIECopyRelocations && isa<GlobalVariable>(GV);
+ Options.MCOptions.MCPIECopyRelocations && GV && isa<GlobalVariable>(GV);
Triple::ArchType Arch = TT.getArch();
bool IsPPC =
Arch == Triple::ppc || Arch == Triple::ppc64 || Arch == Triple::ppc64le;
OpenPOWER on IntegriCloud