[PATCH] Fix PR37380
Richard Guenther
rguenther@suse.de
Tue Sep 16 14:08:00 GMT 2008
This works around the gimplifier issue in PR37380 by not calling it
when we do not need to.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2008-09-16 Richard Guenther <rguenther@suse.de>
PR middle-end/37380
* tree-sra.c (sra_build_assignment): Do not call the gimplifier
if not necessary.
* gcc.c-torture/compile/pr37380.c: New testcase.
Index: trunk/gcc/tree-sra.c
===================================================================
*** trunk.orig/gcc/tree-sra.c 2008-09-02 15:20:12.000000000 +0200
--- trunk/gcc/tree-sra.c 2008-09-16 11:07:52.000000000 +0200
*************** sra_build_assignment (tree dst, tree src
*** 2308,2315 ****
&& !useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (src)))
src = fold_convert (TREE_TYPE (dst), src);
! src = force_gimple_operand (src, &seq2, false, NULL_TREE);
! gimple_seq_add_seq (&seq, seq2);
stmt = gimple_build_assign (dst, src);
gimple_seq_add_stmt (&seq, stmt);
return seq;
--- 2308,2321 ----
&& !useless_type_conversion_p (TREE_TYPE (dst), TREE_TYPE (src)))
src = fold_convert (TREE_TYPE (dst), src);
! /* ??? Only call the gimplifier if we need to. Otherwise we may
! end up substituting with DECL_VALUE_EXPR - see PR37380. */
! if (!handled_component_p (src)
! && !SSA_VAR_P (src))
! {
! src = force_gimple_operand (src, &seq2, false, NULL_TREE);
! gimple_seq_add_seq (&seq, seq2);
! }
stmt = gimple_build_assign (dst, src);
gimple_seq_add_stmt (&seq, stmt);
return seq;
Index: trunk/gcc/testsuite/gcc.c-torture/compile/pr37380.c
===================================================================
*** /dev/null 1970-01-01 00:00:00.000000000 +0000
--- trunk/gcc/testsuite/gcc.c-torture/compile/pr37380.c 2008-09-16 11:08:24.000000000 +0200
***************
*** 0 ****
--- 1,51 ----
+ typedef struct basic_block_def *basic_block;
+ typedef struct gimple_seq_node_d *gimple_seq_node;
+ typedef struct gimple_seq_d *gimple_seq;
+ typedef struct
+ {
+ gimple_seq_node ptr;
+ gimple_seq seq;
+ basic_block bb;
+ } gimple_stmt_iterator;
+ typedef void *gimple;
+ extern void exit(int);
+ struct gimple_seq_node_d
+ {
+ gimple stmt;
+ struct gimple_seq_node_d *next;
+ };
+ struct gimple_seq_d
+ {
+ };
+ static __inline__ gimple_stmt_iterator
+ gsi_start (gimple_seq seq)
+ {
+ gimple_stmt_iterator i;
+ i.seq = seq;
+ return i;
+ }
+ static __inline__ unsigned char
+ gsi_end_p (gimple_stmt_iterator i)
+ {
+ return i.ptr == ((void *)0);
+ }
+ static __inline__ void
+ gsi_next (gimple_stmt_iterator *i)
+ {
+ i->ptr = i->ptr->next;
+ }
+ static __inline__ gimple
+ gsi_stmt (gimple_stmt_iterator i)
+ {
+ return i.ptr->stmt;
+ }
+ void
+ c_warn_unused_result (gimple_seq seq)
+ {
+ gimple_stmt_iterator i;
+ for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+ {
+ gimple g = gsi_stmt (i);
+ if (!g) exit(0);
+ }
+ }
More information about the Gcc-patches
mailing list