From cTuning.org

(Difference between revisions)
Jump to: navigation, search
Current revision (20:30, 20 November 2009) (view source)
 
(One intermediate revision not shown.)
Line 99: Line 99:
Instead of the "bypass_gimple_in_ipa" hack, could we have a plugin event in execute_ipa_pass_list before it calls do_per_function_toporder,
Instead of the "bypass_gimple_in_ipa" hack, could we have a plugin event in execute_ipa_pass_list before it calls do_per_function_toporder,
which can set a flag for record_pass, which can then reset the flag before it returns.
which can set a flag for record_pass, which can then reset the flag before it returns.
 +
 +
=== event names ===
 +
Old: "all_passes_start" New: PLUGIN_ALL_PASSES_START
 +
 +
special case: Old: "avoid_gate" New: PLUGIN_OVERRIDE_GATE
=== Specifying plugins and plugin arguments, license check, and plugin startup ===
=== Specifying plugins and plugin arguments, license check, and plugin startup ===
-
This is detailed in doc/plugins.texi [http://gcc.gnu.org/onlinedocs/gccint/Plugins.html doc/plugins.texi].
+
This is detailed in [http://gcc.gnu.org/onlinedocs/gccint/Plugins.html doc/plugins.texi].
=== Things currently left out of the merge ===
=== Things currently left out of the merge ===

Current revision

Moving GCC to mainline ...

Separating ICI into:

  • manipulating with passes
  • calling events by name


Contents

Joern's new vision of ICI

(Step-by-step comparison with old one):

current ICI: registered parameters act as global variables throughout GCC.

In ipa_passes:

+  static int ici_ipa_passes_substitute_status;
+  static int ici_all_ipa_passes = 1;
+  static int ici_bypass_gimple_in_ipa = 0;
   set_cfun (NULL);
   current_function_decl = NULL;
   gimple_register_cfg_hooks ();
   bitmap_obstack_initialize (NULL);
-  execute_ipa_pass_list (all_ipa_passes);
+  
+  /* ICI: parameter all_ipa_pass is valid and set to 1 only 
+     when we execute IPA_PASS or SIMPLE_IPA_PASS.  */
+  register_event_parameter ("all_ipa_passes", 
+                            &ici_all_ipa_passes, 
+                            EP_SILENT);
+  /* ICI: parameter bypass_gimple_in_ipa is used to ensure
+     GIMPLE subpass of IPA passes are record only once.  */
+  register_event_parameter ("bypass_gimple_in_ipa", 
+                            &ici_bypass_gimple_in_ipa, 
+                            EP_SILENT);
...
+  unregister_event_parameter ("bypass_gimple_in_ipa");

In do_per_function_toporder:

+              int *bypass
+                  = (int *) get_event_parameter ("bypass_gimple_in_ipa");
              push_cfun (DECL_STRUCT_FUNCTION (node->decl));
              current_function_decl = node->decl;
              callback (data);
+              /* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/
+              if (bypass)
+                *bypass = 1;

In execute_ipa_pass_list:

+  int *ici_bypass_gimple_in_ipa;
... 
+              ici_bypass_gimple_in_ipa 
+                = (int *) get_event_parameter ("bypass_gimple_in_ipa");
+              if (ici_bypass_gimple_in_ipa)
+                  *ici_bypass_gimple_in_ipa = 0;

Other parameters of the "pass_execution" event are similarly manipulated all over GCC.

Proposed: events in gcc proper pass all the parameters in the event call to the low-level ICI plugin, which in turn makes them available to high-level plugins via get_event_parameter. The entire hash-table based event parameter handling lives in the low-level ICI plugin, and is thus invisible in GCC proper.

Example of the usage of ICI going to the mainline

If you really need a global variable in gcc proper, declare it in a header file, probably plugin.h:

extern int ici_bypass_gimple_in_ipa;

and define it in one of the files that manipulate it:

int ici_bypass_gimple_in_ipa;

Note: if your system supports common blocks (which is very likely), for purposes of prototyping you can define the global variable in the header file as long as you don't need an explicit initializer; but when a patch is to be contributed to the GCC mainline, you should only have a declaration in the header file.

Now you can manipulate the global variable directly when you want to change it, e.g. in do_per_function_toporder:

              /* Reset bypass_gimple_in_ipa to stop recording GIMPLE passes*/
              ici_bypass_gimple_in_ipa = 1;

At the event raising site, the parameters become explicit:

  invoke_plugin_va_callbacks (PLUGIN_PASS_EXECUTION,
                              "_pass_type", EP_INT, &(pass->type),
                              "all_ipa_passes", EP_SILENT, &ici_all_ipa_passes,
                              "all_passes", EP_SILENT, &ici_all_passes,
                              "bypass_gimple_in_ipa", EP_SILENT, &ici_bypass_gimple_in_ipa);

Better yet, remove global plugin variables from GCC proper. E.g. you have the all_passes_start and all_passes_end hooks, so you could register / unregister the all_passes parameter in these events' callbacks. Likewise for all_ipa_passes.

Instead of the "bypass_gimple_in_ipa" hack, could we have a plugin event in execute_ipa_pass_list before it calls do_per_function_toporder, which can set a flag for record_pass, which can then reset the flag before it returns.

event names

Old: "all_passes_start" New: PLUGIN_ALL_PASSES_START

special case: Old: "avoid_gate" New: PLUGIN_OVERRIDE_GATE

Specifying plugins and plugin arguments, license check, and plugin startup

This is detailed in doc/plugins.texi.

Things currently left out of the merge

patches to graphite.c: graphite has been re-written

register_pass[_by_name] calls in toplev.c : I believe these are redundant, because the two affected passes are already registered in the pass tree, with the side effect of calling register_pass_by_name.

parameters "all_ipa_passes", "bypass_gimple_in_ipa", "all_passes" - gcc already gernerates low-level plugin events that can be used to keep track of these.

I write some plugin code to set these parameters. There I set bypass_gimple_in_ipa ins the PLUGIN_PASS_EXECUTION callback, which means it will only be set for the first function where the pass is executed; the previous behaviour was to set it after processing the first function, even if the PLUGIN_PASS_EXECUTION would not have been called because of a gate action. I hope my change is for the better rather than the worse.

Locations of visitors to this page