[clang] [RISCV][Clang] Remove default feature -save-restore. (PR #76390)
https://github.com/yetingk created https://github.com/llvm/llvm-project/pull/76390 It's unnecessary to defaultly pass feature `-save-restore`, since risc-v backend defaultly disables save-restore functionality. >From 97fe56d808f1752ac4b7d26deecabb857e0a4208 Mon Sep 17 00:00:00 2001 From: Yeting Kuo Date: Tue, 26 Dec 2023 02:11:30 -0800 Subject: [PATCH] [RISCV][Clang] Remove default feature -save-restore. It's unnecessary to defaultly pass -save-restore, since riscv backend defaultly disable save-restore functionality. --- clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 6 ++ clang/test/Driver/riscv-default-features.c | 2 -- clang/test/Driver/riscv-features.c | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 25b43cefce6b57..f385a97eca991b 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -169,10 +169,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, // GCC Compatibility: -mno-save-restore is default, unless -msave-restore is // specified. - if (Args.hasFlag(options::OPT_msave_restore, options::OPT_mno_save_restore, false)) -Features.push_back("+save-restore"); - else -Features.push_back("-save-restore"); + AddTargetFeature(Args, Features, options::OPT_msave_restore, + options::OPT_mno_save_restore, "save-restore"); // -mno-unaligned-access is default, unless -munaligned-access is specified. AddTargetFeature(Args, Features, options::OPT_munaligned_access, diff --git a/clang/test/Driver/riscv-default-features.c b/clang/test/Driver/riscv-default-features.c index 6e48f7cc37dcb0..4c3883c1cc1184 100644 --- a/clang/test/Driver/riscv-default-features.c +++ b/clang/test/Driver/riscv-default-features.c @@ -2,9 +2,7 @@ // RUN: %clang --target=riscv64-unknown-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64 // RV32: "target-features"="+32bit,+a,+c,+m,+relax, -// RV32-SAME: -save-restore // RV64: "target-features"="+64bit,+a,+c,+m,+relax, -// RV64-SAME: -save-restore // Dummy function int foo(void){ diff --git a/clang/test/Driver/riscv-features.c b/clang/test/Driver/riscv-features.c index 716f3f6da57b88..d3700f71aa7e1d 100644 --- a/clang/test/Driver/riscv-features.c +++ b/clang/test/Driver/riscv-features.c @@ -24,7 +24,7 @@ // SAVE-RESTORE: "-target-feature" "+save-restore" // NO-SAVE-RESTORE: "-target-feature" "-save-restore" -// DEFAULT: "-target-feature" "-save-restore" +// DEFAULT-NOT: "-target-feature" "-save-restore" // DEFAULT-NOT: "-target-feature" "+save-restore" // RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | FileCheck %s -check-prefix=FAST-UNALIGNED-ACCESS ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV][Clang] Remove default feature -save-restore. (PR #76390)
llvmbot wrote: @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-risc-v Author: Yeting Kuo (yetingk) Changes It's unnecessary to defaultly pass feature `-save-restore`, since risc-v backend defaultly disables save-restore functionality. --- Full diff: https://github.com/llvm/llvm-project/pull/76390.diff 3 Files Affected: - (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+2-4) - (modified) clang/test/Driver/riscv-default-features.c (-2) - (modified) clang/test/Driver/riscv-features.c (+1-1) ``diff diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp index 25b43cefce6b57..f385a97eca991b 100644 --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -169,10 +169,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple, // GCC Compatibility: -mno-save-restore is default, unless -msave-restore is // specified. - if (Args.hasFlag(options::OPT_msave_restore, options::OPT_mno_save_restore, false)) -Features.push_back("+save-restore"); - else -Features.push_back("-save-restore"); + AddTargetFeature(Args, Features, options::OPT_msave_restore, + options::OPT_mno_save_restore, "save-restore"); // -mno-unaligned-access is default, unless -munaligned-access is specified. AddTargetFeature(Args, Features, options::OPT_munaligned_access, diff --git a/clang/test/Driver/riscv-default-features.c b/clang/test/Driver/riscv-default-features.c index 6e48f7cc37dcb0..4c3883c1cc1184 100644 --- a/clang/test/Driver/riscv-default-features.c +++ b/clang/test/Driver/riscv-default-features.c @@ -2,9 +2,7 @@ // RUN: %clang --target=riscv64-unknown-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV64 // RV32: "target-features"="+32bit,+a,+c,+m,+relax, -// RV32-SAME: -save-restore // RV64: "target-features"="+64bit,+a,+c,+m,+relax, -// RV64-SAME: -save-restore // Dummy function int foo(void){ diff --git a/clang/test/Driver/riscv-features.c b/clang/test/Driver/riscv-features.c index 716f3f6da57b88..d3700f71aa7e1d 100644 --- a/clang/test/Driver/riscv-features.c +++ b/clang/test/Driver/riscv-features.c @@ -24,7 +24,7 @@ // SAVE-RESTORE: "-target-feature" "+save-restore" // NO-SAVE-RESTORE: "-target-feature" "-save-restore" -// DEFAULT: "-target-feature" "-save-restore" +// DEFAULT-NOT: "-target-feature" "-save-restore" // DEFAULT-NOT: "-target-feature" "+save-restore" // RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | FileCheck %s -check-prefix=FAST-UNALIGNED-ACCESS `` https://github.com/llvm/llvm-project/pull/76390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits