[PATCH] D44888: [RISCV] Default enable linker relaxation and add -mno-relax flag to disable it

Shiva Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 25 18:44:44 PDT 2018


shiva0217 created this revision.
shiva0217 added reviewers: asb, apazos.
Herald added subscribers: cfe-commits, kito-cheng, niosHD, sabuasal, jordy.potman.lists, simoncook, johnrusso, rbar.

Default enable linker relaxation and add -mno-relax flag to disable it.


Repository:
  rC Clang

https://reviews.llvm.org/D44888

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Arch/RISCV.cpp


Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "ToolChains/CommonArgs.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -51,6 +52,15 @@
       }
     }
   }
+  if (Args.getLastArg(options::OPT_mno_relax)) {
+    // Not passing relax.
+  } else {
+    // Default enable relaxation.
+    Features.push_back("+relax");
+  }
+  // Now add any that the user explicitly requested on the command line,
+  // which may override the defaults.
+  handleTargetFeaturesGroup(Args, Features, options::OPT_m_riscv_Features_Group);
 }
 
 StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -150,6 +150,9 @@
 def m_x86_Features_Group : OptionGroup<"<x86 features group>">,
                            Group<m_Group>, Flags<[CoreOption]>, DocName<"X86">;
 
+def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
+                             Group<m_Group>, DocName<"RISCV">;
+
 def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_Group>,
                    Flags<[HelpHidden]>;
 
@@ -1868,6 +1871,9 @@
 def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>,
   HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">;
 
+def mno_relax : Flag<["-"], "mno-relax">,
+    Group<m_riscv_Features_Group>;
+
 def mno_constant_cfstrings : Flag<["-"], "mno-constant-cfstrings">, Group<m_Group>;
 def mno_global_merge : Flag<["-"], "mno-global-merge">, Group<m_Group>, Flags<[CC1Option]>,
   HelpText<"Disable merging of globals">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44888.139757.patch
Type: text/x-patch
Size: 2016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180326/306dc8dd/attachment.bin>


More information about the cfe-commits mailing list