From: Jakub Jelinek Date: Tue, 31 Jan 2017 08:33:36 +0000 (+0100) Subject: re PR c++/79267 (internal compiler error with -O3 or -O2 -finline-functions) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6dae84928a112b2f176ad168d8c5b7e0ecdd5cb;p=gcc.git re PR c++/79267 (internal compiler error with -O3 or -O2 -finline-functions) PR tree-optimization/79267 * value-prof.c (gimple_ic): Only drop lhs for noreturn calls if should_remove_lhs_p is true. * g++.dg/opt/pr79267.C: New test. From-SVN: r245053 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eed607a8d1f..8916373f826 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-01-31 Jakub Jelinek + + PR tree-optimization/79267 + * value-prof.c (gimple_ic): Only drop lhs for noreturn calls + if should_remove_lhs_p is true. + 2017-01-30 Alexandre Oliva PR debug/63238 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8210eae17ba..96b25d63061 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-31 Jakub Jelinek + + PR tree-optimization/79267 + * g++.dg/opt/pr79267.C: New test. + 2017-01-30 Alexandre Oliva PR debug/63238 diff --git a/gcc/testsuite/g++.dg/opt/pr79267.C b/gcc/testsuite/g++.dg/opt/pr79267.C new file mode 100644 index 00000000000..177eee6c6f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr79267.C @@ -0,0 +1,69 @@ +// PR tree-optimization/79267 +// { dg-do compile } +// { dg-options "-O3" } + +struct A { A (int); }; +struct B +{ + virtual void av () = 0; + void aw (); + void h () { av (); aw (); } +}; +template struct G : B +{ + T ba; + G (int, T) : ba (0) {} + void av () { ba (0); } +}; +struct I +{ + B *bc; + template I (j, T) try { G (0, 0); } catch (...) {} + ~I () { bc->h (); } +}; +template struct C { typedef M *i; }; +template struct J +{ + J (); + template J (O, T p2) : be (0, p2) {} + typename C::i operator-> (); + I be; +}; +struct H : A { H () : A (0) {} }; +struct D { J d; void q (); }; +template class bs; +int z; + +void +foo (int p1, int *, int) +{ + if (p1 == 0) + throw H (); +} + +D bar (); +template struct L +{ + struct K { K (int); void operator() (int *) { bar ().q (); } }; + static J bp () { bq (0); } + template static void bq (br) { J (0, K (0)); } +}; +struct F +{ + virtual J x (int) { foo (0, 0, 0); J > (L >::bp ()); } +}; + +void +baz () +{ + if (z) + { + J d, e; + d->x (0); + e->x (0); + } + J v, i, j; + v->x (0); + i->x (0); + j->x (0); +} diff --git a/gcc/value-prof.c b/gcc/value-prof.c index d4da8c45a22..097e4094095 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1358,7 +1358,8 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, dcall_stmt = as_a (gimple_copy (icall_stmt)); gimple_call_set_fndecl (dcall_stmt, direct_call->decl); dflags = flags_from_decl_or_type (direct_call->decl); - if ((dflags & ECF_NORETURN) != 0) + if ((dflags & ECF_NORETURN) != 0 + && should_remove_lhs_p (gimple_call_lhs (dcall_stmt))) gimple_call_set_lhs (dcall_stmt, NULL_TREE); gsi_insert_before (&gsi, dcall_stmt, GSI_SAME_STMT);