From patchwork Thu Jan 18 12:08:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 84338 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C46143858C36 for ; Thu, 18 Jan 2024 12:10:11 +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 45ACE3858C36 for ; Thu, 18 Jan 2024 12:09:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45ACE3858C36 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 45ACE3858C36 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=1705579778; cv=none; b=p+0TFdBjHUAUMJR6VwJIqaCrM0AxxbZw4+FCSN3PNFlWkNorCSZ1z0BIK9byU3jH+ULYEPIDQoOlbklGj8Qab8zzkGc2bkQaUH+5mki5M9GffnOaRPEd4fNkXESAUyh/UsUHXLTUxvAjlkfgTtGRI0jsSCbVt6PlIXMCBwS2NRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705579778; c=relaxed/simple; bh=bEN2Ghg8tkI6XmYjv40kyS1A6DOExLzLUEdnBmTZ7NM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=Z0RFkYw57RZbezUVv2SvsqCXYG/FLB8cloqhLHh1PRgXY6DNBWhQm7Pp8c+3N3Av0w6N+FkIHAQiphytwBA9jankVTted78lmhZbLH6hxA/kHkk5qhFFhw1XmoaB33pWT0YqhKMj2m0QPWkSsWR4qBUH6cEZJN8u4mTc7fMAC3A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (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 13D1021EC7 for ; Thu, 18 Jan 2024 12:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705579772; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=1MP4R26mbhO8TAZLbggJNbqwvGhvl8Sf1DyeAnIsbSE=; b=NtMW5OUlJslV9Q+NWuYpxQCpYF2qQ0dsz1/9Hn7jxLM22Zf2pXZaMbO67xAPWYUsz/e9Q/ IP/NZkHYnLuRgCr1zlvQ4YgUWag3llmoOnkdWxhXHgiauN//dfkaUvmCELIwKtHtZ6AySD uZKGMsUeHZ0JmmBvWiAzYgTwAKCoNbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705579772; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=1MP4R26mbhO8TAZLbggJNbqwvGhvl8Sf1DyeAnIsbSE=; b=dWksJF5F87L2sjbS1C79ZnOgv/P0Z7Ud9hFPE81JrI1OQKatHKkTvMlQbY+9Mqi4sdn+Ir I+qUDJj7z8HGSWBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705579772; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=1MP4R26mbhO8TAZLbggJNbqwvGhvl8Sf1DyeAnIsbSE=; b=NtMW5OUlJslV9Q+NWuYpxQCpYF2qQ0dsz1/9Hn7jxLM22Zf2pXZaMbO67xAPWYUsz/e9Q/ IP/NZkHYnLuRgCr1zlvQ4YgUWag3llmoOnkdWxhXHgiauN//dfkaUvmCELIwKtHtZ6AySD uZKGMsUeHZ0JmmBvWiAzYgTwAKCoNbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705579772; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=1MP4R26mbhO8TAZLbggJNbqwvGhvl8Sf1DyeAnIsbSE=; b=dWksJF5F87L2sjbS1C79ZnOgv/P0Z7Ud9hFPE81JrI1OQKatHKkTvMlQbY+9Mqi4sdn+Ir I+qUDJj7z8HGSWBQ== Date: Thu, 18 Jan 2024 13:08:32 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix memory leak in vectorizable_store MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 1.01 X-Spamd-Result: default: False [1.01 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.98)[-0.977]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_SPAM_SHORT(2.59)[0.863]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[99.99%] X-Spam-Status: No, score=-10.8 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+patchwork=sourceware.org@gcc.gnu.org Message-Id: <20240118121011.C46143858C36@sourceware.org> The following fixes a memory leak in vectorizable_store which happens because the functions populating gvec_oprnds[i] will call .create () on the incoming vector, leaking what we've previously allocated. Bootstrap and regtest running on x86_64-unknown-linux-gnu. * tree-vect-stmts.cc (vectorizable_store): Do not allocate storage for gvec_oprnds elements. --- gcc/tree-vect-stmts.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index cabd4e3ae86..69d76c3b350 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -8772,7 +8772,7 @@ vectorizable_store (vec_info *vinfo, tree vec_mask = NULL; auto_delete_vec> gvec_oprnds (group_size); for (i = 0; i < group_size; i++) - gvec_oprnds.quick_push (new auto_vec (ncopies)); + gvec_oprnds.quick_push (new auto_vec ()); if (memory_access_type == VMAT_LOAD_STORE_LANES) {