From 0526ed2aef5ba7faa8ea26015e9854db82a71395 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 11 Jan 2018 18:46:01 +0100 Subject: [PATCH] re PR middle-end/83718 (ICE: Floating point exception in profile_count::apply_scale) PR middle-end/83718 * tree-inline.c (copy_cfg_body): Adjust num&den for scaling after they are computed. * g++.dg/torture/pr83718.C: New testcase. From-SVN: r256544 --- gcc/ChangeLog | 6 ++ gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/torture/pr83718.C | 115 +++++++++++++++++++++++++ gcc/tree-inline.c | 4 +- 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr83718.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 878d72c2239..f8bd20f6aeb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-01-11 Jan Hubicka + + PR middle-end/83718 + * tree-inline.c (copy_cfg_body): Adjust num&den for scaling + after they are computed. + 2018-01-11 Bin Cheng PR tree-optimization/83695 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4524063d0f3..f1eb59b80b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-11 Jan Hubicka + + PR middle-end/83718 + * g++.dg/torture/pr83718.C: New testcase. + 2018-01-11 Martin Jambor PR ipa/83178 diff --git a/gcc/testsuite/g++.dg/torture/pr83718.C b/gcc/testsuite/g++.dg/torture/pr83718.C new file mode 100644 index 00000000000..2fa28064202 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr83718.C @@ -0,0 +1,115 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c++11" } */ + +class a +{ +public: + int c (const char *); +}; +class B +{ + virtual int *d (a, bool); +}; + +bool e, f, g; + +class: B +{ + int ah; + int * + d (a, bool) + { + if (e) + return &ah; + a bj; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (f) + return &ah; + bj.c (""); + if (g) + return &ah; + if (f) + return &ah; + e = a ().c(""); + return &ah; + } +} b; + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 5910745d096..b0d9beb530a 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -2683,8 +2683,6 @@ copy_cfg_body (copy_body_data * id, profile_count den = ENTRY_BLOCK_PTR_FOR_FN (src_cfun)->count; profile_count num = entry_block_map->count; - profile_count::adjust_for_ipa_scaling (&num, &den); - cfun_to_copy = id->src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl); /* Register specific tree functions. */ @@ -2707,6 +2705,8 @@ copy_cfg_body (copy_body_data * id, ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = den; } + profile_count::adjust_for_ipa_scaling (&num, &den); + /* Must have a CFG here at this point. */ gcc_assert (ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (callee_fndecl))); -- 2.30.2