[clang] [RISCV][NFC] Use AddTargetFeature to add fast-unaligned-access (PR #74280)

Wang Pengcheng via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 3 22:12:01 PST 2023


https://github.com/wangpc-pp created https://github.com/llvm/llvm-project/pull/74280

We can reduce some code.


>From 1a9364a8b1e0eae320774253ac98a445daf7ec9f Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Mon, 4 Dec 2023 14:11:19 +0800
Subject: [PATCH] [RISCV][NFC] Use AddTargetFeature to add
 fast-unaligned-access

We can reduce some code.
---
 clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 5d990ba78e5cc..0b696111e7d71 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -171,13 +171,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
     Features.push_back("-save-restore");
 
   // -mno-unaligned-access is default, unless -munaligned-access is specified.
-  if (const Arg *A = Args.getLastArg(options::OPT_munaligned_access,
-                                     options::OPT_mno_unaligned_access)) {
-    if (A->getOption().matches(options::OPT_munaligned_access))
-      Features.push_back("+fast-unaligned-access");
-    else
-      Features.push_back("-fast-unaligned-access");
-  }
+  AddTargetFeature(Args, Features, options::OPT_munaligned_access,
+                   options::OPT_mno_unaligned_access, "fast-unaligned-access");
 
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.



More information about the cfe-commits mailing list