From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 77B433860C35 for ; Tue, 10 Nov 2020 16:23:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 77B433860C35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sebastian.huber@embedded-brains.de Received: from sslproxy02.your-server.de ([78.47.166.47]) by dedi548.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1kcWQR-0003fm-Qc; Tue, 10 Nov 2020 17:23:19 +0100 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1kcWQR-000MD7-NN; Tue, 10 Nov 2020 17:23:19 +0100 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id E391F2A1610; Tue, 10 Nov 2020 17:20:38 +0100 (CET) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id bxXT_wCWhnsZ; Tue, 10 Nov 2020 17:20:38 +0100 (CET) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 868302A165B; Tue, 10 Nov 2020 17:20:38 +0100 (CET) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fuwOqc2TraFK; Tue, 10 Nov 2020 17:20:38 +0100 (CET) Received: from shuber-nb-linux.eb.localhost (unknown [10.10.171.18]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 55E572A1610; Tue, 10 Nov 2020 17:20:38 +0100 (CET) Subject: Re: Gcov info registration without constructor? From: Sebastian Huber To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , gcc@gcc.gnu.org References: <4c921363-879d-5c4a-cda6-f0fcce4f7719@embedded-brains.de> Message-ID: Date: Tue, 10 Nov 2020 17:23:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------935F35F9B60E57CB21002B7E" Content-Language: en-US X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.102.4/25984/Tue Nov 10 14:18:29 2020) X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, BODY_8BITS, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 16:23:23 -0000 This is a multi-part message in MIME format. --------------935F35F9B60E57CB21002B7E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Hello Martin, attached is a proof of concept. I am not sure how I can make the new=20 section read-only. Currently, it is writable: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .section=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 .gcov_info,"aw" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .align 2 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .type=C2=A0=C2=A0 .LPBX2, @ob= ject =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .size=C2=A0=C2=A0 .LPBX2, 4 .LPBX2: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .long=C2=A0=C2=A0 .LPBX0 I probably need also a patch for the GCC options documentation, test=20 cases, a GCC bootstrap on Linux, release notes, ...? Do I have to wait=20 for the GCC 11 development start? --=20 embedded brains GmbH Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber@embedded-brains.de Phone: +49-89-18 94 741 - 16 Fax: +49-89-18 94 741 - 08 PGP: Public key available on request. embedded brains GmbH Registergericht: Amtsgericht M=C3=BCnchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler Unsere Datenschutzerkl=C3=A4rung finden Sie hier: https://embedded-brains= .de/datenschutzerklaerung/ --------------935F35F9B60E57CB21002B7E Content-Type: text/x-patch; charset=UTF-8; name="0001-Add-fprofile-info-section-support.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Add-fprofile-info-section-support.patch" >From 305eb4066742418d3b14ee6e8bec76bfb2835a99 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 10 Nov 2020 16:21:07 +0100 Subject: [PATCH] Add -fprofile-info-section support --- gcc/common.opt | 8 ++++++++ gcc/coverage.c | 19 +++++++++++++++++-- gcc/opts.c | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index 7d0e0d9c88a..1b69da681e3 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2268,6 +2268,14 @@ fprofile-generate= Common Joined RejectNegative Enable common options for generating profile info for profile feedback directed optimizations, and set -fprofile-dir=. +fprofile-info-section +Common RejectNegative +Register a pointer to the profile information in the .gcov_info section. + +fprofile-info-section= +Common Joined RejectNegative Var(profile_info_section) +Register a pointer to the profile information in the named section. + fprofile-partial-training Common Report Var(flag_profile_partial_training) Optimization Do not assume that functions never executed during the train run are cold. diff --git a/gcc/coverage.c b/gcc/coverage.c index 7711412c3be..ec1c5d3d125 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -1151,8 +1151,23 @@ coverage_obj_init (void) ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 0); DECL_NAME (gcov_info_var) = get_identifier (name_buf); - build_init_ctor (gcov_info_type); - build_gcov_exit_decl (); + if (profile_info_section) + { + tree var = build_decl (BUILTINS_LOCATION, + VAR_DECL, NULL_TREE, + build_pointer_type (gcov_info_type)); + TREE_STATIC (var) = 1; + ASM_GENERATE_INTERNAL_LABEL (name_buf, "LPBX", 2); + DECL_NAME (var) = get_identifier (name_buf); + set_decl_section_name (var, profile_info_section); + DECL_INITIAL (var) = build_fold_addr_expr (gcov_info_var); + varpool_node::finalize_decl (var); + } + else + { + build_init_ctor (gcov_info_type); + build_gcov_exit_decl (); + } return true; } diff --git a/gcc/opts.c b/gcc/opts.c index 96291e89a49..fd6e669471e 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -2602,6 +2602,10 @@ common_handle_option (struct gcc_options *opts, SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, value); break; + case OPT_fprofile_info_section: + opts->x_profile_info_section = ".gcov_info"; + break; + case OPT_fpatchable_function_entry_: { char *patch_area_arg = xstrdup (arg); -- 2.26.2 --------------935F35F9B60E57CB21002B7E--