This is the mail archive of the 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]

Blackfin patch: invalid code generated by reload with FD-PIC

A while ago, with our 4.1 based compiler, I ran into a bug compiling
crafty for Blackfin FD-PIC.  We get into a situation during
reload_as_needed as follows:

99: reloaded: insn P3 = P2 + (P3 << 2);
266: output reload: R0 = P3;
101: current insn: parallel (r0 = call symbol || use r6)

Instead of R6, we need the FD-PIC register, which is P3, so we add an
input reload.  Normally, this would be P3 = R6, but here we override
that with P3 = P1 (P1 was reloaded from R6 earlier).
R0 dies in the call, so we then end up in delete_output_reload, which
thinks that insn 266 can safely be deleted.  This is because it doesn't
notice that the call needs the previous calue of R0 - call arguments
don't show up in the insn pattern, only in CALL_INSN_FUNCTION_USAGE.

Hence this patch, to scan CALL_INSN_FUNCTION_USAGE.

Bootstrapped and regression tested on i686-linux; I've also verified
that code generation does not change on this target with my .i sandbox.
Committed as 119571.


Index: ChangeLog
--- ChangeLog	(revision 119561)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2006-12-06  Bernd Schmidt  <>
+	* reload1.c (delete_output_reload): Count occurrences in
+	* rtlanal.c (count_occurrences): Handle EXPR_LIST nodes without
+	crashing at the end of the list.
 2006-12-05  Eric Christopher  <>
 	* config/i386/i386.c (x86_output_aligned_bss): Move out
Index: rtlanal.c
--- rtlanal.c	(revision 119539)
+++ rtlanal.c	(working copy)
@@ -509,6 +509,12 @@ count_occurrences (rtx x, rtx find, int 
     case CC0:
       return 0;
+    case EXPR_LIST:
+      count = count_occurrences (XEXP (x, 0), find, count_dest);
+      if (XEXP (x, 1))
+	count += count_occurrences (XEXP (x, 1), find, count_dest);
+      return count;
     case MEM:
       if (MEM_P (find) && rtx_equal_p (x, find))
 	return 1;
Index: reload1.c
--- reload1.c	(revision 119539)
+++ reload1.c	(working copy)
@@ -7972,6 +7972,9 @@ delete_output_reload (rtx insn, int j, i
   n_occurrences = count_occurrences (PATTERN (insn), reg, 0);
+  if (CALL_P (insn) && CALL_INSN_FUNCTION_USAGE (insn))
+    n_occurrences += count_occurrences (CALL_INSN_FUNCTION_USAGE (insn),
+					reg, 0);
   if (substed)
     n_occurrences += count_occurrences (PATTERN (insn),
 					eliminate_regs (substed, 0,

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