From patchwork Mon Jun 12 12:38:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 774599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wmXWr4Mv3z9s71 for ; Mon, 12 Jun 2017 22:39:04 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="QO6YGegW"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=GFlSM5cPvj9NkSvUN/paijZqhtmhbFPYOFPU70GpD4IC4drspnJvN ovcOzN532aJUh56ycnfy9yjUVoYGaWaXpi9JI7XNnd+8PHTVKO89KoFtscZYnLeq FVnkbfsEAY1TkX7qRzWf3KdA9+zrY5yTASfy18hix/nFIld68G6FBI= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=kxGQ0h+850TvahdAOC343EzSbnE=; b=QO6YGegW80aR4j9E3tv3 d02xTal1V+b8asHkrd6/rywsSQi66xHXNGeevfn/huVgDpMAOvbm/oYH8Nak4FtG T9CTqi9eEjRu5m4a6gtLSnUgq60sjSL2ic0NFxWebrKql4V9ZZPaSMt+5XYxw0rU ri89kZ7VeUgxEAZavwr1+Y0= Received: (qmail 64381 invoked by alias); 12 Jun 2017 12:38:50 -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 54858 invoked by uid 89); 12 Jun 2017 12:38:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=sum X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 12:38:42 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 7051A545007; Mon, 12 Jun 2017 14:38:43 +0200 (CEST) Date: Mon, 12 Jun 2017 14:38:43 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Output cgraph profile inconsistencies Message-ID: <20170612123843.GH9766@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, this patch adds code to output profile instantieis in callgraph. Bootstrapped/regtested x86_64-linux, comitted. Honza Index: cgraph.c =================================================================== --- cgraph.c (revision 249112) +++ cgraph.c (working copy) @@ -2094,7 +2094,7 @@ cgraph_node::dump (FILE *f) fprintf (f, " Function flags:"); if (count.initialized_p ()) { - fprintf (f, " profile_count "); + fprintf (f, " count: "); count.dump (f); } if (origin) @@ -2172,10 +2172,13 @@ cgraph_node::dump (FILE *f) fprintf (f, " Called by: "); + profile_count sum = profile_count::zero (); for (edge = callers; edge; edge = edge->next_caller) { fprintf (f, "%s ", edge->caller->dump_name ()); edge->dump_edge_flags (f); + if (edge->count.initialized_p ()) + sum += edge->count; } fprintf (f, "\n Calls: "); @@ -2186,6 +2189,36 @@ cgraph_node::dump (FILE *f) } fprintf (f, "\n"); + if (count.initialized_p ()) + { + bool ok = true; + bool min = false; + ipa_ref *ref; + + FOR_EACH_ALIAS (this, ref) + if (dyn_cast (ref->referring)->count.initialized_p ()) + sum += dyn_cast (ref->referring)->count; + + if (global.inlined_to + || (symtab->state < EXPANSION + && ultimate_alias_target () == this && only_called_directly_p ())) + ok = !count.differs_from_p (sum); + else if (count > profile_count::from_gcov_type (100) + && count < sum.apply_scale (99, 100)) + ok = false, min = true; + if (!ok) + { + fprintf (f, " Invalid sum of caller counts "); + sum.dump (f); + if (min) + fprintf (f, ", should be at most "); + else + fprintf (f, ", should be "); + count.dump (f); + fprintf (f, "\n"); + } + } + for (edge = indirect_calls; edge; edge = edge->next_callee) { if (edge->indirect_info->polymorphic)