From patchwork Fri Nov 17 20:17:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Jires X-Patchwork-Id: 166329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp789972vqn; Fri, 17 Nov 2023 12:19:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwqHxM6oC/FAQQG1Ze5gXtKcVfzl892laoyPPoa69zB+ZiHhHW63O5SjslqxBvEB5gip4B X-Received: by 2002:a05:6214:124c:b0:670:710f:2042 with SMTP id r12-20020a056214124c00b00670710f2042mr174638qvv.15.1700252350262; Fri, 17 Nov 2023 12:19:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700252350; cv=pass; d=google.com; s=arc-20160816; b=fMJ34ZRdjxlz47zC1ceF3hBb3Fr636d5z1F2N5X8TI3uq1kVz2f1cW2cPxaWtjXt+l hXaGm2uQaQvY22CPsnkxnn+1Q5SfVtAzAdQiTdDPwBBX/tk5aEN9u17q7j8ySUqh87Be i5/hTWBzK1440MwHwUTSAAyW+i2cZMyTAYxIap9+ES2KLLg+qrIIpJpuuRfTHIHsi5jC dI/xO9VWpgFM/FRi4Bzm50s4PYcNXGXZ7T4+Z1cJKmTJ9UHsPnTMZjG6OsgLb4cD4f37 XEvRqq+xqgp0acbz7atTksGZntn8Y9ZV+rTbc1zYU8Y1i9c2MGAI4v7jR0FfQpupswTk FRlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=+weIGxwXo/8De0+gZFSXrhCKLRAnzFdsl4El7qME/iI=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=CxrNhzHSyZ6wHlOJtbg6hYS3g0Hy/P/T29sGVEkb5+FKoQL13bXt21o4FZL101kcXb JYPAdtSIjy/yF/j27ec+JpY8UvPo5tTsICX0DBelWvG6+N9LBIEuXq1SfCMnsrE7B9EG 80Xh/X8wXquZ7JfGgKnvfZZ4AP9WQyyYPSHb1CDcj8d6Mxoew9DNcANKGFAzK7pMw6jK a58ZqABVxWU9jc4BywxejqkQry2PgJcgJxI5QZJ6JQ746LHc8lAP4+E3psFq/yOOktQe rKvn9XBmZ2u5R3/pd9L5kYfcdJyDkrvtZKXrsTFDktXqHYPlOANIAGljlFz/dzoVDEGa Vu2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qY3mjI+A; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ggdqQt7q; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i6-20020a056214020600b006563f18c948si2270583qvt.367.2023.11.17.12.19.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 12:19:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=qY3mjI+A; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=ggdqQt7q; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E9AA38582AF for ; Fri, 17 Nov 2023 20:19:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id CA0693857B8B for ; Fri, 17 Nov 2023 20:17:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA0693857B8B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CA0693857B8B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700252258; cv=none; b=Gc0O5uUwsOPSMc+FHbnR2g+UTs8kFWiA5dh4gh6s7e5GJ+v64gNk9gvRTwcItnw+RAN6DZoQHf+i9Mc0dTSwK0nahSq9jG0xqNuslo/d6SEuPfj74cXZ2j08Gw2p0XIEj8CggS83T3xM+J6wAaRSftdqvzTDTpD2IJ4I3zDrhAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700252258; c=relaxed/simple; bh=XqZfn1Klj0awjdeMxfSv9n8ID2VjvGYG3bvTQoL4tWo=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=B1mYqTdJNOMQVeKPhcRu8yFasO7Ut7s8264YWKL6iqgd84l00xsa4D2xkP9WtP8tX+7yT5PiBuQWRga1CXKzBvU5Yv/Q+ZEhg4Al9trWAeqA+xCkPMudFnnC7m1CS0EgLCPubt46v0Irhfnv4gLQN+A5k8wkpXit40i8N+4UwnY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E71AA1F37E for ; Fri, 17 Nov 2023 20:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1700252255; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+weIGxwXo/8De0+gZFSXrhCKLRAnzFdsl4El7qME/iI=; b=qY3mjI+A4vx83qdUCF/JMNvfDoR0+U+XGEmvST0iR6GaeQm7nsLhG7MD+QQaVePdc9iLTe 7JJKLbEGpU7s2ruCu8bWHQ/ChwZsMdcXFal/0iqf4EwQYtx5/VQTvw/w+Zf7Ss4WUDP1tM 6Ex0m9fpNPifqGBp8tMZi5tYWID9vEw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1700252255; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+weIGxwXo/8De0+gZFSXrhCKLRAnzFdsl4El7qME/iI=; b=ggdqQt7qkeSjrNeWHw6XEfu7mluJPT3abtHlPhApAClR8zfSyqQDudovumgOFdJAQbVzd7 tOwDjp13MQ1mzdAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D02E41341F for ; Fri, 17 Nov 2023 20:17:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qJEGMV/KV2VnGgAAMHmgww (envelope-from ) for ; Fri, 17 Nov 2023 20:17:35 +0000 Date: Fri, 17 Nov 2023 21:17:34 +0100 From: Michal Jires To: gcc-patches@gcc.gnu.org Subject: [PATCH 7/7] lto: partition specific lto_clone_numbers Message-ID: <7c76f258995c20eb0b44eb021f44039718dc45ce.1700222403.git.mjires@suse.cz> References: <18cc1c3980551ac1881eea6e78811a629c7baa82.1700222403.git.mjires@suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <18cc1c3980551ac1881eea6e78811a629c7baa82.1700222403.git.mjires@suse.cz> Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -3.02 X-Spamd-Result: default: False [-3.02 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; CLAM_VIRUS_FAIL(0.00)[failed to scan and retransmits exceed]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.17)[-0.859]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.75)[98.89%] X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782843808116600994 X-GMAIL-MSGID: 1782843808116600994 Replaces "lto_priv.$clone_number" by "lto_priv.$partition_hash.$partition_specific_clone_number". To reduce divergence for incremental LTO. Bootstrapped/regtested on x86_64-pc-linux-gnu gcc/lto/ChangeLog: * lto-partition.cc (set_clone_partition_name_checksum): New. (CHECKSUM_STRING): New. (privatize_symbol_name_1): Use partition hash for lto_priv. (lto_promote_cross_file_statics): Use set_clone_partition_name_checksum. (lto_promote_statics_nonwpa): Changed clone_map type. --- gcc/lto/lto-partition.cc | 49 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc index eb31ecba0d3..a2ce24eea23 100644 --- a/gcc/lto/lto-partition.cc +++ b/gcc/lto/lto-partition.cc @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-fnsummary.h" #include "lto-partition.h" #include "sreal.h" +#include "md5.h" #include #include @@ -1516,8 +1517,36 @@ validize_symbol_for_target (symtab_node *node) } } -/* Maps symbol names to unique lto clone counters. */ -static hash_map *lto_clone_numbers; +/* Maps symbol names with partition checksum to unique lto clone counters. */ +using clone_map = hash_map>, unsigned>; +static clone_map *lto_clone_numbers; +uint64_t current_partition_checksum = 0; + +/* Computes a quick checksum to distinguish partitions of clone numbers. */ +void +set_clone_partition_name_checksum (ltrans_partition part) +{ +#define CHECKSUM_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), &ctx) + struct md5_ctx ctx; + md5_init_ctx (&ctx); + + CHECKSUM_STRING (part->name); + + lto_symtab_encoder_iterator lsei; + lto_symtab_encoder_t encoder = part->encoder; + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + symtab_node *node = lsei_node (lsei); + CHECKSUM_STRING (node->name ()); + } + + uint64_t checksum[2]; + md5_finish_ctx (&ctx, checksum); + current_partition_checksum = checksum[0]; +#undef CHECKSUM_STRING +} /* Helper for privatize_symbol_name. Mangle NODE symbol name represented by DECL. */ @@ -1531,10 +1560,16 @@ privatize_symbol_name_1 (symtab_node *node, tree decl) return false; const char *name = maybe_rewrite_identifier (name0); - unsigned &clone_number = lto_clone_numbers->get_or_insert (name); + + unsigned &clone_number = lto_clone_numbers->get_or_insert ( + std::pair {name, current_partition_checksum}); + + char lto_priv[32]; + sprintf (lto_priv, "lto_priv.%lu", current_partition_checksum); + symtab->change_decl_assembler_name (decl, clone_function_name ( - name, "lto_priv", clone_number)); + name, lto_priv, clone_number)); clone_number++; if (node->lto_file_data) @@ -1735,11 +1770,13 @@ lto_promote_cross_file_statics (void) part->encoder = compute_ltrans_boundary (part->encoder); } - lto_clone_numbers = new hash_map; + lto_clone_numbers = new clone_map; /* Look at boundaries and promote symbols as needed. */ for (i = 0; i < n_sets; i++) { + set_clone_partition_name_checksum (ltrans_partitions[i]); + lto_symtab_encoder_iterator lsei; lto_symtab_encoder_t encoder = ltrans_partitions[i]->encoder; @@ -1778,7 +1815,7 @@ lto_promote_statics_nonwpa (void) { symtab_node *node; - lto_clone_numbers = new hash_map; + lto_clone_numbers = new clone_map; FOR_EACH_SYMBOL (node) { rename_statics (NULL, node);