From e3e6cff41e9d63815a0396e02ee17d0a1261fccd Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 26 Jan 2009 09:55:30 +0000 Subject: [PATCH] re PR tree-optimization/38745 (ICE: statement makes a memory store, but has no VDEFS) 2009-01-26 Richard Guenther PR tree-optimization/38745 * tree-ssa.c (execute_update_addresses_taken): Do not include variables that cannot possibly be a register in not_reg_needs. Do not clear TREE_ADDRESSABLE on vars that may not become registers. * tree-ssa.c (update_alias_info_1): Include those in the set of addressable vars. * g++.dg/torture/pr38745.C: New testcase. From-SVN: r143673 --- gcc/ChangeLog | 10 +++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/torture/pr38745.C | 36 ++++++++++++++++++++++++++ gcc/tree-ssa-alias.c | 16 ++++++++++++ gcc/tree-ssa.c | 7 ++++- 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr38745.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f9ca88026124..505c99a394bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2009-01-26 Richard Guenther + + PR tree-optimization/38745 + * tree-ssa.c (execute_update_addresses_taken): Do not include + variables that cannot possibly be a register in not_reg_needs. + Do not clear TREE_ADDRESSABLE on vars that may not become + registers. + * tree-ssa.c (update_alias_info_1): Include those in the set + of addressable vars. + 2009-01-26 Richard Guenther PR middle-end/38851 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ea1493ac9f36..5743ae0d7c82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-26 Richard Guenther + + PR tree-optimization/38745 + * g++.dg/torture/pr38745.C: New testcase. + 2009-01-26 Richard Guenther PR middle-end/38851 diff --git a/gcc/testsuite/g++.dg/torture/pr38745.C b/gcc/testsuite/g++.dg/torture/pr38745.C new file mode 100644 index 000000000000..4ad9d85fe369 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr38745.C @@ -0,0 +1,36 @@ +/* { dg-do compile } */ + +union u_u16 +{ + unsigned short v; + struct + { + unsigned char lo8, hi8; + } __attribute__ ((__may_alias__)) u; +} __attribute__ ((__may_alias__)); +union u_u32 +{ + unsigned int v; + struct + { + u_u16 lo16, hi16; + } u; +} __attribute__ ((__may_alias__)); +union u_u64 +{ + struct + { + u_u32 lo32, hi32; + } u; +}; +struct Record +{ +}; +long long +UnpackFullKey (Record & rec, const char *&p) +{ + long long c64 = 0; + (*(u_u16 *) & (*(u_u32 *) & ( *(u_u64*)&c64).u.lo32.v).u.lo16.v).u.hi8 = 1; + return c64; +} + diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 4e9d28bf9eba..9ed242d03a8d 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -2483,6 +2483,22 @@ update_alias_info_1 (gimple stmt, struct alias_info *ai) if (addr_taken) bitmap_ior_into (gimple_addressable_vars (cfun), addr_taken); + /* If we have a call or an assignment, see if the lhs contains + a local decl that requires not to be a gimple register. */ + if (gimple_code (stmt) == GIMPLE_ASSIGN + || gimple_code (stmt) == GIMPLE_CALL) + { + tree lhs = gimple_get_lhs (stmt); + /* A plain decl does not need it set. */ + if (lhs && handled_component_p (lhs)) + { + tree var = get_base_address (lhs); + if (DECL_P (var) + && is_gimple_reg_type (TREE_TYPE (var))) + bitmap_set_bit (gimple_addressable_vars (cfun), DECL_UID (var)); + } + } + /* Process each operand use. For pointers, determine whether they are dereferenced by the statement, or whether their value escapes, etc. */ diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 935cad676c14..91cbc1950018 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1731,7 +1731,12 @@ execute_update_addresses_taken (void) || bitmap_bit_p (addresses_taken, DECL_UID (var))) continue; - if (TREE_ADDRESSABLE (var)) + if (TREE_ADDRESSABLE (var) + /* Do not change TREE_ADDRESSABLE if we need to preserve var as + a non-register. Otherwise we are confused and forget to + add virtual operands for it. */ + && (!is_gimple_reg_type (TREE_TYPE (var)) + || !bitmap_bit_p (not_reg_needs, DECL_UID (var)))) { TREE_ADDRESSABLE (var) = 0; if (is_gimple_reg (var)) -- 2.47.2