This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Fix PR 14470
- From: Diego Novillo <dnovillo at redhat dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Jason Merrill <jason at redhat dot com>
- Date: Wed, 14 Apr 2004 14:58:03 -0400
- Subject: [tree-ssa] Fix PR 14470
- Organization: Red Hat Canada
The problem boils down to 'd = t[d]++' being gimplified into:
T.1 = t[d];
d = T.1;
T.2 = T.1 + 1;
t[d] = T.2;
Instead of
T.1 = t[d];
T.3 = T.1;
T.2 = T.1 + 1;
t[d] = T.2;
d = T.3;
In reading some of the comments in the PR, the code seems to be valid.
The gimplifier was updating 'd' before 'T[d]', generating a SEGV at
runtime (gcc.c-torture/execute/20040313-1.c).
I have told the gimplifier to force the post-side effects of the RHS of
assignments to happen before the assignment itself. I am not actually
sure if this is the right semantics to implement, but it seems to me to
be the only way of doing it.
Jason, is this OK? Bootstrapped x86 and amd64. Fixes
gcc.c-torture/execute/20040313-1.c and
gfortran.fortran-torture/execute/read_eof.f90.
Thanks. Diego.
* gimplify.c (gimplify_modify_expr): Force post side-effects
on the RHS of an assignment to occur before the actual
assignment.
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.148
diff -d -c -p -u -r1.1.2.148 gimplify.c
--- gimplify.c 8 Apr 2004 02:42:25 -0000 1.1.2.148
+++ gimplify.c 14 Apr 2004 16:21:40 -0000
@@ -2408,7 +2408,7 @@ gimplify_modify_expr (tree *expr_p, tree
return gimplify_cond_expr (expr_p, pre_p, *to_p);
}
- ret = gimplify_expr (from_p, pre_p, post_p, is_gimple_rhs, fb_rvalue);
+ ret = gimplify_expr (from_p, pre_p, NULL, is_gimple_rhs, fb_rvalue);
if (ret == GS_ERROR)
return ret;