This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.0 PATCH] Fix ICE in gimplify_call_expr (PR middle-end/26092)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ian Lance Taylor <ian at airs dot com>, Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Feb 2006 06:39:23 -0500
- Subject: [4.0 PATCH] Fix ICE in gimplify_call_expr (PR middle-end/26092)
- References: <20060208152625.GN24295@devserv.devel.redhat.com> <m3lkwibd34.fsf@gossamer.airs.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Feb 10, 2006 at 10:53:51PM -0800, Ian Lance Taylor wrote:
> > 2006-02-08 Jakub Jelinek <jakub@redhat.com>
> >
> > PR middle-end/26092
> > * gimplify.c (gimplify_call_expr): Don't call get_callee_fndecl
> > twice if decl is a builtin. When trying again, call get_callee_fndecl
> > first to verify it is still a builtin.
> >
> > * gcc.c-torture/compile/20060208-1.c: New test.
>
> This is OK.
Mark just pinged me in bugzilla about GCC 4.0 which has the same bug.
Here is backported patch, bootstrapped/regtested on x86_64-linux.
Ok for 4.0?
2006-02-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/26092
* gimplify.c (gimplify_call_expr): When trying again, call
get_callee_fndecl first to verify it is still a builtin.
* gcc.c-torture/compile/20060208-1.c: New test.
--- gcc/gimplify.c (revision 110927)
+++ gcc/gimplify.c (revision 110928)
@@ -1796,17 +1796,21 @@ gimplify_call_expr (tree *expr_p, tree *
TREE_OPERAND (*expr_p, 1) = nreverse (TREE_OPERAND (*expr_p, 1));
/* Try this again in case gimplification exposed something. */
- if (ret != GS_ERROR && decl && DECL_BUILT_IN (decl))
+ if (ret != GS_ERROR)
{
- tree new = fold_builtin (*expr_p, !want_value);
-
- if (new && new != *expr_p)
+ decl = get_callee_fndecl (*expr_p);
+ if (decl && DECL_BUILT_IN (decl))
{
- /* There was a transformation of this call which computes the
- same value, but in a more efficient way. Return and try
- again. */
- *expr_p = new;
- return GS_OK;
+ tree new = fold_builtin (*expr_p, !want_value);
+
+ if (new && new != *expr_p)
+ {
+ /* There was a transformation of this call which computes the
+ same value, but in a more efficient way. Return and try
+ again. */
+ *expr_p = new;
+ return GS_OK;
+ }
}
}
--- gcc/testsuite/gcc.c-torture/compile/20060208-1.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/20060208-1.c (revision 110928)
@@ -0,0 +1,10 @@
+/* PR middle-end/26092 */
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc (size_t);
+
+void *(*const foo) (size_t) = malloc;
+
+void *test (void)
+{
+ return (*foo) (3);
+}
Jakub