* adding a PLUGIN_PARSED_UNIT event
@ 2009-10-15 17:08 Basile STARYNKEVITCH
2009-11-19 16:59 ` Diego Novillo
0 siblings, 1 reply; 2+ messages in thread
From: Basile STARYNKEVITCH @ 2009-10-15 17:08 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
Hello All,
The attached patch, to trunk rev 152849, add a PLUGIN_PARSED_UNIT event,
invoked at start of cgraph_finalize_compilation_unit after all the
compilation unit has been parsed.
My intuition is that we should better provide a little more hooks,
especially at a such higher level. Doing everything only in passes is
not practical (and was the reason to add stuff like PLUGIN_FINISH_UNIT
gcc/ChangeLog:
2009-10-15 Basile Starynkevitch <basile@starynkevitch.net>
* doc/plugins.texi (Plugin callbacks): added PLUGIN_PARSED_UNIT.
* cgraphunit.c (cgraph_finalize_compilation_unit): Added
invocation of PLUGIN_PARSED_UNIT callbacks.
* gcc-plugin.h: Added PLUGIN_PARSED_UNIT.
* plugin.c (plugin_event_name): Added PLUGIN_PARSED_UNIT.
(invoke_plugin_callbacks): ditto.
I am bootstrapping it right now on x86_64-unknown-gnu-linux for c&c++
Comments are welcome.
I also believe that we should have plugin hooks for builtins.
Regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
[-- Attachment #2: plugin_parsed_unit-patch-rev_152849.diff --]
[-- Type: text/x-patch, Size: 2507 bytes --]
Index: gcc/doc/plugins.texi
===================================================================
--- gcc/doc/plugins.texi (revision 152849)
+++ gcc/doc/plugins.texi (working copy)
@@ -136,6 +136,8 @@ enum plugin_event
PLUGIN_REGISTER_GGC_CACHES, /* Register an extra GGC cache table. */
PLUGIN_ATTRIBUTES, /* Called during attribute registration */
PLUGIN_START_UNIT, /* Called before processing a translation unit. */
+ PLUGIN_PARSED_UNIT, /* Called after a translation unit has
+ been parsed. */
PLUGIN_EVENT_LAST /* Dummy event used for indexing callback
array. */
@};
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c (revision 152849)
+++ gcc/cgraphunit.c (working copy)
@@ -1052,6 +1052,9 @@ cgraph_finalize_compilation_unit (void)
{
timevar_push (TV_CGRAPH);
+ /* Invoke registered plugin callbacks. */
+ invoke_plugin_callbacks (PLUGIN_PARSED_UNIT, NULL);
+
/* Do not skip analyzing the functions if there were errors, we
miss diagnostics for following functions otherwise. */
Index: gcc/gcc-plugin.h
===================================================================
--- gcc/gcc-plugin.h (revision 152849)
+++ gcc/gcc-plugin.h (working copy)
@@ -43,6 +43,8 @@ enum plugin_event
PLUGIN_REGISTER_GGC_CACHES, /* Register an extra GGC cache table. */
PLUGIN_ATTRIBUTES, /* Called during attribute registration. */
PLUGIN_START_UNIT, /* Called before processing a translation unit. */
+ PLUGIN_PARSED_UNIT, /* Called after a translation unit has
+ been parsed. */
PLUGIN_EVENT_LAST /* Dummy event used for indexing callback
array. */
};
Index: gcc/plugin.c
===================================================================
--- gcc/plugin.c (revision 152849)
+++ gcc/plugin.c (working copy)
@@ -58,7 +58,8 @@ const char *plugin_event_name[] =
"PLUGIN_GGC_END",
"PLUGIN_REGISTER_GGC_ROOTS",
"PLUGIN_REGISTER_GGC_CACHES",
- "PLUGIN_START_UNIT",
+ "PLUGIN_START_UNIT",
+ "PLUGIN_PARSED_UNIT",
"PLUGIN_EVENT_LAST"
};
@@ -365,6 +366,7 @@ invoke_plugin_callbacks (enum plugin_event event,
{
case PLUGIN_FINISH_TYPE:
case PLUGIN_START_UNIT:
+ case PLUGIN_PARSED_UNIT:
case PLUGIN_FINISH_UNIT:
case PLUGIN_CXX_CP_PRE_GENERICIZE:
case PLUGIN_ATTRIBUTES:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: adding a PLUGIN_PARSED_UNIT event
2009-10-15 17:08 adding a PLUGIN_PARSED_UNIT event Basile STARYNKEVITCH
@ 2009-11-19 16:59 ` Diego Novillo
0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2009-11-19 16:59 UTC (permalink / raw)
To: Basile STARYNKEVITCH; +Cc: gcc-patches
On Thu, Oct 15, 2009 at 08:28, Basile STARYNKEVITCH
<basile@starynkevitch.net> wrote:
> Hello All,
>
> The attached patch, to trunk rev 152849, add a PLUGIN_PARSED_UNIT event,
> invoked at start of cgraph_finalize_compilation_unit after all the
> compilation unit has been parsed.
What are you expecting to do with it? All the functions have been
parsed at that point, but they are not in a usable state for analysis.
Perhaps we want a hook right after all the functions have been
lowered and converted into SSA (right before the call to
cgraph_optimize).
Diego.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-19 16:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-15 17:08 adding a PLUGIN_PARSED_UNIT event Basile STARYNKEVITCH
2009-11-19 16:59 ` Diego Novillo
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).