From: Jakub Jelinek Date: Tue, 30 May 2017 07:15:49 +0000 (+0200) Subject: backport: re PR target/71910 (ICE on valid OpenMP code) X-Git-Tag: releases/gcc-5.5.0~310 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32de0ec707640dbe04d1a9e8c9b5a269a4e32d30;p=thirdparty%2Fgcc.git backport: re PR target/71910 (ICE on valid OpenMP code) Backported from mainline 2016-08-16 Jakub Jelinek PR target/71910 * tree-cfg.c (execute_fixup_cfg): Add node variable, use it. Before inlining, add cgraph edge for the added __builtin_unreachable call. * g++.dg/gomp/pr71910.C: New test. From-SVN: r248598 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c6c4f53f734f..42f03d60e4e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-08-16 Jakub Jelinek + + PR target/71910 + * tree-cfg.c (execute_fixup_cfg): Add node variable, use it. Before inlining, + add cgraph edge for the added __builtin_unreachable call. + 2016-08-15 Martin Liska Jakub Jelinek diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cfd28cf1e4c..213ce7f0280d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-08-16 Jakub Jelinek + + PR target/71910 + * g++.dg/gomp/pr71910.C: New test. + 2016-08-15 Jakub Jelinek PR tree-optimization/72824 diff --git a/gcc/testsuite/g++.dg/gomp/pr71910.C b/gcc/testsuite/g++.dg/gomp/pr71910.C new file mode 100644 index 000000000000..0063be8a9b0f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr71910.C @@ -0,0 +1,13 @@ +// PR target/71910 +// { dg-do compile } +// { dg-additional-options "-O2" } + +#include + +int +main () +{ + std::vector vec(10); +#pragma omp parallel + __builtin_exit (0); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 76654775418b..2a76c41ebf91 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -8619,16 +8619,14 @@ execute_fixup_cfg (void) gcov_type count_scale; edge e; edge_iterator ei; + cgraph_node *node = cgraph_node::get (current_function_decl); count_scale - = GCOV_COMPUTE_SCALE (cgraph_node::get (current_function_decl)->count, - ENTRY_BLOCK_PTR_FOR_FN (cfun)->count); + = GCOV_COMPUTE_SCALE (node->count, ENTRY_BLOCK_PTR_FOR_FN (cfun)->count); - ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = - cgraph_node::get (current_function_decl)->count; - EXIT_BLOCK_PTR_FOR_FN (cfun)->count = - apply_scale (EXIT_BLOCK_PTR_FOR_FN (cfun)->count, - count_scale); + ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count; + EXIT_BLOCK_PTR_FOR_FN (cfun)->count + = apply_scale (EXIT_BLOCK_PTR_FOR_FN (cfun)->count, count_scale); FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs) e->count = apply_scale (e->count, count_scale); @@ -8721,10 +8719,19 @@ execute_fixup_cfg (void) { if (stmt && is_gimple_call (stmt)) gimple_call_set_ctrl_altering (stmt, false); - stmt = gimple_build_call - (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0); + tree fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE); + stmt = gimple_build_call (fndecl, 0); gimple_stmt_iterator gsi = gsi_last_bb (bb); gsi_insert_after (&gsi, stmt, GSI_NEW_STMT); + if (!cfun->after_inlining) + { + gcall *call_stmt = dyn_cast (stmt); + int freq + = compute_call_stmt_bb_frequency (current_function_decl, + bb); + node->create_edge (cgraph_node::get_create (fndecl), + call_stmt, bb->count, freq); + } } } }