aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2014-11-25 09:07:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2014-11-25 09:07:25 +0000
commit26ed270e0fa48c1205256c1a4409a009ff6aa40f (patch)
tree6fca5efbac99f4cdc951686440646b60961d2b43 /gcc
parentb286be940a8231b35ed111f6044b2bf7da471d07 (diff)
downloadgcc-26ed270e0fa48c1205256c1a4409a009ff6aa40f.zip
gcc-26ed270e0fa48c1205256c1a4409a009ff6aa40f.tar.gz
gcc-26ed270e0fa48c1205256c1a4409a009ff6aa40f.tar.bz2
rs6000.c (rs6000_call_aix): For the AIX ABI, do not load the static chain if the call was originally direct.
* config/rs6000/rs6000.c (rs6000_call_aix): For the AIX ABI, do not load the static chain if the call was originally direct. From-SVN: r218040
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/rs6000/rs6000.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/powerpc/longcall-2.c32
4 files changed, 48 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8ff9c72..bed7cb8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-25 Eric Botcazou <ebotcazou@adacore.com>
+
+ * config/rs6000/rs6000.c (rs6000_call_aix): For the AIX ABI, do not
+ load the static chain if the call was originally direct.
+
2014-11-25 Jan Hubicka <hubicka@ucw.cz>
PR ipa/64059
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a87e762..6873c77 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -32853,6 +32853,8 @@ rs6000_legitimate_constant_p (machine_mode mode, rtx x)
void
rs6000_call_aix (rtx value, rtx func_desc, rtx flag, rtx cookie)
{
+ const bool direct_call_p
+ = GET_CODE (func_desc) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (func_desc);
rtx toc_reg = gen_rtx_REG (Pmode, TOC_REGNUM);
rtx toc_load = NULL_RTX;
rtx toc_restore = NULL_RTX;
@@ -32921,8 +32923,11 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx flag, rtx cookie)
func_toc_offset));
toc_load = gen_rtx_USE (VOIDmode, func_toc_mem);
- /* If we have a static chain, load it up. */
- if (TARGET_POINTERS_TO_NESTED_FUNCTIONS)
+ /* If we have a static chain, load it up. But, if the call was
+ originally direct, the 3rd word has not been written since no
+ trampoline has been built, so we ought not to load it, lest we
+ override a static chain value. */
+ if (!direct_call_p && TARGET_POINTERS_TO_NESTED_FUNCTIONS)
{
rtx sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
rtx func_sc_offset = GEN_INT (2 * GET_MODE_SIZE (Pmode));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a8d7cd..6f96bfb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-25 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.target/powerpc/longcall-2.c: New test.
+
2014-11-25 Marek Polacek <polacek@redhat.com>
PR c/63877
diff --git a/gcc/testsuite/gcc.target/powerpc/longcall-2.c b/gcc/testsuite/gcc.target/powerpc/longcall-2.c
new file mode 100644
index 0000000..fc73cee
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/longcall-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-mlongcall" } */
+
+extern void abort (void);
+
+#define VAL 12345678
+
+int j = VAL;
+
+void
+bar (void)
+{
+ if (j != VAL)
+ abort ();
+}
+
+int
+main (void)
+{
+ int i = VAL;
+
+ int foo (void)
+ {
+ if (i != VAL)
+ abort ();
+ }
+
+ foo ();
+ bar ();
+
+ return 0;
+}