Author: Koakuma Date: 2025-03-23T20:56:40+07:00 New Revision: 385311625945e65990bd60bea76a045dcaf3f47b
URL: https://github.com/llvm/llvm-project/commit/385311625945e65990bd60bea76a045dcaf3f47b DIFF: https://github.com/llvm/llvm-project/commit/385311625945e65990bd60bea76a045dcaf3f47b.diff LOG: [SPARC][Driver] Set correct IAS mode defaults for Linux and Free/OpenBSD (#130108) 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](https://github.com/llvm/llvm-project/issues/125124). Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/sparc-ias-Wa.s Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index fe917902a01cd..fb3ed2db0e3c0 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2875,6 +2875,17 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-target-feature"); CmdArgs.push_back(MipsTargetFeature); } + + // Those OSes default to enabling VIS on 64-bit SPARC. + // See also the corresponding code for external assemblers in + // sparc::getSparcAsmModeForCPU(). + bool IsSparcV9ATarget = + (C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) && + (Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD()); + if (IsSparcV9ATarget && SparcTargetFeatures.empty()) { + CmdArgs.push_back("-target-feature"); + CmdArgs.push_back("+vis"); + } for (const char *Feature : SparcTargetFeatures) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back(Feature); diff --git a/clang/test/Driver/sparc-ias-Wa.s b/clang/test/Driver/sparc-ias-Wa.s index 79456c02935be..c031f237297d3 100644 --- a/clang/test/Driver/sparc-ias-Wa.s +++ b/clang/test/Driver/sparc-ias-Wa.s @@ -58,3 +58,12 @@ // V9D: "-target-feature" "+vis" // V9D: "-target-feature" "+vis2" // V9D: "-target-feature" "+vis3" + +// RUN: %clang --target=sparc64-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=VIS-DEFAULT %s +// RUN: %clang --target=sparc64-freebsd -### -fintegrated-as -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=VIS-DEFAULT %s +// RUN: %clang --target=sparc64-openbsd -### -fintegrated-as -c %s 2>&1 | \ +// RUN: FileCheck -check-prefix=VIS-DEFAULT %s +// VIS-DEFAULT: -cc1as +// VIS-DEFAULT: "-target-feature" "+vis" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits