[PATCH] Fixup IRA debug dump output

Peter Bergner bergner@linux.ibm.com
Wed Apr 17 21:47:00 GMT 2019


On 4/17/19 12:57 PM, Jeff Law wrote:
> On 4/17/19 9:35 AM, Peter Bergner wrote:
>> 	* ira-conflicts.c (print_allocno_conflicts): Always print something,
>> 	even for allocno's with no conflicts.
>> 	(print_conflicts): Print an extra newline.
> OK.  And while it's technically not a regression fix, I think this can
> safely go in now :-)


Hi Jeff,

Ok, I committed the patch which is an improvement over the old code.  Thanks!


However, debugging PR87871 some more, I still didn't see p116 conflict with
r0 like Vlad said it did with the new debug output.  Not surprising, since
the patch only affected adding missing \n's to the output.  So I dumped the
OBJECT_TOTAL_CONFLICT_HARD_REGS() output for p116 and sure enough, it does
mention r0.  I then called print_allocno_conflicts() by hand and it still
didn't output r0 as a conflicting hard reg.  Stepping through the debugger,
I see that the:

  if (OBJECT_CONFLICT_ARRAY (obj) != NULL)
    {
      fprintf (file, "\n;;     total conflict hard regs:\n");
      fprintf (file, ";;     conflict hard regs:\n\n");
      continue;
    }

...is actually incorrect.  The "if" test only says we don't have any
conflicts with any other allocnos/pseudos.  It doesn't tell us whether we
have any hard register conflicts or not, so we really shouldn't do a continue
here.  Instead, we should guard the code that outputs the allocno conflicts
and then fall down to the hard reg conflict prints, that should also be
suitably guarded.  With the patch below, we now see the missing r0 conflict
Vlad said was there.

  ;; a5(r116,l0) conflicts:
  ;;     total conflict hard regs: 0
  ;;     conflict hard regs:


    cp0:a0(r111)<->a4(r117)@330:move
    cp1:a2(r114)<->a3(r112)@41:shuffle
    ...

Note, I still don't understand why p116 conflicts with r0, but that is
orthogonal to actually printing out the conflict sets as they exist.

Is this ok as well?  ...and I'm sorry for not noticing this issue before.

Peter

	* ira-conflicts.c (print_allocno_conflicts): Print the hard register
	conflicts, even if there are no allocno conflicts.

Index: gcc/ira-conflicts.c
===================================================================
--- gcc/ira-conflicts.c	(revision 270420)
+++ gcc/ira-conflicts.c	(working copy)
@@ -632,47 +632,58 @@ print_allocno_conflicts (FILE * file, bo
       ira_object_t conflict_obj;
       ira_object_conflict_iterator oci;
 
-      if (OBJECT_CONFLICT_ARRAY (obj) == NULL)
+      if (OBJECT_CONFLICT_ARRAY (obj) != NULL)
 	{
-	  fprintf (file, "\n;;     total conflict hard regs:\n");
-	  fprintf (file, ";;     conflict hard regs:\n\n");
-	  continue;
-	}
-
-      if (n > 1)
-	fprintf (file, "\n;;   subobject %d:", i);
-      FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
-	{
-	  ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
-	  if (reg_p)
-	    fprintf (file, " r%d,", ALLOCNO_REGNO (conflict_a));
-	  else
+	  if (n > 1)
+	    fprintf (file, "\n;;   subobject %d:", i);
+	  FOR_EACH_OBJECT_CONFLICT (obj, conflict_obj, oci)
 	    {
-	      fprintf (file, " a%d(r%d", ALLOCNO_NUM (conflict_a),
-		       ALLOCNO_REGNO (conflict_a));
-	      if (ALLOCNO_NUM_OBJECTS (conflict_a) > 1)
-		fprintf (file, ",w%d", OBJECT_SUBWORD (conflict_obj));
-	      if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL)
-		fprintf (file, ",b%d", bb->index);
+	      ira_allocno_t conflict_a = OBJECT_ALLOCNO (conflict_obj);
+	      if (reg_p)
+		fprintf (file, " r%d,", ALLOCNO_REGNO (conflict_a));
 	      else
-		fprintf (file, ",l%d",
-			 ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop_num);
-	      putc (')', file);
+		{
+		  fprintf (file, " a%d(r%d", ALLOCNO_NUM (conflict_a),
+			   ALLOCNO_REGNO (conflict_a));
+		  if (ALLOCNO_NUM_OBJECTS (conflict_a) > 1)
+		    fprintf (file, ",w%d", OBJECT_SUBWORD (conflict_obj));
+		  if ((bb = ALLOCNO_LOOP_TREE_NODE (conflict_a)->bb) != NULL)
+		    fprintf (file, ",b%d", bb->index);
+		  else
+		    fprintf (file, ",l%d",
+			     ALLOCNO_LOOP_TREE_NODE (conflict_a)->loop_num);
+		  putc (')', file);
+		}
 	    }
 	}
-      COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_TOTAL_CONFLICT_HARD_REGS (obj));
-      AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
-      AND_HARD_REG_SET (conflicting_hard_regs,
-			reg_class_contents[ALLOCNO_CLASS (a)]);
-      print_hard_reg_set (file, "\n;;     total conflict hard regs:",
-			  conflicting_hard_regs);
-
-      COPY_HARD_REG_SET (conflicting_hard_regs, OBJECT_CONFLICT_HARD_REGS (obj));
-      AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
-      AND_HARD_REG_SET (conflicting_hard_regs,
-			reg_class_contents[ALLOCNO_CLASS (a)]);
-      print_hard_reg_set (file, ";;     conflict hard regs:",
-			  conflicting_hard_regs);
+
+      if (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) != NULL)
+	{
+	  COPY_HARD_REG_SET (conflicting_hard_regs,
+			     OBJECT_TOTAL_CONFLICT_HARD_REGS (obj));
+	  AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
+	  AND_HARD_REG_SET (conflicting_hard_regs,
+			    reg_class_contents[ALLOCNO_CLASS (a)]);
+	  print_hard_reg_set (file, "\n;;     total conflict hard regs:",
+			      conflicting_hard_regs);
+	}
+      else
+	fprintf (file, "\n;;     total conflict hard regs:\n");
+
+
+      if (OBJECT_CONFLICT_HARD_REGS (obj) != NULL)
+	{
+	  COPY_HARD_REG_SET (conflicting_hard_regs,
+			     OBJECT_CONFLICT_HARD_REGS (obj));
+	  AND_COMPL_HARD_REG_SET (conflicting_hard_regs, ira_no_alloc_regs);
+	  AND_HARD_REG_SET (conflicting_hard_regs,
+			    reg_class_contents[ALLOCNO_CLASS (a)]);
+	  print_hard_reg_set (file, ";;     conflict hard regs:",
+			      conflicting_hard_regs);
+	}
+      else
+	fprintf (file, ";;     conflict hard regs:\n");
+
       putc ('\n', file);
     }
 



More information about the Gcc-patches mailing list