summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2019-06-23 22:05:08 +0000
committerpatrick <patrick@openbsd.org>2019-06-23 22:05:08 +0000
commitf27a781c9811da94fe68b2cf34237c2a61b48c96 (patch)
tree820064216b8f115ba79122ebd03c5451b59fd690 /gnu/llvm/lib/Target/X86/X86Subtarget.cpp
parentImport LLVM 8.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-f27a781c9811da94fe68b2cf34237c2a61b48c96.tar.xz
wireguard-openbsd-f27a781c9811da94fe68b2cf34237c2a61b48c96.zip
Merge LLVM 8.0.0 release.
Prepared with help from jsg@ and mortimer@ Tested on amd64 by bcallah@, krw@, naddy@ Tested on arm64 by patrick@ Tested on macppc by kettenis@ Tested on octeon by visa@ Tested on sparc64 by claudio@
Diffstat (limited to 'gnu/llvm/lib/Target/X86/X86Subtarget.cpp')
-rw-r--r--gnu/llvm/lib/Target/X86/X86Subtarget.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/gnu/llvm/lib/Target/X86/X86Subtarget.cpp b/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
index 31c125980c3..0c9ce8802e1 100644
--- a/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/gnu/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -77,6 +77,8 @@ X86Subtarget::classifyLocalReference(const GlobalValue *GV) const {
if (isTargetELF()) {
switch (TM.getCodeModel()) {
// 64-bit small code model is simple: All rip-relative.
+ case CodeModel::Tiny:
+ llvm_unreachable("Tiny codesize model not supported on X86");
case CodeModel::Small:
case CodeModel::Kernel:
return X86II::MO_NO_FLAG;
@@ -139,8 +141,11 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV,
if (TM.shouldAssumeDSOLocal(M, GV))
return classifyLocalReference(GV);
- if (isTargetCOFF())
- return X86II::MO_DLLIMPORT;
+ if (isTargetCOFF()) {
+ if (GV->hasDLLImportStorageClass())
+ return X86II::MO_DLLIMPORT;
+ return X86II::MO_COFFSTUB;
+ }
if (is64Bit()) {
// ELF supports a large, truly PIC code model with non-PC relative GOT
@@ -220,14 +225,22 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
if (CPUName.empty())
CPUName = "generic";
- // Make sure 64-bit features are available in 64-bit mode. (But make sure
- // SSE2 can be turned off explicitly.)
std::string FullFS = FS;
if (In64BitMode) {
+ // SSE2 should default to enabled in 64-bit mode, but can be turned off
+ // explicitly.
if (!FullFS.empty())
- FullFS = "+64bit,+sse2," + FullFS;
+ FullFS = "+sse2," + FullFS;
else
- FullFS = "+64bit,+sse2";
+ FullFS = "+sse2";
+
+ // If no CPU was specified, enable 64bit feature to satisy later check.
+ if (CPUName == "generic") {
+ if (!FullFS.empty())
+ FullFS = "+64bit," + FullFS;
+ else
+ FullFS = "+64bit";
+ }
}
// LAHF/SAHF are always supported in non-64-bit mode.
@@ -238,14 +251,6 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
FullFS = "+sahf";
}
- // OpenBSD/amd64 defaults to -mretpoline
- if (isTargetOpenBSD() && In64BitMode) {
- if (!FullFS.empty())
- FullFS = "+retpoline," + FullFS;
- else
- FullFS = "+retpoline";
- }
-
// Parse features string and set the CPU.
ParseSubtargetFeatures(CPUName, FullFS);
@@ -270,8 +275,9 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
LLVM_DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
<< ", 3DNowLevel " << X863DNowLevel << ", 64bit "
<< HasX86_64 << "\n");
- assert((!In64BitMode || HasX86_64) &&
- "64-bit code requested on a subtarget that doesn't support it!");
+ if (In64BitMode && !HasX86_64)
+ report_fatal_error("64-bit code requested on a subtarget that doesn't "
+ "support it!");
// Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
// 32 and 64 bit) and for all 64-bit targets.