From patchwork Wed Apr 24 22:50:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cary Coutant X-Patchwork-Id: 239328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 645DB2C00F5 for ; Thu, 25 Apr 2013 08:50:11 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=AQalIIBoUwDKDPVW87bUxYOK4q0go/XzX+JvGOW+NKLB5e QtJgK8SYGZ6rV26xN/W+11vXQDci1QsJg2pnMGQNT3yaQOcHPo1tDMdY0SsfGmpj WRS+mSMmZixWKwNz2pvpWETOB+LClrEELU5F3U2SUjLqMadaSwHWh7Vh7+9dM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=d9750Sq5kWLcjszv72qCwknlRk0=; b=xu76AuHHA/KY+L72Oc1Q x36A0eWAhAezfls+U3IGj8L+I1A/pOlJ3Hmzwp+lSjwq1aVsAhVa/b9Sl7I1I2ca MhCmoCoNLZz4lQdCttCpQYEU2dMbUBdbJzeAt4tmBFszWF8POZ31xoN2UVfWoKl8 zs/d79qbg8dMOjcfTQcli8A= Received: (qmail 30979 invoked by alias); 24 Apr 2013 22:50:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 30969 invoked by uid 89); 24 Apr 2013 22:50:05 -0000 X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, TW_CP autolearn=ham version=3.3.1 Received: from mail-da0-f47.google.com (HELO mail-da0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 24 Apr 2013 22:50:04 +0000 Received: by mail-da0-f47.google.com with SMTP id p1so1098749dad.6 for ; Wed, 24 Apr 2013 15:50:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=0Ldte9aPFuy1e1N3LTsdBglEi3dpc3S4Ifr6Q5Y65wc=; b=OJWKnotKkbhiswmPhaUutOFCkbfD0J/mDAzlWK/GS6EaVahifxkHqK9wlD2LK9dE/I uxkLWhfxhmFUqbxbPFJWYMJA6HSG16/W1Ni7CaaVSxAw9JOjbguYWUvj/dDV+NOK5/RS aF7fU7517fPL6+8g3qAZOrQ7vrqavwt5EwvzhBRXRi3LxhnhKpa2Di+ceVg9g8JAUIJ5 f47Lqs9WdWCHqaAVtUPDXOqhErtQ5jvt+pSusdSdX4XPkLO1QU+qI6vRfrji6hy7C60b O1HyMyXSrU09bF73AZOhCcAfQGKA0UHf3EzXrevAvVMV+bw3W0KWr7OZNbQJLSdTTy1D UrMg== MIME-Version: 1.0 X-Received: by 10.66.162.201 with SMTP id yc9mr21872175pab.170.1366843802801; Wed, 24 Apr 2013 15:50:02 -0700 (PDT) Received: by 10.68.242.70 with HTTP; Wed, 24 Apr 2013 15:50:02 -0700 (PDT) Date: Wed, 24 Apr 2013 15:50:02 -0700 Message-ID: Subject: [patch] Fix non-deterministic output order for type stubs in DWARF output From: Cary Coutant To: Jason Merrill , gcc-patches X-Gm-Message-State: ALoCoQlns8EZkcWjXEGe+VDU2eFwycTJ/KrEAW6scfqJYxwFCyKXHtRVs7j94EwOpJkOvuU8kAAjX65QC2p4CSq6P841+Kac1ziwqe1vJtfjUA6yXO8mI79Cah0JqQbHENb9ovtfnCTtBw/tfE6I56yK9E7QHP6P5SRtMg287IiqPHMNajkT7JJBc19F8FmIyfQY7zK5Eq4B Jason, would you like to take a look at this patch before I commit it? If I turn on -fdebug-types-section, I get a random failure in g++.dg/pch/system-2.C. This failure is being caused by non-deterministic order of the type stubs emitted by optimize_external_refs, because it's using the address of the DIE as a hash for the extern_map hash table. This patch makes the output order deterministic by using either the die_symbol (as a string) or the type signature for the hash value. Bootstrapped on x86_64 with no regressions. (I'm not planning to turn on -fdebug-types-section by default; I'm just trying to make sure the test suite is clean with it on so that I can turn it on in the google branches.) -cary 2013-04-24 Cary Coutant gcc/ * dwarf2out.c (hash_external_ref): Use die_symbol or signature for hash so that hash table traversal order is deterministic. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 198260) +++ gcc/dwarf2out.c (working copy) @@ -7385,7 +7385,22 @@ static hashval_t hash_external_ref (const void *p) { const struct external_ref *r = (const struct external_ref *)p; - return htab_hash_pointer (r->type); + dw_die_ref die = r->type; + hashval_t h = 0; + + /* We can't use the address of the DIE for hashing, because + that will make the order of the stub DIEs non-deterministic. */ + if (! die->comdat_type_p) + /* We have a symbol; use it to compute a hash. */ + h = htab_hash_string (die->die_id.die_symbol); + else + { + /* We have a type signature; use a subset of the bits as the hash. + The 8-byte signature is at least as large as hashval_t. */ + comdat_type_node_ref type_node = die->die_id.die_type_node; + memcpy (&h, type_node->signature, sizeof (h)); + } + return h; } /* Compare external_refs. */