From patchwork Fri Jan 12 07:56:47 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: 859567 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-470931-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="s84V7zlc"; 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 3zHwZL0ZZYz9t3G for ; Fri, 12 Jan 2018 19:16:41 +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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; q=dns; s=default; b= yYNEhpO/ZIEeA4HlbdwFBnnIUFvpQQ+WrDp2VQFXHQBxRh7O091es0U5vAo1iWP+ NNi2jkZ55YUaDxJCqYCtQ6soldX89p0isR7wF/5R7D3J+7gyK5DXE8kcEf7eVE7f /yyIwyTsaynXC8xRMlPZeIkKahy+mcKQOJUh2/cNdXg= 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 :resent-from:resent-to:resent-date:resent-message-id:message-id :in-reply-to:references:from:date:subject:to; s=default; bh=BXgA 0Sn+kxaOArL8eibXYwuDp5o=; b=s84V7zlch+Htjv8fQRSe6G85yYf1DDxQqZrE HUJNIMRQoLj/gmdZ60CEuBUFjf/yt6T+GnHfH4NlxFELwqxu9McAIcVLAjUQbBGZ 96/3JwUfSuXIYqg2WkvO9qg7WiSMJUiOykNuwF7uLtR9TN8BG4Prav0b9dDTZ9gc hpxdK6A= Received: (qmail 30932 invoked by alias); 12 Jan 2018 08:14:54 -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 30907 invoked by uid 89); 12 Jan 2018 08:14:53 -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=folders, Arrays 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, 12 Jan 2018 08:14:52 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4DC6BAD6A for ; Fri, 12 Jan 2018 08:14:49 +0000 (UTC) Resent-From: =?utf-8?q?Martin_Li=C5=A1ka?= Resent-To: GCC Patches Resent-Date: Fri, 12 Jan 2018 09:14:48 +0100 Resent-Message-ID: <096791c3-a82d-91c3-931f-d38460c302c1@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Message-Id: <80e8f37462e725cf977910ff4594b03d45182f13.1515744628.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Fri, 12 Jan 2018 08:56:47 +0100 Subject: [PATCH 2/3] Fix integer overflow in stats of trees. To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/ChangeLog: 2018-01-12 Martin Liska * tree-core.h: Use uint64_t instead of int. * tree.c (tree_node_counts): Likewise. (tree_node_sizes): Likewise. (dump_tree_statistics): Use PRIu64 in printf format. --- gcc/tree-core.h | 4 ++-- gcc/tree.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index 56acd10a653..478c631998c 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -2123,8 +2123,8 @@ extern GTY(()) tree integer_types[itk_none]; extern GTY(()) tree sizetype_tab[(int) stk_type_kind_last]; /* Arrays for keeping track of tree node statistics. */ -extern int tree_node_counts[]; -extern int tree_node_sizes[]; +extern uint64_t tree_node_counts[]; +extern uint64_t tree_node_sizes[]; /* True if we are in gimple form and the actions of the folders need to be restricted. False if we are not in gimple form and folding is not diff --git a/gcc/tree.c b/gcc/tree.c index 722ce021b67..c008a55804c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -129,9 +129,9 @@ extern int _obstack_allocated_p (struct obstack *h, void *obj); /* Statistics-gathering stuff. */ -static int tree_code_counts[MAX_TREE_CODES]; -int tree_node_counts[(int) all_kinds]; -int tree_node_sizes[(int) all_kinds]; +static uint64_t tree_code_counts[MAX_TREE_CODES]; +uint64_t tree_node_counts[(int) all_kinds]; +uint64_t tree_node_sizes[(int) all_kinds]; /* Keep in sync with tree.h:enum tree_node_kind. */ static const char * const tree_node_kind_names[] = { @@ -9123,25 +9123,27 @@ dump_tree_statistics (void) if (GATHER_STATISTICS) { int i; - int total_nodes, total_bytes; + uint64_t total_nodes, total_bytes; fprintf (stderr, "\nKind Nodes Bytes\n"); mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES); total_nodes = total_bytes = 0; for (i = 0; i < (int) all_kinds; i++) { - fprintf (stderr, "%-20s %7d %10d\n", tree_node_kind_names[i], - tree_node_counts[i], tree_node_sizes[i]); + fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", + tree_node_kind_names[i], tree_node_counts[i], + tree_node_sizes[i]); total_nodes += tree_node_counts[i]; total_bytes += tree_node_sizes[i]; } mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES); - fprintf (stderr, "%-20s %7d %10d\n", "Total", total_nodes, total_bytes); + fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total", + total_nodes, total_bytes); mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES); fprintf (stderr, "Code Nodes\n"); mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES); for (i = 0; i < (int) MAX_TREE_CODES; i++) - fprintf (stderr, "%-32s %7d\n", get_tree_code_name ((enum tree_code) i), - tree_code_counts[i]); + fprintf (stderr, "%-32s %7" PRIu64 "\n", + get_tree_code_name ((enum tree_code) i), tree_code_counts[i]); mem_usage::print_dash_line (TREE_MEM_USAGE_SPACES); fprintf (stderr, "\n"); ssanames_print_statistics ();