This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tuples] gs_bind changes


On Thu, Jul 05, 2007 at 02:25:29PM -0700, Christopher Matthews wrote:
> Hi Aldy!
>  Since I updated I'm getting a segfault (stack attached).  It looks like in:
> if (GS_SUBCODE_FLAGS (outer_bind) != GS_BIND)
> outer_bind is null in my case. Is it my bad test case?

The compiler should never segfault, regardless of the input, so this is
indeed a bug.

It looks like my code does not handle empty bodies.  I've fixed this,
and also fixed a typo where we were using GS_SUBCODE_FLAGS instead of
GS_CODE.

The original gimplifier code handled empty bodies; I've done likewise,
though this particular case of a "foo() {}" should've been handled by
gimplify_bind_expr() which is currently not working, because I haven't
coded it yet :-).  Still, it's probably a good idea to handle empty
bodies.

Thank you for pointing this out.

	* gimple-pretty-print.c (dump_gimple_stmt): Alphabetize cases.
	Add case for GS_NOP.
	* gimplify.c (gimplify_body): Handle null bodies.
	Use GS_CODE instead of GS_SUBCODE_FLAGS.

Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 126380)
+++ gimple-pretty-print.c	(working copy)
@@ -313,14 +313,14 @@ dump_gimple_stmt (pretty_printer *buffer
       dump_gs_bind (buffer, gs, spc, flags);
       break;
 
-    case GS_RETURN:
-      dump_gs_return (buffer, gs, spc, flags);
-      break;
-
     case GS_CALL:
       dump_gs_call (buffer, gs, spc, flags);
       break;
 
+    case GS_COND:
+      dump_gs_cond (buffer, gs, spc, flags);
+      break;
+
     case GS_LABEL:
       dump_generic_node (buffer, gs_label_label (gs), spc, flags, false);
       pp_character (buffer, ':');
@@ -331,8 +331,12 @@ dump_gimple_stmt (pretty_printer *buffer
       dump_generic_node (buffer, gs_goto_dest (gs), spc, flags, false);
       break;
 
-    case GS_COND:
-      dump_gs_cond (buffer, gs, spc, flags);
+    case GS_NOP:
+      pp_string (buffer, "GS_NOP tuple");
+      break;
+
+    case GS_RETURN:
+      dump_gs_return (buffer, gs, spc, flags);
       break;
 
     default:
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 126380)
+++ gimplify.c	(working copy)
@@ -6497,9 +6497,14 @@ gimplify_body (tree *body_p, gs_seq seq_
   gimplify_stmt (body_p, seq_p);
 
   outer_bind = gs_seq_first (seq_p);
+  if (!outer_bind)
+    {
+      outer_bind = gs_build_nop ();
+      gs_add (outer_bind, seq_p);
+    }
 
   /* If there isn't an outer GS_BIND, add one.  */
-  if (GS_SUBCODE_FLAGS (outer_bind) != GS_BIND)
+  if (GS_CODE (outer_bind) != GS_BIND)
     {
       outer_bind = gs_build_bind (NULL_TREE, seq_p);
       gs_seq_set_first (seq_p, outer_bind);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]