From patchwork Mon Aug 9 13:58:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Huber X-Patchwork-Id: 1515115 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4GjyNG22qcz9sWS for ; Mon, 9 Aug 2021 23:58:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E6A07389681B for ; Mon, 9 Aug 2021 13:58:18 +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 10D263857832 for ; Mon, 9 Aug 2021 13:58:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10D263857832 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 1mD5n2-000EXY-RG; Mon, 09 Aug 2021 15:58:04 +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 1mD5n2-000A0R-OX; Mon, 09 Aug 2021 15:58:04 +0200 Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 731C12A1610; Mon, 9 Aug 2021 15:58:04 +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 1m4vR1xpzR7D; Mon, 9 Aug 2021 15:58:04 +0200 (CEST) Received: from localhost (localhost.localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 1D0D12A165B; Mon, 9 Aug 2021 15:58:04 +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 pvbbPHkMT5yJ; Mon, 9 Aug 2021 15:58:04 +0200 (CEST) Received: from linux-diu0.suse (unknown [192.168.96.161]) by mail.embedded-brains.de (Postfix) with ESMTP id EF75C2A1610; Mon, 9 Aug 2021 15:58:03 +0200 (CEST) From: Sebastian Huber To: gcc-patches@gcc.gnu.org Subject: [PATCH] gcov: Add GCOV_TYPE_SIZE target macro Date: Mon, 9 Aug 2021 15:58:03 +0200 Message-Id: <20210809135803.22055-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/26258/Mon Aug 9 10:18:46 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 -fprofile-update=atomic is used, then the target must provide atomic operations for the counters of the type returned by get_gcov_type(). This is a 64-bit type for targets which have a 64-bit long long type. On 32-bit targets this could be an issue since they may not provide 64-bit atomic operations. Allow targets to override the default type size with the new GCOV_TYPE_SIZE target macro. gcc/ * config/sparc/rtemself.h (GCOV_TYPE_SIZE): Define. * coverage.c (get_gcov_type): Use GCOV_TYPE_SIZE. * defaults.h (GCOV_TYPE_SIZE): Define default. * tree-profile.c (gimple_gen_edge_profiler): Use precision of gcov_type_node. (gimple_gen_time_profiler): Likewise. --- gcc/config/sparc/rtemself.h | 2 ++ gcc/coverage.c | 3 +-- gcc/defaults.h | 4 ++++ gcc/tree-profile.c | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gcc/config/sparc/rtemself.h b/gcc/config/sparc/rtemself.h index fa972af640c..ac4f70c48c4 100644 --- a/gcc/config/sparc/rtemself.h +++ b/gcc/config/sparc/rtemself.h @@ -40,3 +40,5 @@ /* Use the default */ #undef LINK_GCC_C_SEQUENCE_SPEC + +#define GCOV_TYPE_SIZE 32 diff --git a/gcc/coverage.c b/gcc/coverage.c index ac9a9fdad22..e655c164d66 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -145,8 +145,7 @@ static void coverage_obj_finish (vec *); tree get_gcov_type (void) { - scalar_int_mode mode - = smallest_int_mode_for_size (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32); + scalar_int_mode mode = smallest_int_mode_for_size (GCOV_TYPE_SIZE); return lang_hooks.types.type_for_mode (mode, false); } diff --git a/gcc/defaults.h b/gcc/defaults.h index ba79a8e48ed..1cf06d26176 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -1475,4 +1475,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef TARGET_UNIT target_unit; #endif +#ifndef GCOV_TYPE_SIZE +#define GCOV_TYPE_SIZE (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32) +#endif + #endif /* ! GCC_DEFAULTS_H */ diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 5a74cc96e13..cf46912631c 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -250,7 +250,7 @@ gimple_gen_edge_profiler (int edgeno, edge e) { /* __atomic_fetch_add (&counter, 1, MEMMODEL_RELAXED); */ tree addr = tree_coverage_counter_addr (GCOV_COUNTER_ARCS, edgeno); - tree f = builtin_decl_explicit (LONG_LONG_TYPE_SIZE > 32 + tree f = builtin_decl_explicit (TYPE_PRECISION (gcov_type_node) > 32 ? BUILT_IN_ATOMIC_FETCH_ADD_8: BUILT_IN_ATOMIC_FETCH_ADD_4); gcall *stmt = gimple_build_call (f, 3, addr, one, @@ -525,7 +525,7 @@ gimple_gen_time_profiler (unsigned tag) tree_time_profiler_counter); gassign *assign = gimple_build_assign (ptr, NOP_EXPR, addr); gsi_insert_before (&gsi, assign, GSI_NEW_STMT); - tree f = builtin_decl_explicit (LONG_LONG_TYPE_SIZE > 32 + tree f = builtin_decl_explicit (TYPE_PRECISION (gcov_type_node) > 32 ? BUILT_IN_ATOMIC_ADD_FETCH_8: BUILT_IN_ATOMIC_ADD_FETCH_4); gcall *stmt = gimple_build_call (f, 3, ptr, one,