From patchwork Tue Nov 30 01:06:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1561407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=KttHEDwJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4J33vZ2KfXz9sRR for ; Tue, 30 Nov 2021 12:06:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B637385AC2A for ; Tue, 30 Nov 2021 01:06:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B637385AC2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638234388; bh=Cw70AMZmUZ6rURcQWcktfGYUmb0QIGADeGxsPRhTL80=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KttHEDwJp7zTqQdTS/7gGBjkZfjlyLbzkz48LKM6Hv02cht9ZDTYXz3VJYRwboeW1 CdC4KklhtJWYJ+EIDhXz5iBgmvWiAl5fXvFcgpMX13oHOmXbArGXJIoj9z74c9IIou R2ci3lF6DpiRLPaRvw19HdGb23T8EHvppDwJA8UY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 725B0385840B for ; Tue, 30 Nov 2021 01:06:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 725B0385840B Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-hrxfq3NTMKu-8m01CQEPFA-1; Mon, 29 Nov 2021 20:06:05 -0500 X-MC-Unique: hrxfq3NTMKu-8m01CQEPFA-1 Received: by mail-qv1-f69.google.com with SMTP id kj12-20020a056214528c00b003bde2e1df71so27095419qvb.18 for ; Mon, 29 Nov 2021 17:06:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:from:subject; bh=rcGXdFQEwPHTfjBEFGVBXuOCUlq+ht9NkF+JWeEg1HI=; b=D1cufksz1g4yDGLVOqYet+dpWaEdpy7alVPevEVVho7N84P+FV9lqWLTDT81cBKgIL U0jb7JtyrMg2bVRbQP3QtSFXjQUMUy1mBe0EX8yytkDFXfHair3npqyP2H49nF4HWu4V urdkkbdroVrw4/BGfpaf8OLe0BKWRurS0YKtH5t+FVXRfeVfHIwomHpT3+DcyWkA5FAg rJaeIKxUUdDG8yaGRkqgb+pdAHhm8BZLy9os5vKbEoGl11oOnHEEL7WDcbjJdgFmFbSL au9KTvM5O6Nr+tQGz71jPtBJJnIoFpMz7Zh+npiDRq6xOf2OXohFsYt8pQ7zHSeYHqMC EB9g== X-Gm-Message-State: AOAM531BTUX0BgJCTSkTQ3PFBX2KLshFmbH68F3dTKM5XLbLov+FLU0z 67MhNSlFP9PiyqIhqjLE6Ix1vl5X0Kv4EaCDerm57VU9pjHmuUGV9X4FR7dGrPn1uU8CRbzaOM4 17ETn72voFoh1jN6Qnr2HFyS8YsgzIrnKT18ffvXATXugjqgoYvLYTROUFhWHMtyEvPaTHA== X-Received: by 2002:a05:6214:27cd:: with SMTP id ge13mr35112392qvb.75.1638234364971; Mon, 29 Nov 2021 17:06:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEuXiWSj0VkOfUNxggN6AvpHMhjA9/udjDjNMUp/n0qmwITJXBN8e3rwPBg+N9mVn4jo3qNw== X-Received: by 2002:a05:6214:27cd:: with SMTP id ge13mr35112371qvb.75.1638234364725; Mon, 29 Nov 2021 17:06:04 -0800 (PST) Received: from [192.168.0.102] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id q185sm8263814qke.64.2021.11.29.17.06.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Nov 2021 17:06:04 -0800 (PST) Message-ID: <8f4cea4d-9f7b-3ffd-e8da-f391af861f3a@redhat.com> Date: Mon, 29 Nov 2021 20:06:01 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 To: gcc-patches Subject: [COMMITTED] tree-optimization/103467 - Don't reuse reference after potential resize. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" After making sure the vector is large enough, we use a reference to the object through the rest of the function.  One path however requests the def chain for a dependant ssa-name, and if that request caused a resize, then our reference is no longer valid. On this path, simply use the object directly. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed as obvious. Andrew commit ab202b659dbdfd3a1f45ffe7a5052f35b5e8fa6d Author: Andrew MacLeod Date: Mon Nov 29 19:53:50 2021 -0500 Don't reuse reference after potential resize. When a new def chain is requested, any existing reference may no longer be valid, so just use the object directly. PR tree-optimization/103467 * gimple-range-gori.cc (range_def_chain::register_dependency): Don't use an object reference after a potential resize. diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 911d7ac4ec8..0dba34b58c5 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -278,11 +278,12 @@ range_def_chain::register_dependency (tree name, tree dep, basic_block bb) { // Get the def chain for the operand. b = get_def_chain (dep); - // If there was one, copy it into result. + // If there was one, copy it into result. Access def_chain directly + // as the get_def_chain request above could reallocate the vector. if (b) - bitmap_ior_into (src.bm, b); + bitmap_ior_into (m_def_chain[v].bm, b); // And copy the import list. - set_import (src, NULL_TREE, get_imports (dep)); + set_import (m_def_chain[v], NULL_TREE, get_imports (dep)); } else // Originated outside the block, so it is an import.