From 6f36637be032fb300c4711fcd6cac2a5a53f52f8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 30 Oct 2017 16:32:31 +0000 Subject: Move isDSOLocal check and add a comment. llvm-svn: 316920 --- llvm/lib/Target/TargetMachine.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Target/TargetMachine.cpp') diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 1b05e6ce9f4..5dcb89477a3 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -114,6 +114,17 @@ static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV) { bool TargetMachine::shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const { + // If the IR producer requested that this GV be treated as dso local, obey. + if (GV && GV->isDSOLocal()) + return true; + + // According to the llvm language reference, we should be able to just return + // false in here if we have a GV, as we know it is 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. As a result we + // still have some pre-dso_local logic in here to improve the quality of the + // generated code: + Reloc::Model RM = getRelocationModel(); const Triple &TT = getTargetTriple(); @@ -137,8 +148,7 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, GV->hasExternalWeakLinkage()) return false; - if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility() || - GV->isDSOLocal())) + if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility())) return true; if (TT.isOSBinFormatMachO()) { -- cgit v1.2.3