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.129.124]) by sourceware.org (Postfix) with ESMTPS id D8C173858D39 for ; Tue, 2 Apr 2024 17:18:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8C173858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D8C173858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712078305; cv=none; b=sZ8aj3Ua9VaCfnUjkMWcAB8lP/K1utvswzeNRLmXpbMqMkhadxy/Tpj0QFWHjoAG9w05n04MHDBoj6Lud9EA26pkx063gdeYxyYuep/sN0YBnT2SO1adwJEo/PPlmYUb0quDPnowStyw5ITwAAWFXDPeyT6bZYGVve0tbcLrgIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712078305; c=relaxed/simple; bh=Z7ntvSk2jI3rI1Jb82c64vGY+lUsZLeuW10LKjO7mj4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=DS8Ejn1/MuRB8vES8AjpayITbE3Vca9b2cl/0+K05llDhn//F5J7/LuWHXfHAcNuBZgoFCSk+FU9XPRFVZqNLj55QMD4PZSzXz7xz0cj5e47qxyul9UldrbcjDzQ5CAnsM0qhMKWzKMX/ndoOdc36SQKD7BD/I+6CBszEsnDwSs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712078302; 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=vl8EIuehUAgaGIq8at4z0cAVhZp6sWLAop5hM1yBfrk=; b=doeRInopRwJMgIMEO5AWO4zty67yde6go//NfkW7kgQkYypkm0bHnNjVWys2JxiiCOnLXY wM56wRwK2b3zxLmW9nvNr79yABerIO6oGd8dOAT4cIm09QzYqdinyYiogEjUfPqX5CuvSn l2HhSTilPbx0u0Fnixno6QcuLCcPSC8= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-R51V8ba_OXOjJ0RdWRkHTw-1; Tue, 02 Apr 2024 13:18:19 -0400 X-MC-Unique: R51V8ba_OXOjJ0RdWRkHTw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69905553c97so22884666d6.2 for ; Tue, 02 Apr 2024 10:18:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712078298; x=1712683098; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vl8EIuehUAgaGIq8at4z0cAVhZp6sWLAop5hM1yBfrk=; b=ACr1/xwyjXfp6zt7p2VdJS8XhdtlPKAbC0IpbQ/tqV1Q+a71lnfxoYQNGGmeHgnSj1 kSkO2WokrnHdWdmFRWM0f+wMx7whAW7LYJ5XFl+4vJxf75x0ZN8UBxbw5jBrtc3nCBDO h4hRA7+owU2tFJeQi5Md4s/MJGbyMeMpwnMOKAFAVtQusZc9QSxA+MkQZztZu4X4GnXs 2pXI62wEBR8SkJtaAxcU61nr7kZK740mthwId3wDfNIFUjzwFOPtNXCxWocoWKSatDHm d6oFtWBrlFVB7N6By91GBuhHZ1VXQcWPQN1Kw8k6NK8Yn206ZmoylIBHqy9c/bFb8Ceb Uy6g== X-Forwarded-Encrypted: i=1; AJvYcCUNODH+nRSp3xjsJsfToyZZhJ3kPeIPpV9iTZYoMygkAx8y7416INUjPAQEr0xKqzgYb+bW5qkbrlHN6EBnfXedeCPL6IRWXA== X-Gm-Message-State: AOJu0YzRo9/cpTIH2o2tCAs+F+M1xH/BkO6E+j1xWtO9QBEtRPe6p+q5 3vTKwWZNoL4ul81Q39NHxyy/pDYzRPl3ttAFYpy62ePYDIMV5pPuKwtygbJzGZjNUKAsyXZk2w6 iVsXwFtyg3OkTuCCAzmnWZNHCY0VH9nOR/TTvdptPHZc9LVwQ3Bd2n0VCzoUAiU8= X-Received: by 2002:a0c:f291:0:b0:699:2525:7ec4 with SMTP id k17-20020a0cf291000000b0069925257ec4mr134243qvl.14.1712078298545; Tue, 02 Apr 2024 10:18:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIfuvj2sfsqYu3NlMUzhRUJXONGWSBFuwgXYFBnXs6z+nutYInh3z/9MLYaUIy6ftDl5F94w== X-Received: by 2002:a0c:f291:0:b0:699:2525:7ec4 with SMTP id k17-20020a0cf291000000b0069925257ec4mr134231qvl.14.1712078298285; Tue, 02 Apr 2024 10:18:18 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id v13-20020a05620a122d00b00789f5cf990bsm4449475qkj.36.2024.04.02.10.18.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Apr 2024 10:18:17 -0700 (PDT) Message-ID: Date: Tue, 2 Apr 2024 13:18:17 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Keep DECL_SAVED_TREE of destructor instantiations in modules [PR104040] To: Nathaniel Shead , gcc-patches@gcc.gnu.org Cc: Nathan Sidwell References: <660633b1.170a0220.717f3.817f@mx.google.com> From: Jason Merrill In-Reply-To: <660633b1.170a0220.717f3.817f@mx.google.com> 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: 7bit X-Spam-Status: No, score=-12.3 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_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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/28/24 23:21, Nathaniel Shead wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? > > -- >8 -- > > A template instantiation still needs to have its DECL_SAVED_TREE so that > its definition is emitted into the CMI. This way it can be emitted in > the object file of any importers that use it, in case it doesn't end up > getting emitted in this TU. > > PR c++/104040 > > gcc/cp/ChangeLog: > > * semantics.cc (expand_or_defer_fn_1): Also keep DECL_SAVED_TREE > for template instantiations. > > gcc/testsuite/ChangeLog: > > * g++.dg/modules/pr104040_a.C: New test. > * g++.dg/modules/pr104040_b.C: New test. > > Signed-off-by: Nathaniel Shead > --- > gcc/cp/semantics.cc | 7 +++++-- > gcc/testsuite/g++.dg/modules/pr104040_a.C | 14 ++++++++++++++ > gcc/testsuite/g++.dg/modules/pr104040_b.C | 8 ++++++++ > 3 files changed, 27 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/modules/pr104040_a.C > create mode 100644 gcc/testsuite/g++.dg/modules/pr104040_b.C > > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index adb1ba48d29..84e9901509a 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -5033,9 +5033,12 @@ expand_or_defer_fn_1 (tree fn) > /* We don't want to process FN again, so pretend we've written > it out, even though we haven't. */ > TREE_ASM_WRITTEN (fn) = 1; > - /* If this is a constexpr function, keep DECL_SAVED_TREE. */ > + /* If this is a constexpr function, or the body might need to be > + exported from a module CMI, keep DECL_SAVED_TREE. */ > if (!DECL_DECLARED_CONSTEXPR_P (fn) > - && !(modules_p () && DECL_DECLARED_INLINE_P (fn))) > + && !(modules_p () > + && (DECL_DECLARED_INLINE_P (fn) > + || DECL_TEMPLATE_INSTANTIATION (fn)))) How about using vague_linkage_p? > DECL_SAVED_TREE (fn) = NULL_TREE; > return false; > } > diff --git a/gcc/testsuite/g++.dg/modules/pr104040_a.C b/gcc/testsuite/g++.dg/modules/pr104040_a.C > new file mode 100644 > index 00000000000..ea36ce0a798 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/pr104040_a.C > @@ -0,0 +1,14 @@ > +// PR c++/104040 > +// { dg-additional-options "-fmodules-ts" } > +// { dg-module-cmi test } > + > +export module test; > + > +export template > +struct test { > + ~test() {} > +}; > + > +test use() { > + return {}; > +} > diff --git a/gcc/testsuite/g++.dg/modules/pr104040_b.C b/gcc/testsuite/g++.dg/modules/pr104040_b.C > new file mode 100644 > index 00000000000..efe014673fb > --- /dev/null > +++ b/gcc/testsuite/g++.dg/modules/pr104040_b.C > @@ -0,0 +1,8 @@ > +// PR c++/104040 > +// { dg-additional-options "-fmodules-ts" } > + > +import test; > + > +int main() { > + test t{}; > +}