Message ID | alpine.LSU.2.20.1702171240160.8538@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
On Fri, 17 Feb 2017, Richard Biener wrote: > > The following annotates two key wrappers around copy_node in the C++ FE > with MEM-STAT info (and with CXX_MEM_STAT_INFO this is surprisingly > easy, without adding _stat variants and macros as we have for the classic > way from the pre-C++ era). > > It also annotates more type building functions in tree.c (all in the > attempt to get a better idea on where all the types are built for C++ > sources). > > Bootstrapped without --enable-gather-detailed-mem-stats, bootstrapped > with --enable-gather-detailed-mem-stats and visually inspected the > improved stats on some example C++ code. > > There are still some more functions worth annotating: > > tree.c:8239 (build_range_type_1) 840: 0.0% > 666120: 3.2% > tree.c:8362 (build_array_type_1) 3024: 0.0% > 671496: 3.2% > tree.c:4841 (build_type_attribute_qual_variant) 13776: 0.1% > 67032: 0.3% > tree.c:8681 (build_method_type_directly) 41832: 0.3% > 202944: 1.0% > hash-table.h:736 (expand) 15136: 0.1% > 5826600: 27.8% > tree.c:8532 (build_function_type) 148344: 1.1% > 3538080: 16.9% > cp/lex.c:556 (retrofit_lang_decl) 78628: 0.6% > 43776: 0.2% > cp/lex.c:526 (build_lang_decl_loc) 87968: 0.6% > 260776: 1.2% 3902184: 7.5% 536840: 23.8% 15444 > > is it ok if I go forward with this (at this stage, also for C++ > specifics above?) > > Would it be welcome to scrap _stat and the macro wrappings everywhere > at this stage? And even unify CXX_MEM_STAT_INFO and MEM_STAT_INFO, also dropping support for host compilers < GCC 4.8, GCC 4.8 introduced __builtin_FILE and friends (you'd have to bootstrap with older host compilers or clang which doesn't seem to support those either and still claims to be GCC 4.2.1 ...). Richard. > Thanks, > Richard. > > 2017-02-17 Richard Biener <rguenther@suse.de> > > * tree.h (build_qualified_type): Annotate with CXX_MEM_STAT_INFO. > (build_distinct_type_copy): Likewise. > (build_variant_type_copy): Likewise. > * tree.c (build_qualified_type): Pass down mem-stat info. > (build_distinct_type_copy): Likewise. > (build_variant_type_copy): Likewise. > > cp/ > * cp-tree.h (copy_decl): Annotate with CXX_MEM_STAT_INFO. > (copy_type): Likewise. > * lex.c (copy_decl): Pass down mem-stat info. > (copy_type): Likewise. > > Index: gcc/tree.h > =================================================================== > --- gcc/tree.h (revision 245526) > +++ gcc/tree.h (working copy) > @@ -4258,7 +4258,7 @@ extern tree get_qualified_type (tree, in > /* Like get_qualified_type, but creates the type if it does not > exist. This function never returns NULL_TREE. */ > > -extern tree build_qualified_type (tree, int); > +extern tree build_qualified_type (tree, int CXX_MEM_STAT_INFO); > > /* Create a variant of type T with alignment ALIGN. */ > > @@ -4276,8 +4276,8 @@ extern tree build_aligned_type (tree, un > > /* Make a copy of a type node. */ > > -extern tree build_distinct_type_copy (tree); > -extern tree build_variant_type_copy (tree); > +extern tree build_distinct_type_copy (tree CXX_MEM_STAT_INFO); > +extern tree build_variant_type_copy (tree CXX_MEM_STAT_INFO); > > /* Given a hashcode and a ..._TYPE node (for which the hashcode was made), > return a canonicalized ..._TYPE node, so that duplicates are not made. > Index: gcc/tree.c > =================================================================== > --- gcc/tree.c (revision 245526) > +++ gcc/tree.c (working copy) > @@ -6622,7 +6622,7 @@ get_qualified_type (tree type, int type_ > exist. This function never returns NULL_TREE. */ > > tree > -build_qualified_type (tree type, int type_quals) > +build_qualified_type (tree type, int type_quals MEM_STAT_DECL) > { > tree t; > > @@ -6632,7 +6632,7 @@ build_qualified_type (tree type, int typ > /* If not, build it. */ > if (!t) > { > - t = build_variant_type_copy (type); > + t = build_variant_type_copy (type PASS_MEM_STAT); > set_type_quals (t, type_quals); > > if (((type_quals & TYPE_QUAL_ATOMIC) == TYPE_QUAL_ATOMIC)) > @@ -6695,9 +6695,9 @@ build_aligned_type (tree type, unsigned > TYPE_CANONICAL points to itself. */ > > tree > -build_distinct_type_copy (tree type) > +build_distinct_type_copy (tree type MEM_STAT_DECL) > { > - tree t = copy_node (type); > + tree t = copy_node_stat (type PASS_MEM_STAT); > > TYPE_POINTER_TO (t) = 0; > TYPE_REFERENCE_TO (t) = 0; > @@ -6733,11 +6733,11 @@ build_distinct_type_copy (tree type) > require structural equality checks). */ > > tree > -build_variant_type_copy (tree type) > +build_variant_type_copy (tree type MEM_STAT_DECL) > { > tree t, m = TYPE_MAIN_VARIANT (type); > > - t = build_distinct_type_copy (type); > + t = build_distinct_type_copy (type PASS_MEM_STAT); > > /* Since we're building a variant, assume that it is a non-semantic > variant. This also propagates TYPE_STRUCTURAL_EQUALITY_P. */ > Index: gcc/cp/cp-tree.h > =================================================================== > --- gcc/cp/cp-tree.h (revision 245526) > +++ gcc/cp/cp-tree.h (working copy) > @@ -6080,8 +6080,8 @@ extern tree unqualified_fn_lookup_error > extern tree build_lang_decl (enum tree_code, tree, tree); > extern tree build_lang_decl_loc (location_t, enum tree_code, tree, tree); > extern void retrofit_lang_decl (tree); > -extern tree copy_decl (tree); > -extern tree copy_type (tree); > +extern tree copy_decl (tree CXX_MEM_STAT_INFO); > +extern tree copy_type (tree CXX_MEM_STAT_INFO); > extern tree cxx_make_type (enum tree_code); > extern tree make_class_type (enum tree_code); > extern bool cxx_init (void); > Index: gcc/cp/lex.c > =================================================================== > --- gcc/cp/lex.c (revision 245526) > +++ gcc/cp/lex.c (working copy) > @@ -607,11 +607,11 @@ cxx_dup_lang_specific_decl (tree node) > /* Copy DECL, including any language-specific parts. */ > > tree > -copy_decl (tree decl) > +copy_decl (tree decl MEM_STAT_DECL) > { > tree copy; > > - copy = copy_node (decl); > + copy = copy_node_stat (decl PASS_MEM_STAT); > cxx_dup_lang_specific_decl (copy); > return copy; > } > @@ -645,11 +645,11 @@ copy_lang_type (tree node) > /* Copy TYPE, including any language-specific parts. */ > > tree > -copy_type (tree type) > +copy_type (tree type MEM_STAT_DECL) > { > tree copy; > > - copy = copy_node (type); > + copy = copy_node_stat (type PASS_MEM_STAT); > copy_lang_type (copy); > return copy; > } >
On Fri, Feb 17, 2017 at 01:22:57PM +0100, Richard Biener wrote: > And even unify CXX_MEM_STAT_INFO and MEM_STAT_INFO, also dropping support > for host compilers < GCC 4.8, GCC 4.8 introduced __builtin_FILE and > friends (you'd have to bootstrap with older host compilers or clang > which doesn't seem to support those either and still claims to be > GCC 4.2.1 ...). Do you mean drop support for host < GCC 4.8 if detailed mem stats gathering is requested, or dropping support for such host compilers altogether? I have no problem with the former, big problem with the latter. Jakub
On Fri, 17 Feb 2017, Jakub Jelinek wrote: > On Fri, Feb 17, 2017 at 01:22:57PM +0100, Richard Biener wrote: > > And even unify CXX_MEM_STAT_INFO and MEM_STAT_INFO, also dropping support > > for host compilers < GCC 4.8, GCC 4.8 introduced __builtin_FILE and > > friends (you'd have to bootstrap with older host compilers or clang > > which doesn't seem to support those either and still claims to be > > GCC 4.2.1 ...). > > Do you mean drop support for host < GCC 4.8 if detailed mem stats gathering > is requested, or dropping support for such host compilers altogether? > I have no problem with the former, big problem with the latter. The former, and it would just make stage1 more-or-less behave as if detailed mem stats gathering would be disabled (with a simple-minded approach GATHER_STATISTICS would still be 1 but all MEM_STAT_DECL, etc. would expand to nothing, thus require __builtin_FILE () support). Richard.
On Fri, Feb 17, 2017 at 6:51 AM, Richard Biener <rguenther@suse.de> wrote: > > The following annotates two key wrappers around copy_node in the C++ FE > with MEM-STAT info (and with CXX_MEM_STAT_INFO this is surprisingly > easy, without adding _stat variants and macros as we have for the classic > way from the pre-C++ era). > > It also annotates more type building functions in tree.c (all in the > attempt to get a better idea on where all the types are built for C++ > sources). > > Bootstrapped without --enable-gather-detailed-mem-stats, bootstrapped > with --enable-gather-detailed-mem-stats and visually inspected the > improved stats on some example C++ code. > > There are still some more functions worth annotating: > > tree.c:8239 (build_range_type_1) 840: 0.0% > 666120: 3.2% > tree.c:8362 (build_array_type_1) 3024: 0.0% > 671496: 3.2% > tree.c:4841 (build_type_attribute_qual_variant) 13776: 0.1% > 67032: 0.3% > tree.c:8681 (build_method_type_directly) 41832: 0.3% > 202944: 1.0% > hash-table.h:736 (expand) 15136: 0.1% > 5826600: 27.8% > tree.c:8532 (build_function_type) 148344: 1.1% > 3538080: 16.9% > cp/lex.c:556 (retrofit_lang_decl) 78628: 0.6% > 43776: 0.2% > cp/lex.c:526 (build_lang_decl_loc) 87968: 0.6% > 260776: 1.2% 3902184: 7.5% 536840: 23.8% 15444 > > is it ok if I go forward with this (at this stage, also for C++ > specifics above?) > > Would it be welcome to scrap _stat and the macro wrappings everywhere > at this stage? The patch looks fine to me, I don't have an opinion about appropriateness for this stage. Jason
On Sat, Feb 18, 2017 at 3:45 AM, Jason Merrill <jason@redhat.com> wrote: > On Fri, Feb 17, 2017 at 6:51 AM, Richard Biener <rguenther@suse.de> wrote: >> >> The following annotates two key wrappers around copy_node in the C++ FE >> with MEM-STAT info (and with CXX_MEM_STAT_INFO this is surprisingly >> easy, without adding _stat variants and macros as we have for the classic >> way from the pre-C++ era). >> >> It also annotates more type building functions in tree.c (all in the >> attempt to get a better idea on where all the types are built for C++ >> sources). >> >> Bootstrapped without --enable-gather-detailed-mem-stats, bootstrapped >> with --enable-gather-detailed-mem-stats and visually inspected the >> improved stats on some example C++ code. >> >> There are still some more functions worth annotating: >> >> tree.c:8239 (build_range_type_1) 840: 0.0% >> 666120: 3.2% >> tree.c:8362 (build_array_type_1) 3024: 0.0% >> 671496: 3.2% >> tree.c:4841 (build_type_attribute_qual_variant) 13776: 0.1% >> 67032: 0.3% >> tree.c:8681 (build_method_type_directly) 41832: 0.3% >> 202944: 1.0% >> hash-table.h:736 (expand) 15136: 0.1% >> 5826600: 27.8% >> tree.c:8532 (build_function_type) 148344: 1.1% >> 3538080: 16.9% >> cp/lex.c:556 (retrofit_lang_decl) 78628: 0.6% >> 43776: 0.2% >> cp/lex.c:526 (build_lang_decl_loc) 87968: 0.6% >> 260776: 1.2% 3902184: 7.5% 536840: 23.8% 15444 >> >> is it ok if I go forward with this (at this stage, also for C++ >> specifics above?) >> >> Would it be welcome to scrap _stat and the macro wrappings everywhere >> at this stage? > > The patch looks fine to me, I don't have an opinion about > appropriateness for this stage. Re-bootstrapped / tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. > Jason
Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 245526) +++ gcc/tree.h (working copy) @@ -4258,7 +4258,7 @@ extern tree get_qualified_type (tree, in /* Like get_qualified_type, but creates the type if it does not exist. This function never returns NULL_TREE. */ -extern tree build_qualified_type (tree, int); +extern tree build_qualified_type (tree, int CXX_MEM_STAT_INFO); /* Create a variant of type T with alignment ALIGN. */ @@ -4276,8 +4276,8 @@ extern tree build_aligned_type (tree, un /* Make a copy of a type node. */ -extern tree build_distinct_type_copy (tree); -extern tree build_variant_type_copy (tree); +extern tree build_distinct_type_copy (tree CXX_MEM_STAT_INFO); +extern tree build_variant_type_copy (tree CXX_MEM_STAT_INFO); /* Given a hashcode and a ..._TYPE node (for which the hashcode was made), return a canonicalized ..._TYPE node, so that duplicates are not made. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 245526) +++ gcc/tree.c (working copy) @@ -6622,7 +6622,7 @@ get_qualified_type (tree type, int type_ exist. This function never returns NULL_TREE. */ tree -build_qualified_type (tree type, int type_quals) +build_qualified_type (tree type, int type_quals MEM_STAT_DECL) { tree t; @@ -6632,7 +6632,7 @@ build_qualified_type (tree type, int typ /* If not, build it. */ if (!t) { - t = build_variant_type_copy (type); + t = build_variant_type_copy (type PASS_MEM_STAT); set_type_quals (t, type_quals); if (((type_quals & TYPE_QUAL_ATOMIC) == TYPE_QUAL_ATOMIC)) @@ -6695,9 +6695,9 @@ build_aligned_type (tree type, unsigned TYPE_CANONICAL points to itself. */ tree -build_distinct_type_copy (tree type) +build_distinct_type_copy (tree type MEM_STAT_DECL) { - tree t = copy_node (type); + tree t = copy_node_stat (type PASS_MEM_STAT); TYPE_POINTER_TO (t) = 0; TYPE_REFERENCE_TO (t) = 0; @@ -6733,11 +6733,11 @@ build_distinct_type_copy (tree type) require structural equality checks). */ tree -build_variant_type_copy (tree type) +build_variant_type_copy (tree type MEM_STAT_DECL) { tree t, m = TYPE_MAIN_VARIANT (type); - t = build_distinct_type_copy (type); + t = build_distinct_type_copy (type PASS_MEM_STAT); /* Since we're building a variant, assume that it is a non-semantic variant. This also propagates TYPE_STRUCTURAL_EQUALITY_P. */ Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 245526) +++ gcc/cp/cp-tree.h (working copy) @@ -6080,8 +6080,8 @@ extern tree unqualified_fn_lookup_error extern tree build_lang_decl (enum tree_code, tree, tree); extern tree build_lang_decl_loc (location_t, enum tree_code, tree, tree); extern void retrofit_lang_decl (tree); -extern tree copy_decl (tree); -extern tree copy_type (tree); +extern tree copy_decl (tree CXX_MEM_STAT_INFO); +extern tree copy_type (tree CXX_MEM_STAT_INFO); extern tree cxx_make_type (enum tree_code); extern tree make_class_type (enum tree_code); extern bool cxx_init (void); Index: gcc/cp/lex.c =================================================================== --- gcc/cp/lex.c (revision 245526) +++ gcc/cp/lex.c (working copy) @@ -607,11 +607,11 @@ cxx_dup_lang_specific_decl (tree node) /* Copy DECL, including any language-specific parts. */ tree -copy_decl (tree decl) +copy_decl (tree decl MEM_STAT_DECL) { tree copy; - copy = copy_node (decl); + copy = copy_node_stat (decl PASS_MEM_STAT); cxx_dup_lang_specific_decl (copy); return copy; } @@ -645,11 +645,11 @@ copy_lang_type (tree node) /* Copy TYPE, including any language-specific parts. */ tree -copy_type (tree type) +copy_type (tree type MEM_STAT_DECL) { tree copy; - copy = copy_node (type); + copy = copy_node_stat (type PASS_MEM_STAT); copy_lang_type (copy); return copy; }