Re: r271162 - Handle -Wa,--mrelax-relocations=[no|yes].

2016-05-28 Thread David Majnemer via cfe-commits
On Sat, May 28, 2016 at 7:01 PM, Rafael Espindola via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rafael
> Date: Sat May 28 21:01:14 2016
> New Revision: 271162
>
> URL: http://llvm.org/viewvc/llvm-project?rev=271162=rev
> Log:
> Handle -Wa,--mrelax-relocations=[no|yes].
>
> Added:
> cfe/trunk/test/CodeGen/relax.c
> cfe/trunk/test/Driver/relax.c
> cfe/trunk/test/Driver/relax.s
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/tools/driver/cc1as_main.cpp
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=271162=271161=271162=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Sat May 28 21:01:14 2016
> @@ -143,6 +143,8 @@ def mno_exec_stack : Flag<["-"], "mnoexe
>HelpText<"Mark the file as not needing an executable stack">;
>  def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,
>HelpText<"Make assembler warnings fatal">;
> +def mrelax_relocations : Flag<["--"], "mrelax-relocations">,
> +HelpText<"Use relaxabel elf relocations">;
>

relaxable?


>  def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
>  HelpText<"Compress DWARF debug sections using zlib">;
>  def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=271162=271161=271162=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Sat May 28
> 21:01:14 2016
> @@ -30,6 +30,7 @@ CODEGENOPT(Name, Bits, Default)
>
>  CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
>  CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
> +CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
>  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
>  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit
> __attribute__((malloc)) operator new
>  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=271162=271161=271162=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat May 28 21:01:14 2016
> @@ -593,6 +593,7 @@ TargetMachine *EmitAssemblyHelper::Creat
>Options.UseInitArray = CodeGenOpts.UseInitArray;
>Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
>Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
> +  Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
>
>// Set EABI version.
>Options.EABIVersion =
> llvm::StringSwitch(TargetOpts.EABIVersion)
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271162=271161=271162=diff
>
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Sat May 28 21:01:14 2016
> @@ -2797,6 +2797,8 @@ static void CollectArgsForIntegratedAsse
>// When using an integrated assembler, translate -Wa, and -Xassembler
>// options.
>bool CompressDebugSections = false;
> +
> +  bool UseRelaxRelocations = false;
>const char *MipsTargetFeature = nullptr;
>for (const Arg *A :
> Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
> @@ -2872,6 +2874,12 @@ static void CollectArgsForIntegratedAsse
>} else if (Value == "-nocompress-debug-sections" ||
>   Value == "--nocompress-debug-sections") {
>  CompressDebugSections = false;
> +  } else if (Value == "-mrelax-relocations=yes" ||
> + Value == "--mrelax-relocations=yes") {
> +UseRelaxRelocations = true;
> +  } else if (Value == "-mrelax-relocations=no" ||
> + Value == "--mrelax-relocations=no") {
> +UseRelaxRelocations = false;
>} else if (Value.startswith("-I")) {
>  CmdArgs.push_back(Value.data());
>  // We need to consume the next argument if the current arg is a
> plain
> @@ -2903,6 +2911,8 @@ static void CollectArgsForIntegratedAsse
>  else
>D.Diag(diag::warn_debug_compression_unavailable);
>}
> +  if 

r271162 - Handle -Wa,--mrelax-relocations=[no|yes].

2016-05-28 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Sat May 28 21:01:14 2016
New Revision: 271162

URL: http://llvm.org/viewvc/llvm-project?rev=271162=rev
Log:
Handle -Wa,--mrelax-relocations=[no|yes].

Added:
cfe/trunk/test/CodeGen/relax.c
cfe/trunk/test/Driver/relax.c
cfe/trunk/test/Driver/relax.s
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=271162=271161=271162=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Sat May 28 21:01:14 2016
@@ -143,6 +143,8 @@ def mno_exec_stack : Flag<["-"], "mnoexe
   HelpText<"Mark the file as not needing an executable stack">;
 def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,
   HelpText<"Make assembler warnings fatal">;
+def mrelax_relocations : Flag<["--"], "mrelax-relocations">,
+HelpText<"Use relaxabel elf relocations">;
 def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
 HelpText<"Compress DWARF debug sections using zlib">;
 def msave_temp_labels : Flag<["-"], "msave-temp-labels">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=271162=271161=271162=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Sat May 28 21:01:14 2016
@@ -30,6 +30,7 @@ CODEGENOPT(Name, Bits, Default)
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
+CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=271162=271161=271162=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat May 28 21:01:14 2016
@@ -593,6 +593,7 @@ TargetMachine *EmitAssemblyHelper::Creat
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+  Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=271162=271161=271162=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat May 28 21:01:14 2016
@@ -2797,6 +2797,8 @@ static void CollectArgsForIntegratedAsse
   // When using an integrated assembler, translate -Wa, and -Xassembler
   // options.
   bool CompressDebugSections = false;
+
+  bool UseRelaxRelocations = false;
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
@@ -2872,6 +2874,12 @@ static void CollectArgsForIntegratedAsse
   } else if (Value == "-nocompress-debug-sections" ||
  Value == "--nocompress-debug-sections") {
 CompressDebugSections = false;
+  } else if (Value == "-mrelax-relocations=yes" ||
+ Value == "--mrelax-relocations=yes") {
+UseRelaxRelocations = true;
+  } else if (Value == "-mrelax-relocations=no" ||
+ Value == "--mrelax-relocations=no") {
+UseRelaxRelocations = false;
   } else if (Value.startswith("-I")) {
 CmdArgs.push_back(Value.data());
 // We need to consume the next argument if the current arg is a plain
@@ -2903,6 +2911,8 @@ static void CollectArgsForIntegratedAsse
 else
   D.Diag(diag::warn_debug_compression_unavailable);
   }
+  if (UseRelaxRelocations)
+CmdArgs.push_back("--mrelax-relocations");
   if (MipsTargetFeature != nullptr) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back(MipsTargetFeature);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: