This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix missing profiles with PGO (PR tree-optimization/83051).
- From: Martin Liška <mliska at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jan Hubicka <hubicka at ucw dot cz>
- Date: Fri, 19 Jan 2018 16:10:32 +0100
- Subject: [PATCH] Fix missing profiles with PGO (PR tree-optimization/83051).
- Authentication-results: sourceware.org; auth=none
Hello.
Following ICE can be seen when we have -fprofile-generate or -fprofile-use w/ missing
gcda file. I hope the proper fix is to check for reliable profile.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
gcc/ChangeLog:
2018-01-19 Martin Liska <mliska@suse.cz>
PR tree-optimization/83051
* predict.c (handle_missing_profiles): Consider profile only
if it's reliable.
gcc/testsuite/ChangeLog:
2018-01-19 Martin Liska <mliska@suse.cz>
PR tree-optimization/83051
* gcc.dg/torture/pr83055.c: New test.
---
gcc/predict.c | 2 +-
gcc/testsuite/gcc.dg/torture/pr83055.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr83055.c
diff --git a/gcc/predict.c b/gcc/predict.c
index 4c1e4489b55..c5144e49c8d 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -3357,7 +3357,7 @@ handle_missing_profiles (void)
if (!(node->count == profile_count::zero ()))
continue;
for (e = node->callers; e; e = e->next_caller)
- if (e->count.initialized_p () && e->count > 0)
+ if (e->count.initialized_p () && e->count.reliable_p ())
{
call_count = call_count + e->count;
diff --git a/gcc/testsuite/gcc.dg/torture/pr83055.c b/gcc/testsuite/gcc.dg/torture/pr83055.c
new file mode 100644
index 00000000000..9bc71c6cddf
--- /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 ();
+}