diff mbox

fix fr30 libgcc build

Message ID 20101008105938.GM17388@nightcrawler
State New
Headers show

Commit Message

Nathan Froyd Oct. 8, 2010, 10:59 a.m. UTC
Building fr30-elf currently dies in libgcc with:

../.././gcc/dp-bit.c: In function ‘__make_dp’:
../.././gcc/dp-bit.c:1566:1: internal compiler error: in cselib_record_set, at cselib.c:2009

I think this is a problem with the machine description:

(define_insn "leave_func"
  [(set (reg:SI 15) (reg:SI 14))
   (set (reg:SI 14) (mem:SI (post_inc:SI (reg:SI 15))))]
  "reload_completed"
  "leave"
)

The above ICE in cselib comes from processing this insn:

(insn 78 77 79 2 (parallel [
            (set (reg/f:SI 15 sp)
                (plus:SI (reg/f:SI 20 ap)
                    (const_int -8 [0xfffffffffffffff8])))
            (set (reg/f:SI 14 fp)
                (mem:SI (reg/f:SI 15 sp) [0 S4 A32]))
            (set (reg/f:SI 15 sp)
                (plus:SI (reg/f:SI 15 sp)
                    (const_int 4 [0x4])))
        ]) ../.././gcc/dp-bit.c:1566 39 {leave_func}
     (nil))

cselib gets confused by the multiple sets of r15 in a single parallel.
I have seen this sort of failure on other targets, too.

This can be fixed by rewriting the pattern to avoid the multiple sets of
r15, though the pattern is now slightly uglier.  The patch below does
this, and also adds a suitable definition of TARGET_EXCEPT_UNWIND_INFO.

Tested with cross to fr30-elf.  OK to commit?

-Nathan

	* config/fr30/fr30.c (TARGET_EXCEPT_UNWIND_INFO): Define.
	* config/fr30/fr30.md (leave_func): Rewrite without post_inc.

Comments

Nick Clifton Oct. 8, 2010, 12:40 p.m. UTC | #1
Hi Nathan,

> 	* config/fr30/fr30.c (TARGET_EXCEPT_UNWIND_INFO): Define.
> 	* config/fr30/fr30.md (leave_func): Rewrite without post_inc.

Approved - please apply - and thanks for fixing this!

Cheers
   Nick
Richard Henderson Oct. 8, 2010, 4:41 p.m. UTC | #2
On 10/08/2010 03:59 AM, Nathan Froyd wrote:
> -  [(set (reg:SI 15) (reg:SI 14))
> -   (set (reg:SI 14) (mem:SI (post_inc:SI (reg:SI 15))))]
> +  [(set (reg:SI 15) (plus:SI (reg:SI 14) (const_int 4)))
> +   (set (reg:SI 14) (mem:SI (minus:SI (reg:SI 15) (const_int 4))))]

This isn't correct either.  This is (implicitly) a PARALLEL.
I.e. all actions take place simultaneously.  I.e. r15 has not
been updated for use in the SET of r14.

  (parallel [(set r15 (plus r14 4))
	     (set r14 (mem r14))])


r~
diff mbox

Patch

Index: config/fr30/fr30.md
===================================================================
--- config/fr30/fr30.md	(revision 165159)
+++ config/fr30/fr30.md	(working copy)
@@ -1203,8 +1203,8 @@  (define_insn "return_from_func"
 )
 
 (define_insn "leave_func"
-  [(set (reg:SI 15) (reg:SI 14))
-   (set (reg:SI 14) (mem:SI (post_inc:SI (reg:SI 15))))]
+  [(set (reg:SI 15) (plus:SI (reg:SI 14) (const_int 4)))
+   (set (reg:SI 14) (mem:SI (minus:SI (reg:SI 15) (const_int 4))))]
   "reload_completed"
   "leave"
 )
Index: config/fr30/fr30.c
===================================================================
--- config/fr30/fr30.c	(revision 165159)
+++ config/fr30/fr30.c	(working copy)
@@ -172,6 +172,9 @@  static void fr30_trampoline_init (rtx, t
 #undef TARGET_TRAMPOLINE_INIT
 #define TARGET_TRAMPOLINE_INIT fr30_trampoline_init
 
+#undef TARGET_EXCEPT_UNWIND_INFO
+#define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
+
 struct gcc_target targetm = TARGET_INITIALIZER;