From patchwork Fri Sep 13 17:31:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Martin X-Patchwork-Id: 1985423 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nasilyan.com header.i=@nasilyan.com header.a=rsa-sha256 header.s=tey23rxsjton5kop5bydp3vc5ylkyjkg header.b=kfApEBK2; dkim=pass (1024-bit key; unprotected) header.d=amazonses.com header.i=@amazonses.com header.a=rsa-sha256 header.s=uku4taia5b5tsbglxyj6zym32efj7xqv header.b=UOEBa9Wg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X51fc0Nssz1y1C for ; Sat, 14 Sep 2024 03:35:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C12E13858C78 for ; Fri, 13 Sep 2024 17:35:17 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from a2-56.smtp-out.eu-west-1.amazonses.com (a2-56.smtp-out.eu-west-1.amazonses.com [54.240.2.56]) by sourceware.org (Postfix) with ESMTPS id 7F5BE3858C35 for ; Fri, 13 Sep 2024 17:31:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F5BE3858C35 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=nasilyan.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eu-west-1.amazonses.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F5BE3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.240.2.56 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726248716; cv=none; b=wmvNNhVxuVqULR7WiUctQaQ9ojeCJ9HQQC/IcNRXcvAqLsSut1tDlAe+Qk5SVfBrOB30mqyH8lF1WWdRr/8uWdRjOTIPbkVd3XJrAUwowMQVN23Fh2AWa8J4eHvSgy8x6fpGfmP8d3BYVzfC4BmiaRq/gbFCx/VbYLSCP7AkUZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726248716; c=relaxed/simple; bh=ddFWmTTSe25+rTOeIJWasCeeJFz29GDfhquWpneDN+k=; h=DKIM-Signature:DKIM-Signature:Subject:From:To:Date:Mime-Version: Message-ID; b=Wu3teXjcBysmZyTOpfMXj6Gb8pmG7gbX5TbbNDw1K43cOmvOWY53/GHI9LXo0IlhQ5WE+2ZRp5h3CTaOqO+IEt93AzdGQZ4YkKKec8bMnzski2ptzX6CIGbdxmMdVu9LiKQX3hVRiZjl8nhJcgQBMiadl/tFHrtWVyyLSqN03L4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=tey23rxsjton5kop5bydp3vc5ylkyjkg; d=nasilyan.com; t=1726248713; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:References:Message-Id; bh=ddFWmTTSe25+rTOeIJWasCeeJFz29GDfhquWpneDN+k=; b=kfApEBK24NAqcD0dP6OQtBKDy86pjpEX7ZUe0gsOGQRVh4gqkmr83PV9lF5n8gsf 2z2kYfngs07VO0oPGwIGf5ypxZuILTxeKlvKKhTib3oVPWVBSA9Q6YQ2Qc7BNieOEFO SQDsYVMZb/gIOG86ku4ZoLAoxOUp2OtXFOPbI3qs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1726248713; h=Subject:From:To:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:References:Message-Id:Feedback-ID; bh=ddFWmTTSe25+rTOeIJWasCeeJFz29GDfhquWpneDN+k=; b=UOEBa9WgfYG9O+BgZ10sjKu+qWZ7uhmH6/FKU+eq2j1lV9WYkOlB88c+q0VvxTiU GlgF6HdwPSnDO+DF9l2T9Jp+/1I6EouwMsvQdS6mlCelfoa8gZy/ItVpQfRr3tc3WMm KjbohEoPhxQHdbXXCm8W0fylD1XwCzSTvKUSk5dY= Subject: [PATCH] c++: Don't mix timevar_start and auto_cond_timevar for TV_NAME_LOOKUP [PR116681] From: =?utf-8?q?Simon_Martin?= To: =?utf-8?q?gcc-patches=40gcc=2Egnu=2Eorg?= Date: Fri, 13 Sep 2024 17:31:53 +0000 Mime-Version: 1.0 References: <20240913173150.10314-1-simon@nasilyan.com> X-Mailer: Amazon WorkMail Thread-Index: AQHbBgLRE4ulJ6MtS0SPiSB+cPsqGg== Thread-Topic: [PATCH] c++: Don't mix timevar_start and auto_cond_timevar for TV_NAME_LOOKUP [PR116681] X-Original-Mailer: git-send-email 2.44.0 X-Wm-Sent-Timestamp: 1726248712 Message-ID: <01020191ec70fbc0-12b70323-086b-4394-953d-e93afaae5d84-000000@eu-west-1.amazonses.com> Feedback-ID: ::1.eu-west-1.b24dn6frgCi6dh20skzbuMRr7UL8M6Soir/3ogtEjHQ=:AmazonSES X-SES-Outgoing: 2024.09.13-54.240.2.56 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org We currently ICE upon the following testcase when using -ftime-report === cut here === template < int> using __conditional_t = int; template < typename _Iter > concept random_access_iterator = requires { new _Iter; }; template < typename _Iterator > struct reverse_iterator { using iterator_concept = __conditional_t< random_access_iterator< _Iterator>>; }; void RemoveBottom() { int iter; for (reverse_iterator< int > iter;;) ; } === cut here === The problem is that qualified_namespace_lookup does a plain start() of the TV_NAME_LOOKUP timer (that asserts that the timer is not already started). However this timer has already been cond_start()'d in the call stack - by pushdecl - so the assert fails. This patch simply ensures that we always conditionally start this timer (which is done in all other places that use it). Successfully tested on x86_64-pc-linux-gnu. PR c++/116681 gcc/cp/ChangeLog: * name-lookup.cc (qualified_namespace_lookup): Use an auto_cond_timer instead of using timevar_start and timevar_stop. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-pr116681.C: New test. --- gcc/cp/name-lookup.cc | 3 +-- .../g++.dg/cpp2a/concepts-pr116681.C | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-pr116681.C diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index bfe17b7cb2f..c7a693e02d5 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -7421,10 +7421,9 @@ tree lookup_qualified_name (tree t, const char *p, LOOK_want w, bool c) static bool qualified_namespace_lookup (tree scope, name_lookup *lookup) { - timevar_start (TV_NAME_LOOKUP); + auto_cond_timevar tv (TV_NAME_LOOKUP); query_oracle (lookup->name); bool found = lookup->search_qualified (ORIGINAL_NAMESPACE (scope)); - timevar_stop (TV_NAME_LOOKUP); return found; } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-pr116681.C b/gcc/testsuite/g++.dg/cpp2a/concepts-pr116681.C new file mode 100644 index 00000000000..f1b47797f1e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-pr116681.C @@ -0,0 +1,20 @@ +// PR c++/116681 +// { dg-do compile { target c++20 } } +// { dg-additional-options "-ftime-report" } +// { dg-allow-blank-lines-in-output 1 } +// { dg-prune-output "Time variable" } +// { dg-prune-output "k" } +// { dg-prune-output "\[0-9\]+%" } + +template < int> using __conditional_t = int; +template < typename _Iter > +concept random_access_iterator = requires { new _Iter; }; +template < typename _Iterator > struct reverse_iterator { + using iterator_concept = __conditional_t< random_access_iterator< _Iterator >>; +}; +void RemoveBottom() +{ + int iter; + for (reverse_iterator< int > iter;;) + ; +}