From patchwork Wed Aug 28 10:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1977784 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.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u7zUyRRp; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JpCFkwbB; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u7zUyRRp; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=JpCFkwbB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wv1GX3dgFz1yZd for ; Wed, 28 Aug 2024 20:43:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DCA9385EC11 for ; Wed, 28 Aug 2024 10:43:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 161FB384B42C for ; Wed, 28 Aug 2024 10:42:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 161FB384B42C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 161FB384B42C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724841770; cv=none; b=Uw3GhX7KIEhfYsVnESEtMvcydrTrOaBze5G4kXsxC1QtFi0rWl64wEPnNOfemD6F5QJPMDldVvbPqJk4ZYZ5kd46uda1mnEf5ro/5XDYB0pN18/DeV3VNugSZdUMh04KwM6x9SmIC7KFqrjsz3EpvFx88BXR1+U44LcD8ykQPJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724841770; c=relaxed/simple; bh=WTy+305ScBtccbAbIz5BIisTQQZ625Hd3JWykhRJGvo=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=LT/Col9EzhMHlou0ckAEwf3owmR8/uCAGoYDc+1MIyAI5KUy9HPCDzwL6QFFtVOdo2ahnq6lsu4iKavbLuUq2/c4tQXG13IO5REGciNVwP5WqtuZhpRZePX8sJ6j3hpQzzTp96ei+LjkkYu1NmseiBM5aIpeUakglJvMV53B0+4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (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-out1.suse.de (Postfix) with ESMTPS id 311E4219DF for ; Wed, 28 Aug 2024 10:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724841768; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=OYjdlX0Ih38d3S4jBAJVCjuxTK3ASz5MqnGyEoewPz4=; b=u7zUyRRpQNQFNLZKK20O3D2Yf2vqc8r9F3Ky+KUnkogkGJm1DzrvQ85AfQ3kPQrh110gbo DIIJ8ZCHm4tje25s6lEUUjLhMj3DlQn87xhACoIQXJgBhBbYnPlTqVJic3kpqCvOV1LEbD /uOiLmTgjlcCDQCEvaD2HjJ/jXTSob0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724841768; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=OYjdlX0Ih38d3S4jBAJVCjuxTK3ASz5MqnGyEoewPz4=; b=JpCFkwbBbFsIbSgsauDUEKn7CchFQ5zwHi0kE8W4xFDgynTtoVeCbb3GbaVqvxLlYqIf8N pOnLnPP+lAoO/7Dg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724841768; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=OYjdlX0Ih38d3S4jBAJVCjuxTK3ASz5MqnGyEoewPz4=; b=u7zUyRRpQNQFNLZKK20O3D2Yf2vqc8r9F3Ky+KUnkogkGJm1DzrvQ85AfQ3kPQrh110gbo DIIJ8ZCHm4tje25s6lEUUjLhMj3DlQn87xhACoIQXJgBhBbYnPlTqVJic3kpqCvOV1LEbD /uOiLmTgjlcCDQCEvaD2HjJ/jXTSob0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724841768; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=OYjdlX0Ih38d3S4jBAJVCjuxTK3ASz5MqnGyEoewPz4=; b=JpCFkwbBbFsIbSgsauDUEKn7CchFQ5zwHi0kE8W4xFDgynTtoVeCbb3GbaVqvxLlYqIf8N pOnLnPP+lAoO/7Dg== Date: Wed, 28 Aug 2024 12:42:48 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix leak of SLP nodes when building store interleaving MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-1.07 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.33)[-0.325]; NEURAL_HAM_SHORT(-0.14)[-0.705]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] X-Spam-Score: -1.07 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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 Message-Id: <20240828104314.5DCA9385EC11@sourceware.org> The following fixes a leak of the discovered single-lane store SLP nodes from which we only use their children. This uncovers a latent reference counting issue in the interleaving build where we fail to increment their reference count. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vect-slp.cc (vect_build_slp_store_interleaving): Fix reference counting. (vect_build_slp_instance): Release rhs_nodes. --- gcc/tree-vect-slp.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 79d83efb015..d110c992b04 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3486,6 +3486,7 @@ vect_build_slp_store_interleaving (vec &rhs_nodes, { SLP_TREE_CHILDREN (perm) .quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]); + SLP_TREE_CHILDREN (rhs_nodes[j])[l]->refcnt++; for (unsigned k = 0; k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k) { @@ -3949,6 +3950,9 @@ vect_build_slp_instance (vec_info *vinfo, /* Now we assume we can build the root SLP node from all stores. */ node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts); + while (!rhs_nodes.is_empty ()) + vect_free_slp_tree (rhs_nodes.pop ()); + /* Create a new SLP instance. */ slp_instance new_instance = XNEW (class _slp_instance); SLP_INSTANCE_TREE (new_instance) = node;