From 1b7d2dd1e0af14c86155013d8bab4bf44783bc05 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Wed, 13 Oct 2010 15:42:46 +0000 Subject: [PATCH] re PR tree-optimization/45788 (-fwhole-program causes ICE error: BB 3 can not throw but has an EH edge) 2010-10-13 Richard Guenther PR tree-optimization/45788 * cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Delay EH update until fixup-cfg. * g++.dg/pr45788.C: New testcase. From-SVN: r165425 --- gcc/ChangeLog | 6 ++ gcc/cgraphunit.c | 15 +++-- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/pr45788.C | 108 +++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr45788.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 386b2ab29d50..807b7f930796 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-10-13 Richard Guenther + + PR tree-optimization/45788 + * cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee): Delay + EH update until fixup-cfg. + 2010-10-13 Julian Brown * config/arm/arm.h (REG_CLASS_CONTENTS): Remove soft frame pointer diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 95f30e25f574..95b300740375 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2156,6 +2156,7 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) if (e->callee->clone.combined_args_to_skip) { gimple_stmt_iterator gsi; + int lp_nr; new_stmt = gimple_call_copy_skip_args (e->call_stmt, @@ -2168,16 +2169,22 @@ cgraph_redirect_edge_call_stmt_to_callee (struct cgraph_edge *e) gsi = gsi_for_stmt (e->call_stmt); gsi_replace (&gsi, new_stmt, false); - if (maybe_clean_or_replace_eh_stmt (e->call_stmt, new_stmt)) - gimple_purge_dead_eh_edges (gimple_bb (new_stmt)); + /* We need to defer cleaning EH info on the new statement to + fixup-cfg. We may not have dominator information at this point + and thus would end up with unreachable blocks and have no way + to communicate that we need to run CFG cleanup then. */ + lp_nr = lookup_stmt_eh_lp (e->call_stmt); + if (lp_nr != 0) + { + remove_stmt_from_eh_lp (e->call_stmt); + add_stmt_to_eh_lp (new_stmt, lp_nr); + } } else { new_stmt = e->call_stmt; gimple_call_set_fndecl (new_stmt, e->callee->decl); update_stmt (new_stmt); - if (maybe_clean_eh_stmt (new_stmt)) - gimple_purge_dead_eh_edges (gimple_bb (new_stmt)); } cgraph_set_call_stmt_including_clones (e->caller, e->call_stmt, new_stmt); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65ca05c9df64..537a5071a220 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-10-13 Richard Guenther + + PR tree-optimization/45788 + * g++.dg/pr45788.C: New testcase. + 2010-10-13 Richard Guenther PR tree-optimization/45970 diff --git a/gcc/testsuite/g++.dg/pr45788.C b/gcc/testsuite/g++.dg/pr45788.C new file mode 100644 index 000000000000..de3340df3318 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr45788.C @@ -0,0 +1,108 @@ +// { dg-do compile { target x86_64-*-* } } +// { dg-options "-O3 -fwhole-program -msse2" } + +typedef long unsigned int __darwin_size_t; +typedef __darwin_size_t size_t; + +typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); +typedef float __v4sf __attribute__ ((__vector_size__ (16))); +extern inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_mul_ps (__m128 __A, __m128 __B) { + return (__m128) __builtin_ia32_mulps ((__v4sf)__A, (__v4sf)__B); +} +extern inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_set1_ps (float __F) { + return __extension__ (__m128)(__v4sf){ + __F, __F, __F, __F }; +} +extern inline __m128 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) _mm_setr_ps (float __Z, float __Y, float __X, float __W) { +} +typedef float real; +template struct vectorX { +}; +template<> struct vectorX { + union { + __m128 s; + struct { + }; + }; + vectorX(__m128 s) : s(s) { + } + +} +__attribute__((aligned)); +template<> struct vectorX { + typedef float T; + typedef vectorX V; + union { + __m128 s; + struct { + T r, g, b, a; + }; + }; + vectorX(T a_, T b, T c, T d = 1) : s(_mm_setr_ps(a_,b,c,d)) { + } + vectorX(__m128 s) : s(s) { + } + vectorX(const V &t) : s(t.s) { + } + V &operator *=(const T t) { + s = _mm_mul_ps(s, _mm_set1_ps(t)); + return *this; + } + inline V operator *(const T t) const __attribute__((always_inline)) { + return V(*this) *= t; + }; +} +__attribute__((aligned)); +typedef vectorX color3; +typedef vectorX color4; +typedef color3 color; +static inline color4 c3to4(color c) { + color4 res(c.s); + res.a=1; + return res; +} +static inline color c4to3(color4 c) { + return color(c.s); +} +static inline color4 to_premultiplied(color c, real a) { + color4 res = c3to4(c); + return res * a; +} +static inline color4 to_premultiplied(color4 cs) { + return to_premultiplied(c4to3(cs), cs.a); +} +struct texture { +}; +struct flat_texture : public texture { + color4 c; + flat_texture(const color4 &c) : c(to_premultiplied(c)) { + } +}; +struct checkerboard_texture : public texture { + color4 even, odd; + checkerboard_texture(const color4 &even, const color4 &odd) : even(to_premultiplied(even)), odd(to_premultiplied(odd)) { + } +}; +struct texture_placement { + texture *tex; +}; +struct surface { + texture_placement textures[16]; + size_t texcount; +}; +struct primitive { + surface mat; +}; +static void set_color(primitive *p, color4 c) { + p->mat.textures[0].tex = new flat_texture(c); +} +static primitive **checkerboard_scene(int *pi) { + primitive **prims = new primitive*[6]; + set_color(prims[0], color4(.7,.7,.7)); + prims[1]->mat.textures[prims[1]->mat.texcount++].tex = new checkerboard_texture(color4(1,.1,.1),color4(.1,.15,1)); + set_color(prims[2], color4(.7,.9,.7)); +} +int main (int argc, char * const argv[]) { + int primi; + primitive **prims = checkerboard_scene(&primi); +}