From patchwork Fri Jan 19 15:10:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 863588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-471662-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="GzXX2Til"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zNPQr0hrnz9s72 for ; Sat, 20 Jan 2018 02:10:43 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; q=dns; s=default; b=jIQp+xMsAPMt9OHM0ue/9sktzWYzMeY7T8d+hF7Lj5AiMtbmy2 gzJACoYdIjZW54YHbYGQBJjNZC7Ri3ZcDJEVKllTsfmm6rKEWF0GPXP1939pidUG 833Sn4Xu5E2FlmILQKxxI/qdOSJ01qYGFCVuVeaY+AdtRg8h+EkUv5e50= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:cc:message-id:date:mime-version:content-type; s= default; bh=f1jyavw2qrQRUwfmAiaaW5Ugj0M=; b=GzXX2TildzJh8nA2deQj 25cpXryfu6N+GIcfk5TiE7o7XlKN5VPFoHsQS53NQajap6Uqna5aknsksL6+vb1p AYoCAdsaiUYUCbeTBi0zucPSYtQPCc3rl16mVr/JQXWJ7YeZx14xfnP5yK0r6Tbh fVBIqSVP0EqqQhW7towlQvY= Received: (qmail 33563 invoked by alias); 19 Jan 2018 15:10:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 33547 invoked by uid 89); 19 Jan 2018 15:10:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=profiles X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Jan 2018 15:10:35 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F3098AE9C; Fri, 19 Jan 2018 15:10:32 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Fix missing profiles with PGO (PR tree-optimization/83051). To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Message-ID: <791bc219-eba0-ee14-9007-7a000c5786ff@suse.cz> Date: Fri, 19 Jan 2018 16:10:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-IsSubscribed: yes 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 PR tree-optimization/83051 * predict.c (handle_missing_profiles): Consider profile only if it's reliable. gcc/testsuite/ChangeLog: 2018-01-19 Martin Liska 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 (); +}