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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 9CF8F385702B for ; Thu, 3 Sep 2020 18:29:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CF8F385702B Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-64-6F_dHnkeNB6GhCnt6LN8aQ-1; Thu, 03 Sep 2020 14:29:03 -0400 X-MC-Unique: 6F_dHnkeNB6GhCnt6LN8aQ-1 Received: by mail-qt1-f198.google.com with SMTP id j35so2702333qtk.14 for ; Thu, 03 Sep 2020 11:29:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=GCYY2bf8+VI3Wus5YfCkCVa19H2GUbcMGGW8VT0H69U=; b=Q5HXDF1ucnn0Cx7oIWEjOlS2jFa7LWNYvOp7A5L5XASKDqAeIVIpC03ygP+8JwLaM7 R8+jHSVOQZcxkbW0PC8j9hOuu+CL2QYRWw/P8+s5ZN06HbfYF0yepLd6wKpQ4N4jkGy/ dReNDOTD6MdWeKxTbxF1hMcyBM5265lU+h8cyvm8+JN6Wx2YVLayhZqUvrm9KKCH7AtD RZYdwyJBGiXuh6B4YlfAp3M5fU4O701Mlxrhpvwc5j/rUs24D603CkYiox5Cix9bejgw 8/Fuh8iSnJmTE8QAjmsw7qZuLYUDleYdCGwOqZfGJj/KtMsiUIS6y0VeP6IbdKFOUlg0 YXIg== X-Gm-Message-State: AOAM532glIPssIxuzZ6AdyTz1013YcXb5tUo/iwJHvWVfueVWLnsEoB6 Y6O94GcJZwOAcvHbkgN05iZLJkivSUNvGeQTGmA9EPw6GpXR0xcYfxGtqgz/M/SzfDP9F69pga6 uAE0fMX4rz+yNGnhLoQ== X-Received: by 2002:a0c:d803:: with SMTP id h3mr3111969qvj.0.1599157741916; Thu, 03 Sep 2020 11:29:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc3Vg04CKKasdsQAPu5g2xnlZ+5xMkhyIQ9EXsLzh0eTSpadAUUDNOUB9uPwyvTmYwM90d9A== X-Received: by 2002:a0c:d803:: with SMTP id h3mr3111947qvj.0.1599157741608; Thu, 03 Sep 2020 11:29:01 -0700 (PDT) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id h17sm2755408qke.68.2020.09.03.11.29.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 11:29:00 -0700 (PDT) Subject: Re: [PATCH] c++: Fix another PCH hash_map issue [PR96901] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20200903082041.GI18149@tucnak> From: Jason Merrill Message-ID: Date: Thu, 3 Sep 2020 14:29:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200903082041.GI18149@tucnak> X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2020 18:29:07 -0000 On 9/3/20 4:20 AM, Jakub Jelinek wrote: > Hi! > > The recent libstdc++ changes caused lots of libstdc++-v3 tests FAILs > on i686-linux, all of them in the same spot during constexpr evaluation > of a recursive _S_gcd call. > The problem is yet another hash_map that used the default hasing of > tree keys through pointer hashing which is preserved across PCH write/read. > During PCH handling, the addresses of GC objects are changed, which means > that the hash values of the keys in such hash tables change without those > hash tables being rehashed. Which in the fundef_copies_table case usually > means we just don't find a copy of a FUNCTION_DECL body for recursive uses > and start from scratch. But when the hash table keeps growing, the "dead" > elements in the hash table can sometimes reappear and break things. > In particular what I saw under the debugger is when the fundef_copies_table > hash map has been used on the outer _S_gcd call, it didn't find an entry for > it, so returned a slot with *slot == NULL, which is treated as that the > function itself is used directly (i.e. no recursion), but that addition of > a hash table slot caused the recursive _S_gcd call to actually find > something in the hash table, unfortunately not the new *slot == NULL spot, > but a different one from the pre-PCH streaming which contained the returned > toplevel (non-recursive) call entry for it, which means that for the > recursive _S_gcd call we actually used the same trees as for the outer ones > rather than a copy of those, which breaks constexpr evaluation. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk (and given that it is latent eventually for release branches > too)? OK. > 2020-09-03 Jakub Jelinek > > PR c++/96901 > * tree.h (struct decl_tree_traits): New type. > (decl_tree_map): New typedef. > > * constexpr.c (fundef_copies_table): Change type from > hash_map * to decl_tree_map *. > > --- gcc/tree.h.jj 2020-08-31 22:50:28.545593391 +0200 > +++ gcc/tree.h 2020-09-02 17:44:45.478358927 +0200 > @@ -5453,6 +5453,11 @@ struct type_tree_cache_traits > : simple_cache_map_traits { }; > typedef hash_map type_tree_cache_map; > > +/* Similarly to decl_tree_cache_map, but without caching. */ > +struct decl_tree_traits > + : simple_hashmap_traits { }; > +typedef hash_map decl_tree_map; > + > /* Initialize the abstract argument list iterator object ITER with the > arguments from CALL_EXPR node EXP. */ > static inline void > --- gcc/cp/constexpr.c.jj 2020-09-01 22:47:49.946383670 +0200 > +++ gcc/cp/constexpr.c 2020-09-02 17:46:35.267758742 +0200 > @@ -1203,7 +1203,7 @@ maybe_initialize_constexpr_call_table (v > > This is not GC-deletable to avoid GC affecting UID generation. */ > > -static GTY(()) hash_map *fundef_copies_table; > +static GTY(()) decl_tree_map *fundef_copies_table; > > /* Reuse a copy or create a new unshared copy of the function FUN. > Return this copy. We use a TREE_LIST whose PURPOSE is body, VALUE > > Jakub >