summaryrefslogtreecommitdiff
path: root/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:17:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:17:04 +0000
commitb915e9e0fc85ba6f398b3fab0db6a81a8913af94 (patch)
tree98b8f811c7aff2547cab8642daf372d6c59502fb /lib/Target/TargetMachine.cpp
parent6421cca32f69ac849537a3cff78c352195e99f1b (diff)
Notes
Diffstat (limited to 'lib/Target/TargetMachine.cpp')
-rw-r--r--lib/Target/TargetMachine.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp
index 82c68505c4e1..e16ced1661a1 100644
--- a/lib/Target/TargetMachine.cpp
+++ b/lib/Target/TargetMachine.cpp
@@ -77,6 +77,16 @@ void TargetMachine::resetTargetOptions(const Function &F) const {
RESET_OPTION(UnsafeFPMath, "unsafe-fp-math");
RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math");
+ RESET_OPTION(NoTrappingFPMath, "no-trapping-math");
+
+ StringRef Denormal =
+ F.getFnAttribute("denormal-fp-math").getValueAsString();
+ if (Denormal == "ieee")
+ Options.FPDenormalMode = FPDenormal::IEEE;
+ else if (Denormal == "preserve-sign")
+ Options.FPDenormalMode = FPDenormal::PreserveSign;
+ else if (Denormal == "positive-zero")
+ Options.FPDenormalMode = FPDenormal::PositiveZero;
}
/// Returns the code generation relocation model. The choices are static, PIC,
@@ -105,9 +115,6 @@ static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV) {
llvm_unreachable("invalid TLS model");
}
-// FIXME: make this a proper option
-static bool CanUseCopyRelocWithPIE = false;
-
bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
const GlobalValue *GV) const {
Reloc::Model RM = getRelocationModel();
@@ -117,8 +124,11 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
if (GV && GV->hasDLLImportStorageClass())
return false;
- // Every other GV is local on COFF
- if (TT.isOSBinFormatCOFF())
+ // Every other GV is local on COFF.
+ // Make an exception for windows OS in the triple: Some firmwares builds use
+ // *-win32-macho triples. This (accidentally?) produced windows relocations
+ // without GOT tables in older clang versions; Keep this behaviour.
+ if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO()))
return true;
if (GV && (GV->hasLocalLinkage() || !GV->hasDefaultVisibility()))
@@ -141,8 +151,10 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
return true;
bool IsTLS = GV && GV->isThreadLocal();
+ bool IsAccessViaCopyRelocs =
+ Options.MCOptions.MCPIECopyRelocations && GV && isa<GlobalVariable>(GV);
// Check if we can use copy relocations.
- if (!IsTLS && (RM == Reloc::Static || CanUseCopyRelocWithPIE))
+ if (!IsTLS && (RM == Reloc::Static || IsAccessViaCopyRelocs))
return true;
}
@@ -198,12 +210,12 @@ void TargetMachine::getNameWithPrefix(SmallVectorImpl<char> &Name,
return;
}
const TargetLoweringObjectFile *TLOF = getObjFileLowering();
- TLOF->getNameWithPrefix(Name, GV, Mang, *this);
+ TLOF->getNameWithPrefix(Name, GV, *this);
}
-MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const {
- SmallString<128> NameStr;
- getNameWithPrefix(NameStr, GV, Mang);
+MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV) const {
const TargetLoweringObjectFile *TLOF = getObjFileLowering();
+ SmallString<128> NameStr;
+ getNameWithPrefix(NameStr, GV, TLOF->getMangler());
return TLOF->getContext().getOrCreateSymbol(NameStr);
}