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: 199952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp67823dyb; Mon, 12 Feb 2024 09:40:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGi9AtR4FPydFL0b2zn3PFLBP5JeIrXOkUuoWrzfJmBmcMy0+psMjVdlUaH8qx1Ow0fLu1e X-Received: by 2002:ac8:57d0:0:b0:42c:7f52:9807 with SMTP id w16-20020ac857d0000000b0042c7f529807mr2228783qta.42.1707759643563; Mon, 12 Feb 2024 09:40:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707759643; cv=pass; d=google.com; s=arc-20160816; b=bMO7vkdlxSTTEL3tje1+KNsOItHVqFChmrQaNAKGXhBVltZcJDBDtBxnEvSIUrBfYH 1/ly6cEObo+MPsPSD1HKKZuDgLL4eevCUAytDecMPEuxTdTxwnWH1uWAIuXYXZksu346 im8K0hpPNbioBBfMpEuTY9NAyV2PSvcI0Sd9rxKboixwPkMkLDIDq1VdKqx1TMvI+lrg eYMG2RzeKDKpxIdezFBO9gUKroywAXvgzx2NNtp5ERnCmO8g4xV7iNp6ODFGj8mwS4xG 5nwDn9kNyBaM0oyv/E14l1Iwcm4TlVGWnW99kIujqKaBdEtUsY2Z6Mwle+q6Kzx4l66u 6qNw== 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:mime-version:message-id:date :user-agent:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=d1otElOXZLm7DRChUflxY/KYwXqyfCYtn+HAvRdE7k0=; fh=14si1PYHqCwfbh4//iJoPknemnjTTdqTmlLeE21+xzg=; b=0pm2RuiDXhGSmSQ3slH6eK938udBh/cA67KTO6QRBJt3pD5rv+HDriJWDWz43NvP87 DGWouzaWr+21hjSSdeTg3HysH0ZlkQgQxi+12X5yUqy3y2N8XGGak/i9pEnTKhZeFrg7 CAg9FIcrG8YzSGalBJ1E7K2Ac6X3X6Pb3ydvBlfBEOxLfHY4bD3k6twQHGxmvg4jMpLn MEVTYHd6AlEEdG6U3insR9oc9Q2w93Zm77K03npihe4u4lhjRj9iUieUwbwQ21Vme3D6 MW3HP3D88GmUb0Jm8BgD9VqyWFLE4sg1om5bw/qavn+ZnPrOoHkyi9UiVCz4OhVgg9F2 gEwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=xavHFtFR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=xavHFtFR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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" X-Forwarded-Encrypted: i=2; AJvYcCXXFOArCaO2bvPKXXdSBK7TfHoMdVMhVUMt7sCx6aMc51ztYqMWECGMhOramJbPMRM+KvIXNoPlaVo4lg6nknUqC6U6rw== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g9-20020ac87f49000000b0042bf6e0296asi917943qtk.541.2024.02.12.09.40.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:40:43 -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=xavHFtFR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=xavHFtFR; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 4177A3858C78 for ; Mon, 12 Feb 2024 17:40:43 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790715775627389038 X-GMAIL-MSGID: 1790715775627389038 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