[PATCH] D47127: [RISCV] Default enable RISCV linker relaxation

Shiva Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 21 01:05:10 PDT 2018


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

Default enable RISCV linker relaxation


Repository:
  rL LLVM

https://reviews.llvm.org/D47127

Files:
  lib/Driver/ToolChains/Arch/RISCV.cpp
  test/Driver/riscv-features.c


Index: test/Driver/riscv-features.c
===================================================================
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -5,6 +5,8 @@
 
 // RUN: %clang -target riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
 // RUN: %clang -target riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
+// RUN: %clang -target riscv32-unknown-elf -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
 
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
+// DEFAULT: "-target-feature" "+relax"
Index: lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- lib/Driver/ToolChains/Arch/RISCV.cpp
+++ lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -365,6 +365,17 @@
     getExtensionFeatures(D, Args, Features, MArch, OtherExts);
   }
 
+  // -mrelax is default, unless -mno-relax is specified.
+  bool Relax = true;
+  if (auto *A = Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax))
+    if (A->getOption().matches(options::OPT_mno_relax)) {
+      Relax = false;
+      Features.push_back("-relax");
+    }
+
+  if (Relax)
+    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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47127.147740.patch
Type: text/x-patch
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180521/1cc6d77a/attachment.bin>


More information about the llvm-commits mailing list