Committed: robustify CRIS ASM_OUTPUT_CASE_END

Hans-Peter Nilsson hans-peter.nilsson@axis.com
Sat Jul 9 23:01:00 GMT 2011


The recent dwarf2 changes caused notes to be emitted between the
CRIS (casesi expanded to sort-of) tablejump and the jump-table.
I know RTH solved that particular problem another way (thanks!),
but the documented adjacency promise is about of instructions,
not notes, so it seems appropriate to also commit this tested
solution hopefully avoiding some future surprises.  And if
something happens, we have a chance to catch it as an internal
error rather than hoping for a SEGV.

	PR bootstrap/49680
	* config/cris/cris.c (cris_asm_output_case_end): Robustify against
	stray notes and debug insns by using prev_nonnote_nondebug_insn
	instead of PREV_INSN.

Index: config/cris/cris.c
===================================================================
--- config/cris/cris.c	(revision 175272)
+++ config/cris/cris.c	(working copy)
@@ -2275,12 +2275,22 @@ cris_legitimate_pic_operand (rtx x)
 void
 cris_asm_output_case_end (FILE *stream, int num, rtx table)
 {
+  /* Step back, over the label for the table, to the actual casejump and
+     assert that we find only what's expected.  */
+  rtx whole_jump_insn = prev_nonnote_nondebug_insn (table);
+  gcc_assert (whole_jump_insn != NULL_RTX && LABEL_P (whole_jump_insn));
+  whole_jump_insn = prev_nonnote_nondebug_insn (whole_jump_insn);
+  gcc_assert (whole_jump_insn != NULL_RTX
+	      && (JUMP_P (whole_jump_insn)
+		  || (TARGET_V32 && INSN_P (whole_jump_insn)
+		      && GET_CODE (PATTERN (whole_jump_insn)) == SEQUENCE)));
+  /* Get the pattern of the casejump, so we can extract the default label.  */
+  whole_jump_insn = PATTERN (whole_jump_insn);
+
   if (TARGET_V32)
     {
-      rtx whole_jump_insn = PATTERN (PREV_INSN (PREV_INSN (table)));
-
       /* This can be a SEQUENCE, meaning the delay-slot of the jump is
-	 filled.  */
+	 filled.  We also output the offset word a little differently.  */
       rtx parallel_jump
 	= (GET_CODE (whole_jump_insn) == SEQUENCE
 	   ? PATTERN (XVECEXP (whole_jump_insn, 0, 0)) : whole_jump_insn);
@@ -2298,11 +2308,7 @@ cris_asm_output_case_end (FILE *stream, 
 	       "\t.word %LL%d-%LL%d%s\n",
 	       CODE_LABEL_NUMBER (XEXP
 				  (XEXP
-				   (XEXP
-				    (XVECEXP
-				     (PATTERN
-				      (PREV_INSN
-				       (PREV_INSN (table))), 0, 0), 1),
+				   (XEXP (XVECEXP (whole_jump_insn, 0, 0), 1), 
 				    2), 0)),
 	       num,
 	       (TARGET_PDEBUG ? "; default" : ""));

brgds, H-P



More information about the Gcc-patches mailing list