Patchwork passes.c: handle register_pass with a name starting with a star

login
register
mail settings
Submitter Dennis, CHENG Renquan
Date July 11, 2010, 5:03 p.m.
Message ID <1278867813-28931-1-git-send-email-crquan@fedoraproject.org>
Download mbox | patch
Permalink /patch/58529/
State New
Headers show

Comments

Dennis, CHENG Renquan - July 11, 2010, 5:03 p.m.
The gcc included passes have the feature that a name starting with a start do
not dump anything; so should the plugin registered passes have.

And since passes from gcc and from plugin both have been asserted having a name
at least; the check for pass->name in any following code is not necessary.

Bootstraped and tested on i686-pc-linux-gnu with "--enable-checking=all".

2010-07-11  "Dennis, CHENG Renquan" <crquan@fedoraproject.org>

	* passes.c (register_pass): handle plugin registered passes with
	a name starting with a star do not dump anything.
	* passes.c: remove some cases of pass->name check.


--
Git 1.7.1.1

CHENG Renquan
38 St Thomas Walk, Singapore 238118      http://crquan.fedorapeople.org
Basile Starynkevitch - July 11, 2010, 5:39 p.m.
On Mon, 2010-07-12 at 01:03 +0800, Dennis, CHENG Renquan wrote:
> The gcc included passes have the feature that a name starting with a start do
> not dump anything; so should the plugin registered passes have.


I agree with the patch (but I am not authorized to OK it). However, I
strongly believe that we should specifically document that plugin
registered passes should have a name, and that a name starting with a
star don't have any dump files. AFAIK, nothing is clearly written in
http://gcc.gnu.org/onlinedocs/gccint/Plugins.html

And I would rather have the plugin pass registration code check that the
newly inserted plugin pass does have a name, (& probably either a gate
or an exec function, etc.).

Cheers.
Dennis, CHENG Renquan - July 11, 2010, 6:14 p.m.
On Mon, Jul 12, 2010 at 1:39 AM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> On Mon, 2010-07-12 at 01:03 +0800, Dennis, CHENG Renquan wrote:
>> The gcc included passes have the feature that a name starting with a start do
>> not dump anything; so should the plugin registered passes have.
>
> I agree with the patch (but I am not authorized to OK it). However, I
> strongly believe that we should specifically document that plugin
> registered passes should have a name, and that a name starting with a

> And I would rather have the plugin pass registration code check that the
> newly inserted plugin pass does have a name, (& probably either a gate
> or an exec function, etc.).

It really already has, inside register_pass (passes.c), the entry for
all plugin registered passes:

void
register_pass (struct register_pass_info *pass_info)
{
  bool all_instances, success;

  /* The checks below could fail in buggy plugins.  Existing GCC
     passes should never fail these checks, so we mention plugin in
     the messages.  */
  if (!pass_info->pass)
      fatal_error ("plugin cannot register a missing pass");

  if (!pass_info->pass->name)
      fatal_error ("plugin cannot register an unnamed pass");

If pass doesn't have a name, it would exit with fatal_error;

> star don't have any dump files. AFAIK, nothing is clearly written in
> http://gcc.gnu.org/onlinedocs/gccint/Plugins.html
The real problem should be the documentation, I should have another
patch to document plugin registered pass (passes.texi);

>
> Cheers.
> --
> 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 mine, sont seulement les miennes} ***
Dennis, CHENG Renquan - July 11, 2010, 6:17 p.m.
On Mon, Jul 12, 2010 at 1:39 AM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> On Mon, 2010-07-12 at 01:03 +0800, Dennis, CHENG Renquan wrote:
>> The gcc included passes have the feature that a name starting with a start do
>> not dump anything; so should the plugin registered passes have.

And I have a plugin "dotgen" utilizing this "no dump file" pass
feature; there explained
http://gcc.gnu.org/ml/gcc/2010-07/msg00170.html
Dennis, CHENG Renquan - July 20, 2010, 10:20 a.m.
On Mon, Jul 12, 2010 at 3:17 AM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> I did know about this star name convention. I very probably contributed
> to discuss & implement it.

where, have you implemented it somewhere? if what I did is really
duplicate, I will give up;

