-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[Driver] Default to -mv8plus on 32-bit Solaris/SPARC #150176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
While investigating PR llvm#149990, I noticed that while both the Oracle Studio compilers and GCC default to `-mv8plus` on 32-bit Solaris/SPARC, Clang does not. This patch fixes this by enabling the `v8plus` feature. Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Rainer Orth (rorth) ChangesWhile investigating PR #149990, I noticed that while both the Oracle Studio compilers and GCC default to This patch fixes this by enabling the Tested on Full diff: https://github.com/llvm/llvm-project/pull/150176.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 33331351244e1..94a94f1e9c487 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -37,6 +37,13 @@ const char *sparc::getSparcAsmModeForCPU(StringRef Name,
.Case("niagara4", "-Av9d")
.Default(DefV9CPU);
} else {
+ const char *DefV8CPU;
+
+ if (Triple.isOSSolaris())
+ DefV8CPU = "-Av8plus";
+ else
+ DefV8CPU = "-Av8";
+
return llvm::StringSwitch<const char *>(Name)
.Case("v8", "-Av8")
.Case("supersparc", "-Av8")
@@ -72,7 +79,7 @@ const char *sparc::getSparcAsmModeForCPU(StringRef Name,
.Case("gr712rc", "-Aleon")
.Case("leon4", "-Aleon")
.Case("gr740", "-Aleon")
- .Default("-Av8");
+ .Default(DefV8CPU);
}
}
@@ -160,6 +167,8 @@ void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple,
(Triple.getArch() == llvm::Triple::sparcv9) &&
(Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
bool IsSparcV9BTarget = Triple.isOSSolaris();
+ bool IsSparcV8PlusTarget =
+ Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris();
if (Arg *A = Args.getLastArg(options::OPT_mvis, options::OPT_mno_vis)) {
if (A->getOption().matches(options::OPT_mvis))
Features.push_back("+vis");
@@ -196,6 +205,8 @@ void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple,
if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) {
if (A->getOption().matches(options::OPT_mv8plus))
Features.push_back("+v8plus");
+ } else if (IsSparcV8PlusTarget) {
+ Features.push_back("+v8plus");
}
if (Args.hasArg(options::OPT_ffixed_g1))
diff --git a/clang/test/Driver/sparc-target-features.c b/clang/test/Driver/sparc-target-features.c
index 48a180caf259b..bd17da112bbd2 100644
--- a/clang/test/Driver/sparc-target-features.c
+++ b/clang/test/Driver/sparc-target-features.c
@@ -39,4 +39,8 @@
// SOFT-QUAD-FLOAT: "-target-feature" "-hard-quad-float"
// RUN: %clang --target=sparc -mv8plus %s -### 2>&1 | FileCheck -check-prefix=V8PLUS %s
+/// 32-bit Solaris/SPARC defaults to -mv8plus
+// RUN: %clang --target=sparc-sun-solaris2.11 %s -### 2>&1 | FileCheck -check-prefix=V8PLUS %s
+// RUN: %clang --target=sparc-sun-solaris2.11 -mno-v8plus %s -### 2>&1 | FileCheck -check-prefix=NO-V8PLUS %s
// V8PLUS: "-target-feature" "+v8plus"
+// NO-V8PLUS-NOT: "-target-feature" "+v8plus"
|
While investigating PR llvm#149990, I noticed that while both the Oracle Studio compilers and GCC default to `-mv8plus` on 32-bit Solaris/SPARC, Clang does not. This patch fixes this by enabling the `v8plus` feature. Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.
While investigating PR llvm#149990, I noticed that while both the Oracle Studio compilers and GCC default to `-mv8plus` on 32-bit Solaris/SPARC, Clang does not. This patch fixes this by enabling the `v8plus` feature. Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`. (cherry picked from commit 0623389)
While investigating PR llvm#149990, I noticed that while both the Oracle Studio compilers and GCC default to `-mv8plus` on 32-bit Solaris/SPARC, Clang does not. This patch fixes this by enabling the `v8plus` feature. Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`. (cherry picked from commit 0623389)
While investigating PR #149990, I noticed that while both the Oracle Studio compilers and GCC default to
-mv8plus
on 32-bit Solaris/SPARC, Clang does not.This patch fixes this by enabling the
v8plus
feature.Tested on
sparcv9-sun-solaris2.11
andsparc64-unknown-linux-gnu
.