r351579 - [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls'

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 16:15:49 PST 2019


Merged to 8.0 in r352139.

On Fri, Jan 18, 2019 at 11:58 AM Vladimir Stefanovic via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
> Author: vstefanovic
> Date: Fri Jan 18 11:54:51 2019
> New Revision: 351579
>
> URL: http://llvm.org/viewvc/llvm-project?rev=351579&view=rev
> Log:
> [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls'
>
> These two options enable/disable emission of R_{MICRO}MIPS_JALR fixups along
> with PIC calls. The linker may then try to turn PIC calls into direct jumps.
> By default, these fixups do get emitted by the backend, use
> '-mno-relax-pic-calls' to omit them.
>
> Differential revision: https://reviews.llvm.org/D56878
>
> Modified:
>     cfe/trunk/include/clang/Driver/Options.td
>     cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>     cfe/trunk/test/Driver/mips-features.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=351579&r1=351578&r2=351579&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Fri Jan 18 11:54:51 2019
> @@ -2418,6 +2418,14 @@ def modd_spreg : Flag<["-"], "modd-spreg
>  def mno_odd_spreg : Flag<["-"], "mno-odd-spreg">, Group<m_mips_Features_Group>,
>    HelpText<"Disable odd single-precision floating point registers">,
>    Flags<[HelpHidden]>;
> +def mrelax_pic_calls : Flag<["-"], "mrelax-pic-calls">,
> +  Group<m_mips_Features_Group>,
> +  HelpText<"Try turning PIC calls (j{al}r{c} $25) into direct calls "
> +  "(MIPS only)">, Flags<[HelpHidden]>;
> +def mno_relax_pic_calls : Flag<["-"], "mno-relax-pic-calls">,
> +  Group<m_mips_Features_Group>,
> +  HelpText<"Do not try turning PIC calls (j{al}r{c} $25) into direct calls "
> +  "(MIPS only)">, Flags<[HelpHidden]>;
>  def mglibc : Flag<["-"], "mglibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
>  def muclibc : Flag<["-"], "muclibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
>  def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group<Action_Group>,
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=351579&r1=351578&r2=351579&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jan 18 11:54:51 2019
> @@ -1716,6 +1716,14 @@ void Clang::AddMIPSTargetArgs(const ArgL
>      } else
>        D.Diag(diag::warn_target_unsupported_compact_branches) << CPUName;
>    }
> +
> +  if (Arg *A = Args.getLastArg(options::OPT_mrelax_pic_calls,
> +                               options::OPT_mno_relax_pic_calls)) {
> +    if (A->getOption().matches(options::OPT_mno_relax_pic_calls)) {
> +      CmdArgs.push_back("-mllvm");
> +      CmdArgs.push_back("-mips-jalr-reloc=0");
> +    }
> +  }
>  }
>
>  void Clang::AddPPCTargetArgs(const ArgList &Args,
>
> Modified: cfe/trunk/test/Driver/mips-features.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=351579&r1=351578&r2=351579&view=diff
> ==============================================================================
> --- cfe/trunk/test/Driver/mips-features.c (original)
> +++ cfe/trunk/test/Driver/mips-features.c Fri Jan 18 11:54:51 2019
> @@ -444,3 +444,15 @@
>  // RUN:     -mginv -mno-ginv 2>&1 \
>  // RUN:   | FileCheck --check-prefix=CHECK-NO-GINV %s
>  // CHECK-NO-GINV: "-target-feature" "-ginv"
> +//
> +// -mrelax-pic-calls
> +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
> +// RUN:     -mno-relax-pic-calls -mrelax-pic-calls 2>&1 \
> +// RUN:   | FileCheck --check-prefix=CHECK-RELAX-PIC-CALLS %s
> +// CHECK-RELAX-PIC-CALLS-NOT: "-mllvm" "-mips-jalr-reloc=0"
> +//
> +// -mno-relax-pic-calls
> +// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
> +// RUN:     -mrelax-pic-calls -mno-relax-pic-calls 2>&1 \
> +// RUN:   | FileCheck --check-prefix=CHECK-NO-RELAX-PIC-CALLS %s
> +// CHECK-NO-RELAX-PIC-CALLS: "-mllvm" "-mips-jalr-reloc=0"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list