Commit e299a383 by Richard Sandiford Committed by Richard Sandiford

re PR target/57260 (Generated R_MIPS_GOT_MIPS relocation for direct function…

re PR target/57260 (Generated R_MIPS_GOT_MIPS relocation for direct function call while compiling with -O2 on MIPS N64)

gcc/
	PR target/57260
	* config/mips/mips.c (mips_function_ok_for_sibcall): Don't allow
	sibling calls to functions that would normally be lazily bound,
	unless $gp is call-clobbered.

gcc/testsuite/
	PR target/57260
	* gcc.target/mips/call-1.c: Restrict to o32.
	* gcc.target/mips/call-5.c, gcc.target/mips/call-6.c: New test.

From-SVN: r198945
parent 1e6cf26e
2013-05-15 Richard Sandiford <rdsandiford@googlemail.com>
PR target/57260
* config/mips/mips.c (mips_function_ok_for_sibcall): Don't allow
sibling calls to functions that would normally be lazily bound,
unless $gp is call-clobbered.
2013-05-15 Uros Bizjak <ubizjak@gmail.com> 2013-05-15 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (iy86_option_override_internal): Update * config/i386/i386.c (iy86_option_override_internal): Update
......
...@@ -6995,6 +6995,15 @@ mips_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED) ...@@ -6995,6 +6995,15 @@ mips_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
&& mips_call_may_need_jalx_p (decl)) && mips_call_may_need_jalx_p (decl))
return false; return false;
/* Sibling calls should not prevent lazy binding. Lazy-binding stubs
require $gp to be valid on entry, so sibcalls can only use stubs
if $gp is call-clobbered. */
if (decl
&& TARGET_CALL_SAVED_GP
&& !TARGET_ABICALLS_PIC0
&& !targetm.binds_local_p (decl))
return false;
/* Otherwise OK. */ /* Otherwise OK. */
return true; return true;
} }
......
2013-05-15 Richard Sandiford <rdsandiford@googlemail.com>
PR target/57260
* gcc.target/mips/call-1.c: Restrict to o32.
* gcc.target/mips/call-5.c, gcc.target/mips/call-6.c: New test.
2013-05-15 Paolo Carlini <paolo.carlini@oracle.com> 2013-05-15 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with * g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with
......
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls" } */ /* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */ /* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalr\t" } } */ /* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalr\t" } } */ /* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalr\t" } } */ /* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail\n1:\tjr\t" } } */ /* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail\n1:\tjr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail2\n1:\tjr\t" } } */ /* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail2\n1:\tjr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail3\n1:\tjr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail4\n1:\tjr\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); } __attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal (); int normal ();
...@@ -31,3 +33,17 @@ NOMIPS16 void g () ...@@ -31,3 +33,17 @@ NOMIPS16 void g ()
{ {
tail2 (); tail2 ();
} }
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}
/* Like call-1.c, but for n32. We cannot use sibling calls for tail and tail2
in this case (PR target/57260). */
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=n32" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail2\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail3\n1:\tjr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail4\n1:\tjr\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal ();
void normal2 ();
NOMIPS16 f (int *p)
{
*p = normal ();
normal2 ();
staticfunc ();
return 1;
}
int tail ();
NOMIPS16 h ()
{
return tail ();
}
void tail2 ();
NOMIPS16 void g ()
{
tail2 ();
}
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}
/* Like call-5.c, but for n64. */
/* { dg-options "-mrelax-pic-calls -mshared -foptimize-sibling-calls -mabi=64" } */
/* { dg-skip-if "requires -foptimize-sibling-calls" { *-*-* } { "-O0" } { "" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,normal2\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,staticfunc\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail2\n1:\tjalr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail3\n1:\tjr\t" } } */
/* { dg-final { scan-assembler "\\.reloc\t1f,R_MIPS_JALR,tail4\n1:\tjr\t" } } */
__attribute__ ((noinline)) static void staticfunc () { asm (""); }
int normal ();
void normal2 ();
NOMIPS16 f (int *p)
{
*p = normal ();
normal2 ();
staticfunc ();
return 1;
}
int tail ();
NOMIPS16 h ()
{
return tail ();
}
void tail2 ();
NOMIPS16 void g ()
{
tail2 ();
}
__attribute__ ((visibility ("hidden"))) void tail3 ();
NOMIPS16 void j ()
{
tail3 ();
}
__attribute__ ((noinline)) static void tail4 () { asm (""); }
NOMIPS16 void k ()
{
tail4 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment