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]

[h8/300] FRAME_RELATED in epilogue


The H8 code sets FRAME_RELATED_P on any stack adjustment, not just the
prologue one.  The flag in the epilogue enables the epilogue unwinder,
which then crashes because all the other support is missing.  This
patch removes that one flag so that gcc doesn't crash.  Alternately, I
suppose we could add full epilogue unwinding support, in which case
this email serves as a quick fix for people who need a non-crashing
gcc :-)

	* conifg/h8300/h8300.c (F): Add "in_epilogue" flag.
	(Fpa): Pass it
	(h8300_emit_stack_adjustment): Propogate it.
	(push): Pass it.
	(h8300_expand_prologue): Likewise.
	(h8300_expand_epilogue): Likewise.

Index: gcc/config/h8300/h8300.c
===================================================================
--- gcc/config/h8300/h8300.c	(revision 155929)
+++ gcc/config/h8300/h8300.c	(working copy)
@@ -80,13 +80,13 @@ typedef unsigned char h8300_length_table
 /* Forward declarations.  */
 static const char *byte_reg (rtx, int);
 static int h8300_interrupt_function_p (tree);
 static int h8300_saveall_function_p (tree);
 static int h8300_monitor_function_p (tree);
 static int h8300_os_task_function_p (tree);
-static void h8300_emit_stack_adjustment (int, HOST_WIDE_INT);
+static void h8300_emit_stack_adjustment (int, HOST_WIDE_INT, bool);
 static HOST_WIDE_INT round_frame_size (HOST_WIDE_INT);
 static unsigned int compute_saved_regs (void);
 static void push (int);
 static void pop (int);
 static const char *cond_string (enum rtx_code);
 static unsigned int h8300_asm_insn_count (const char *);
@@ -506,15 +506,16 @@ byte_reg (rtx x, int b)
        || (h8300_current_function_interrupt_function_p ()		\
 	   && call_used_regs[regno]					\
 	   && !current_function_is_leaf)))
 
 /* We use this to wrap all emitted insns in the prologue.  */
 static rtx
-F (rtx x)
+F (rtx x, bool set_it)
 {
-  RTX_FRAME_RELATED_P (x) = 1;
+  if (set_it)
+    RTX_FRAME_RELATED_P (x) = 1;
   return x;
 }
 
 /* Mark all the subexpressions of the PARALLEL rtx PAR as
    frame-related.  Return PAR.
 
@@ -525,22 +526,22 @@ static rtx
 Fpa (rtx par)
 {
   int len = XVECLEN (par, 0);
   int i;
 
   for (i = 0; i < len; i++)
-    F (XVECEXP (par, 0, i));
+    F (XVECEXP (par, 0, i), true);
 
   return par;
 }
 
 /* Output assembly language to FILE for the operation OP with operand size
    SIZE to adjust the stack pointer.  */
 
 static void
-h8300_emit_stack_adjustment (int sign, HOST_WIDE_INT size)
+h8300_emit_stack_adjustment (int sign, HOST_WIDE_INT size, bool in_prologue)
 {
   /* If the frame size is 0, we don't have anything to do.  */
   if (size == 0)
     return;
 
   /* H8/300 cannot add/subtract a large constant with a single
@@ -549,15 +550,15 @@ h8300_emit_stack_adjustment (int sign, H
   if (TARGET_H8300
       && size > 4
       && !h8300_current_function_interrupt_function_p ()
       && !(cfun->static_chain_decl != NULL && sign < 0))
     {
       rtx r3 = gen_rtx_REG (Pmode, 3);
-      F (emit_insn (gen_movhi (r3, GEN_INT (sign * size))));
+      F (emit_insn (gen_movhi (r3, GEN_INT (sign * size))), in_prologue);
       F (emit_insn (gen_addhi3 (stack_pointer_rtx,
-				stack_pointer_rtx, r3)));
+				stack_pointer_rtx, r3)), in_prologue);
     }
   else
     {
       /* The stack adjustment made here is further optimized by the
 	 splitter.  In case of H8/300, the splitter always splits the
 	 addition emitted here to make the adjustment interrupt-safe.
@@ -565,17 +566,17 @@ h8300_emit_stack_adjustment (int sign, H
 	 the splitter will do.  */
       if (Pmode == HImode)
 	{
 	  rtx x = emit_insn (gen_addhi3 (stack_pointer_rtx,
 					 stack_pointer_rtx, GEN_INT (sign * size)));
 	  if (size < 4)
-	    F (x);
+	    F (x, in_prologue);
 	}
       else
 	F (emit_insn (gen_addsi3 (stack_pointer_rtx,
-				  stack_pointer_rtx, GEN_INT (sign * size))));
+				  stack_pointer_rtx, GEN_INT (sign * size))), in_prologue);
     }
 }
 
 /* Round up frame size SIZE.  */
 
 static HOST_WIDE_INT
@@ -619,13 +620,13 @@ push (int rn)
   if (TARGET_H8300)
     x = gen_push_h8300 (reg);
   else if (!TARGET_NORMAL_MODE)
     x = gen_push_h8300hs_advanced (reg);
   else
     x = gen_push_h8300hs_normal (reg);
-  x = F (emit_insn (x));
+  x = F (emit_insn (x), 1);
   REG_NOTES (x) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, 0);
 }
 
 /* Emit an insn to pop register RN.  */
 
 static void
@@ -851,13 +852,13 @@ h8300_expand_prologue (void)
     emit_insn (gen_monitor_prologue ());
 
   if (frame_pointer_needed)
     {
       /* Push fp.  */
       push (HARD_FRAME_POINTER_REGNUM);
-      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
+      F (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx), 1);
     }
 
   /* Push the rest of the registers in ascending order.  */
   saved_regs = compute_saved_regs ();
   for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno += n_regs)
     {
@@ -882,13 +883,13 @@ h8300_expand_prologue (void)
 
 	  h8300_push_pop (regno, n_regs, 0, 0);
 	}
     }
 
   /* Leave room for locals.  */
-  h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()));
+  h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()), true);
 }
 
 /* Return nonzero if we can use "rts" for the function currently being
    compiled.  */
 
 int
@@ -917,13 +918,13 @@ h8300_expand_epilogue (void)
     return;
 
   frame_size = round_frame_size (get_frame_size ());
   returned_p = false;
 
   /* Deallocate locals.  */
-  h8300_emit_stack_adjustment (1, frame_size);
+  h8300_emit_stack_adjustment (1, frame_size, false);
 
   /* Pop the saved registers in descending order.  */
   saved_regs = compute_saved_regs ();
   for (regno = FIRST_PSEUDO_REGISTER - 1; regno >= 0; regno -= n_regs)
     {
       n_regs = 1;


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