Skip to content

Commit b4e9b74

Browse files
committed
[SPARC][Driver] Set correct IAS mode defaults for Linux and Free/OpenBSD
On those OSes, clang should set the assembler to enable VIS by default. This is already the case when clang calls an external assembler, so make sure clang+IAS use the same defaults. This should fix [issue #125124](#125124).
1 parent 560cfd5 commit b4e9b74

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,17 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
28762876
CmdArgs.push_back("-target-feature");
28772877
CmdArgs.push_back(MipsTargetFeature);
28782878
}
2879+
2880+
// Those OSes default to enabling VIS on 64-bit SPARC.
2881+
// See also the corresponding code for external assemblers in
2882+
// sparc::getSparcAsmModeForCPU().
2883+
bool IsSparcV9ATarget =
2884+
(C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) &&
2885+
(Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
2886+
if (IsSparcV9ATarget && SparcTargetFeatures.empty()) {
2887+
CmdArgs.push_back("-target-feature");
2888+
CmdArgs.push_back("+vis");
2889+
}
28792890
for (const char *Feature : SparcTargetFeatures) {
28802891
CmdArgs.push_back("-target-feature");
28812892
CmdArgs.push_back(Feature);

clang/test/Driver/sparc-ias-Wa.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,12 @@
5858
// V9D: "-target-feature" "+vis"
5959
// V9D: "-target-feature" "+vis2"
6060
// V9D: "-target-feature" "+vis3"
61+
62+
// RUN: %clang --target=sparc64-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
63+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
64+
// RUN: %clang --target=sparc64-freebsd -### -fintegrated-as -c %s 2>&1 | \
65+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
66+
// RUN: %clang --target=sparc64-openbsd -### -fintegrated-as -c %s 2>&1 | \
67+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
68+
// VIS-DEFAULT: -cc1as
69+
// VIS-DEFAULT: "-target-feature" "+vis"

0 commit comments

Comments
 (0)