From patchwork Thu Jun 16 15:04:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 55136 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 039F8382C156 for ; Thu, 16 Jun 2022 15:05:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 039F8382C156 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655391923; bh=PJtm4H3uuV9KrEYDoie02u4C/G0mmKaBwES6BI0vfJE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vd/hwJ3C5Aj8X+DnJCdp8KTo9onOv+4GAFLU8iscqwZDq4ejcmT/CWuEhyQ7aRIPt keVuyzveUdpJsciWX9uotDt7qHTOj3Xe6PkZwC83G5WaHhnrMvAchO6mmcnj5k0y0b wYbOBPFe8HaG5eYvWFVza4j6fx5ByPn2+zqUqUno= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 077BB38582A8 for ; Thu, 16 Jun 2022 15:04:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 077BB38582A8 Received: by mail-ed1-x533.google.com with SMTP id x5so2612417edi.2 for ; Thu, 16 Jun 2022 08:04:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gcpV4EYiFMPlvyday3NPsJiLTKxbgqH3DF+FXAirKvo=; b=dSLEC0QvOQ1RCu6TWytmLPgAQwZ1Y+qxKQ9/M0Sa2yoUZndSlkLNxA4GuOd87NajM+ meP8GxYtaYKRDVRicyMOBuwj5ejU1HcSiLOejKtGk/WYaPIjf5pQHWplbNeLilmhI6KM cQoNMZgqyqC68YTLuAg7fl58KUY7yGexv73fIiGhs894lBLkngDh6W7l+fQzlyRp5gdI WAvnJ6Tf/k/I8u9E/L2VMvbya5yCAYuX5xYccRTWr4LPzrOFrmTrfIUTzd8OCmndtR5G 4ZBIrcWB60pEwWTwCsb5d0MyULUger/Ro0nQqvqeK/xNWI+22wEFJz8T8xtqgdbatAc+ L8HA== X-Gm-Message-State: AJIora99IfjD5hyF11og3WqwQJ8HF7MQBH88aZtxCTgZEf7h7iWM4PJO TcKfIroaDZKmM0Ft/fDyz3FNIt2FoosrE/fLzVNim+6ABx8= X-Google-Smtp-Source: AGRyM1u+ZZg8KYiQr2cUODDkSuJgACgT73ylO6ZOXXwJNoRDvSXiDDo7DFw7pN8FdRtRFNXrd24/0axlM9PpXqYcy3o= X-Received: by 2002:a05:6402:1488:b0:431:56cb:bbc5 with SMTP id e8-20020a056402148800b0043156cbbbc5mr6907761edv.199.1655391890307; Thu, 16 Jun 2022 08:04:50 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 16 Jun 2022 20:34:13 +0530 Message-ID: Subject: [statistics.cc] Emit asm name of function with -fdump-statistics-asmname To: gcc Patches X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Prathamesh Kulkarni via Gcc-patches From: Prathamesh Kulkarni Reply-To: Prathamesh Kulkarni Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, I just noticed -fdump-statistics supports asmname sub-option, which according to the doc states: "If DECL_ASSEMBLER_NAME has been set for a given decl, use that in the dump instead of DECL_NAME. Its primary use is ease of use working backward from mangled names in the assembly file." When passed -fdump-statistics-asmname, the dump however still contains the original name of functions. The patch modifies statistics.cc to emit asm name of function instead. Also for C++, it helps to better disambiguate overloaded function names in the stats dump file. I have attached stats dump for a simple test-case. Does it look OK ? Thanks, Prathamesh 29 ssa "unused VAR_DECLs removed" "foo" 1 47 fre "RPO blocks" "foo" 1 47 fre "RPO iterations == 10" "foo" 1 47 fre "RPO blocks visited" "foo" 1 47 fre "RPO blocks executable" "foo" 1 47 fre "RPO block visited times == 1" "foo" 1 47 fre "RPO num avail == 1" "foo" 1 47 fre "RPO num values == 3" "foo" 1 47 fre "RPO num lattice == 3" "foo" 1 47 fre "RPO num values == 2" "foo" 1 47 fre "RPO blocks" "foo" 1 47 fre "RPO iterations == 10" "foo" 1 47 fre "RPO num lattice == 2" "foo" 1 47 fre "RPO blocks visited" "foo" 1 47 fre "RPO blocks executable" "foo" 1 47 fre "RPO block visited times == 1" "foo" 1 47 fre "RPO num avail == 1" "foo" 1 120 fre "RPO blocks" "foo" 1 120 fre "RPO iterations == 10" "foo" 1 120 fre "RPO blocks visited" "foo" 1 120 fre "RPO blocks executable" "foo" 1 120 fre "RPO block visited times == 1" "foo" 1 120 fre "RPO num avail == 1" "foo" 1 120 fre "RPO num values == 3" "foo" 1 120 fre "RPO num lattice == 3" "foo" 1 151 pre "RPO blocks" "foo" 1 151 pre "RPO iterations == 10" "foo" 1 151 pre "compute_antic iterations == 2" "foo" 1 151 pre "RPO blocks visited" "foo" 1 151 pre "RPO blocks executable" "foo" 1 151 pre "RPO block visited times == 1" "foo" 1 151 pre "RPO num avail == 1" "foo" 1 151 pre "RPO num values == 3" "foo" 1 151 pre "RPO num lattice == 3" "foo" 1 151 pre "insert iterations == 1" "foo" 1 201 fre "RPO blocks" "foo" 1 201 fre "RPO iterations == 10" "foo" 1 201 fre "RPO blocks visited" "foo" 1 201 fre "RPO blocks executable" "foo" 1 201 fre "RPO block visited times == 1" "foo" 1 201 fre "RPO num avail == 1" "foo" 1 201 fre "RPO num values == 3" "foo" 1 201 fre "RPO num lattice == 3" "foo" 1 293 combine "two-insn combine" "foo" 2 120 fre "RPO num values == 2" "foo" 1 120 fre "RPO blocks" "foo" 1 120 fre "RPO iterations == 10" "foo" 1 120 fre "RPO num lattice == 2" "foo" 1 120 fre "RPO blocks visited" "foo" 1 120 fre "RPO blocks executable" "foo" 1 120 fre "RPO block visited times == 1" "foo" 1 120 fre "RPO num avail == 1" "foo" 1 151 pre "RPO num values == 2" "foo" 1 151 pre "RPO blocks" "foo" 1 151 pre "RPO iterations == 10" "foo" 1 151 pre "compute_antic iterations == 2" "foo" 1 151 pre "RPO num lattice == 2" "foo" 1 151 pre "RPO blocks visited" "foo" 1 151 pre "RPO blocks executable" "foo" 1 151 pre "RPO block visited times == 1" "foo" 1 151 pre "RPO num avail == 1" "foo" 1 151 pre "insert iterations == 1" "foo" 1 201 fre "RPO num values == 2" "foo" 1 201 fre "RPO blocks" "foo" 1 201 fre "RPO iterations == 10" "foo" 1 201 fre "RPO num lattice == 2" "foo" 1 201 fre "RPO blocks visited" "foo" 1 201 fre "RPO blocks executable" "foo" 1 201 fre "RPO block visited times == 1" "foo" 1 201 fre "RPO num avail == 1" "foo" 1 29 ssa "unused VAR_DECLs removed" "_Z3fooi" 1 47 fre "RPO blocks" "_Z3fooii" 1 47 fre "RPO iterations == 10" "_Z3fooii" 1 47 fre "RPO blocks visited" "_Z3fooii" 1 47 fre "RPO blocks executable" "_Z3fooii" 1 47 fre "RPO block visited times == 1" "_Z3fooii" 1 47 fre "RPO num avail == 1" "_Z3fooii" 1 47 fre "RPO num values == 3" "_Z3fooii" 1 47 fre "RPO num lattice == 3" "_Z3fooii" 1 47 fre "RPO num values == 2" "_Z3fooi" 1 47 fre "RPO blocks" "_Z3fooi" 1 47 fre "RPO iterations == 10" "_Z3fooi" 1 47 fre "RPO num lattice == 2" "_Z3fooi" 1 47 fre "RPO blocks visited" "_Z3fooi" 1 47 fre "RPO blocks executable" "_Z3fooi" 1 47 fre "RPO block visited times == 1" "_Z3fooi" 1 47 fre "RPO num avail == 1" "_Z3fooi" 1 120 fre "RPO blocks" "_Z3fooii" 1 120 fre "RPO iterations == 10" "_Z3fooii" 1 120 fre "RPO blocks visited" "_Z3fooii" 1 120 fre "RPO blocks executable" "_Z3fooii" 1 120 fre "RPO block visited times == 1" "_Z3fooii" 1 120 fre "RPO num avail == 1" "_Z3fooii" 1 120 fre "RPO num values == 3" "_Z3fooii" 1 120 fre "RPO num lattice == 3" "_Z3fooii" 1 151 pre "RPO blocks" "_Z3fooii" 1 151 pre "RPO iterations == 10" "_Z3fooii" 1 151 pre "compute_antic iterations == 2" "_Z3fooii" 1 151 pre "RPO blocks visited" "_Z3fooii" 1 151 pre "RPO blocks executable" "_Z3fooii" 1 151 pre "RPO block visited times == 1" "_Z3fooii" 1 151 pre "RPO num avail == 1" "_Z3fooii" 1 151 pre "RPO num values == 3" "_Z3fooii" 1 151 pre "RPO num lattice == 3" "_Z3fooii" 1 151 pre "insert iterations == 1" "_Z3fooii" 1 201 fre "RPO blocks" "_Z3fooii" 1 201 fre "RPO iterations == 10" "_Z3fooii" 1 201 fre "RPO blocks visited" "_Z3fooii" 1 201 fre "RPO blocks executable" "_Z3fooii" 1 201 fre "RPO block visited times == 1" "_Z3fooii" 1 201 fre "RPO num avail == 1" "_Z3fooii" 1 201 fre "RPO num values == 3" "_Z3fooii" 1 201 fre "RPO num lattice == 3" "_Z3fooii" 1 293 combine "two-insn combine" "_Z3fooii" 2 120 fre "RPO num values == 2" "_Z3fooi" 1 120 fre "RPO blocks" "_Z3fooi" 1 120 fre "RPO iterations == 10" "_Z3fooi" 1 120 fre "RPO num lattice == 2" "_Z3fooi" 1 120 fre "RPO blocks visited" "_Z3fooi" 1 120 fre "RPO blocks executable" "_Z3fooi" 1 120 fre "RPO block visited times == 1" "_Z3fooi" 1 120 fre "RPO num avail == 1" "_Z3fooi" 1 151 pre "RPO num values == 2" "_Z3fooi" 1 151 pre "RPO blocks" "_Z3fooi" 1 151 pre "RPO iterations == 10" "_Z3fooi" 1 151 pre "compute_antic iterations == 2" "_Z3fooi" 1 151 pre "RPO num lattice == 2" "_Z3fooi" 1 151 pre "RPO blocks visited" "_Z3fooi" 1 151 pre "RPO blocks executable" "_Z3fooi" 1 151 pre "RPO block visited times == 1" "_Z3fooi" 1 151 pre "RPO num avail == 1" "_Z3fooi" 1 151 pre "insert iterations == 1" "_Z3fooi" 1 201 fre "RPO num values == 2" "_Z3fooi" 1 201 fre "RPO blocks" "_Z3fooi" 1 201 fre "RPO iterations == 10" "_Z3fooi" 1 201 fre "RPO num lattice == 2" "_Z3fooi" 1 201 fre "RPO blocks visited" "_Z3fooi" 1 201 fre "RPO blocks executable" "_Z3fooi" 1 201 fre "RPO block visited times == 1" "_Z3fooi" 1 201 fre "RPO num avail == 1" "_Z3fooi" 1 diff --git a/gcc/statistics.cc b/gcc/statistics.cc index 0d596e34189..ff4f9cc7fb6 100644 --- a/gcc/statistics.cc +++ b/gcc/statistics.cc @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "context.h" #include "pass_manager.h" +#include "tree.h" static int statistics_dump_nr; static dump_flags_t statistics_dump_flags; @@ -113,6 +114,21 @@ curr_statistics_hash (void) return statistics_hashes[idx]; } +/* Helper function to return asmname or name of FN + depending on whether asmname option is set. */ + +static const char * +get_function_name (struct function *fn) +{ + if (statistics_dump_flags & TDF_ASMNAME) + { + tree asmname = decl_assembler_name (fn->decl); + if (asmname) + return IDENTIFIER_POINTER (asmname); + } + return function_name (fn); +} + /* Helper for statistics_fini_pass. Print the counter difference since the last dump for the pass dump files. */ @@ -152,7 +168,7 @@ statistics_fini_pass_2 (statistics_counter **slot, current_pass->static_pass_number, current_pass->name, counter->id, counter->val, - current_function_name (), + get_function_name (cfun), count); else fprintf (statistics_dump_file, @@ -160,7 +176,7 @@ statistics_fini_pass_2 (statistics_counter **slot, current_pass->static_pass_number, current_pass->name, counter->id, - current_function_name (), + get_function_name (cfun), count); counter->prev_dumped_count = counter->count; return 1; @@ -329,7 +345,7 @@ statistics_counter_event (struct function *fn, const char *id, int incr) current_pass ? current_pass->static_pass_number : -1, current_pass ? current_pass->name : "none", id, - function_name (fn), + get_function_name (fn), incr); } @@ -359,5 +375,5 @@ statistics_histogram_event (struct function *fn, const char *id, int val) current_pass->static_pass_number, current_pass->name, id, val, - function_name (fn)); + get_function_name (fn)); }