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

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 12 03:16:35 PST 2023


Author: Wang Pengcheng
Date: 2023-12-12T19:16:30+08:00
New Revision: 985c00819583a23b58d8c8cdeaefe6f9ed49e9cf

URL: https://github.com/llvm/llvm-project/commit/985c00819583a23b58d8c8cdeaefe6f9ed49e9cf
DIFF: https://github.com/llvm/llvm-project/commit/985c00819583a23b58d8c8cdeaefe6f9ed49e9cf.diff

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

We can reduce some code.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Removed: 
    


################################################################################
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