aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2018-01-25 18:24:06 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2018-01-25 17:24:06 +0000
commit19e502d4132a2b02e71f75e4a20e6396081cdbc5 (patch)
tree40eefb30e2607667caeed4fc99309a54ae635dbd /gcc
parent41df0109de5fe4ddad66bfd742ee813688362ab8 (diff)
downloadgcc-19e502d4132a2b02e71f75e4a20e6396081cdbc5.zip
gcc-19e502d4132a2b02e71f75e4a20e6396081cdbc5.tar.gz
gcc-19e502d4132a2b02e71f75e4a20e6396081cdbc5.tar.bz2
re PR tree-optimization/83055 (ICE in operator>, at profile-count.h:834)
PR middle-end/83055 * predict.c (drop_profile): Do not push/pop cfun; update also node->count. (handle_missing_profiles): Fix logic looking for zero profiles. * gcc.dg/torture/pr83055.c: New testcase. From-SVN: r257059
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/predict.c23
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr83055.c13
4 files changed, 35 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 65ef87a..cc7e48c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-25 Jan Hubicka <hubicka@ucw.cz>
+
+ PR middle-end/83055
+ * predict.c (drop_profile): Do not push/pop cfun; update also
+ node->count.
+ (handle_missing_profiles): Fix logic looking for zero profiles.
+
2018-01-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/83977
diff --git a/gcc/predict.c b/gcc/predict.c
index 25629db..79ee71f 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -3311,32 +3311,28 @@ drop_profile (struct cgraph_node *node, profile_count call_count)
}
basic_block bb;
- push_cfun (DECL_STRUCT_FUNCTION (node->decl));
- if (flag_guess_branch_prob)
+ if (opt_for_fn (node->decl, flag_guess_branch_prob))
{
bool clear_zeros
- = ENTRY_BLOCK_PTR_FOR_FN
- (DECL_STRUCT_FUNCTION (node->decl))->count.nonzero_p ();
+ = !ENTRY_BLOCK_PTR_FOR_FN (fn)->count.nonzero_p ();
FOR_ALL_BB_FN (bb, fn)
if (clear_zeros || !(bb->count == profile_count::zero ()))
bb->count = bb->count.guessed_local ();
- DECL_STRUCT_FUNCTION (node->decl)->cfg->count_max =
- DECL_STRUCT_FUNCTION (node->decl)->cfg->count_max.guessed_local ();
+ fn->cfg->count_max = fn->cfg->count_max.guessed_local ();
}
else
{
FOR_ALL_BB_FN (bb, fn)
bb->count = profile_count::uninitialized ();
- DECL_STRUCT_FUNCTION (node->decl)->cfg->count_max
- = profile_count::uninitialized ();
+ fn->cfg->count_max = profile_count::uninitialized ();
}
- pop_cfun ();
struct cgraph_edge *e;
for (e = node->callees; e; e = e->next_callee)
e->count = gimple_bb (e->call_stmt)->count;
for (e = node->indirect_calls; e; e = e->next_callee)
e->count = gimple_bb (e->call_stmt)->count;
+ node->count = ENTRY_BLOCK_PTR_FOR_FN (fn)->count;
profile_status_for_fn (fn)
= (flag_guess_branch_prob ? PROFILE_GUESSED : PROFILE_ABSENT);
@@ -3373,12 +3369,12 @@ handle_missing_profiles (void)
gcov_type max_tp_first_run = 0;
struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
- if (!(node->count == profile_count::zero ()))
+ if (node->count.ipa ().nonzero_p ())
continue;
for (e = node->callers; e; e = e->next_caller)
- if (e->count.initialized_p () && e->count > 0)
+ if (e->count.ipa ().initialized_p () && e->count.ipa () > 0)
{
- call_count = call_count + e->count;
+ call_count = call_count + e->count.ipa ();
if (e->caller->tp_first_run > max_tp_first_run)
max_tp_first_run = e->caller->tp_first_run;
@@ -3411,7 +3407,8 @@ handle_missing_profiles (void)
struct cgraph_node *callee = e->callee;
struct function *fn = DECL_STRUCT_FUNCTION (callee->decl);
- if (callee->count > 0)
+ if (!(e->count.ipa () == profile_count::zero ())
+ && callee->count.ipa ().nonzero_p ())
continue;
if ((DECL_COMDAT (callee->decl) || DECL_EXTERNAL (callee->decl))
&& fn && fn->cfg
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 222df9d..1a62d91 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-25 Jan Hubicka <hubicka@ucw.cz>
+
+ PR middle-end/83055
+ * gcc.dg/torture/pr83055.c: New testcase.
+
2018-01-25 Jakub Jelinek <jakub@redhat.com>
PR c++/84031
diff --git a/gcc/testsuite/gcc.dg/torture/pr83055.c b/gcc/testsuite/gcc.dg/torture/pr83055.c
new file mode 100644
index 0000000..9bc71c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr83055.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fprofile-generate" } */
+
+void __attribute__ ((__cold__)) a (void);
+void b (void);
+void __attribute__ ((noinline)) c (void) { a (); }
+
+void
+d (void)
+{
+ b ();
+ c ();
+}