aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2013-05-15 19:16:34 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2013-05-15 19:16:34 +0000
commite299a383a9334fe71492e54ccfa9888434d69d05 (patch)
tree3d392484a1d49b2407852da42793dd5b4ea7c9d9 /gcc
parent1e6cf26ea81901fb00daef06d74966bcacbd99eb (diff)
downloadgcc-e299a383a9334fe71492e54ccfa9888434d69d05.zip
gcc-e299a383a9334fe71492e54ccfa9888434d69d05.tar.gz
gcc-e299a383a9334fe71492e54ccfa9888434d69d05.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/mips/mips.c9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/mips/call-1.c18
-rw-r--r--gcc/testsuite/gcc.target/mips/call-5.c51
-rw-r--r--gcc/testsuite/gcc.target/mips/call-6.c50
6 files changed, 140 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6d61a4e..425e3d2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+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>
* config/i386/i386.c (iy86_option_override_internal): Update
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index f7c1f8c..066e7a1 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -6995,6 +6995,15 @@ mips_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
&& mips_call_may_need_jalx_p (decl))
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. */
return true;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index be7ccec..e608612 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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>
* g++.dg/cpp0x/lambda/lambda-shadow1.C: Replace dg-warnings with
diff --git a/gcc/testsuite/gcc.target/mips/call-1.c b/gcc/testsuite/gcc.target/mips/call-1.c
index a9c97c3..2a9f1e5 100644
--- a/gcc/testsuite/gcc.target/mips/call-1.c
+++ b/gcc/testsuite/gcc.target/mips/call-1.c
@@ -1,10 +1,12 @@
-/* { 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-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:\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 (""); }
int normal ();
@@ -31,3 +33,17 @@ NOMIPS16 void g ()
{
tail2 ();
}
+
+__attribute__ ((visibility ("hidden"))) void tail3 ();
+
+NOMIPS16 void j ()
+{
+ tail3 ();
+}
+
+__attribute__ ((noinline)) static void tail4 () { asm (""); }
+
+NOMIPS16 void k ()
+{
+ tail4 ();
+}
diff --git a/gcc/testsuite/gcc.target/mips/call-5.c b/gcc/testsuite/gcc.target/mips/call-5.c
new file mode 100644
index 0000000..2e58178
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-5.c
@@ -0,0 +1,51 @@
+/* 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 ();
+}
diff --git a/gcc/testsuite/gcc.target/mips/call-6.c b/gcc/testsuite/gcc.target/mips/call-6.c
new file mode 100644
index 0000000..86f3dc4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-6.c
@@ -0,0 +1,50 @@
+/* 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 ();
+}