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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4A7023858D39 for ; Tue, 28 Mar 2023 15:33:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A7023858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680017587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oxaAVPRtWnUz0dI6hZvjtqS3uY1gOUxVpxMt0N62xaw=; b=E7RM5mQeZUq3sRx78M4eYgk83YjUV2MuzIVhPdethLyCUbOdbZSwYcda2AfDS1WamsZlWO RBC0ELr+BvpepeYlDNVOo/oNPi3+273efw4fwEiEun/16OBg7cEJ23L4AlOu5XEjdr0CcH Sd8NJq5nVMDC4LPz8D7XVAtIVmA9mSc= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-4_BdIMcdOSSCU5iiXS7cLg-1; Tue, 28 Mar 2023 11:33:03 -0400 X-MC-Unique: 4_BdIMcdOSSCU5iiXS7cLg-1 Received: by mail-qt1-f198.google.com with SMTP id v7-20020a05622a188700b003e0e27bbc2eso8389192qtc.8 for ; Tue, 28 Mar 2023 08:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680017582; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oxaAVPRtWnUz0dI6hZvjtqS3uY1gOUxVpxMt0N62xaw=; b=LL/z4IMWW3lK3/M48qHjhzBgWR5jY10EI0guQnOrxtIQRhCl5HpUC2lIOwQ6bNBWKp 0eDUHkWy0QVVURyQ39vSvfrW4mkt8td9hwmcy+DHIdS4B1qayyfh3q1fz4THWt/oux7K xEwIvO5no5vgs/D6sJbGw+R+Kk3xAOAaLGkbuTEVFrtrBHkjClIAlp56hHhvl7kRSujI XlsPBetzY9MKGFPsdFf3sKimeA+BC6gaA66DQZrZ/5anW1f2OPcfbNIFyjih+WlAfUWW rccXRamLGOK3bd401MnRaCbNd+7Ax8HesFO2OvuSG7CQofOzestk5Vsw9L6YpaPcUTj8 /EaQ== X-Gm-Message-State: AAQBX9c/H90nds9JoC+eBjMtwl0NoA0ZCVomeUdam3acI/K1bZTKulHz POUc5QTICDmSWYGcgnHwkHDcnjXNCByeLG+4zjafqsL2G3OBKkuZc1BtXpqk2NPndlHRBwxUR8k f+JTebr1TNaS2LNEFDW/BAvv0cw== X-Received: by 2002:a05:622a:134f:b0:3bf:d372:a5bf with SMTP id w15-20020a05622a134f00b003bfd372a5bfmr29874317qtk.45.1680017582283; Tue, 28 Mar 2023 08:33:02 -0700 (PDT) X-Google-Smtp-Source: AKy350amOapZz0eHxisQ+JpAkPOxaoLmP5zNbIppJvWwYUAW5NXsNiknB5bN1hsgTVgMvakxovgcIg== X-Received: by 2002:a05:622a:134f:b0:3bf:d372:a5bf with SMTP id w15-20020a05622a134f00b003bfd372a5bfmr29874280qtk.45.1680017581955; Tue, 28 Mar 2023 08:33:01 -0700 (PDT) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id m64-20020a375843000000b0073b8512d2dbsm17607069qkb.72.2023.03.28.08.33.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Mar 2023 08:33:01 -0700 (PDT) Message-ID: Date: Tue, 28 Mar 2023 11:32:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: PING^2 Re: [PATCH RFC] c++: lambda mangling alias issues [PR107897] From: Jason Merrill To: Jan Hubicka Cc: gcc-patches@gcc.gnu.org References: <20230308025945.648936-1-jason@redhat.com> <4d1a02da-b1b5-1cdb-c435-ba0299d8bd9b@redhat.com> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 3/14/23 11:16, Jason Merrill wrote: > On 3/8/23 11:54, Jason Merrill wrote: >> On 3/8/23 11:15, Jason Merrill wrote: >>> On 3/8/23 10:53, Jan Hubicka wrote: >>>>> Tested x86_64-pc-linux-gnu.  Does this look good, or do we want to >>>>> factor the >>>>> flag clearing into a symtab_node counterpart to cgraph_node::reset? >>>>> >>>>> -- 8< -- >>>>> >>>>> In 107897, by the time we are looking at the mangling clash, the >>>>> alias has already been removed from the symbol table by >>>>> analyze_functions, >>>>> so we can't look at n->cpp_implicit_alias.  So just assume that >>>>> it's an >>>>> alias if it's internal. >>>>> >>>>> In 108887 the problem is that removing the mangling alias from the >>>>> symbol >>>>> table confuses analyze_functions, because it ended up as >>>>> first_analyzed >>>>> somehow, so it becomes a dangling pointer.  Fixed by clearing >>>>> various flags >>>>> to neutralize the alias. >>>>> >>>>>     PR c++/107897 >>>>>     PR c++/108887 >>>>> >>>>> gcc/cp/ChangeLog: >>>>> >>>>>     * decl2.cc (record_mangling): Improve symbol table handling. >>>>> >>>>> gcc/testsuite/ChangeLog: >>>>> >>>>>     * g++.dg/cpp2a/concepts-lambda3.C: Use -flto if supported. >>>>>     * g++.dg/cpp0x/lambda/lambda-mangle7.C: New test. >>>>> --- >>>>>   gcc/cp/decl2.cc                               | 25 +++++-- >>>>>   .../g++.dg/cpp0x/lambda/lambda-mangle7.C      | 70 >>>>> +++++++++++++++++++ >>>>>   gcc/testsuite/g++.dg/cpp2a/concepts-lambda3.C |  1 + >>>>>   3 files changed, 91 insertions(+), 5 deletions(-) >>>>>   create mode 100644 >>>>> gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle7.C >>>>> >>>>> diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc >>>>> index 387e24542cd..e6e58b08de4 100644 >>>>> --- a/gcc/cp/decl2.cc >>>>> +++ b/gcc/cp/decl2.cc >>>>> @@ -4742,15 +4742,30 @@ record_mangling (tree decl, bool need_warning) >>>>>       = mangled_decls->find_slot_with_hash (id, >>>>> IDENTIFIER_HASH_VALUE (id), >>>>>                         INSERT); >>>>> -  /* If this is already an alias, remove the alias, because the real >>>>> +  /* If this is already an alias, cancel the alias, because the real >>>>>        decl takes precedence.  */ >>>>>     if (*slot && DECL_ARTIFICIAL (*slot) && DECL_IGNORED_P (*slot)) >>>>> -    if (symtab_node *n = symtab_node::get (*slot)) >>>>> -      if (n->cpp_implicit_alias) >>>>> +    { >>>>> +      if (symtab_node *n = symtab_node::get (*slot)) >>>>>       { >>>>> -      n->remove (); >>>>> -      *slot = NULL_TREE; >>>>> +      if (n->cpp_implicit_alias) >>>>> +        { >>>>> +          /* Actually removing the node isn't safe if other code >>>>> is already >>>>> +         holding a pointer to it, so just neutralize it.  */ >>>>> +          n->remove_from_same_comdat_group (); >>>>> +          n->analyzed = false; >>>>> +          n->definition = false; >>>>> +          n->alias = false; >>>>> +          n->cpp_implicit_alias = false; >>>> We have n->reset () for that which is used in similar situation when >>>> frontends overwrites extern inline function by its different offline >>>> implementation. >>> >>> The problem there is that reset() is a member of cgraph_node, not >>> symtab_node, and I need something that works for variables as well. >>> >>>> reset doesn't call remove_from_same_comdat_group probably because it >>>> was >>>> never used on anything in comdat group.  So I think it would make sense >>>> to call n->reset() here and add remove_from_same_comdat_group into >>>> that. >> >> How about moving it to symtab_node and using dyn_cast for the cgraph >> bits, like this: > > Ping? (Patch in attachment in earlier message) >