From patchwork Fri Jun 5 15:24:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 481395 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C04F91401DE for ; Sat, 6 Jun 2015 01:24:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=r5vcy0fx; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=P+LjaPWL/c1D98LfZ8Mc1EdejKJmmI213JmyPmS/Y7+z6s NExzluJuvBAUxe37qD0JmOo4ZMKJc9zADHs6Os15H2bXOz63nl+w7et45Zzpe6JU fo8tscMb/BknEfnOR5TppIOD8I7XBwtKKPzQ8qeZhuMoTu2EHwGDTHIPEMkcQ= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=oopX0YvCcftCBIrpg7D8QUO7jkc=; b=r5vcy0fx6410k7rYON4g Bp+LD2JFxFNDLHWiDUncXo6Ui9iAzy+tPFyS0tV3R0Xdjgn/Yc7eCyAjPY7u2sw9 68a64TtMc5peoOnT8L6V30e0jKA1gm2R4L05oWlxoMpvH+OVSxsQTWM38eJxAG6Y 5ROEc5HN0r93KUAbaYrnF04= Received: (qmail 85009 invoked by alias); 5 Jun 2015 15:24:14 -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 84929 invoked by uid 89); 5 Jun 2015 15:24:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 05 Jun 2015 15:24:06 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 9852B3500E7 for ; Fri, 5 Jun 2015 15:24:05 +0000 (UTC) Received: from [10.10.63.231] (vpn-63-231.rdu2.redhat.com [10.10.63.231]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t55FO3iD013989 for ; Fri, 5 Jun 2015 11:24:04 -0400 Message-ID: <5571BF13.2070103@redhat.com> Date: Fri, 05 Jun 2015 11:24:03 -0400 From: Andrew MacLeod User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches Subject: [patch] Adjust hash-table.h and it's pre-requisite includes. X-IsSubscribed: yes There is a horrible morass of include dependencies between hash-map.h, mem-stats.h and hash-table.h. There are even includes in both directions (mem-stats.h and hash-map.h include each other, as do hash-map.h and hash-table.h.. blech). Some of those files need parts of the other file to compile, and those whole mess is quite awful. They also manage to include vec.h into their little party 3 times as well, and it also has some icky #ifdefs. So I spent some time sorting out the situation, and reduced it down to a straight dependency list, rooted by hash-table.h. There are no double direction includes, and no header is included more than once. Once sorted out, I moved the root of this tree into coretypes.h since pretty much every file requires everything in the dependency chain. This chain consists of statistics.h, ggc.h, vec.h, hashtab.h, inchash.h, mem-stats-traits.h, hash-map-traits.h, mem-stats.h, hash-map.h and hash-table.h. With hash-table.h at the root of the dependency list, I wondered how many files actually need just that. So I flattened a source tree such that coretypes.h included the other required include files, but each .c file included hash-table.h. Then I tried removing the includes. It turned out that virtually every file needs hash-table.h. Part of that is due to how tightly integrated with mem-stats.h it is (they still need each other), and that is used throughout the compiler. So I think it makes sense to put that in coretypes.h. I also noticed that hash-set.h is included in a lot of places as well. Wondering how much it was actually needed, I preformed the same flattening exercise and found that only about 10% of the files in gcc core didn't need it to compile... the rest all needed it due to hash_set being in a prototype parameter list or in a structure declared in a commonly used header file (function.h, gimple-walk.h, tree-core.h, tree.h,...) . It would be a lot of work to remove this dependency (if its even possible), so I added hash-set.h to coretypes.h as well. rtl.h needed hash-table.h added to the GENERATOR list, but not hash-set.. I guess the generators don't use it much :-) The only other thing of note is the change to vec.h. It had an ugly set of checks to see whether it was being used in a generator file, and if not whether GC was available, then included it if it wasn't or provided 3 prototypes if it wasn't suppose to be included. These allows it to compile when GC isn't available (those routines referencing the GC functions would never be referred to when GC isnt available). With my other changes, most of those checks weren't necessary. I also figured it was best to simply include those 3 prototypes for ggc_free, ggc_round_alloc_size, and ggc_realloc all the time. When there isn't ggc.h, things remain as they are now. If there is a ggc.h included, it will provide static confirmation that those prototypes are up-to-date and in sync with how ggc.h defines them. The first patch contains all of those changes. The second one is fully automated and removes all these headers from every other .c and .h file in the compiler. This also included changes to many of the gen*.c routines. I adjusted the #include list for all the *generated* .c files to also be up to date with this patchset as well at the previous one which moved wide-int and friends into coretypes.h This bootstraps with all languages enabled on x86_64-unknown-linux-gnu with no new regressions. It also causes no failures for all the targets in config-list.mk. OK for trunk? Andrew * coretypes.h: Include hash-table.h and hash-set.h for host files. * ggc.h: Don't include statistics.h> * hash-map.h: Remove all includes. * hash-set.h: Likewise. * hash-table.h: Add statistics.h, inchash.h and hash-map-traits.h to the include list. Remove . * inchash.h: Remove all includes. * mem-stats.h: Likewise. * vec.h: No special processing for generators or ggc. Index: coretypes.h =================================================================== --- coretypes.h (revision 224136) +++ coretypes.h (working copy) @@ -307,6 +307,8 @@ #include "double-int.h" #include "real.h" #include "fixed-value.h" -#endif +#include "hash-table.h" +#include "hash-set.h" +#endif /* GENERATOR_FILE && !USED_FOR_TARGET */ #endif /* coretypes.h */ Index: ggc.h =================================================================== --- ggc.h (revision 224135) +++ ggc.h (working copy) @@ -20,7 +20,6 @@ #ifndef GCC_GGC_H #define GCC_GGC_H -#include "statistics.h" /* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with an external gc library that might be linked in. */ Index: hash-map.h =================================================================== --- hash-map.h (revision 224135) +++ hash-map.h (working copy) @@ -21,13 +21,6 @@ #ifndef hash_map_h #define hash_map_h -#include -#include -#include "hash-table.h" -#include "hash-map-traits.h" -#include "mem-stats.h" -#include "vec.h" - template class GTY((user)) hash_map Index: hash-set.h =================================================================== --- hash-set.h (revision 224135) +++ hash-set.h (working copy) @@ -21,8 +21,6 @@ #ifndef hash_set_h #define hash_set_h -#include "hash-table.h" - /* implement default behavior for traits when types allow it. */ struct default_hashset_traits Index: hash-table.h =================================================================== --- hash-table.h (revision 224135) +++ hash-table.h (working copy) @@ -196,10 +196,13 @@ #ifndef TYPED_HASHTAB_H #define TYPED_HASHTAB_H +#include "statistics.h" #include "ggc.h" +#include "vec.h" #include "hashtab.h" -#include +#include "inchash.h" #include "mem-stats-traits.h" +#include "hash-map-traits.h" template class hash_map; template class hash_set; @@ -774,7 +777,6 @@ #include "mem-stats.h" #include "hash-map.h" -#include "vec.h" extern mem_alloc_description hash_table_usage; Index: inchash.h =================================================================== --- inchash.h (revision 224136) +++ inchash.h (working copy) @@ -20,7 +20,6 @@ #ifndef INCHASH_H #define INCHASH_H 1 -#include "hashtab.h" /* This file implements an incremential hash function ADT, to be used by code that incrementially hashes a lot of unrelated data Index: mem-stats.h =================================================================== --- mem-stats.h (revision 224135) +++ mem-stats.h (working copy) @@ -1,11 +1,6 @@ #ifndef GCC_MEM_STATS_H #define GCC_MEM_STATS_H -#include "hash-map-traits.h" -#include "inchash.h" -#include "mem-stats-traits.h" -#include "vec.h" - /* Forward declaration. */ template @@ -358,7 +353,6 @@ reverse_mem_map_t *m_reverse_map; }; -#include "hash-map.h" /* Returns true if instance PTR is registered by the memory description. */ Index: vec.h =================================================================== --- vec.h (revision 224135) +++ vec.h (working copy) @@ -22,39 +22,15 @@ #ifndef GCC_VEC_H #define GCC_VEC_H -/* FIXME - When compiling some of the gen* binaries, we cannot enable GC - support because the headers generated by gengtype are still not - present. In particular, the header file gtype-desc.h is missing, - so compilation may fail if we try to include ggc.h. +/* Some gen* file have no ggc support as the header file gtype-desc.h is + missing. Provide these definitions in case ggc.h has not been included. + This is not a problem because any code that runs before gengtype is built + will never need to use GC vectors.*/ - Since we use some of those declarations, we need to provide them - (even if the GC-based templates are not used). This is not a - problem because the code that runs before gengtype is built will - never need to use GC vectors. But it does force us to declare - these functions more than once. */ -#ifdef GENERATOR_FILE -#define VEC_GC_ENABLED 0 -#else -#define VEC_GC_ENABLED 1 -#endif // GENERATOR_FILE +extern void ggc_free (void *); +extern size_t ggc_round_alloc_size (size_t requested_size); +extern void *ggc_realloc (void *, size_t MEM_STAT_DECL); -#include "statistics.h" // For CXX_MEM_STAT_INFO. - -#if VEC_GC_ENABLED -#include "ggc.h" -#else -# ifndef GCC_GGC_H - /* Even if we think that GC is not enabled, the test that sets it is - weak. There are files compiled with -DGENERATOR_FILE that already - include ggc.h. We only need to provide these definitions if ggc.h - has not been included. Sigh. */ - - extern void ggc_free (void *); - extern size_t ggc_round_alloc_size (size_t requested_size); - extern void *ggc_realloc (void *, size_t MEM_STAT_DECL); -# endif // GCC_GGC_H -#endif // VEC_GC_ENABLED - /* Templated vector type and associated interfaces. The interface functions are typesafe and use inline functions,