This is the mail archive of the
mailing list for the GCC project.
Blackfin patch: invalid code generated by reload with FD-PIC
- From: Bernd Schmidt <bernds_cb1 at t-online dot de>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 06 Dec 2006 01:29:27 +0100
- Subject: Blackfin patch: invalid code generated by reload with FD-PIC
- References: <44E8683A.email@example.com>
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.
--- ChangeLog (revision 119561)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2006-12-06 Bernd Schmidt <firstname.lastname@example.org>
+ * 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 <email@example.com>
* config/i386/i386.c (x86_output_aligned_bss): Move out
--- rtlanal.c (revision 119539)
+++ rtlanal.c (working copy)
@@ -509,6 +509,12 @@ count_occurrences (rtx x, rtx find, int
+ 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;
if (MEM_P (find) && rtx_equal_p (x, find))
--- 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);
n_occurrences += count_occurrences (PATTERN (insn),
eliminate_regs (substed, 0,