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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Wang Pengcheng (wangpc-pp)

<details>
<summary>Changes</summary>

We can reduce some code.


---
Full diff: https://github.com/llvm/llvm-project/pull/74280.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+2-7) 


``````````diff
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.

``````````

</details>


https://github.com/llvm/llvm-project/pull/74280


More information about the cfe-commits mailing list