On Mon, Jul 12, 2010 at 2:17 AM, Dennis, CHENG Renquan
<crquan@fedoraproject.org> wrote:
> On Mon, Jul 12, 2010 at 1:39 AM, Basile Starynkevitch
> <basile@starynkevitch.net> wrote:
>> On Mon, 2010-07-12 at 01:03 +0800, Dennis, CHENG Renquan wrote:
>>> The gcc included passes have the feature that a name starting with a start do
>>> not dump anything; so should the plugin registered passes have.
>
> And I have a plugin "dotgen" utilizing this "no dump file" pass
> feature; there explained
> http://gcc.gnu.org/ml/gcc/2010-07/msg00170.html

pinging, some other comments?

Patch

--- gcc-4.5-20100708/gcc/passes.c.orig	2010-05-19 21:14:37.000000000 +0800
+++ gcc-4.5-20100708/gcc/passes.c	2010-07-12 00:58:48.999787669 +0800
@@ -422,7 +422,7 @@  register_dump_files_1 (struct opt_pass *
       int new_properties = (properties | pass->properties_provided)
 			   & ~pass->properties_destroyed;
 
-      if (pass->name && pass->name[0] != '*')
+      if (pass->name[0] != '*')
         register_one_dump_file (pass);
 
       if (pass->sub)
@@ -488,7 +488,7 @@  make_pass_instance (struct opt_pass *pas
          and so it should rename the dump file.  The first instance will
          be -1, and be number of duplicates = -static_pass_number - 1.
          Subsequent instances will be > 0 and just the duplicate number.  */
-      if ((pass->name && pass->name[0] != '*') || track_duplicates)
+      if (pass->name[0] != '*' || track_duplicates)
         {
           pass->static_pass_number -= 1;
           new_pass->static_pass_number = -pass->static_pass_number;
@@ -553,7 +553,6 @@  position_pass (struct register_pass_info
       /* Check if the current pass is of the same type as the new pass and
          matches the name and the instance number of the reference pass.  */
       if (pass->type == new_pass_info->pass->type
-          && pass->name
           && !strcmp (pass->name, new_pass_info->reference_pass_name)
           && ((new_pass_info->ref_pass_instance_number == 0)
               || (new_pass_info->ref_pass_instance_number ==
@@ -678,19 +677,24 @@  register_pass (struct register_pass_info
   while (added_pass_nodes)
     {
       struct pass_list_node *next_node = added_pass_nodes->next;
-      enum tree_dump_index tdi;
-      register_one_dump_file (added_pass_nodes->pass);
-      if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS
-          || added_pass_nodes->pass->type == IPA_PASS)
-        tdi = TDI_ipa_all;
-      else if (added_pass_nodes->pass->type == GIMPLE_PASS)
-        tdi = TDI_tree_all;
-      else
-        tdi = TDI_rtl_all;
-      /* Check if dump-all flag is specified.  */
-      if (get_dump_file_info (tdi)->state)
-        get_dump_file_info (added_pass_nodes->pass->static_pass_number)
-            ->state = get_dump_file_info (tdi)->state;
+
+      if (added_pass_nodes->pass->name[0] != '*')
+	{
+	  enum tree_dump_index tdi;
+
+	  register_one_dump_file (added_pass_nodes->pass);
+	  if (added_pass_nodes->pass->type == SIMPLE_IPA_PASS
+	      || added_pass_nodes->pass->type == IPA_PASS)
+	    tdi = TDI_ipa_all;
+	  else if (added_pass_nodes->pass->type == GIMPLE_PASS)
+	    tdi = TDI_tree_all;
+	  else
+	    tdi = TDI_rtl_all;
+	  /* Check if dump-all flag is specified.  */
+	  if (get_dump_file_info (tdi)->state)
+	    get_dump_file_info (added_pass_nodes->pass->static_pass_number)
+	      ->state = get_dump_file_info (tdi)->state;
+    	}
       XDELETE (added_pass_nodes);
       added_pass_nodes = next_node;
     }
@@ -1542,7 +1546,7 @@  execute_one_pass (struct opt_pass *pass)
   invoke_plugin_callbacks (PLUGIN_PASS_EXECUTION, pass);
 
   if (!quiet_flag && !cfun)
-    fprintf (stderr, " <%s>", pass->name ? pass->name : "");
+    fprintf (stderr, " <%s>", pass->name);
 
   /* Note that the folders should only create gimple expressions.
      This is a hack until the new folder is ready.  */