From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 995603858C62 for ; Thu, 23 May 2024 13:29:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 995603858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 995603858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716470956; cv=none; b=i36Bw43/UM3erhx+z7FmKA62SJ6Iz13HyUpGK8u70tNcqgvdvPYkQQcH4zyBLnAwMXpUpSHRaoU2COcq9ON8ualPyui54Bc8b5EigAenH4DBbeKuadrLcYbCB9Tt/AiRxB2Pd6yIYHxDGxPTeijy41rfW5UwF3YZAfOsDCzQgRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716470956; c=relaxed/simple; bh=IjEJeEdJBifmmn2m7c8SNAbXRCxxnDTDuc8yk1EOffs=; h=DKIM-Signature:Message-ID:Date:From:To:Subject:MIME-Version; b=U4GS5lQ1m5JB0zlqz8eQ8Zik0N8uurU7kxkB4kfvgpcFZ80AGzFDAiQBbmKaAzM5A3Al9fYbXSaBWDzY/zBMwYaSY8qz75C0uC45M8CHZTW2NwFVJhsTIB6X0JUfHzDowBNgeqnhHqu1tOf5u1JHFBoT3aV+zG7swoeY8VzugOs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ee0132a6f3so17879965ad.0 for ; Thu, 23 May 2024 06:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716470951; x=1717075751; darn=gcc.gnu.org; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=sE5bB7xqdp6YhTIAfkQRjrz9VxnlizmhDkX0zR0nVMA=; b=PpICDIWXaEFU4rT8km9a1yXoqhLnpA+iA4i3ogynEJUfioQwb1K674OK5aR+8PA7rk mLnAFHzzWSbv3v7L5DoGngTlwyckdEhRvunVPR5lDeZ5EYylAXDmSnc8ZIC6dV8t+8cr zPu/DqaaVkJQrq3HKOnGO6f3/G6WsBIGBd20T2yNsgYvDqxBkVao9Cpbnn6mGQzIyVSD ztElSUZbaseA2W7nH7bJncXPiTSAp4BVgst+6GfS46sXCYcEC8VKGQ39IC37v+A8/URA Z2Hi+rE1Gv/q7TMdrhI8eJs9wWlqF3vvRX5yFSHemOId1lk2RMVo1AjAeZERxom135FF 9wAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716470951; x=1717075751; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sE5bB7xqdp6YhTIAfkQRjrz9VxnlizmhDkX0zR0nVMA=; b=qRr+wyByb5SvSI9cMRODh5J5MAgV7ugH7Plcr1tCN1VWezzxlyKE5qcHWis6dRXOxU aZphZKtFQr3Ft98gaWzAWpX2DEAAwDnUx299/yiwjHHAiJcqRRJYuR6DmQYg9vZl6uN7 2QPFs87p841BuSBhX9HxoUdQJUYg9rPPKBvDI32vLndzBIZovUP9JbHn2Niy3giLhK+V xdr+hl2bnpUHBT61sTZZ1YwD1hD5lmgNJxRPREk8Iocffgp3XmqKTtmrwwlR66Of9n62 JZXHlg+KWTvRCm1XNNV/f/M7JvaMAzXbFYxrfYJ97uS2py33eSmboxjyULWiTjyES4WK xCBQ== X-Gm-Message-State: AOJu0Yw0cP85YeWKWGypJioGh5ezFmXPyKWOOMyN2Aa433qfWAance3a OwN/MiraHyYhS555WVSOwcnRIxpqZ3w1DuPgIg8NslW6z9RgbIb9 X-Google-Smtp-Source: AGHT+IEvMCxsWWwcR8DMNB+76ZUnFSxO4jgaFiQ8R1L3k7s0UvE56AOtoyBptpIk7ewm2OxrXs6fsg== X-Received: by 2002:a17:902:ce0c:b0:1f3:220f:f317 with SMTP id d9443c01a7336-1f3220ff423mr58253065ad.35.1716470951375; Thu, 23 May 2024 06:29:11 -0700 (PDT) Received: from Thaum. (14-200-72-253.tpgi.com.au. [14.200.72.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c036272sm255663425ad.188.2024.05.23.06.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 06:29:10 -0700 (PDT) Message-ID: <664f44a6.170a0220.7a70.2e85@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 23 May 2024 23:29:06 +1000 From: Nathaniel Shead To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Nathan Sidwell Subject: [PATCH 2/2] c++/modules: Remember that header units have CMIs References: <664181e2.650a0220.dbfd8.e3d5@mx.google.com> <10d5ff7c-3d30-4317-97d9-91ea2370bbfa@redhat.com> <6646f5cb.170a0220.fb17d.75a5@mx.google.com> <664f443b.620a0220.3bb2.27d7@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <664f443b.620a0220.3bb2.27d7@mx.google.com> X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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 List-Id: And here's that patch. As far as I can tell there should be no visible change anymore, so there aren't any testcases. Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- This appears to be an oversight in the definition of module_has_cmi_p. This change will allow us to use the function directly in more places that need to additional work only if generating a module CMI in the future, allowing us to do additional work only when we know we need it. gcc/cp/ChangeLog: * cp-tree.h (module_has_cmi_p): Also include header units. (module_maybe_has_cmi_p): Update comment. * module.cc (set_defining_module): Only need to track declarations for later exporting if the module may have a CMI. * name-lookup.cc (pushdecl): Likewise. Signed-off-by: Nathaniel Shead --- gcc/cp/cp-tree.h | 7 +++---- gcc/cp/module.cc | 2 +- gcc/cp/name-lookup.cc | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ba9e848c177..9472759d3c8 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7381,7 +7381,7 @@ inline bool module_interface_p () inline bool module_partition_p () { return module_kind & MK_PARTITION; } inline bool module_has_cmi_p () -{ return module_kind & (MK_INTERFACE | MK_PARTITION); } +{ return module_kind & (MK_INTERFACE | MK_PARTITION | MK_HEADER); } inline bool module_purview_p () { return module_kind & MK_PURVIEW; } @@ -7393,9 +7393,8 @@ inline bool named_module_purview_p () inline bool named_module_attach_p () { return named_module_p () && module_attach_p (); } -/* We don't know if this TU will have a CMI while parsing the GMF, - so tentatively assume that it might, for the purpose of determining - whether no-linkage decls could be used by an importer. */ +/* Like module_has_cmi_p, but tentatively assumes that this TU may have a + CMI if we haven't seen the module-declaration yet. */ inline bool module_maybe_has_cmi_p () { return module_has_cmi_p () || (named_module_p () && !module_purview_p ()); } diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 520dd710549..8639ed6f1a2 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -19216,7 +19216,7 @@ set_defining_module (tree decl) gcc_checking_assert (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_IMPORT_P (decl)); - if (module_p ()) + if (module_maybe_has_cmi_p ()) { /* We need to track all declarations within a module, not just those in the module purview, because we don't necessarily know yet if diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 78f08acffaa..f1f8c19feb1 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -4103,7 +4103,7 @@ pushdecl (tree decl, bool hiding) if (level->kind == sk_namespace && TREE_PUBLIC (level->this_entity) - && module_p ()) + && module_maybe_has_cmi_p ()) maybe_record_mergeable_decl (slot, name, decl); } } -- 2.43.2