From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122259 invoked by alias); 26 May 2017 07:54:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 122231 invoked by uid 89); 26 May 2017 07:54:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=31AM, 31am X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 May 2017 07:54:55 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15AD82B0A66; Fri, 26 May 2017 07:54:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 15AD82B0A66 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 15AD82B0A66 Received: from tucnak.zalov.cz (unknown [10.36.118.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B08AD5C3FD; Fri, 26 May 2017 07:54:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v4Q7stDj021820; Fri, 26 May 2017 09:54:55 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v4Q7srVj021819; Fri, 26 May 2017 09:54:53 +0200 Date: Fri, 26 May 2017 08:08:00 -0000 From: Jakub Jelinek To: Nathan Sidwell Cc: GCC Patches Subject: Re: [C++ PATCH] Reimplement ADL Message-ID: <20170526075453.GJ8499@tucnak> Reply-To: Jakub Jelinek References: <4f2b3ce9-7f06-6a10-f1c9-4542b3651bd0@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f2b3ce9-7f06-6a10-f1c9-4542b3651bd0@acm.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg02007.txt.bz2 On Thu, May 25, 2017 at 09:03:31AM -0400, Nathan Sidwell wrote: > This patch reimplements ADL. > > I replace the existing adl_lookup object with a new name_lookup object, and > move all the workers into it as member fns. > > In terms of implementation, ADL requires us to look in a bunch of places, > and we obviously want to look in each place only once. The current > implementation uses a vector, which it scans to see if we've met the class > or namespace before. Not even a hash table! > > Anyway, this implementation introduces LOOKUP_SEEN_P and LOOKUP_FOUND_P to > directly mark the DECL node. Hence determination is now O(1) rather than > O(N^2). We still have a vector to recall which decls we need to unmark at > the end of the lookup. We need two markers on a class, because depending on > how we found it we may need to search additional things about it. (These two > maker bits will be used in later changes too.) > > One quirk is that ADL can be recursive. ADL can cause template > instantiation, which can in turn cause a different ADL to happen. The new > testcase is an example of this. So, we need to detect this and undo/redo > the outer DECL marking during the inner ADL. Thus implementing a simple > chain of ADLs and using their record of which decls got marked to undo/redo. > The fiddly bit there is recording whether LOOKUP_FOUND_P was set or not > (LOOKUP_SEEN_P will be). To record that I simply push those DECLS with > lookup_found_p set onto the stack. They'll thus appear twice, and we can > infer from the second sighting that it had FOUND_P set (and pop the stack). > The recursion is a rare event, so we optimize the non-recursive case. > > I use a static vec for the scopes of outermost lookup object. That'll avoid > malloc/free for every lookup in the usual case. Inner lookups get their own > stack (but as mentioned are rare). > > I still keep the old code's determination of whether a found fn was in the > original lookup or not. That will go away soon. As will the iteration over > inline namespaces. I believe this broke FAIL: libgomp.c++/udr-12.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-12.C compilation failed to produce executable FAIL: libgomp.c++/udr-13.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-13.C compilation failed to produce executable FAIL: libgomp.c++/udr-16.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-16.C compilation failed to produce executable FAIL: libgomp.c++/udr-2.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-2.C compilation failed to produce executable FAIL: libgomp.c++/udr-3.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-3.C compilation failed to produce executable FAIL: libgomp.c++/udr-6.C (test for excess errors) UNRESOLVED: libgomp.c++/udr-6.C compilation failed to produce executable The OpenMP UDRs can't be found anymore with the patch. Can you please have a look? > 2017-05-25 Nathan Sidwell > > gcc/cp/ > * cp-tree.h (LOOKUP_SEEN_P, LOOKUP_FOUND_P): New. > * name-lookup.h (lookup_arg_dependent): Return plain tree. > * name-lookup.c (arg_lookup, arg_assoc, arg_assoc_args, > arg_assoc_args_vec, arg_assoc_type, add_function, > arg_assoc_namespace, arg_assoc_class_only, arg_assoc_bases, > arg_assoc_class, arg_assoc_template_arg, arg_assoc, > lookup_arg_dependent_1): Delete. > (name_lookup): New lookup object. > (name_lookup::preserve_state, name_lookup::restore_state, > name_lookup::mark_seen, name_lookup::find_and_mark, > name_lookup::add_fns, name_lookup::adl_namespace_only, > name_lookup::adl_namespace, name_lookup::adl_class_only, > name_lookup::adl_bases, name_lookup::adl_class, > name_lookup::adl_expr, name_lookup::adl_type, > name_lookup::adl_template_arg, name_lookup::search_adl): New. > (lookup_arg_dependent): Return a plain tree. Adjust. > (is_associated_namespace): Move later. > gcc/cp/ > * g++.dg/lookup/koenig14.C: New. Jakub