From patchwork Thu Jan 11 10:21:48 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: 859570 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-470934-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="vhzqdUB0"; 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 3zHwb03NQvz9t3G for ; Fri, 12 Jan 2018 19:17:16 +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= vlpG1VBtXTEzaIy8grwdgODflZs2YxWc6QUbeJISOrGbme8ltG4dBEzOj8EluqvS GEM0lpJPlKR2tmkqzOw3qfOphkESrJEKCIZdCs/ROJAW/f1qzPi1rW1b/15CV7Y6 jLJJFE6O+Xemw6R92zBrtnrAe5D5YZynFNATXxyGBG8= 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=qP7P fEuzALbXj7Kvw4Ck2bEJbkI=; b=vhzqdUB0UPRqIbUXXdud8zHY4fdYtt8SUxOO yrSr0o8c7Ho2Z9jeu1zn9oG+rUL/gnvEw/4/9tr5AWlAgGcZsfcrlXhD+OvzLuW7 upowOlKUY9p7K5KySgqL8cAl94bp677VItM5vhwQNrEaMb+0+SQSM1Ud/7GDGT4i KKw5JvM= Received: (qmail 31061 invoked by alias); 12 Jan 2018 08:14:55 -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 31036 invoked by uid 89); 12 Jan 2018 08:14:54 -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=rows, TOTAL, genautomata, peak 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 50930AE15 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: Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Message-Id: <8c09612e2a15845771b85ce2a16c155c49977267.1515744628.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Thu, 11 Jan 2018 11:21:48 +0100 Subject: [PATCH 1/3] Fix --enable-gather-detailed-mem-stats build. To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/ChangeLog: 2018-01-11 Martin Liska * Makefile.in: As qsort_chk is implemented in vec.c, add vec.o to linkage of gencfn-macros. * tree.c (build_new_poly_int_cst): Add CXX_MEM_STAT_INFO as it's passing the info to record_node_allocation_statistics. (test_vector_cst_patterns): Add CXX_MEM_STAT_INFO to declaration and pass the info. * ggc-common.c (struct ggc_usage): Add operator== and use it in operator< and compare function. * mem-stats.h (struct mem_usage): Likewise. * vec.c (struct vec_usage): Remove operator< and compare function. Can be simply inherited. --- gcc/Makefile.in | 3 ++- gcc/ggc-common.c | 17 ++++++++++++++++- gcc/mem-stats.h | 17 ++++++++++++++++- gcc/tree.c | 37 +++++++++++++++++++++++-------------- gcc/vec.c | 21 --------------------- 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index fb988cda9d1..f04b8a224c0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2810,7 +2810,8 @@ genprog = $(genprogerr) check checksum condmd match build/genautomata$(build_exeext) : BUILD_LIBS += -lm build/genrecog$(build_exeext) : build/hash-table.o build/inchash.o -build/gencfn-macros$(build_exeext) : build/hash-table.o build/ggc-none.o +build/gencfn-macros$(build_exeext) : build/hash-table.o build/vec.o \ + build/ggc-none.o # For stage1 and when cross-compiling use the build libcpp which is # built with NLS disabled. For stage2+ use the host library and diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index d435a4b0175..f83fc136d04 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -836,10 +836,22 @@ struct ggc_usage: public mem_usage : mem_usage (allocated, times, peak), m_freed (freed), m_collected (collected), m_overhead (overhead) {} + /* Equality operator. */ + inline bool + operator== (const ggc_usage &second) const + { + return (get_balance () == second.get_balance () + && m_peak == second.m_peak + && m_times == second.m_times); + } + /* Comparison operator. */ inline bool operator< (const ggc_usage &second) const { + if (*this == second) + return false; + return (get_balance () == second.get_balance () ? (m_peak == second.m_peak ? m_times < second.m_times : m_peak < second.m_peak) @@ -926,7 +938,10 @@ struct ggc_usage: public mem_usage const mem_pair_t f = *(const mem_pair_t *)first; const mem_pair_t s = *(const mem_pair_t *)second; - return (*f.second) < (*s.second); + if (*f.second == *s.second) + return 0; + + return *f.second < *s.second ? 1 : -1; } /* Compare rows in final GGC summary dump. */ diff --git a/gcc/mem-stats.h b/gcc/mem-stats.h index 00cb2b0aa9c..741c07301d9 100644 --- a/gcc/mem-stats.h +++ b/gcc/mem-stats.h @@ -163,10 +163,22 @@ struct mem_usage m_instances + second.m_instances); } + /* Equality operator. */ + inline bool + operator== (const mem_usage &second) const + { + return (m_allocated == second.m_allocated + && m_peak == second.m_peak + && m_allocated == second.m_allocated); + } + /* Comparison operator. */ inline bool operator< (const mem_usage &second) const { + if (*this == second) + return false; + return (m_allocated == second.m_allocated ? (m_peak == second.m_peak ? m_times < second.m_times : m_peak < second.m_peak) : m_allocated < second.m_allocated); @@ -181,7 +193,10 @@ struct mem_usage const mem_pair_t f = *(const mem_pair_t *)first; const mem_pair_t s = *(const mem_pair_t *)second; - return (*f.second) < (*s.second); + if (*f.second == *s.second) + return 0; + + return *f.second < *s.second ? 1 : -1; } /* Dump usage coupled to LOC location, where TOTAL is sum of all rows. */ diff --git a/gcc/tree.c b/gcc/tree.c index bed59d33bb2..722ce021b67 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1332,7 +1332,8 @@ build_new_int_cst (tree type, const wide_int &cst) /* Return a new POLY_INT_CST with coefficients COEFFS and type TYPE. */ static tree -build_new_poly_int_cst (tree type, tree (&coeffs)[NUM_POLY_INT_COEFFS]) +build_new_poly_int_cst (tree type, tree (&coeffs)[NUM_POLY_INT_COEFFS] + CXX_MEM_STAT_INFO) { size_t length = sizeof (struct tree_poly_int_cst); record_node_allocation_statistics (POLY_INT_CST, length); @@ -14429,7 +14430,7 @@ check_vector_cst_stepped (vec expected, tree actual, /* Test the creation of VECTOR_CSTs. */ static void -test_vector_cst_patterns () +test_vector_cst_patterns (ALONE_CXX_MEM_STAT_INFO) { auto_vec elements (8); elements.quick_grow (8); @@ -14440,24 +14441,28 @@ test_vector_cst_patterns () { 0, 1, 2, 3, 4, 5, 6, 7 }. */ for (unsigned int i = 0; i < 8; ++i) elements[i] = build_int_cst (element_type, i); - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 1); + tree vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 1); /* Try the same with the first element replaced by 100: { 100, 1, 2, 3, 4, 5, 6, 7 }. */ elements[0] = build_int_cst (element_type, 100); - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 1); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 1); /* Try a series that wraps around. { 100, 65531, 65532, 65533, 65534, 65535, 0, 1 }. */ for (unsigned int i = 1; i < 8; ++i) elements[i] = build_int_cst (element_type, (65530 + i) & 0xffff); - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 1); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 1); /* Try a downward series: { 100, 79, 78, 77, 76, 75, 75, 73 }. */ for (unsigned int i = 1; i < 8; ++i) elements[i] = build_int_cst (element_type, 80 - i); - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 1); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 1); /* Try two interleaved series with different bases and steps: { 100, 53, 66, 206, 62, 212, 58, 218 }. */ @@ -14467,39 +14472,43 @@ test_vector_cst_patterns () elements[i] = build_int_cst (element_type, 70 - i * 2); elements[i + 1] = build_int_cst (element_type, 200 + i * 3); } - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 2); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 2); /* Try a duplicated value: { 100, 100, 100, 100, 100, 100, 100, 100 }. */ for (unsigned int i = 1; i < 8; ++i) elements[i] = elements[0]; - check_vector_cst_duplicate (elements, - build_vector (vector_type, elements), 1); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_duplicate (elements, vector, 1); /* Try an interleaved duplicated value: { 100, 55, 100, 55, 100, 55, 100, 55 }. */ elements[1] = build_int_cst (element_type, 55); for (unsigned int i = 2; i < 8; ++i) elements[i] = elements[i - 2]; - check_vector_cst_duplicate (elements, - build_vector (vector_type, elements), 2); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_duplicate (elements, vector, 2); /* Try a duplicated value with 2 exceptions { 41, 97, 100, 55, 100, 55, 100, 55 }. */ elements[0] = build_int_cst (element_type, 41); elements[1] = build_int_cst (element_type, 97); - check_vector_cst_fill (elements, build_vector (vector_type, elements), 2); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_fill (elements, vector, 2); /* Try with and without a step { 41, 97, 100, 21, 100, 35, 100, 49 }. */ for (unsigned int i = 3; i < 8; i += 2) elements[i] = build_int_cst (element_type, i * 7); - check_vector_cst_stepped (elements, build_vector (vector_type, elements), 2); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_stepped (elements, vector, 2); /* Try a fully-general constant: { 41, 97, 100, 21, 100, 9990, 100, 49 }. */ elements[5] = build_int_cst (element_type, 9990); - check_vector_cst_fill (elements, build_vector (vector_type, elements), 4); + vector = build_vector (vector_type, elements PASS_MEM_STAT); + check_vector_cst_fill (elements, vector, 4); } /* Verify that STRIP_NOPS (NODE) is EXPECTED. diff --git a/gcc/vec.c b/gcc/vec.c index 98a1d779a00..695cd1eba5a 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -60,15 +60,6 @@ struct vec_usage: public mem_usage : mem_usage (allocated, times, peak), m_items (items), m_items_peak (items_peak) {} - /* Comparison operator. */ - inline bool - operator< (const vec_usage &second) const - { - return (m_allocated == second.m_allocated ? - (m_peak == second.m_peak ? m_times < second.m_times - : m_peak < second.m_peak) : m_allocated < second.m_allocated); - } - /* Sum the usage with SECOND usage. */ vec_usage operator+ (const vec_usage &second) @@ -115,18 +106,6 @@ struct vec_usage: public mem_usage print_dash_line (); } - /* Compare wrapper used by qsort method. */ - static int - compare (const void *first, const void *second) - { - typedef std::pair mem_pair_t; - - const mem_pair_t f = *(const mem_pair_t *)first; - const mem_pair_t s = *(const mem_pair_t *)second; - - return (*f.second) < (*s.second); - } - /* Current number of items allocated. */ size_t m_items; /* Peak value of number of allocated items. */ 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 (); From patchwork Fri Jan 12 08:04:05 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: 859568 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-470932-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="RNCMFQy8"; 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 3zHwZY6hg2z9t3H for ; Fri, 12 Jan 2018 19:16:53 +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= Bcip6AoBGrs7fcrhp4DIaN4qu/47ddWF/9eGIE5Uw3DJrXSixdcqxQ9au0bkcuUj g6K/xYmHm4QZQ4BYKCPz4kvJ1WzmydZ93yB63u9SIYOeK/pOiXuQKrSkl37hLc5n 7yUrGE71FMcpc5NlTRBMOJQzJot3jITXis5vECyi4jg= 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=O6m4 NZ2aBz1F0JD+C4eEWsgGSmM=; b=RNCMFQy846l21hZyHwE5xc8Ukd8B9MJWErn8 j31rD9p7ya8GYpDoSQSITDiauQVSwSDMe5hmG/ppknhgY4xHCQZnoBe8GGfvyJj7 ZuHFBkSghz4Nu543Kz5PTW2roAfnaI2Z4njm3qlnC/wkDj9Vx1X4MGTuiUBhCY8o PvLYVLo= Received: (qmail 30940 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 30903 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= 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 relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4DD4EAE13 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: <120ce931-9a78-bba3-4a8d-f1fec80c0719@suse.cz> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Message-Id: <0aca5e4c4a4a463b13c0a0916689e1a4d924bb12.1515744628.git.mliska@suse.cz> In-Reply-To: References: From: marxin Date: Fri, 12 Jan 2018 09:04:05 +0100 Subject: [PATCH 3/3] Fix integer overflow in stats of GIMPLE statements. To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes gcc/ChangeLog: 2018-01-12 Martin Liska * gimple.c (gimple_alloc_counts): Use uint64_t instead of int. (gimple_alloc_sizes): Likewise. (dump_gimple_statistics): Use PRIu64 in printf format. * gimple.h: Change uint64_t to int. --- gcc/gimple.c | 17 ++++++++++------- gcc/gimple.h | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gcc/gimple.c b/gcc/gimple.c index e24b9fd611d..c1b7229a6b7 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -77,8 +77,8 @@ EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = { /* Gimple stats. */ -int gimple_alloc_counts[(int) gimple_alloc_kind_all]; -int gimple_alloc_sizes[(int) gimple_alloc_kind_all]; +uint64_t gimple_alloc_counts[(int) gimple_alloc_kind_all]; +uint64_t gimple_alloc_sizes[(int) gimple_alloc_kind_all]; /* Keep in sync with gimple.h:enum gimple_alloc_kind. */ static const char * const gimple_alloc_kind_names[] = { @@ -2057,11 +2057,12 @@ gimple_assign_rhs_could_trap_p (gimple *s) void dump_gimple_statistics (void) { - int i, total_tuples = 0, total_bytes = 0; + int i; + uint64_t total_tuples = 0, total_bytes = 0; if (! GATHER_STATISTICS) { - fprintf (stderr, "No gimple statistics\n"); + fprintf (stderr, "No GIMPLE statistics\n"); return; } @@ -2070,13 +2071,15 @@ dump_gimple_statistics (void) fprintf (stderr, "---------------------------------------\n"); for (i = 0; i < (int) gimple_alloc_kind_all; ++i) { - fprintf (stderr, "%-20s %7d %10d\n", gimple_alloc_kind_names[i], - gimple_alloc_counts[i], gimple_alloc_sizes[i]); + fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", + gimple_alloc_kind_names[i], gimple_alloc_counts[i], + gimple_alloc_sizes[i]); total_tuples += gimple_alloc_counts[i]; total_bytes += gimple_alloc_sizes[i]; } fprintf (stderr, "---------------------------------------\n"); - fprintf (stderr, "%-20s %7d %10d\n", "Total", total_tuples, total_bytes); + fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total", + total_tuples, total_bytes); fprintf (stderr, "---------------------------------------\n"); } diff --git a/gcc/gimple.h b/gcc/gimple.h index 8c0e9aefe54..281015ad3e2 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -6386,8 +6386,8 @@ enum gimple_alloc_kind gimple_alloc_kind_all }; -extern int gimple_alloc_counts[]; -extern int gimple_alloc_sizes[]; +extern uint64_t gimple_alloc_counts[]; +extern uint64_t gimple_alloc_sizes[]; /* Return the allocation kind for a given stmt CODE. */ static inline enum gimple_alloc_kind