[PR,57805] Wasted work in write_roots()
diff mbox

Message ID 3ee8c50b1df5dd4ff6403be6416ef009.squirrel@webmail.cs.wisc.edu
State New
Headers show

Commit Message

pchang9@cs.wisc.edu July 17, 2013, 4:38 p.m. UTC
Hi,

The problem appears in revision 200945 in version 4.9.  I attached
a one-line patch that fixes it.  I also reported this problem at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57805.

In method "write_roots()" in gcc/gengtype.c, the loop on line 4682 should
break immediately after "skip_p" is set to "1". All the iterations after
"skip_p" set to "1" do not perform any useful work, at best they just set
"skip_p" again to "1".

Suggested patch:


-Chang
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 200945)
+++ gcc/gengtype.c	(working copy)
@@ -4682,7 +4682,10 @@
       for (o = v->opt; o; o = o->next)
 	if (strcmp (o->name, "deletable") == 0
 	    || strcmp (o->name, "if_marked") == 0)
-	  skip_p = 1;
+	  {
+	    skip_p = 1;
+	    break;
+	  }
 
       if (skip_p)
 	continue;

Comments

Jeff Law July 18, 2013, 4:08 p.m. UTC | #1
On 07/17/2013 10:38 AM, pchang9@cs.wisc.edu wrote:
> Hi,
>
> The problem appears in revision 200945 in version 4.9.  I attached
> a one-line patch that fixes it.  I also reported this problem at
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57805.
>
> In method "write_roots()" in gcc/gengtype.c, the loop on line 4682 should
> break immediately after "skip_p" is set to "1". All the iterations after
> "skip_p" set to "1" do not perform any useful work, at best they just set
> "skip_p" again to "1".
Bootstrapped and regression tested on x86_64-unknown-linux-gnu. 
Installed onto the trunk.

jeff

Patch
diff mbox

Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 200945)
+++ gcc/gengtype.c	(working copy)
@@ -4682,7 +4682,10 @@ 
       for (o = v->opt; o; o = o->next)
 	if (strcmp (o->name, "deletable") == 0
 	    || strcmp (o->name, "if_marked") == 0)
-	  skip_p = 1;
+	  {
+	    skip_p = 1;
+	    break;
+	  }

       if (skip_p)
 	continue;