summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvmakarov <vmakarov@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-14 20:54:00 +0000
committerH.J. Lu <hjl.tools@gmail.com>2015-09-25 14:26:02 -0700
commit44f9e0b8eda2a1820c2e45efcf676047335f1c59 (patch)
treea8abe90dfd82727ba542abd09154265f04198924
parentf75fa122f858e1a5c0f1d1b2dcfa4bdd4ed9ec1f (diff)
downloadgcc-44f9e0b8eda2a1820c2e45efcf676047335f1c59.tar.gz
Fix PR rtl-optimization/66626
2015-07-14 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/66626 * lra-constraints.c (lra_constraints): Prevent equivalence substitution for static chain pseudo in functions with nonlocal goto. 2015-07-14 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/66626 * gcc.target/i386/pr66626.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225789 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/lra-constraints.c8
-rw-r--r--gcc/testsuite/gcc.target/i386/pr66626.c26
2 files changed, 33 insertions, 1 deletions
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 5a1c25a05f4..bd1209f82ee 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4328,7 +4328,13 @@ lra_constraints (bool first_p)
&& ((CONST_POOL_OK_P (PSEUDO_REGNO_MODE (i), x)
&& (targetm.preferred_reload_class
(x, lra_get_allocno_class (i)) == NO_REGS))
- || contains_symbol_ref_p (x))))
+ || contains_symbol_ref_p (x)))
+ /* Static chain equivalence may contain eliminable
+ regs and the result of elimination might be wrong
+ after restoring frame pointer for a nonlocal
+ goto. */
+ || (cfun->static_chain_decl && crtl->has_nonlocal_goto
+ && REG_EXPR (reg) == cfun->static_chain_decl))
ira_reg_equiv[i].defined_p = false;
if (contains_reg_p (x, false, true))
ira_reg_equiv[i].profitable_p = false;
diff --git a/gcc/testsuite/gcc.target/i386/pr66626.c b/gcc/testsuite/gcc.target/i386/pr66626.c
new file mode 100644
index 00000000000..dca4afc299a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr66626.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -mregparm=3" } */
+/* { dg-require-effective-target ia32 } */
+extern void abort (void);
+
+int s (int i, int j, int k, int l)
+{
+ __label__ l1;
+ int f (int i, int j, int k, int l)
+ {
+ if (i + j + k + l == 10)
+ goto l1;
+ return 0;
+ }
+ return f (i, j, k, l);
+ l1:;
+ return 1;
+}
+
+int main ()
+{
+ if (s (1, 2, 3, 4) != 1)
+ abort ();
+
+ return 0;
+}