[PATCH] Fix PR56131 - gcc.dg/pr56035.c ICEs gcc on sparc-linux

Tom de Vries Tom_deVries@mentor.com
Tue Feb 5 11:30:00 GMT 2013


On 05/02/13 11:12, Jakub Jelinek wrote:
> On Tue, Feb 05, 2013 at 11:01:22AM +0100, Tom de Vries wrote:
>> I'm not sure I understand your comment.
>>
>> The BLOCK_FOR_INSN of the note was NULL. The NOTE_BASIC_BLOCK of the note was
>> correct. Are you saying that the BLOCK_FOR_INSN should not have been NULL?
> 
> Yeah, I mean the following invariant should hold IMHO:
> !NOTE_INSN_BASIC_BLOCK_P (insn) || NOTE_BASIC_BLOCK (insn) == BLOCK_FOR_INSN (insn)
> NOTE_INSN_BASIC_BLOCK for some bb outside of that bb?  That looks fishy.
> Haven't bootstrapped/regtested with such a check anywhere, just compiled one
> largish C++ testcase with it.
> 

Jakub,

I've used patch below to print rtl with a BLOCK_FOR_INSN annotation, and looked
at behaviour for x86_64 and sparc.

For sparc, BLOCK_FOR_INSN is always NULL starting at pass_mach dump files, due
to pass_free_cfg that calls free_bb_for_insn, whose only purpose is to set the
BLOCK_FOR_INSN field to NULL.

So all NOTE_INSN_BASIC_BLOCKs in the .mach dump and after violate the invariant
formulated above:
...
[bfi NULL](note 13 8 201 [bb 2] NOTE_INSN_BASIC_BLOCK)
...

For x86_64, we recompute BLOCK_FOR_INSN in pass_mach here:
...
static void
ix86_reorg (void)
{
  /* We are freeing block_for_insn in the toplev to keep compatibility
     with old MDEP_REORGS that are not CFG based.  Recompute it now.  */
  compute_bb_for_insn ();
...
so we have BLOCK_FOR_INSN all the way till pass_final.

The PR56131 ICE occurred for sparc in pass_delay_slots, after pass_mach, so it's
expected that BLOCK_FOR_INSN is NULL.

Thanks,
- Tom


Index: gcc/print-rtl.c
===================================================================
--- gcc/print-rtl.c (revision 195747)
+++ gcc/print-rtl.c (working copy)
@@ -800,6 +800,20 @@ print_rtl_single_with_indent (FILE *outf
   sawclose = 0;
   fputs (s_indent, outfile);
   fputs (print_rtx_head, outfile);
+#ifndef GENERATOR_FILE
+  {
+    basic_block bb;
+    if (GET_RTX_LENGTH (GET_CODE (x)) >= 4
+	&& GET_RTX_FORMAT (GET_CODE (x))[3] == 'B')
+      {
+	bb = BLOCK_FOR_INSN (x);
+	if (bb != 0)
+	  fprintf (outfile, " [bfi %d]", bb->index);
+	else
+	  fprintf (outfile, " [bfi NULL]");
+      }
+  }
+#endif



More information about the Gcc-patches mailing list