diff options
author | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-23 13:20:41 +0000 |
---|---|---|
committer | jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-23 13:20:41 +0000 |
commit | fb8b391ecb51a51cf50deb24823c3b089848f2ae (patch) | |
tree | b293e3ccbf8e0a029d6133c38c71e73dd385f953 | |
parent | 6107e73ffdc01f5d81c4e2f45e3d72e94fb8a158 (diff) | |
download | gcc-fb8b391ecb51a51cf50deb24823c3b089848f2ae.tar.gz |
2013-05-22 Martin Jambor <mjambor@suse.cz>
PR middle-end/57347
* tree.h (contains_bitfld_component_ref_p): Declare.
* tree-sra.c (contains_bitfld_comp_ref_p): Move...
* tree.c (contains_bitfld_component_ref_p): ...here. Adjust its caller.
* ipa-prop.c (determine_known_aggregate_parts): Check that LHS does
not access a bit-field. Assert all final offsets are byte-aligned.
testsuite/
* gcc.dg/ipa/pr57347.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199252 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/pr57347.c | 27 | ||||
-rw-r--r-- | gcc/tree-sra.c | 19 | ||||
-rw-r--r-- | gcc/tree.c | 17 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
7 files changed, 64 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c46d03ee9f..a97a295a263 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2013-05-22 Martin Jambor <mjambor@suse.cz> + + PR middle-end/57347 + * tree.h (contains_bitfld_component_ref_p): Declare. + * tree-sra.c (contains_bitfld_comp_ref_p): Move... + * tree.c (contains_bitfld_component_ref_p): ...here. Adjust its caller. + * ipa-prop.c (determine_known_aggregate_parts): Check that LHS does + not access a bit-field. Assert all final offsets are byte-aligned. + 2013-05-23 Richard Biener <rguenther@suse.de> PR tree-optimization/57380 diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index ae2a823a4e5..7129b302156 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1327,7 +1327,9 @@ determine_known_aggregate_parts (gimple call, tree arg, lhs = gimple_assign_lhs (stmt); rhs = gimple_assign_rhs1 (stmt); - if (!is_gimple_reg_type (rhs)) + if (!is_gimple_reg_type (rhs) + || TREE_CODE (lhs) == BIT_FIELD_REF + || contains_bitfld_component_ref_p (lhs)) break; lhs_base = get_ref_base_and_extent (lhs, &lhs_offset, &lhs_size, @@ -1418,6 +1420,7 @@ determine_known_aggregate_parts (gimple call, tree arg, { struct ipa_agg_jf_item item; item.offset = list->offset - arg_offset; + gcc_assert ((item.offset % BITS_PER_UNIT) == 0); item.value = unshare_expr_without_location (list->constant); jfunc->agg.items->quick_push (item); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a22b4a92bc..b8e99a45011 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-22 Martin Jambor <mjambor@suse.cz> + + PR middle-end/57347 + * gcc.dg/ipa/pr57347.c: New test. + 2013-05-23 Richard Biener <rguenther@suse.de> PR tree-optimization/57380 diff --git a/gcc/testsuite/gcc.dg/ipa/pr57347.c b/gcc/testsuite/gcc.dg/ipa/pr57347.c new file mode 100644 index 00000000000..731b4868ec3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr57347.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +struct S1 { int f0; int f1 : 10; int f2 : 13; }; +int i; +int *j = &i; + +static void +foo (struct S1 s) +{ + int *p; + int l[88]; + int **pp = &p; + *pp = &l[1]; + l[0] = 1; + *j = 1 && s.f2; +} + +int +main () +{ + struct S1 s = { 0, 0, 1 }; + foo (s); + if (i != 1) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index c430c54bb7c..7e950aeecdf 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2998,23 +2998,6 @@ get_repl_default_def_ssa_name (struct access *racc) return get_or_create_ssa_default_def (cfun, racc->replacement_decl); } -/* Return true if REF has a COMPONENT_REF with a bit-field field declaration - somewhere in it. */ - -static inline bool -contains_bitfld_comp_ref_p (const_tree ref) -{ - while (handled_component_p (ref)) - { - if (TREE_CODE (ref) == COMPONENT_REF - && DECL_BIT_FIELD (TREE_OPERAND (ref, 1))) - return true; - ref = TREE_OPERAND (ref, 0); - } - - return false; -} - /* Return true if REF has an VIEW_CONVERT_EXPR or a COMPONENT_REF with a bit-field field declaration somewhere in it. */ @@ -3110,7 +3093,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) ??? This should move to fold_stmt which we simply should call after building a VIEW_CONVERT_EXPR here. */ if (AGGREGATE_TYPE_P (TREE_TYPE (lhs)) - && !contains_bitfld_comp_ref_p (lhs)) + && !contains_bitfld_component_ref_p (lhs)) { lhs = build_ref_for_model (loc, lhs, 0, racc, gsi, false); gimple_assign_set_lhs (*stmt, lhs); diff --git a/gcc/tree.c b/gcc/tree.c index 62909b07b64..6c71025b6b4 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -11785,4 +11785,21 @@ warn_deprecated_use (tree node, tree attr) } } +/* Return true if REF has a COMPONENT_REF with a bit-field field declaration + somewhere in it. */ + +bool +contains_bitfld_component_ref_p (const_tree ref) +{ + while (handled_component_p (ref)) + { + if (TREE_CODE (ref) == COMPONENT_REF + && DECL_BIT_FIELD (TREE_OPERAND (ref, 1))) + return true; + ref = TREE_OPERAND (ref, 0); + } + + return false; +} + #include "gt-tree.h" diff --git a/gcc/tree.h b/gcc/tree.h index f2dc1b10466..1d2b252dec0 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -5974,6 +5974,7 @@ extern tree block_ultimate_origin (const_tree); extern tree get_binfo_at_offset (tree, HOST_WIDE_INT, tree); extern tree get_ref_base_and_extent (tree, HOST_WIDE_INT *, HOST_WIDE_INT *, HOST_WIDE_INT *); +extern bool contains_bitfld_component_ref_p (const_tree); /* In tree-nested.c */ extern tree build_addr (tree, tree); |