* [PATCH] gcc::context creation
@ 2017-05-16 16:01 Nathan Sidwell
2017-05-18 15:15 ` Nathan Sidwell
2017-05-19 9:03 ` Richard Biener
0 siblings, 2 replies; 16+ messages in thread
From: Nathan Sidwell @ 2017-05-16 16:01 UTC (permalink / raw)
To: GCC Patches, Richard Biener; +Cc: =?UTF-8?Q?mliska
[-- Attachment #1: Type: text/plain, Size: 726 bytes --]
This patch breaks apart the creation of the pass manager from
gcc::context's ctor. This will allow us to register additional dumps
between the dumpfile manager creation and the pass manager. As I
described in https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01164.html
when I tried to do this for the language-specific dumps, the existing
LANG_HOOKS_INIT_OPTIONS ran too late, and I had to create a new hook and
call it from gcc::context's constructor to get it done before the passes
were created. That's ugly. Calling the hook from toplev seems better.
Also, I noticed that we were passing a pointer to the
not-yet-fully-constructed context to the pass manager, which smells funny.
ok?
nathan
--
Nathan Sidwell
[-- Attachment #2: ctx.diff --]
[-- Type: text/x-patch, Size: 1927 bytes --]
2017-05-16 Nathan Sidwell <nathan@acm.org>
* context.h (context::set_passes): New.
* context.c (context::context): Do not create pass manager.
* toplev.c (general_init): Create pass manager here.
Index: context.c
===================================================================
--- context.c (revision 248110)
+++ context.c (working copy)
@@ -29,14 +29,9 @@ along with GCC; see the file COPYING3.
gcc::context *g;
gcc::context::context ()
+ : m_passes (NULL), m_dumps (new gcc::dump_manager ())
{
have_offload = false;
-
- /* The pass manager's constructor uses the dump manager (to set up
- dumps for the various passes), so the dump manager must be set up
- before the pass manager. */
- m_dumps = new gcc::dump_manager ();
- m_passes = new gcc::pass_manager (this);
}
gcc::context::~context ()
Index: context.h
===================================================================
--- context.h (revision 248110)
+++ context.h (working copy)
@@ -39,6 +39,12 @@ public:
/* Pass-management. */
+ void set_passes (pass_manager *m)
+ {
+ gcc_assert (!m_passes);
+ m_passes = m;
+ }
+
pass_manager *get_passes () { gcc_assert (m_passes); return m_passes; }
/* Handling dump files. */
Index: toplev.c
===================================================================
--- toplev.c (revision 248110)
+++ toplev.c (working copy)
@@ -1154,9 +1154,13 @@ general_init (const char *argv0, bool in
processing. */
init_ggc_heuristics ();
- /* Create the singleton holder for global state.
- Doing so also creates the pass manager and with it the passes. */
+ /* Create the singleton holder for global state. This creates the
+ dump manager. */
g = new gcc::context ();
+
+ /* Create the passes. */
+ g->set_passes (new gcc::pass_manager (g));
+
symtab = new (ggc_cleared_alloc <symbol_table> ()) symbol_table ();
statistics_early_init ();
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-16 16:01 [PATCH] gcc::context creation Nathan Sidwell
@ 2017-05-18 15:15 ` Nathan Sidwell
2017-05-19 9:10 ` Richard Biener
2017-05-24 10:59 ` Jakub Jelinek
2017-05-19 9:03 ` Richard Biener
1 sibling, 2 replies; 16+ messages in thread
From: Nathan Sidwell @ 2017-05-18 15:15 UTC (permalink / raw)
To: GCC Patches, Richard Biener; +Cc: Martin Liška
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]
On 05/16/2017 11:26 AM, Nathan Sidwell wrote:
> This patch breaks apart the creation of the pass manager from
> gcc::context's ctor. This will allow us to register additional dumps
... https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01295.html
This patch builds upon the context creation patch (this diff includes
it), to implement a new LANG_HOOK_REGISTER_DUMPS language hook. I call
it between creating the dump manager and instantiating the optimization
passes.
The patch then uses the hook to move the current -fdump-class-hierarchy
option into the C++ FE entirely, removing TDI_class and associated
handling from dumpfile and c-family/c-opts.c. The option gets renamed
to -fdump-lang-class in the process.
Obviously -fdump-translation-unit is the next candidate, and possibly
-fdump-tree-original.
ok?
nathan
--
Nathan Sidwell
[-- Attachment #2: dfilehook.diff --]
[-- Type: text/x-patch, Size: 15264 bytes --]
2017-05-18 Nathan Sidwell <nathan@acm.org>
LANG_HOOK_REGISTER_DUMPS
gcc/
* context.h (context::set_passes): New.
* context.c (context::context): Do not create pass manager.
* toplev.c (general_init): Create pass manager here. Call
register dump lang hook.
* doc/invoke.texi: Document -fdump-lang option family.
* dumpfile.c (dump_files): Remove class dump here.
(FIRST_AUTO_NUMBERED_DUMP): Adjust.
* dumpfile.h (tree_dump_index): Remove TDI_class.
* langhooks-def.h (lhd_register_dumps): Declare.
(LANG_HOOKS_REGISTER_DUMPS): Define.
(LANG_HOOKS_INITIALIZER): Add it.
* langhooks.c (lhd_register_dumps): Define.
* langhooks.h (struct lang_hooks): Add register_dumps.
c-family/
* c-opts.c (class_dump_file, class_dump_flags): Delete.
(c_common_parse_file): Remove class dump handling.
(get_dump_info): Likewise.
cp/
* class.c (class_dump_id): Define.
(dump_class_hierarchy, dump_vtable, dump_vtt): Use it.
* cp-objcp-common.c (cp_register_dumps): New.
* cp-objcp-common.h (cp_register_dumps): Declare.
(LANG_HOOKS_REGISTER_DUMPS): Override.
* cp-tree.h (class_dump_id): Declare.
testsuite/
* g++.dg/inherit/covariant7.C: Adjust.
Index: c-family/c-opts.c
===================================================================
--- c-family/c-opts.c (revision 248195)
+++ c-family/c-opts.c (working copy)
@@ -102,8 +102,6 @@ static size_t include_cursor;
/* Dump files/flags to use during parsing. */
static FILE *original_dump_file = NULL;
static dump_flags_t original_dump_flags;
-static FILE *class_dump_file = NULL;
-static dump_flags_t class_dump_flags;
/* Whether any standard preincluded header has been preincluded. */
static bool done_preinclude;
@@ -1098,10 +1096,9 @@ c_common_parse_file (void)
for (;;)
{
c_finish_options ();
- /* Open the dump files to use for the original and class dump output
+ /* Open the dump file to use for the original dump output
here, to be used during parsing for the current file. */
original_dump_file = dump_begin (TDI_original, &original_dump_flags);
- class_dump_file = dump_begin (TDI_class, &class_dump_flags);
pch_init ();
push_file_scope ();
c_parse_file ();
@@ -1120,11 +1117,6 @@ c_common_parse_file (void)
dump_end (TDI_original, original_dump_file);
original_dump_file = NULL;
}
- if (class_dump_file)
- {
- dump_end (TDI_class, class_dump_file);
- class_dump_file = NULL;
- }
/* If an input file is missing, abandon further compilation.
cpplib has issued a diagnostic. */
if (!this_input_filename)
@@ -1135,20 +1127,14 @@ c_common_parse_file (void)
}
/* Returns the appropriate dump file for PHASE to dump with FLAGS. */
+
FILE *
get_dump_info (int phase, dump_flags_t *flags)
{
- gcc_assert (phase == TDI_original || phase == TDI_class);
- if (phase == TDI_original)
- {
- *flags = original_dump_flags;
- return original_dump_file;
- }
- else
- {
- *flags = class_dump_flags;
- return class_dump_file;
- }
+ gcc_assert (phase == TDI_original);
+
+ *flags = original_dump_flags;
+ return original_dump_file;
}
/* Common finish hook for the C, ObjC and C++ front ends. */
Index: context.c
===================================================================
--- context.c (revision 248195)
+++ context.c (working copy)
@@ -29,14 +29,9 @@ along with GCC; see the file COPYING3.
gcc::context *g;
gcc::context::context ()
+ : m_passes (NULL), m_dumps (new gcc::dump_manager ())
{
have_offload = false;
-
- /* The pass manager's constructor uses the dump manager (to set up
- dumps for the various passes), so the dump manager must be set up
- before the pass manager. */
- m_dumps = new gcc::dump_manager ();
- m_passes = new gcc::pass_manager (this);
}
gcc::context::~context ()
Index: context.h
===================================================================
--- context.h (revision 248195)
+++ context.h (working copy)
@@ -39,6 +39,12 @@ public:
/* Pass-management. */
+ void set_passes (pass_manager *m)
+ {
+ gcc_assert (!m_passes);
+ m_passes = m;
+ }
+
pass_manager *get_passes () { gcc_assert (m_passes); return m_passes; }
/* Handling dump files. */
Index: cp/class.c
===================================================================
--- cp/class.c (revision 248195)
+++ cp/class.c (working copy)
@@ -37,6 +37,9 @@ along with GCC; see the file COPYING3.
#include "gimplify.h"
#include "intl.h"
+/* Id for dumping the class heirarchy. */
+int class_dump_id;
+
/* The number of nested classes being processed. If we are not in the
scope of any class, this is zero. */
@@ -8914,11 +8917,10 @@ static void
dump_class_hierarchy (tree t)
{
dump_flags_t flags;
- FILE *stream = get_dump_info (TDI_class, &flags);
-
- if (stream)
+ if (FILE *stream = dump_begin (class_dump_id, &flags))
{
dump_class_hierarchy_1 (stream, flags, t);
+ dump_end (class_dump_id, stream);
}
}
@@ -8948,7 +8950,7 @@ static void
dump_vtable (tree t, tree binfo, tree vtable)
{
dump_flags_t flags;
- FILE *stream = get_dump_info (TDI_class, &flags);
+ FILE *stream = dump_begin (class_dump_id, &flags);
if (!stream)
return;
@@ -8971,13 +8973,15 @@ dump_vtable (tree t, tree binfo, tree vt
dump_array (stream, vtable);
fprintf (stream, "\n");
}
+
+ dump_end (class_dump_id, stream);
}
static void
dump_vtt (tree t, tree vtt)
{
dump_flags_t flags;
- FILE *stream = get_dump_info (TDI_class, &flags);
+ FILE *stream = dump_begin (class_dump_id, &flags);
if (!stream)
return;
@@ -8989,6 +8993,8 @@ dump_vtt (tree t, tree vtt)
dump_array (stream, vtt);
fprintf (stream, "\n");
}
+
+ dump_end (class_dump_id, stream);
}
/* Dump a function or thunk and its thunkees. */
Index: cp/cp-objcp-common.c
===================================================================
--- cp/cp-objcp-common.c (revision 248195)
+++ cp/cp-objcp-common.c (working copy)
@@ -352,6 +352,15 @@ cp_pushdecl (tree decl)
return pushdecl (decl);
}
+/* Register c++-specific dumps. */
+
+void
+cp_register_dumps (gcc::dump_manager *dumps)
+{
+ class_dump_id = dumps->dump_register
+ (".class", "lang-class", "lang-class", TDF_LANG, OPTGROUP_NONE, false);
+}
+
void
cp_common_init_ts (void)
{
Index: cp/cp-objcp-common.h
===================================================================
--- cp/cp-objcp-common.h (revision 248195)
+++ cp/cp-objcp-common.h (working copy)
@@ -33,6 +33,7 @@ extern void cp_common_init_ts (void);
extern tree cp_unit_size_without_reusable_padding (tree);
extern tree cp_get_global_decls ();
extern tree cp_pushdecl (tree);
+extern void cp_register_dumps (gcc::dump_manager *);
/* Lang hooks that are shared between C++ and ObjC++ are defined here. Hooks
specific to C++ or ObjC++ go in cp/cp-lang.c and objcp/objcp-lang.c,
@@ -56,6 +57,8 @@ extern tree cp_pushdecl (tree);
#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
#undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
#define LANG_HOOKS_INITIALIZE_DIAGNOSTICS cxx_initialize_diagnostics
+#undef LANG_HOOKS_REGISTER_DUMPS
+#define LANG_HOOKS_REGISTER_DUMPS cp_register_dumps
#undef LANG_HOOKS_HANDLE_OPTION
#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
#undef LANG_HOOKS_HANDLE_FILENAME
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h (revision 248195)
+++ cp/cp-tree.h (working copy)
@@ -5752,6 +5752,9 @@ concept_template_p (tree t)
e.g "int f(void)". */
extern cp_parameter_declarator *no_parameters;
+/* Various dump ids. */
+extern int class_dump_id;
+
/* in call.c */
extern bool check_dtor_name (tree, tree);
int magic_varargs_p (tree);
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 248195)
+++ doc/invoke.texi (working copy)
@@ -544,6 +544,9 @@ Objective-C and Objective-C++ Dialects}.
-fdump-final-insns@r{[}=@var{file}@r{]}
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
-fdump-lang-all @gol
+-fdump-lang-@var{switch} @gol
+-fdump-lang-@var{switch}-@var{options} @gol
+-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
-fdump-passes @gol
-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
-fdump-statistics @gol
@@ -12940,16 +12943,6 @@ When doing debugging dumps (see @option{
instruction numbers for the links to the previous and next instructions
in a sequence.
-@item -fdump-class-hierarchy @r{(C++ only)}
-@itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
-@opindex fdump-class-hierarchy
-Dump a representation of each class's hierarchy and virtual function
-table layout to a file. The file name is made by appending
-@file{.class} to the source file name, and the file is created in the
-same directory as the output file. If the @samp{-@var{options}} form
-is used, @var{options} controls the details of the dump as described
-for the @option{-fdump-tree} options.
-
@item -fdump-ipa-@var{switch}
@opindex fdump-ipa
Control the dumping at various stages of inter-procedural analysis
@@ -12972,8 +12965,26 @@ Dump after function inlining.
@end table
@item -fdump-lang-all
+@itemx -fdump-lang-@var{switch}
+@itemx -fdump-lang-@var{switch}-@var{options}
+@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
@opindex fdump-lang-all
-Control the dumping of language-specific information.
+@opindex fdump-lang
+Control the dumping of language-specific information. The @var{options}
+and @var{filename} portions behave as described in the
+`@option{-fdump-tree} option. The following @var{switch} values are
+accepted:
+
+@table @samp
+@item all
+
+Enable all language-specific dumps.
+
+@item class
+Dump class heirarchy information. Virtual table information is emitted
+unless '@option{slim}' is specified. This option is applicable to C++ only.
+
+@end table
@item -fdump-passes
@opindex fdump-passes
Index: dumpfile.c
===================================================================
--- dumpfile.c (revision 248195)
+++ dumpfile.c (working copy)
@@ -60,15 +60,13 @@ static struct dump_file_info dump_files[
0, 0, 0, 0, 0, false, false},
{".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
0, 0, 0, 0, 1, false, false},
- {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
- 0, 0, 0, 0, 2, false, false},
{".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 3, false, false},
{".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 4, false, false},
{".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE,
0, 0, 0, 0, 5, false, false},
-#define FIRST_AUTO_NUMBERED_DUMP 6
+#define FIRST_AUTO_NUMBERED_DUMP 5
{NULL, "lang-all", NULL, NULL, NULL, NULL, NULL, TDF_LANG,
0, 0, 0, 0, 0, false, false},
Index: dumpfile.h
===================================================================
--- dumpfile.h (revision 248195)
+++ dumpfile.h (working copy)
@@ -31,7 +31,6 @@ enum tree_dump_index
TDI_inheritance, /* dump type inheritance graph. */
TDI_clones, /* dump IPA cloning decisions. */
TDI_tu, /* dump the whole translation unit. */
- TDI_class, /* dump class hierarchy. */
TDI_original, /* dump each function before optimizing it */
TDI_generic, /* dump each function after genericizing it */
TDI_nested, /* dump each function after unnesting it */
Index: langhooks-def.h
===================================================================
--- langhooks-def.h (revision 248195)
+++ langhooks-def.h (working copy)
@@ -39,6 +39,7 @@ extern void lhd_do_nothing (void);
extern void lhd_do_nothing_t (tree);
extern void lhd_do_nothing_f (struct function *);
extern tree lhd_pass_through_t (tree);
+extern void lhd_register_dumps (gcc::dump_manager *);
extern bool lhd_post_options (const char **);
extern alias_set_type lhd_get_alias_set (tree);
extern tree lhd_return_null_tree (tree);
@@ -97,6 +98,7 @@ extern int lhd_type_dwarf_attribute (con
#define LANG_HOOKS_INIT_OPTIONS_STRUCT hook_void_gcc_optionsp
#define LANG_HOOKS_INIT_OPTIONS lhd_init_options
#define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
+#define LANG_HOOKS_REGISTER_DUMPS lhd_register_dumps
#define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lhd_complain_wrong_lang_p
#define LANG_HOOKS_HANDLE_OPTION lhd_handle_option
#define LANG_HOOKS_POST_OPTIONS lhd_post_options
@@ -294,6 +296,7 @@ extern void lhd_end_section (void);
LANG_HOOKS_INIT_OPTIONS_STRUCT, \
LANG_HOOKS_INIT_OPTIONS, \
LANG_HOOKS_INITIALIZE_DIAGNOSTICS, \
+ LANG_HOOKS_REGISTER_DUMPS, \
LANG_HOOKS_COMPLAIN_WRONG_LANG_P, \
LANG_HOOKS_HANDLE_OPTION, \
LANG_HOOKS_POST_OPTIONS, \
Index: langhooks.c
===================================================================
--- langhooks.c (revision 248195)
+++ langhooks.c (working copy)
@@ -322,6 +322,12 @@ lhd_initialize_diagnostics (diagnostic_c
{
}
+/* Called to register dumps. */
+void
+lhd_register_dumps (gcc::dump_manager *)
+{
+}
+
/* Called to perform language-specific options initialization. */
void
lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
Index: langhooks.h
===================================================================
--- langhooks.h (revision 248195)
+++ langhooks.h (working copy)
@@ -326,6 +326,9 @@ struct lang_hooks
global diagnostic context structure. */
void (*initialize_diagnostics) (diagnostic_context *);
+ /* Register language-specific dumps. */
+ void (*register_dumps) (gcc::dump_manager *);
+
/* Return true if a warning should be given about option OPTION,
which is for the wrong language, false if it should be quietly
ignored. */
Index: testsuite/g++.dg/inherit/covariant7.C
===================================================================
--- testsuite/g++.dg/inherit/covariant7.C (revision 248195)
+++ testsuite/g++.dg/inherit/covariant7.C (working copy)
@@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-prune-output "direct base" }
-// { dg-options "-fdump-class-hierarchy" }
+// { dg-options "-fdump-lang-class" }
// Copyright (C) 2002 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 27 Dec 2002 <nathan@codesourcery.com>
Index: toplev.c
===================================================================
--- toplev.c (revision 248195)
+++ toplev.c (working copy)
@@ -1154,9 +1154,17 @@ general_init (const char *argv0, bool in
processing. */
init_ggc_heuristics ();
- /* Create the singleton holder for global state.
- Doing so also creates the pass manager and with it the passes. */
+ /* Create the singleton holder for global state. This creates the
+ dump manager. */
g = new gcc::context ();
+
+ /* Allow languages to register their dumps before the optimization
+ passes. */
+ lang_hooks.register_dumps (g->get_dumps ());
+
+ /* Create the passes. */
+ g->set_passes (new gcc::pass_manager (g));
+
symtab = new (ggc_cleared_alloc <symbol_table> ()) symbol_table ();
statistics_early_init ();
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-16 16:01 [PATCH] gcc::context creation Nathan Sidwell
2017-05-18 15:15 ` Nathan Sidwell
@ 2017-05-19 9:03 ` Richard Biener
1 sibling, 0 replies; 16+ messages in thread
From: Richard Biener @ 2017-05-19 9:03 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, mliska@suse.cz >> Martin Liška
On Tue, May 16, 2017 at 5:26 PM, Nathan Sidwell <nathan@acm.org> wrote:
> This patch breaks apart the creation of the pass manager from gcc::context's
> ctor. This will allow us to register additional dumps between the dumpfile
> manager creation and the pass manager. As I described in
> https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01164.html when I tried to do
> this for the language-specific dumps, the existing LANG_HOOKS_INIT_OPTIONS
> ran too late, and I had to create a new hook and call it from gcc::context's
> constructor to get it done before the passes were created. That's ugly.
> Calling the hook from toplev seems better.
>
> Also, I noticed that we were passing a pointer to the
> not-yet-fully-constructed context to the pass manager, which smells funny.
>
> ok?
Ok. Might break JIT?
Thanks,
Richard.
> nathan
> --
> Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-18 15:15 ` Nathan Sidwell
@ 2017-05-19 9:10 ` Richard Biener
2017-05-24 10:59 ` Jakub Jelinek
1 sibling, 0 replies; 16+ messages in thread
From: Richard Biener @ 2017-05-19 9:10 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, Martin Liška
On Thu, May 18, 2017 at 5:08 PM, Nathan Sidwell <nathan@acm.org> wrote:
> On 05/16/2017 11:26 AM, Nathan Sidwell wrote:
>>
>> This patch breaks apart the creation of the pass manager from
>> gcc::context's ctor. This will allow us to register additional dumps
>
> ... https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01295.html
>
> This patch builds upon the context creation patch (this diff includes it),
> to implement a new LANG_HOOK_REGISTER_DUMPS language hook. I call it
> between creating the dump manager and instantiating the optimization passes.
>
> The patch then uses the hook to move the current -fdump-class-hierarchy
> option into the C++ FE entirely, removing TDI_class and associated handling
> from dumpfile and c-family/c-opts.c. The option gets renamed to
> -fdump-lang-class in the process.
>
> Obviously -fdump-translation-unit is the next candidate, and possibly
> -fdump-tree-original.
>
>
> ok?
Ok.
Thanks,
Richard.
> nathan
>
>
> --
> Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-18 15:15 ` Nathan Sidwell
2017-05-19 9:10 ` Richard Biener
@ 2017-05-24 10:59 ` Jakub Jelinek
2017-05-24 11:34 ` Jakub Jelinek
2017-05-24 11:47 ` Nathan Sidwell
1 sibling, 2 replies; 16+ messages in thread
From: Jakub Jelinek @ 2017-05-24 10:59 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, Richard Biener, Martin Liška
On Thu, May 18, 2017 at 11:08:51AM -0400, Nathan Sidwell wrote:
> On 05/16/2017 11:26 AM, Nathan Sidwell wrote:
> > This patch breaks apart the creation of the pass manager from
> > gcc::context's ctor. This will allow us to register additional dumps
> ... https://gcc.gnu.org/ml/gcc-patches/2017-05/msg01295.html
>
> This patch builds upon the context creation patch (this diff includes it),
> to implement a new LANG_HOOK_REGISTER_DUMPS language hook. I call it
> between creating the dump manager and instantiating the optimization passes.
>
> The patch then uses the hook to move the current -fdump-class-hierarchy
> option into the C++ FE entirely, removing TDI_class and associated handling
> from dumpfile and c-family/c-opts.c. The option gets renamed to
> -fdump-lang-class in the process.
>
> Obviously -fdump-translation-unit is the next candidate, and possibly
> -fdump-tree-original.
This breaks the dump numbering.
On some simple source file with some OpenMP pragmas in it, with C
and -fopenmp -fdump-tree-all I'm getting (so unless one knows the order
of passes, the indexes and file order no longer reveal the actual pass
sequence):
1.c.003t.omplower
1.c.003t.original
1.c.004t.gimple
1.c.004t.lower
1.c.007t.eh
1.c.008t.cfg
1.c.009t.ompexp
...
The right order is .original, .gimple, then (not included) .nested,
then .omplower, .lower, etc.
With C++ -fopenmp -fdump-tree-all I'm getting:
1.c.003t.original
1.c.004t.gimple
1.c.005t.omplower
1.c.006t.lower
1.c.008t.ehopt
1.c.009t.eh
...
which is slightly better, but there is no space for e.g. the .nested
dump. With -fopenmp -fdump-tree-all -fdump-lang-all and C++ I'm getting
1.c.003t.original
1.c.004l.raw
1.c.004t.gimple
1.c.005t.omplower
1.c.006t.lower
1.c.008t.ehopt
1.c.009t.eh
...
so there is a number clash in between the raw and gimple dumps in addition
to the nested vs. omplower.
So, first question, where should we order the -fdump-lang-* dumps, shall
they go before .original/.gimple/.nested, or in between .original and
.gimple/.nested, or after those 3 (the last option looks just wrong to me)?
Shall the 3 standard dumps be registered like any others?
Shall the number of lang dumps affect the numbering, i.e. is it desirable
that with C and C++ you get different numbers for *t.cfg dump, or *t.gimple?
In many cases it would be better if the numbering was consistent between C
and C++.
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-24 10:59 ` Jakub Jelinek
@ 2017-05-24 11:34 ` Jakub Jelinek
2017-05-24 11:47 ` Nathan Sidwell
1 sibling, 0 replies; 16+ messages in thread
From: Jakub Jelinek @ 2017-05-24 11:34 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, Richard Biener, Martin Liška
On Wed, May 24, 2017 at 12:57:28PM +0200, Jakub Jelinek wrote:
> So, first question, where should we order the -fdump-lang-* dumps, shall
> they go before .original/.gimple/.nested, or in between .original and
> .gimple/.nested, or after those 3 (the last option looks just wrong to me)?
> Shall the 3 standard dumps be registered like any others?
> Shall the number of lang dumps affect the numbering, i.e. is it desirable
> that with C and C++ you get different numbers for *t.cfg dump, or *t.gimple?
> In many cases it would be better if the numbering was consistent between C
> and C++.
If we wanted to order the dumps .original, .gimple, .nested, then 0-n *l.*
dumps, then the rest, then something like the following would work.
But I don't think we want to order .gimple before the *l.* dumps, and I'd
appreciate stable dump offsets between languages, so one can
./cc1 -fdump-tree-all 1.c
./cc1plus -fdump-tree-all 2.c
and diff -up {1,2}.c.074t.whatever instead of figuring out what different
numbers they have.
2017-05-24 Jakub Jelinek <jakub@redhat.com>
* dumpfile.c (dump_files): Use num 1, 2, 3 instead of 3, 4, 5
for .original, .gimple and .nested.
(FIRST_AUTO_NUMBERED_DUMP): Increase to 4.
--- gcc/dumpfile.c.jj 2017-05-22 20:49:02.000000000 +0200
+++ gcc/dumpfile.c 2017-05-24 12:30:17.205182094 +0200
@@ -73,10 +73,10 @@ static struct dump_file_info dump_files[
dump_file_info (".cgraph", "ipa-cgraph", DK_ipa, 0),
dump_file_info (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0),
dump_file_info (".ipa-clones", "ipa-clones", DK_ipa, 0),
- dump_file_info (".original", "tree-original", DK_tree, 3),
- dump_file_info (".gimple", "tree-gimple", DK_tree, 4),
- dump_file_info (".nested", "tree-nested", DK_tree, 5),
-#define FIRST_AUTO_NUMBERED_DUMP 3
+ dump_file_info (".original", "tree-original", DK_tree, 1),
+ dump_file_info (".gimple", "tree-gimple", DK_tree, 2),
+ dump_file_info (".nested", "tree-nested", DK_tree, 3),
+#define FIRST_AUTO_NUMBERED_DUMP 4
dump_file_info (NULL, "lang-all", DK_lang, 0),
dump_file_info (NULL, "tree-all", DK_tree, 0),
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-24 10:59 ` Jakub Jelinek
2017-05-24 11:34 ` Jakub Jelinek
@ 2017-05-24 11:47 ` Nathan Sidwell
2017-05-24 11:58 ` Jakub Jelinek
1 sibling, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2017-05-24 11:47 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, Richard Biener, Martin Liška
On 05/24/2017 06:57 AM, Jakub Jelinek wrote:
> So, first question, where should we order the -fdump-lang-* dumps, shall
> they go before .original/.gimple/.nested, or in between .original and
> .gimple/.nested, or after those 3 (the last option looks just wrong to me)?
I think the lang dumps should come first.
> Shall the 3 standard dumps be registered like any others?
I think they should move to the new dynamic registration.
Should 'original' become a lang dump?
> Shall the number of lang dumps affect the numbering, i.e. is it desirable
> that with C and C++ you get different numbers for *t.cfg dump, or *t.gimple?
> In many cases it would be better if the numbering was consistent between C
> and C++.
I'm ambivalent on this. I can see why consistency might be desirable
though. I'd be fine with making the lang dumps unnumbered to achieve
that -- I don't see an obvious need for a language to have two dumps of
the same name.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-24 11:47 ` Nathan Sidwell
@ 2017-05-24 11:58 ` Jakub Jelinek
2017-05-24 12:12 ` Nathan Sidwell
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Jelinek @ 2017-05-24 11:58 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, Richard Biener, Martin Liška
On Wed, May 24, 2017 at 07:44:49AM -0400, Nathan Sidwell wrote:
> On 05/24/2017 06:57 AM, Jakub Jelinek wrote:
>
> > So, first question, where should we order the -fdump-lang-* dumps, shall
> > they go before .original/.gimple/.nested, or in between .original and
> > .gimple/.nested, or after those 3 (the last option looks just wrong to me)?
>
> I think the lang dumps should come first.
>
> > Shall the 3 standard dumps be registered like any others?
>
> I think they should move to the new dynamic registration.
> Should 'original' become a lang dump?
It would be great if the original dumping was able to use some FE specific
printing, right now the *.original dump is often full of
<<cleanup_point <<< Unknown tree: expr_stmt
and similar stuff. It is desirable that it is provided by every FE though
if it is a lang dump.
On the other side there are 370+ tests that use -fdump-tree-original.
> > Shall the number of lang dumps affect the numbering, i.e. is it desirable
> > that with C and C++ you get different numbers for *t.cfg dump, or *t.gimple?
> > In many cases it would be better if the numbering was consistent between C
> > and C++.
>
> I'm ambivalent on this. I can see why consistency might be desirable
> though. I'd be fine with making the lang dumps unnumbered to achieve that
> -- I don't see an obvious need for a language to have two dumps of the same
> name.
The numbering is not to differentiate between dumps of the same name, that
is done through numbered suffixes of the dump names, but to make the order
of passes visible to the user and for sorted file listing to be provided in
that order. So, rather than having lang files unnumbered, I think it is
better to number them and just have a maximum of lang dumps and if some FE
registers fewers, bump m_next_dump accordingly (create a hole).
That is pretty much the standard behavior, if some dump is registered, but
for whatever reason not dumped, you also get a hole.
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-24 11:58 ` Jakub Jelinek
@ 2017-05-24 12:12 ` Nathan Sidwell
2017-06-05 9:46 ` Jakub Jelinek
0 siblings, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2017-05-24 12:12 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, Richard Biener, Martin Liška
On 05/24/2017 07:57 AM, Jakub Jelinek wrote:
> The numbering is not to differentiate between dumps of the same name, that
> is done through numbered suffixes of the dump names, but to make the order
> of passes visible to the user and for sorted file listing to be provided in
> that order. So, rather than having lang files unnumbered, I think it is
> better to number them and just have a maximum of lang dumps and if some FE
> registers fewers, bump m_next_dump accordingly (create a hole).
> That is pretty much the standard behavior, if some dump is registered, but
> for whatever reason not dumped, you also get a hole.
oh, ok. Seems fine to me.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-05-24 12:12 ` Nathan Sidwell
@ 2017-06-05 9:46 ` Jakub Jelinek
2017-06-05 10:57 ` Nathan Sidwell
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Jelinek @ 2017-06-05 9:46 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: GCC Patches, Richard Biener, Martin Liška
On Wed, May 24, 2017 at 08:00:30AM -0400, Nathan Sidwell wrote:
> On 05/24/2017 07:57 AM, Jakub Jelinek wrote:
>
> > The numbering is not to differentiate between dumps of the same name, that
> > is done through numbered suffixes of the dump names, but to make the order
> > of passes visible to the user and for sorted file listing to be provided in
> > that order. So, rather than having lang files unnumbered, I think it is
> > better to number them and just have a maximum of lang dumps and if some FE
> > registers fewers, bump m_next_dump accordingly (create a hole).
> > That is pretty much the standard behavior, if some dump is registered, but
> > for whatever reason not dumped, you also get a hole.
>
> oh, ok. Seems fine to me.
Here is a patch to implement that. I chose to keep the 3 dumps predefined
dumps and just tweak their registered number, otherwise the changes would be
bigger. The patch additionally renames TDI_generic to TDI_gimple (to match
the dump name and content) and because we have more than 256 dumps these
days and we register them all even at -O0, the patch avoids 4 unnecessary
reallocations. Ok for trunk if testing passes?
2017-06-05 Jakub Jelinek <jakub@redhat.com>
* dumpfile.h (enum tree_dump_index): Rename TDI_generic to
TDI_gimple.
(class dump_manager): Add register_dumps method.
* dumpfile.c: Include langhooks.h.
(dump_files): Use 0 instead of 3/4/5 for TDI_{original,gimple,nested}.
(FIRST_AUTO_NUMBERED_DUMP): Decrease to 1.
(FIRST_ME_AUTO_NUMBERED_DUMP): Define.
(dump_manager::dump_register): Start with 512 entries instead of 32.
(dump_manager::register_dumps): New method.
* toplev.c (general_init): Instead of invoking register_dumps
langhook, invoke register_dumps method on the dump manager.
* gimplify.c (gimplify_function_tree): Use TDI_gimple instead of
TDI_generic.
* gimple-parser.c (c_parser_parse_gimple_body): Use TDI_gimple instead
of TDI_generic.
--- gcc/dumpfile.h.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/dumpfile.h 2017-06-05 11:20:07.563008969 +0200
@@ -31,7 +31,7 @@ enum tree_dump_index
TDI_inheritance, /* dump type inheritance graph. */
TDI_clones, /* dump IPA cloning decisions. */
TDI_original, /* dump each function before optimizing it */
- TDI_generic, /* dump each function after genericizing it */
+ TDI_gimple, /* dump each function after gimplifying it */
TDI_nested, /* dump each function after unnesting it */
TDI_lang_all, /* enable all the language dumps. */
@@ -212,6 +212,11 @@ public:
dump_register (const char *suffix, const char *swtch, const char *glob,
dump_kind dkind, int optgroup_flags, bool take_ownership);
+ /* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+ void
+ register_dumps ();
+
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
get_dump_file_info (int phase) const;
--- gcc/dumpfile.c.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/dumpfile.c 2017-06-05 11:21:27.381013150 +0200
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
#include "dumpfile.h"
#include "context.h"
#include "tree-cfg.h"
+#include "langhooks.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */
@@ -59,10 +60,11 @@ static struct dump_file_info dump_files[
DUMP_FILE_INFO (".cgraph", "ipa-cgraph", DK_ipa, 0),
DUMP_FILE_INFO (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0),
DUMP_FILE_INFO (".ipa-clones", "ipa-clones", DK_ipa, 0),
- DUMP_FILE_INFO (".original", "tree-original", DK_tree, 3),
- DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 4),
- DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 5),
-#define FIRST_AUTO_NUMBERED_DUMP 3
+ DUMP_FILE_INFO (".original", "tree-original", DK_tree, 0),
+ DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 0),
+ DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 0),
+#define FIRST_AUTO_NUMBERED_DUMP 1
+#define FIRST_ME_AUTO_NUMBERED_DUMP 3
DUMP_FILE_INFO (NULL, "lang-all", DK_lang, 0),
DUMP_FILE_INFO (NULL, "tree-all", DK_tree, 0),
@@ -179,7 +181,7 @@ dump_register (const char *suffix, const
if (count >= m_extra_dump_files_alloced)
{
if (m_extra_dump_files_alloced == 0)
- m_extra_dump_files_alloced = 32;
+ m_extra_dump_files_alloced = 512;
else
m_extra_dump_files_alloced *= 2;
m_extra_dump_files = XRESIZEVEC (struct dump_file_info,
@@ -200,6 +202,25 @@ dump_register (const char *suffix, const
}
+/* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+void
+gcc::dump_manager::
+register_dumps ()
+{
+ lang_hooks.register_dumps (this);
+ /* If this assert fails, some FE registered more than
+ FIRST_ME_AUTO_NUMBERED_DUMP - FIRST_AUTO_NUMBERED_DUMP
+ dump files. Bump FIRST_ME_AUTO_NUMBERED_DUMP accordingly. */
+ gcc_assert (m_next_dump <= FIRST_ME_AUTO_NUMBERED_DUMP);
+ if (m_next_dump < FIRST_ME_AUTO_NUMBERED_DUMP)
+ m_next_dump = FIRST_ME_AUTO_NUMBERED_DUMP;
+ dump_files[TDI_original].num = m_next_dump++;
+ dump_files[TDI_gimple].num = m_next_dump++;
+ dump_files[TDI_nested].num = m_next_dump++;
+}
+
+
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
--- gcc/toplev.c.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/toplev.c 2017-06-05 11:04:04.085038583 +0200
@@ -1168,9 +1168,9 @@ general_init (const char *argv0, bool in
dump manager. */
g = new gcc::context ();
- /* Allow languages to register their dumps before the optimization
- passes. */
- lang_hooks.register_dumps (g->get_dumps ());
+ /* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+ g->get_dumps ()->register_dumps ();
/* Create the passes. */
g->set_passes (new gcc::pass_manager (g));
--- gcc/gimplify.c.jj 2017-06-02 09:01:20.000000000 +0200
+++ gcc/gimplify.c 2017-06-05 11:21:45.097792114 +0200
@@ -12732,7 +12732,7 @@ gimplify_function_tree (tree fndecl)
pop_cfun ();
- dump_function (TDI_generic, fndecl);
+ dump_function (TDI_gimple, fndecl);
}
/* Return a dummy expression of type TYPE in order to keep going after an
--- gcc/c/gimple-parser.c.jj 2017-06-02 09:01:07.000000000 +0200
+++ gcc/c/gimple-parser.c 2017-06-05 11:22:04.636548346 +0200
@@ -116,7 +116,7 @@ c_parser_parse_gimple_body (c_parser *pa
we have to go through lowering again. */
cfun->curr_properties = PROP_gimple_any;
- dump_function (TDI_generic, current_function_decl);
+ dump_function (TDI_gimple, current_function_decl);
}
/* Parse a compound statement in gimple function body.
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 9:46 ` Jakub Jelinek
@ 2017-06-05 10:57 ` Nathan Sidwell
2017-06-05 11:47 ` Jakub Jelinek
0 siblings, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2017-06-05 10:57 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, Richard Biener, Martin Liška
On 06/05/2017 05:46 AM, Jakub Jelinek wrote:
> Here is a patch to implement that. I chose to keep the 3 dumps predefined
> dumps and just tweak their registered number, otherwise the changes would be
> bigger.
Yeah, that can wait for another day.
> The patch additionally renames TDI_generic to TDI_gimple (to match
> the dump name and content) and because we have more than 256 dumps these
> days and we register them all even at -O0, the patch avoids 4 unnecessary
> reallocations. Ok for trunk if testing passes?
LGTM, two nits below. (I can't approve though)
> +/* Allow languages and middle-end to register their dumps before the
> + optimization passes. */
blank line needed here, I think?
> +void
> +gcc::dump_manager::
> +register_dumps ()
> +{
> + lang_hooks.register_dumps (this);
> + /* If this assert fails, some FE registered more than
> + FIRST_ME_AUTO_NUMBERED_DUMP - FIRST_AUTO_NUMBERED_DUMP
> + dump files. Bump FIRST_ME_AUTO_NUMBERED_DUMP accordingly. */
> + gcc_assert (m_next_dump <= FIRST_ME_AUTO_NUMBERED_DUMP);
> + if (m_next_dump < FIRST_ME_AUTO_NUMBERED_DUMP)
> + m_next_dump = FIRST_ME_AUTO_NUMBERED_DUMP;
Unconditionally set it? there's the protecting assert. It's almost as
if you want 'else gcc_unreachable ()' (with suitable morph of < to <=).
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 10:57 ` Nathan Sidwell
@ 2017-06-05 11:47 ` Jakub Jelinek
2017-06-05 12:46 ` Nathan Sidwell
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Jelinek @ 2017-06-05 11:47 UTC (permalink / raw)
To: Richard Biener, Nathan Sidwell; +Cc: gcc-patches
On Mon, Jun 05, 2017 at 06:57:47AM -0400, Nathan Sidwell wrote:
> On 06/05/2017 05:46 AM, Jakub Jelinek wrote:
>
> > Here is a patch to implement that. I chose to keep the 3 dumps predefined
> > dumps and just tweak their registered number, otherwise the changes would be
> > bigger.
>
> Yeah, that can wait for another day.
>
> > The patch additionally renames TDI_generic to TDI_gimple (to match
> > the dump name and content) and because we have more than 256 dumps these
> > days and we register them all even at -O0, the patch avoids 4 unnecessary
> > reallocations. Ok for trunk if testing passes?
>
> LGTM, two nits below. (I can't approve though)
>
> > +/* Allow languages and middle-end to register their dumps before the
> > + optimization passes. */
> blank line needed here, I think?
Whether there is a blank between function and its function comment
is something we aren't consistent in, but it seems that in dumpfile.c
there is a blank line, so I'm adjusting.
> > +void
> > +gcc::dump_manager::
> > +register_dumps ()
> > +{
> > + lang_hooks.register_dumps (this);
> > + /* If this assert fails, some FE registered more than
> > + FIRST_ME_AUTO_NUMBERED_DUMP - FIRST_AUTO_NUMBERED_DUMP
> > + dump files. Bump FIRST_ME_AUTO_NUMBERED_DUMP accordingly. */
> > + gcc_assert (m_next_dump <= FIRST_ME_AUTO_NUMBERED_DUMP);
> > + if (m_next_dump < FIRST_ME_AUTO_NUMBERED_DUMP)
> > + m_next_dump = FIRST_ME_AUTO_NUMBERED_DUMP;
>
> Unconditionally set it? there's the protecting assert. It's almost as if
> you want 'else gcc_unreachable ()' (with suitable morph of < to <=).
Unconditional set is fine, else gcc_unreachable (); looks ugly to me.
Here is updated patch:
2017-06-05 Jakub Jelinek <jakub@redhat.com>
* dumpfile.h (enum tree_dump_index): Rename TDI_generic to
TDI_gimple.
(class dump_manager): Add register_dumps method.
* dumpfile.c: Include langhooks.h.
(dump_files): Use 0 instead of 3/4/5 for TDI_{original,gimple,nested}.
(FIRST_AUTO_NUMBERED_DUMP): Decrease to 1.
(FIRST_ME_AUTO_NUMBERED_DUMP): Define.
(dump_manager::dump_register): Start with 512 entries instead of 32.
(dump_manager::register_dumps): New method.
* toplev.c (general_init): Instead of invoking register_dumps
langhook, invoke register_dumps method on the dump manager.
* gimplify.c (gimplify_function_tree): Use TDI_gimple instead of
TDI_generic.
* gimple-parser.c (c_parser_parse_gimple_body): Use TDI_gimple instead
of TDI_generic.
--- gcc/dumpfile.h.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/dumpfile.h 2017-06-05 11:20:07.563008969 +0200
@@ -31,7 +31,7 @@ enum tree_dump_index
TDI_inheritance, /* dump type inheritance graph. */
TDI_clones, /* dump IPA cloning decisions. */
TDI_original, /* dump each function before optimizing it */
- TDI_generic, /* dump each function after genericizing it */
+ TDI_gimple, /* dump each function after gimplifying it */
TDI_nested, /* dump each function after unnesting it */
TDI_lang_all, /* enable all the language dumps. */
@@ -212,6 +212,11 @@ public:
dump_register (const char *suffix, const char *swtch, const char *glob,
dump_kind dkind, int optgroup_flags, bool take_ownership);
+ /* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+ void
+ register_dumps ();
+
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
get_dump_file_info (int phase) const;
--- gcc/dumpfile.c.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/dumpfile.c 2017-06-05 11:21:27.381013150 +0200
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
#include "dumpfile.h"
#include "context.h"
#include "tree-cfg.h"
+#include "langhooks.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */
@@ -59,10 +60,11 @@ static struct dump_file_info dump_files[
DUMP_FILE_INFO (".cgraph", "ipa-cgraph", DK_ipa, 0),
DUMP_FILE_INFO (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0),
DUMP_FILE_INFO (".ipa-clones", "ipa-clones", DK_ipa, 0),
- DUMP_FILE_INFO (".original", "tree-original", DK_tree, 3),
- DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 4),
- DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 5),
-#define FIRST_AUTO_NUMBERED_DUMP 3
+ DUMP_FILE_INFO (".original", "tree-original", DK_tree, 0),
+ DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 0),
+ DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 0),
+#define FIRST_AUTO_NUMBERED_DUMP 1
+#define FIRST_ME_AUTO_NUMBERED_DUMP 3
DUMP_FILE_INFO (NULL, "lang-all", DK_lang, 0),
DUMP_FILE_INFO (NULL, "tree-all", DK_tree, 0),
@@ -179,7 +181,7 @@ dump_register (const char *suffix, const
if (count >= m_extra_dump_files_alloced)
{
if (m_extra_dump_files_alloced == 0)
- m_extra_dump_files_alloced = 32;
+ m_extra_dump_files_alloced = 512;
else
m_extra_dump_files_alloced *= 2;
m_extra_dump_files = XRESIZEVEC (struct dump_file_info,
@@ -200,6 +202,25 @@ dump_register (const char *suffix, const
}
+/* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+
+void
+gcc::dump_manager::
+register_dumps ()
+{
+ lang_hooks.register_dumps (this);
+ /* If this assert fails, some FE registered more than
+ FIRST_ME_AUTO_NUMBERED_DUMP - FIRST_AUTO_NUMBERED_DUMP
+ dump files. Bump FIRST_ME_AUTO_NUMBERED_DUMP accordingly. */
+ gcc_assert (m_next_dump <= FIRST_ME_AUTO_NUMBERED_DUMP);
+ m_next_dump = FIRST_ME_AUTO_NUMBERED_DUMP;
+ dump_files[TDI_original].num = m_next_dump++;
+ dump_files[TDI_gimple].num = m_next_dump++;
+ dump_files[TDI_nested].num = m_next_dump++;
+}
+
+
/* Return the dump_file_info for the given phase. */
struct dump_file_info *
--- gcc/toplev.c.jj 2017-06-02 09:01:10.000000000 +0200
+++ gcc/toplev.c 2017-06-05 11:04:04.085038583 +0200
@@ -1168,9 +1168,9 @@ general_init (const char *argv0, bool in
dump manager. */
g = new gcc::context ();
- /* Allow languages to register their dumps before the optimization
- passes. */
- lang_hooks.register_dumps (g->get_dumps ());
+ /* Allow languages and middle-end to register their dumps before the
+ optimization passes. */
+ g->get_dumps ()->register_dumps ();
/* Create the passes. */
g->set_passes (new gcc::pass_manager (g));
--- gcc/gimplify.c.jj 2017-06-02 09:01:20.000000000 +0200
+++ gcc/gimplify.c 2017-06-05 11:21:45.097792114 +0200
@@ -12732,7 +12732,7 @@ gimplify_function_tree (tree fndecl)
pop_cfun ();
- dump_function (TDI_generic, fndecl);
+ dump_function (TDI_gimple, fndecl);
}
/* Return a dummy expression of type TYPE in order to keep going after an
--- gcc/c/gimple-parser.c.jj 2017-06-02 09:01:07.000000000 +0200
+++ gcc/c/gimple-parser.c 2017-06-05 11:22:04.636548346 +0200
@@ -116,7 +116,7 @@ c_parser_parse_gimple_body (c_parser *pa
we have to go through lowering again. */
cfun->curr_properties = PROP_gimple_any;
- dump_function (TDI_generic, current_function_decl);
+ dump_function (TDI_gimple, current_function_decl);
}
/* Parse a compound statement in gimple function body.
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 11:47 ` Jakub Jelinek
@ 2017-06-05 12:46 ` Nathan Sidwell
2017-06-05 12:50 ` Jakub Jelinek
0 siblings, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2017-06-05 12:46 UTC (permalink / raw)
To: Jakub Jelinek, Richard Biener; +Cc: gcc-patches
On 06/05/2017 07:47 AM, Jakub Jelinek wrote:
> Whether there is a blank between function and its function comment
> is something we aren't consistent in, but it seems that in dumpfile.c
> there is a blank line, so I'm adjusting.
Ok (I only know the blank line rule because someone nitted one of my
patches)
> +#define FIRST_AUTO_NUMBERED_DUMP 1
> +#define FIRST_ME_AUTO_NUMBERED_DUMP 3
When you commit, could you set this to 4 (at least). Right now you have
no headroom for C++ FE changes. And I have a branch with a new lang dump :)
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 12:46 ` Nathan Sidwell
@ 2017-06-05 12:50 ` Jakub Jelinek
2017-06-05 14:55 ` Nathan Sidwell
0 siblings, 1 reply; 16+ messages in thread
From: Jakub Jelinek @ 2017-06-05 12:50 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Richard Biener, gcc-patches
On Mon, Jun 05, 2017 at 08:46:21AM -0400, Nathan Sidwell wrote:
> On 06/05/2017 07:47 AM, Jakub Jelinek wrote:
>
> > Whether there is a blank between function and its function comment
> > is something we aren't consistent in, but it seems that in dumpfile.c
> > there is a blank line, so I'm adjusting.
>
> Ok (I only know the blank line rule because someone nitted one of my
> patches)
>
>
> > +#define FIRST_AUTO_NUMBERED_DUMP 1
> > +#define FIRST_ME_AUTO_NUMBERED_DUMP 3
>
> When you commit, could you set this to 4 (at least). Right now you have no
> headroom for C++ FE changes. And I have a branch with a new lang dump :)
It was the intent that there is no unnecessary gap, the difference
between those two should be simply the maximum any FE registers.
So, on your branch you'd bump it to 4 and on trunk when merging your branch.
Jakub
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 12:50 ` Jakub Jelinek
@ 2017-06-05 14:55 ` Nathan Sidwell
2017-06-06 12:38 ` Richard Biener
0 siblings, 1 reply; 16+ messages in thread
From: Nathan Sidwell @ 2017-06-05 14:55 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Richard Biener, gcc-patches
On 06/05/2017 08:50 AM, Jakub Jelinek wrote:
> It was the intent that there is no unnecessary gap, the difference
> between those two should be simply the maximum any FE registers.
> So, on your branch you'd bump it to 4 and on trunk when merging your branch.
I can live with that.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH] gcc::context creation
2017-06-05 14:55 ` Nathan Sidwell
@ 2017-06-06 12:38 ` Richard Biener
0 siblings, 0 replies; 16+ messages in thread
From: Richard Biener @ 2017-06-06 12:38 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Jakub Jelinek, gcc-patches
On Mon, 5 Jun 2017, Nathan Sidwell wrote:
> On 06/05/2017 08:50 AM, Jakub Jelinek wrote:
>
> > It was the intent that there is no unnecessary gap, the difference
> > between those two should be simply the maximum any FE registers.
> > So, on your branch you'd bump it to 4 and on trunk when merging your branch.
>
> I can live with that.
Me too, in case you still need approval.
Richard.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2017-06-06 12:38 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 16:01 [PATCH] gcc::context creation Nathan Sidwell
2017-05-18 15:15 ` Nathan Sidwell
2017-05-19 9:10 ` Richard Biener
2017-05-24 10:59 ` Jakub Jelinek
2017-05-24 11:34 ` Jakub Jelinek
2017-05-24 11:47 ` Nathan Sidwell
2017-05-24 11:58 ` Jakub Jelinek
2017-05-24 12:12 ` Nathan Sidwell
2017-06-05 9:46 ` Jakub Jelinek
2017-06-05 10:57 ` Nathan Sidwell
2017-06-05 11:47 ` Jakub Jelinek
2017-06-05 12:46 ` Nathan Sidwell
2017-06-05 12:50 ` Jakub Jelinek
2017-06-05 14:55 ` Nathan Sidwell
2017-06-06 12:38 ` Richard Biener
2017-05-19 9:03 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).