From patchwork Mon Aug 9 08:00:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Huber X-Patchwork-Id: 1514955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GjpRn6RgWz9shx for ; Mon, 9 Aug 2021 18:00:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3AA86389200E for ; Mon, 9 Aug 2021 08:00:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id F39173858425 for ; Mon, 9 Aug 2021 08:00:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F39173858425 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=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 1mD0D4-0003E0-IA; Mon, 09 Aug 2021 10:00:34 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mD0D4-000CuS-Eb; Mon, 09 Aug 2021 10:00:34 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 297302A1610; Mon, 9 Aug 2021 10:00:34 +0200 (CEST) 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 6ftG-V2krYp5; Mon, 9 Aug 2021 10:00:33 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id A07BD2A165B; Mon, 9 Aug 2021 10:00:33 +0200 (CEST) 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 eZT7t6bmvpYQ; Mon, 9 Aug 2021 10:00:33 +0200 (CEST) Received: from linux-diu0.suse (unknown [192.168.96.161]) by mail.embedded-brains.de (Postfix) with ESMTP id 840DD2A1610; Mon, 9 Aug 2021 10:00:33 +0200 (CEST) From: Sebastian Huber To: gcc-patches@gcc.gnu.org Subject: [PATCH] gcov: Add -fprofile-update=force-atomic Date: Mon, 9 Aug 2021 10:00:33 +0200 Message-Id: <20210809080033.312-1-sebastian.huber@embedded-brains.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.2/26257/Sun Aug 8 10:20:05 2021) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" If get_gcov_type() returns a 64-bit type, then 64-bit atomic operations in hardware are required for the "atomic" method. Add a new method to force atomic operations even if a library implementation (libatomic) must be used. gcc/ * common.opt (fprofile-update): Add force-atomic method. * coretypes.h (profile_update): Add PROFILE_UPDATE_FORCE_ATOMIC. * doc/invoke.texi (fprofile-update): Document force-atomic method. * tree-profile.c (tree_profiling): Support force-atomic method. --- gcc/common.opt | 5 ++++- gcc/coretypes.h | 3 ++- gcc/doc/invoke.texi | 14 +++++++++----- gcc/tree-profile.c | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index d9da1131eda..ea887c987af 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2247,7 +2247,7 @@ Enable correction of flow inconsistent profile data input. fprofile-update= Common Joined RejectNegative Enum(profile_update) Var(flag_profile_update) Init(PROFILE_UPDATE_SINGLE) --fprofile-update=[single|atomic|prefer-atomic] Set the profile update method. +-fprofile-update=[single|atomic|prefer-atomic|force-atomic] Set the profile update method. fprofile-filter-files= Common Joined RejectNegative Var(flag_profile_filter_files) @@ -2285,6 +2285,9 @@ Enum(profile_update) String(atomic) Value(PROFILE_UPDATE_ATOMIC) EnumValue Enum(profile_update) String(prefer-atomic) Value(PROFILE_UPDATE_PREFER_ATOMIC) +EnumValue +Enum(profile_update) String(force-atomic) Value(PROFILE_UPDATE_FORCE_ATOMIC) + fprofile-prefix-path= Common Joined RejectNegative Var(profile_prefix_path) Remove prefix from absolute path before mangling name for -fprofile-generate= and -fprofile-use=. diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 406572e947d..ded8e718994 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -209,7 +209,8 @@ enum offload_abi { enum profile_update { PROFILE_UPDATE_SINGLE, PROFILE_UPDATE_ATOMIC, - PROFILE_UPDATE_PREFER_ATOMIC + PROFILE_UPDATE_PREFER_ATOMIC, + PROFILE_UPDATE_FORCE_ATOMIC }; /* Type of profile reproducibility methods. */ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index a64cec5387e..df920545ac1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -14905,11 +14905,11 @@ part of the path and keep all file names relative to the main build directory. @item -fprofile-update=@var{method} @opindex fprofile-update -Alter the update method for an application instrumented for profile -feedback based optimization. The @var{method} argument should be one of -@samp{single}, @samp{atomic} or @samp{prefer-atomic}. -The first one is useful for single-threaded applications, -while the second one prevents profile corruption by emitting thread-safe code. +Alter the update method for an application instrumented for profile feedback +based optimization or code-coverage. The @var{method} argument should be one +of @samp{single}, @samp{atomic}, @samp{prefer-atomic} or @samp{force-atomic}. +The first one is useful for single-threaded applications, while the second one +prevents profile corruption by emitting thread-safe code. @strong{Warning:} When an application does not properly join all threads (or creates an detached thread), a profile file can be still corrupted. @@ -14919,6 +14919,10 @@ when supported by a target, or to @samp{single} otherwise. The GCC driver automatically selects @samp{prefer-atomic} when @option{-pthread} is present in the command line. +Using @samp{force-atomic} forces the use of an @samp{atomic} method even if the +target does not support it directly in hardware and a library implementation +must be used instead. + @item -fprofile-filter-files=@var{regex} @opindex fprofile-filter-files diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 5a74cc96e13..ac2ef4ccdf2 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -718,6 +718,8 @@ tree_profiling (void) else if (flag_profile_update == PROFILE_UPDATE_PREFER_ATOMIC) flag_profile_update = can_support_atomic ? PROFILE_UPDATE_ATOMIC : PROFILE_UPDATE_SINGLE; + else if (flag_profile_update == PROFILE_UPDATE_FORCE_ATOMIC) + flag_profile_update = PROFILE_UPDATE_ATOMIC; /* This is a small-ipa pass that gets called only once, from cgraphunit.c:ipa_passes(). */