From 69efc31da2d437bce7aca9f6bf003a901619359c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 11 Oct 2003 22:56:24 +0200 Subject: [PATCH] re PR rtl-optimization/12544 (ICE with large parameters used in nested functions) PR optimization/12544 * function.c (put_var_into_stack): Don't generate ADDRESSOFs for DECL_NONLOCAL decls. From-SVN: r72374 --- gcc/ChangeLog | 6 ++++++ gcc/function.c | 12 ++++++----- gcc/testsuite/ChangeLog | 4 ++++ .../gcc.c-torture/compile/20031011-1.c | 21 +++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20031011-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2012c2b0818..8a7ff9737bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-10-11 Eric Botcazou + + PR optimization/12544 + * function.c (put_var_into_stack): Don't generate ADDRESSOFs + for DECL_NONLOCAL decls. + 2003-10-11 Kazu Hirata * expr.c: Follow spelling conventions. diff --git a/gcc/function.c b/gcc/function.c index 427469eb8ae..6531c022f9e 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -1324,8 +1324,9 @@ put_var_into_stack (tree decl, int rescan) if (function->decl == context) break; - /* If this is a variable-size object with a pseudo to address it, - put that pseudo into the stack, if the var is nonlocal. */ + /* If this is a variable-sized object or a structure passed by invisible + reference, with a pseudo to address it, put that pseudo into the stack + if the var is non-local. */ if (TREE_CODE (decl) != SAVE_EXPR && DECL_NONLOCAL (decl) && GET_CODE (reg) == MEM && GET_CODE (XEXP (reg, 0)) == REG @@ -1335,8 +1336,12 @@ put_var_into_stack (tree decl, int rescan) decl_mode = promoted_mode = GET_MODE (reg); } + /* If this variable lives in the current function and we don't need to put it + in the stack for the sake of setjmp or the non-locality, try to keep it in + a register until we know we actually need the address. */ can_use_addressof = (function == 0 + && ! (TREE_CODE (decl) != SAVE_EXPR && DECL_NONLOCAL (decl)) && optimize > 0 /* FIXME make it work for promoted modes too */ && decl_mode == promoted_mode @@ -1355,9 +1360,6 @@ put_var_into_stack (tree decl, int rescan) if (GET_CODE (reg) == REG) { - /* If this variable lives in the current function and we don't need - to put things in the stack for the sake of setjmp, try to keep it - in a register until we know we actually need the address. */ if (can_use_addressof) gen_mem_addressof (reg, decl, rescan); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b7b24ac6cf6..9c10508818b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-10-11 Eric Botcazou + + * gcc.c-torture/compile/20031011-1.c: New test. + Sat Oct 11 12:26:16 CEST 2003 Jan Hubicka * g++.dg/other/first-global.C: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20031011-1.c b/gcc/testsuite/gcc.c-torture/compile/20031011-1.c new file mode 100644 index 00000000000..e35d76211b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20031011-1.c @@ -0,0 +1,21 @@ +/* PR optimization/12544 */ +/* Origin: Tony Hosking */ + +/* Verify that non-local structures passed by invisible + reference are correctly put in the stack. */ + +typedef struct { + int a; + int f; +} A; + +A *b; + +void x (A a) { + void y () { + a.a = 0; + } + + b = &a; + y(); +} -- 2.30.2