From patchwork Thu Feb 23 11:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 60906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp250514wrd; Thu, 23 Feb 2023 03:04:13 -0800 (PST) X-Google-Smtp-Source: AK7set+hZiSd1SL9iizej9DgNhnmKsWQTrU3BuGwCbTVRdeRFKwz6jbfNMqj/r2ZcDpJmqJcZViV X-Received: by 2002:a05:6402:785:b0:4af:62ad:a36 with SMTP id d5-20020a056402078500b004af62ad0a36mr5129413edy.27.1677150253402; Thu, 23 Feb 2023 03:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677150253; cv=none; d=google.com; s=arc-20160816; b=JmhT1MOnZRGa25xqovKbDYUQC8ccM9QqXAIqSppgJZn5I9Ej/W41TeMoVaYBAFJ6Am oupdg8EynG7h3XfjOEvLuqH2BDIFRGWbnjh9dsGgr4cJLEgNZ3XhxYdi6crQX77HRRAk DfnbqZ0u0r2GIWwj2XDRs8AyzjL2m63kwjmQl8IHSxkqIT+xNoz/pfhbN3E1s23NmIOY aRUbPWgULBw336PzoKkyW9YvPAX34ERyBe8HPDS/2X4wgshydULOtcHGwzLfZt9dDSHD 8OjyLIQ4ja+c4I0sk39DrEc8CMwPek6KHlvP1wpB3Ut/DNMyKZ6YZ9lmvbQ688SjGd6Y 87lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=VzMKnjxYs+hYtp/igO4NHiRX4axF6mEfXAMn6PYZKDs=; b=tYJsaxBrWpLBWmWs43DFW3yoxJpL5/WNyVFfY6Up3owCqJTdrQo7bZG/EcdlJBTu6t sT2zHykmjRmlJ/BehKFgUVVVrkwhASvQFKOaRxvqkGEGDfib8u1BZDAQR+Rw3ezcwIJy nEtydS54Iqk8qB4X7hCicyzoftqqjkT5qITaniF6GVl4ZKOMkLKPHWb8kv2XuusJffFO FwiJCR7ehqn3OCHKIK6sdQm77cgFF5+An/rDhzMjwOl4TiFSrpGGck4WJ/KKQt8TrjnP /orpBNvET6EPmGy4wKgjIYFgpJS3k5dPHiLGMyOvA/vuk3LKXwZKRlpNTkP2OF1y5N+6 SlVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ytYT6lqz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o19-20020a056402039300b004ab250bcee2si1736203edv.644.2023.02.23.03.04.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 03:04:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ytYT6lqz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F14613857BA4 for ; Thu, 23 Feb 2023 11:04:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F14613857BA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677150252; bh=VzMKnjxYs+hYtp/igO4NHiRX4axF6mEfXAMn6PYZKDs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ytYT6lqzpCM0dCpZU3WbYpjWCD/snuEo5emq99OaB4NGwLDNyYTdJ5brmXTa8cL9j /S7FYpdsGKIboDRlQddu/ZW8nbB9201hn3HosHMFS1tF50Mzhxnznw0SpnoSO5cUuo QUgNYV/XP/FarUVmxnk0g2gmjMqi5/c7d1jlASbo= 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 900C13858C5E for ; Thu, 23 Feb 2023 11:03:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 900C13858C5E 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 3F76C5BF5E for ; Thu, 23 Feb 2023 11:03:26 +0000 (UTC) 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 2D39C139B5 for ; Thu, 23 Feb 2023 11:03:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OimxCf5H92OzIAAAMHmgww (envelope-from ) for ; Thu, 23 Feb 2023 11:03:26 +0000 Date: Thu, 23 Feb 2023 12:03:25 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix memory leak in if-conversion MIME-Version: 1.0 Message-Id: <20230223110326.2D39C139B5@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 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 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758619503875194489?= X-GMAIL-MSGID: =?utf-8?q?1758619503875194489?= The following fixes if-conversion failing to release data-references and the data-reference vector. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. * tree-if-conv.cc (tree_if_conversion): Properly manage memory of refs and the contained data references. --- gcc/tree-if-conv.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index 0e384e36394..f133102ad33 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -3534,7 +3534,7 @@ tree_if_conversion (class loop *loop, vec *preds) auto_vec writes_to_lower; bitmap exit_bbs; edge pe; - vec refs; + auto_vec refs; again: rloop = NULL; @@ -3544,7 +3544,6 @@ tree_if_conversion (class loop *loop, vec *preds) need_to_predicate = false; need_to_rewrite_undefined = false; any_complicated_phi = false; - refs.create (5); /* Apply more aggressive if-conversion when loop or its outer loop were marked with simd pragma. When that's the case, we try to if-convert @@ -3701,8 +3700,10 @@ tree_if_conversion (class loop *loop, vec *preds) data_reference_p dr; unsigned int i; for (i = 0; refs.iterate (i, &dr); i++) - free (dr->aux); - + { + free (dr->aux); + free_data_ref (dr); + } refs.truncate (0); if (ifc_bbs)