From: Vladimir Stefanovic Date: Fri, 18 Jan 2019 19:54:51 +0000 (+0000) Subject: [mips] Add '-mrelax-pic-calls', '-mno-relax-pic-calls' X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99113a0ccf3dd77ccc1b3c6fd7bff986e6f376fe;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 351579 --- diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f02a719..d8155a9 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2418,6 +2418,14 @@ def modd_spreg : Flag<["-"], "modd-spreg">, Group, def mno_odd_spreg : Flag<["-"], "mno-odd-spreg">, Group, HelpText<"Disable odd single-precision floating point registers">, Flags<[HelpHidden]>; +def mrelax_pic_calls : Flag<["-"], "mrelax-pic-calls">, + 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, + HelpText<"Do not try turning PIC calls (j{al}r{c} $25) into direct calls " + "(MIPS only)">, Flags<[HelpHidden]>; def mglibc : Flag<["-"], "mglibc">, Group, Flags<[HelpHidden]>; def muclibc : Flag<["-"], "muclibc">, Group, Flags<[HelpHidden]>; def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 75f1689..589f53b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1716,6 +1716,14 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args, } 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, diff --git a/clang/test/Driver/mips-features.c b/clang/test/Driver/mips-features.c index f63fb8d..19725bc 100644 --- a/clang/test/Driver/mips-features.c +++ b/clang/test/Driver/mips-features.c @@ -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"