From 1927a96372b003fe6217c64241bb69d838a67dc8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 4 Jun 2016 16:50:57 +0200 Subject: [PATCH] re PR tree-optimization/71405 (ICE on valid C++ code at -Os and above on x86_64-linux-gnu: verify_gimple failed) PR tree-optimization/71405 * tree-ssa.c (execute_update_addresses_taken): For clobber with incompatible type, build a new clobber with the right type instead of building a VIEW_CONVERT_EXPR around it. * g++.dg/torture/pr71405.C: New test. From-SVN: r237091 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/torture/pr71405.C | 22 ++++++++++++++++++++++ gcc/tree-ssa.c | 13 ++++++++++--- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr71405.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e11cb9e06c..e07d2deed22 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-06-04 Jakub Jelinek + + PR tree-optimization/71405 + * tree-ssa.c (execute_update_addresses_taken): For clobber with + incompatible type, build a new clobber with the right type instead + of building a VIEW_CONVERT_EXPR around it. + 2016-06-04 Oleg Endo PR tree-optimization/52171 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 94b4a33dd41..c272ade5809 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-04 Jakub Jelinek + + PR tree-optimization/71405 + * g++.dg/torture/pr71405.C: New test. + 2016-06-04 Paolo Carlini PR c++/70202 diff --git a/gcc/testsuite/g++.dg/torture/pr71405.C b/gcc/testsuite/g++.dg/torture/pr71405.C new file mode 100644 index 00000000000..52602437a08 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr71405.C @@ -0,0 +1,22 @@ +// PR tree-optimization/71405 +// { dg-do compile } + +struct C +{ + C () {} + int i; +}; + +void * +operator new (__SIZE_TYPE__ x, void *y) +{ + return y; +} + +int +main () +{ + int a; + new (&a) C; + return a; +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index a53322d9837..2f3caf341dd 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1622,9 +1622,16 @@ execute_update_addresses_taken (void) if (gimple_assign_lhs (stmt) != lhs && !useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) - rhs = fold_build1 (VIEW_CONVERT_EXPR, - TREE_TYPE (lhs), rhs); - + { + if (gimple_clobber_p (stmt)) + { + rhs = build_constructor (TREE_TYPE (lhs), NULL); + TREE_THIS_VOLATILE (rhs) = 1; + } + else + rhs = fold_build1 (VIEW_CONVERT_EXPR, + TREE_TYPE (lhs), rhs); + } if (gimple_assign_lhs (stmt) != lhs) gimple_assign_set_lhs (stmt, lhs); -- 2.30.2