From 6e5ad0f92c3e5b4f8c3fcf5a67265874beda1040 Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Tue, 14 Jul 2015 20:54:00 +0000 Subject: [PATCH] re PR rtl-optimization/66626 (gcc.dg/torture/stackalign/non-local-goto-5.c segfaults w/ -mregparm=3 or -miamcu) 2015-07-14 Vladimir Makarov 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 PR rtl-optimization/66626 * gcc.target/i386/pr66626.c: New. From-SVN: r225789 --- gcc/ChangeLog | 7 +++++++ gcc/lra-constraints.c | 8 +++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr66626.c | 26 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr66626.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 79e5ba01c7a..4679097fa0e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-07-14 Vladimir Makarov + + PR rtl-optimization/66626 + * lra-constraints.c (lra_constraints): Prevent equivalence + substitution for static chain pseudo in functions with nonlocal + goto. + 2015-07-14 Sandra Loosemore * config/nios2/nios2.c (TEMP_REG_NUM): Move define up in file. diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index ddb91dd49cf..58a388fa9e8 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -4306,7 +4306,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/ChangeLog b/gcc/testsuite/ChangeLog index 6284431035a..45df0cc0095 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-14 Vladimir Makarov + + PR rtl-optimization/66626 + * gcc.target/i386/pr66626.c: New. + 2015-07-14 Sandra Loosemore * gcc.target/nios2/nios2-stack-check-1.c: Adjust patterns. 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; +} -- 2.30.2