This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix c-c++-common/dwarf2/vla1.c test with -fstack-protector
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 27 Feb 2010 09:18:22 +0100
- Subject: [PATCH] Fix c-c++-common/dwarf2/vla1.c test with -fstack-protector
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
I've noticed this new testcase fails with
RUNTESTFLAGS=--target_board=unix/-fstack-protector
The problem is that for deferred stack allocation rtls for these vars are
created later on during expand_used_vars.
The following patch fixes this by trying again at the end of
expand_used_vars. Ok for trunk?
2010-02-27 Jakub Jelinek <jakub@redhat.com>
* cfgexpand.c (expand_used_vars): If an artificial non-ignored var
has no rtl yet when processing local_decls, queue it and recheck
if deferred stack allocation hasn't assigned it rtl.
--- gcc/cfgexpand.c.jj 2010-02-25 16:52:21.000000000 +0100
+++ gcc/cfgexpand.c 2010-02-27 09:09:52.000000000 +0100
@@ -1283,6 +1283,7 @@ static void
expand_used_vars (void)
{
tree t, next, outer_block = DECL_INITIAL (current_function_decl);
+ tree maybe_local_decls = NULL_TREE;
unsigned i;
/* Compute the phase of the stack frame for this function. */
@@ -1367,6 +1368,15 @@ expand_used_vars (void)
cfun->local_decls = t;
continue;
}
+ else if (rtl == NULL_RTX)
+ {
+ /* If rtl isn't set yet, which can happen e.g. with
+ -fstack-protector, retry before returning from this
+ function. */
+ TREE_CHAIN (t) = maybe_local_decls;
+ maybe_local_decls = t;
+ continue;
+ }
}
ggc_free (t);
@@ -1425,6 +1435,28 @@ expand_used_vars (void)
fini_vars_expansion ();
}
+ /* If there were any artificial non-ignored vars without rtl
+ found earlier, see if deferred stack allocation hasn't assigned
+ rtl to them. */
+ for (t = maybe_local_decls; t; t = next)
+ {
+ tree var = TREE_VALUE (t);
+ rtx rtl = DECL_RTL_IF_SET (var);
+
+ next = TREE_CHAIN (t);
+
+ /* Keep artificial non-ignored vars in cfun->local_decls
+ chain until instantiate_decls. */
+ if (rtl && (MEM_P (rtl) || GET_CODE (rtl) == CONCAT))
+ {
+ TREE_CHAIN (t) = cfun->local_decls;
+ cfun->local_decls = t;
+ continue;
+ }
+
+ ggc_free (t);
+ }
+
/* If the target requires that FRAME_OFFSET be aligned, do it. */
if (STACK_ALIGNMENT_NEEDED)
{
Jakub