From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id C3E29386189F for ; Wed, 23 Sep 2020 20:48:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C3E29386189F Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-558-RjjScNhWN0-gl52PfbzgDA-1; Wed, 23 Sep 2020 16:48:16 -0400 X-MC-Unique: RjjScNhWN0-gl52PfbzgDA-1 Received: by mail-qk1-f199.google.com with SMTP id s141so603389qka.13 for ; Wed, 23 Sep 2020 13:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cCgRPXDz9WEVFEcpfUDYA4VdLDzzi0qCqThjMOWpgeY=; b=PWL6P48vhM75E1djQueCLyx47PcSD1mRXWSy4JleMaKd2Q4M/bxwPZmulIcbUB06/G 9k0fomrANTh2g8gv90LjzSEjspQXwGLUWm1ywh3w+5gAxU/ES4+JS3c8/AUO9LCNR9d5 qEA1eQ0pXbXVfOYEr3Om1DWrzs1nO9gD3VZ4cCqI8E1AC93Un/fW1Mac36u4IX7jSRk/ e1EQLeFNfQKmwOkBG8nlaB2KEiXUly7TM9HS8htbvIyOqJVZQrKCA3HgSwDw/LVQbe22 +nK6vip56/2GIPLZcghR7KSnYwQsiLQiHtU5e82h0KNm17sG1LRspnCPJI+eZNiS79Hr zkxw== X-Gm-Message-State: AOAM533fp5Pu6mtp2RNYmjseWLTeK4Al7pSqrurAnmIkwuJK2EOyUcFk hLWDUUWtzZpmX30Y1IVAj7xjL5nuPoDJZPpdfDlLpGGpABUiKxZDqiEdzaf8YXup7R0oAFMTcWV 73RGDFnhbdnzaSJ3VWA== X-Received: by 2002:a37:a3d8:: with SMTP id m207mr1686553qke.175.1600894095222; Wed, 23 Sep 2020 13:48:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkRYBy8MI1A/g4EESS6Ba1potD/9sumbZ35dAyV0l/b7k0ePDXePwFURmlQojCLmgO/yYnqw== X-Received: by 2002:a37:a3d8:: with SMTP id m207mr1686522qke.175.1600894094717; Wed, 23 Sep 2020 13:48:14 -0700 (PDT) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id d10sm763823qko.32.2020.09.23.13.48.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Sep 2020 13:48:13 -0700 (PDT) Subject: Re: [PATCH] tree-optimization/97151 - improve PTA for C++ operator delete To: Richard Biener , gcc-patches@gcc.gnu.org References: <5878a705-6101-d7ac-fe11-13664a53b220@redhat.com> <0A92F1D5-5521-4F1A-B297-6637479FB278@suse.de> From: Jason Merrill Message-ID: <5e4be9c0-3781-c983-ce05-09763bac67e5@redhat.com> Date: Wed, 23 Sep 2020 16:48:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <0A92F1D5-5521-4F1A-B297-6637479FB278@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-16.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 23 Sep 2020 20:48:19 -0000 On 9/23/20 2:42 PM, Richard Biener wrote: > On September 23, 2020 7:53:18 PM GMT+02:00, Jason Merrill wrote: >> On 9/23/20 4:14 AM, Richard Biener wrote: >>> C++ operator delete, when DECL_IS_REPLACEABLE_OPERATOR_DELETE_P, >>> does not cause the deleted object to be escaped. It also has no >>> other interesting side-effects for PTA so skip it like we do >>> for BUILT_IN_FREE. >> >> Hmm, this is true of the default implementation, but since the function >> >> is replaceable, we don't know what a user definition might do with the >> pointer. > > But can the object still be 'used' after delete? Can delete fail / throw? > > What guarantee does the predicate give us? The deallocation function is called as part of a delete expression in order to release the storage for an object, ending its lifetime (if it was not ended by a destructor), so no, the object can't be used afterward. A deallocation function that throws has undefined behavior. >>> Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. >>> >>> Richard. >>> >>> 2020-09-23 Richard Biener >>> >>> PR tree-optimization/97151 >>> * tree-ssa-structalias.c (find_func_aliases_for_call): >>> DECL_IS_REPLACEABLE_OPERATOR_DELETE_P has no effect on >>> arguments. >>> >>> * g++.dg/cpp1y/new1.C: Adjust for two more handled transforms. >>> --- >>> gcc/testsuite/g++.dg/cpp1y/new1.C | 4 ++-- >>> gcc/tree-ssa-structalias.c | 2 ++ >>> 2 files changed, 4 insertions(+), 2 deletions(-) >>> >>> diff --git a/gcc/testsuite/g++.dg/cpp1y/new1.C >> b/gcc/testsuite/g++.dg/cpp1y/new1.C >>> index aa5f647d535..fec0088cb40 100644 >>> --- a/gcc/testsuite/g++.dg/cpp1y/new1.C >>> +++ b/gcc/testsuite/g++.dg/cpp1y/new1.C >>> @@ -69,5 +69,5 @@ test_unused() { >>> delete p; >>> } >>> >>> -/* { dg-final { scan-tree-dump-times "Deleting : operator delete" 5 >> "cddce1"} } */ >>> -/* { dg-final { scan-tree-dump-times "Deleting : _\\d+ = operator >> new" 7 "cddce1"} } */ >>> +/* { dg-final { scan-tree-dump-times "Deleting : operator delete" 6 >> "cddce1"} } */ >>> +/* { dg-final { scan-tree-dump-times "Deleting : _\\d+ = operator >> new" 8 "cddce1"} } */ >>> diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c >>> index 44fe52e0f65..f676bf91e95 100644 >>> --- a/gcc/tree-ssa-structalias.c >>> +++ b/gcc/tree-ssa-structalias.c >>> @@ -4857,6 +4857,8 @@ find_func_aliases_for_call (struct function >> *fn, gcall *t) >>> point for reachable memory of their arguments. */ >>> else if (flags & (ECF_PURE|ECF_LOOPING_CONST_OR_PURE)) >>> handle_pure_call (t, &rhsc); >>> + else if (fndecl && DECL_IS_REPLACEABLE_OPERATOR_DELETE_P >> (fndecl)) >>> + ; >>> else >>> handle_rhs_call (t, &rhsc); >>> if (gimple_call_lhs (t)) >>> >