Hi! I've noticed several testcases recently that have a dead __builtin_unreachable call in functions right after return stmt. They are optimized away after a while (typically in the cfg pass), but we don't really need to generate them when there is the return. The reason we don't find it is because it is wrapped in some cases in CLEANUP_POINT_EXPR. That doesn't change anything on the function actually ending with a return.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-01-17 Jakub Jelinek <ja...@redhat.com> PR c++/83897 * cp-gimplify.c (cp_maybe_instrument_return): Handle CLEANUP_POINT_EXPR. * g++.dg/cpp0x/pr83897.C: New test. --- gcc/cp/cp-gimplify.c.jj 2018-01-11 18:58:48.348391787 +0100 +++ gcc/cp/cp-gimplify.c 2018-01-16 17:24:41.087336680 +0100 @@ -1581,6 +1581,7 @@ cp_maybe_instrument_return (tree fndecl) t = BIND_EXPR_BODY (t); continue; case TRY_FINALLY_EXPR: + case CLEANUP_POINT_EXPR: t = TREE_OPERAND (t, 0); continue; case STATEMENT_LIST: --- gcc/testsuite/g++.dg/cpp0x/pr83897.C.jj 2018-01-16 17:41:54.723256147 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr83897.C 2018-01-16 17:41:34.274257947 +0100 @@ -0,0 +1,13 @@ +// PR c++/83897 +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -fdump-tree-gimple" } +// { dg-final { scan-tree-dump-not "__builtin_unreachable" "gimple" } } + +struct A {}; +struct B { int a; int b = 5; }; + +A +bar (B) +{ + return {}; +} Jakub