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: [PATCH]: Fix PR29201 - [4.2 Regression] ICE in create_recovery_block, at haifa-sched.c:3692 at -O3


Ian Lance Taylor wrote:
Maxim Kuvyrkov <mkuvyrkov@ispras.ru> writes:

Here are two patches which do the same thing in a slightly different
way.  Pick your choice and, please, comment.

I like your second version better.


I think it would be better still if you pulled

+  barrier = next_nonnote_insn (BB_END (before_recovery));
+  if (LABEL_P (barrier) && JUMP_TABLE_DATA_P (NEXT_INSN (barrier)))
+    barrier = NEXT_INSN (NEXT_INSN (barrier));

into a small function in cfgrtl.c.

Like this one?



Ian

-- Maxim

--- testsuite/gcc.c-torture/compile/pr29201.c	(/local/trunk/gcc)	(revision 550)
+++ testsuite/gcc.c-torture/compile/pr29201.c	(/local/fix-pr29201-1/gcc)	(revision 550)
@@ -0,0 +1,116 @@
+/* { dg-do assemble { target ia64-*-* } } */
+typedef int gint;
+typedef gint gboolean;
+typedef unsigned int guint;
+typedef struct _MetaRectangle MetaRectangle;
+struct _MetaRectangle
+{
+  int x;
+  int y;
+};
+typedef struct _MetaDisplay MetaDisplay;
+typedef struct _MetaFrame MetaFrame;
+typedef struct _MetaWindow MetaWindow;
+typedef struct
+{
+  int win_gravity;
+}
+XSizeHints;
+typedef enum
+{
+  META_DEBUG_FOCUS = 1 << 0, META_DEBUG_WORKAREA = 1 << 1, META_DEBUG_STACK =
+    1 << 6, META_DEBUG_WINDOW_OPS = 1 << 7, META_DEBUG_GEOMETRY =
+    1 << 20, META_DEBUG_EDGE_RESISTANCE = 1 << 21
+}
+MetaStackLayer;
+struct _MetaWindow
+{
+  MetaDisplay *display;
+  MetaFrame *frame;
+  guint user_has_move_resized:1;
+  MetaRectangle user_rect;
+  XSizeHints size_hints;
+};
+void meta_window_get_position (MetaWindow * window, int *x, int *y);
+typedef struct _MetaFrameGeometry MetaFrameGeometry;
+struct _MetaFrameGeometry
+{
+};
+struct _MetaFrame
+{
+  MetaWindow *window;
+  MetaRectangle rect;
+  int child_x;
+  int child_y;
+};
+typedef enum
+{
+  META_IS_CONFIGURE_REQUEST = 1 << 0, META_DO_GRAVITY_ADJUST =
+    1 << 3, META_IS_RESIZE_ACTION = 1 << 4
+}
+MetaMoveResizeFlags;
+adjust_for_gravity (MetaWindow * window, MetaFrameGeometry * fgeom,
+		    gboolean coords_assume_border, int gravity,
+		    MetaRectangle * rect)
+{
+  int ref_x, ref_y;
+  int child_x, child_y;
+  int frame_width, frame_height;
+  switch (gravity)
+    {
+    case 1:
+      ref_x = rect->x;
+    }
+  switch (gravity)
+    {
+    case 1:
+      rect->y = ref_y + child_y;
+    case 2:
+      rect->x = ref_x - frame_width / 2 + child_x;
+      break;
+    case 3:
+    case 5:
+    case 6:
+      rect->x = ref_x - frame_width + child_x;
+    }
+}
+meta_window_move_resize_internal (MetaWindow * window,
+				  MetaMoveResizeFlags flags,
+				  int resize_gravity, int root_x_nw,
+				  int root_y_nw, int w, int h)
+{
+  unsigned int mask;
+  MetaFrameGeometry fgeom;
+  gboolean need_resize_client = (0);
+  gboolean is_configure_request;
+  MetaRectangle new_rect;
+  MetaRectangle old_rect;
+  {
+    adjust_for_gravity (window, window->frame ? &fgeom : ((void *) 0),
+			is_configure_request, window->size_hints.win_gravity,
+			&new_rect);
+  }
+  meta_window_constrain (window, window->frame ? &fgeom : ((void *) 0), flags,
+			 resize_gravity, &old_rect, &new_rect);
+  if (mask != 0)
+    {
+      {
+	meta_topic_real (META_DEBUG_GEOMETRY,
+			 need_resize_client ? "true" : "false");
+      }
+    }
+  {
+    window->user_has_move_resized = (!(0));
+    meta_window_get_position (window, &window->user_rect.x,
+			      &window->user_rect.y);
+  }
+}
+void
+meta_window_get_position (MetaWindow * window, int *x, int *y)
+{
+  if (window->frame)
+    {
+      *x = window->frame->rect.x + window->frame->child_x;
+      *y = window->frame->rect.y + window->frame->child_y;
+    }
+}
--- haifa-sched.c	(/local/trunk/gcc)	(revision 550)
+++ haifa-sched.c	(/local/fix-pr29201-1/gcc)	(revision 550)
@@ -3679,18 +3679,22 @@ static basic_block
 create_recovery_block (void)
 {
   rtx label;
+  rtx barrier;
   basic_block rec;
   
   added_recovery_block_p = true;
 
   if (!before_recovery)
     init_before_recovery ();
- 
-  label = gen_label_rtx ();
-  gcc_assert (BARRIER_P (NEXT_INSN (BB_END (before_recovery))));
-  label = emit_label_after (label, NEXT_INSN (BB_END (before_recovery)));
 
-  rec = create_basic_block (label, label, before_recovery); 
+  barrier = get_last_bb_insn (before_recovery);
+  gcc_assert (BARRIER_P (barrier));
+
+  label = emit_label_after (gen_label_rtx (), barrier);
+
+  rec = create_basic_block (label, label, before_recovery);
+
+  /* Recovery block always end with an unconditional jump.  */
   emit_barrier_after (BB_END (rec));
 
   if (BB_PARTITION (before_recovery) != BB_UNPARTITIONED)
--- basic-block.h	(/local/trunk/gcc)	(revision 550)
+++ basic-block.h	(/local/fix-pr29201-1/gcc)	(revision 550)
@@ -946,6 +946,7 @@ extern void update_br_prob_note (basic_b
 extern void fixup_abnormal_edges (void);
 extern bool inside_basic_block_p (rtx);
 extern bool control_flow_insn_p (rtx);
+extern rtx get_last_bb_insn (basic_block);
 
 /* In bb-reorder.c */
 extern void reorder_basic_blocks (unsigned int);
--- cfgrtl.c	(/local/trunk/gcc)	(revision 550)
+++ cfgrtl.c	(/local/fix-pr29201-1/gcc)	(revision 550)
@@ -361,7 +361,7 @@ cfg_layout_create_basic_block (void *hea
 static void
 rtl_delete_block (basic_block b)
 {
-  rtx insn, end, tmp;
+  rtx insn, end;
 
   /* If the head of this block is a CODE_LABEL, then it might be the
      label for an exception handler which can't be reached.  We need
@@ -370,18 +370,7 @@ rtl_delete_block (basic_block b)
   if (LABEL_P (insn))
     maybe_remove_eh_handler (insn);
 
-  /* Include any jump table following the basic block.  */
-  end = BB_END (b);
-  if (tablejump_p (end, NULL, &tmp))
-    end = tmp;
-
-  /* Include any barriers that may follow the basic block.  */
-  tmp = next_nonnote_insn (end);
-  while (tmp && BARRIER_P (tmp))
-    {
-      end = tmp;
-      tmp = next_nonnote_insn (end);
-    }
+  end = get_last_bb_insn (b);
 
   /* Selectively delete the entire chain.  */
   BB_HEAD (b) = NULL;
@@ -1715,6 +1704,29 @@ update_br_prob_note (basic_block bb)
     return;
   XEXP (note, 0) = GEN_INT (BRANCH_EDGE (bb)->probability);
 }
+
+/* Get the last insn associated with block BB (that includes barriers and
+   tablejumps after BB).  */
+rtx
+get_last_bb_insn (basic_block bb)
+{
+  rtx tmp;
+  rtx end = BB_END (bb);
+
+  /* Include any jump table following the basic block.  */
+  if (tablejump_p (end, NULL, &tmp))
+    end = tmp;
+
+  /* Include any barriers that may follow the basic block.  */
+  tmp = next_nonnote_insn (end);
+  while (tmp && BARRIER_P (tmp))
+    {
+      end = tmp;
+      tmp = next_nonnote_insn (end);
+    }
+
+  return end;
+}
 
 /* Verify the CFG and RTL consistency common for both underlying RTL and
    cfglayout RTL.

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