From patchwork Mon Feb 12 17:39:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1897875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=xavHFtFR; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=a1gYNGF0; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=xavHFtFR; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=a1gYNGF0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TYWvD4y6lz23hw for ; Tue, 13 Feb 2024 04:40:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C5E53858C30 for ; Mon, 12 Feb 2024 17:40:20 +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.223.131]) by sourceware.org (Postfix) with ESMTPS id 524AF3858D38 for ; Mon, 12 Feb 2024 17:39:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 524AF3858D38 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 524AF3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707759598; cv=none; b=cX0//66Fny1VyNBw7pToH0tbbWK5aAYrjT9IOveP6T3/f3L3d1QnFl9jckwfrXz3DioAVxuHncH8VvsYoxc3mZW44zWaOX8rKptQPMwC2OGC2+iDsLVOIwG4ht2xdJ9Ji2ng1iV5JZbNjqWoAkHRiH/pJqb5KMv5hG9X64n4O8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707759598; c=relaxed/simple; bh=A0z9rajAlJKpQvwhwUsiqlAcaPZ2qD+Rg+p9bNNxaBo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=hl3lUKmnoVxBpG5WdddhDisH39SKIDd9vSDc0f70C3WFNjxLhdvOhCIQDAzE+PArxJCo5yUMSLEvrR2SrSoMjcfXDQkzYTJxKzjd/0Wf0q5Qa7w5fMqLaXoBgUTqVhJRbvzRJO/X8ZImdXVFj40KqDhEZcoFXlTlLHzrDbekY78= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 4B3141FBF8; Mon, 12 Feb 2024 17:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707759595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=d1otElOXZLm7DRChUflxY/KYwXqyfCYtn+HAvRdE7k0=; b=xavHFtFR4Pg/ksDQEDJNot+mI2DsiKzoQZS82ITF3VwOPUluQASbXALrXLl9s2bS5xiZUB ECCwRt3poyZW/clAWbrhCLrT7GkW/+eRoaUU1LPRiNfJx8WbikI9Ol1qLUPa8s+5qivEoT l9wJ8oEYXUb2Wt6mipi+b51EtdlJ2bI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707759595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=d1otElOXZLm7DRChUflxY/KYwXqyfCYtn+HAvRdE7k0=; b=a1gYNGF0KVyEWh92I2/chSFD2BPJt3EdoViscX6uG/BLGiCdiT/YndyS6SHHoSM5wLq2QG tzNNhdQdgH+sPtAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707759595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=d1otElOXZLm7DRChUflxY/KYwXqyfCYtn+HAvRdE7k0=; b=xavHFtFR4Pg/ksDQEDJNot+mI2DsiKzoQZS82ITF3VwOPUluQASbXALrXLl9s2bS5xiZUB ECCwRt3poyZW/clAWbrhCLrT7GkW/+eRoaUU1LPRiNfJx8WbikI9Ol1qLUPa8s+5qivEoT l9wJ8oEYXUb2Wt6mipi+b51EtdlJ2bI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707759595; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=d1otElOXZLm7DRChUflxY/KYwXqyfCYtn+HAvRdE7k0=; b=a1gYNGF0KVyEWh92I2/chSFD2BPJt3EdoViscX6uG/BLGiCdiT/YndyS6SHHoSM5wLq2QG tzNNhdQdgH+sPtAw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 42B9A13212; Mon, 12 Feb 2024 17:39:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id icQIEOtXymW7bwAAn2gu4w (envelope-from ); Mon, 12 Feb 2024 17:39:55 +0000 From: Martin Jambor To: GCC Patches Cc: Richard Biener , Jan Hubicka Subject: [PATCH] ipa: call destructors on lattices before freeing them (PR 113476) User-Agent: Notmuch/0.38.2 (https://notmuchmail.org) Emacs/29.2 (x86_64-suse-linux-gnu) Date: Mon, 12 Feb 2024 18:39:54 +0100 Message-ID: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-0.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; TO_DN_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[13.25%] X-Spam-Level: X-Spam-Score: -0.10 X-Spam-Status: No, score=-11.0 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, In PR 113476 we have discovered that ipcp_param_lattices is no longer a POD and should be destructed. This patch does that, calling destructor on each element of the array containing them when the corresponding summary of a node is freed. An alternative would be to change the XCNEWVEC-and-placement-new to initializations in constructors of all things in ipcp_param_lattices and then simply use normal operators new and delete. I am not sure, the initialization through XCNEWVEC may be a bit more efficient although that is probably not a big concern. In the end, I opted for a simpler solution for stage 4. I have verified that valgrind no longer reports lost memory blocks allocated within ipcp_vr_lattice::meet_with_1 on the preprocessed source (dwarf2out.i) attached to Bugzilla. The patch also passes bootstrap and LTO bootstrap and testing on x86_64-linux. OK for master? Thanks, Martin gcc/ChangeLog: 2024-02-09 Martin Jambor PR tree-optimization/113476 * ipa-prop.h (ipa_node_params::~ipa_node_params): Moved... * ipa-cp.cc (ipa_node_params::~ipa_node_params): ...here. Added destruction of lattices. --- gcc/ipa-cp.cc | 17 +++++++++++++++++ gcc/ipa-prop.h | 9 --------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index e85477df32d..9864ff052de 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -399,6 +399,23 @@ public: bool virt_call; }; +/* Destructor of node function summary, placed here because it mainly must + destruct value range lattices not known outside of this source file. */ + +ipa_node_params::~ipa_node_params () +{ + if (lattices) + { + int count = ipa_get_param_count (this); + for (int i = 0; i < count; i++) + lattices[i].~ipcp_param_lattices (); + free (lattices); + } + vec_free (descriptors); + known_csts.release (); + known_contexts.release (); +} + /* Allocation pools for values and their sources in ipa-cp. */ object_allocator > ipcp_cst_values_pool diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 9c78dc9f486..fe401640824 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -670,15 +670,6 @@ ipa_node_params::ipa_node_params () { } -inline -ipa_node_params::~ipa_node_params () -{ - free (lattices); - vec_free (descriptors); - known_csts.release (); - known_contexts.release (); -} - /* Intermediate information that we get from alias analysis about a particular parameter in a particular basic_block. When a parameter or the memory it references is marked modified, we use that information in all dominated