Compiling code that calls a function that returns a complex type with
-mrelax-pic-calls results in an ICE.

khazaddum$ cat tmp.c
__complex__ double cd;
__complex__ double foo (void) { return cd; }
void bar (void) { cd = foo (); }
khazaddum$ ./xgcc -B./ -mabicalls -G0 -mrelax-pic-calls -mexplicit-relocs -O -S
tmp.c
tmp.c: In function ‘bar’:
tmp.c:3:1: error: could not split insn
(call_insn/i 6 18 7 tmp.c:3 (parallel [
            (set (reg:DF 32 $f0)
                (call (mem:SI (reg/f:SI 25 $25 [195]) [0 S4 A32])
                    (unspec [
                            (const_int 16 [0x10])
                            (symbol_ref:SI ("foo") [flags 0x3] <function_decl
0xb74f4000 foo>)
                        ] 55)))
            (set (reg:DF 34 $f2)
                (call (mem:SI (reg/f:SI 25 $25 [195]) [0 S4 A32])
                    (const_int 16 [0x10])))
            (clobber (reg:SI 31 $31))
        ]) 574 {call_value_multiple_internal} (expr_list:REG_DEAD (reg/f:SI 25
$25 [195])
        (expr_list:REG_EH_REGION (const_int 0 [0x0])
            (nil)))
    (expr_list:REG_DEP_TRUE (use (reg:SI 79 $fakec))
        (nil)))
tmp.c:3:1: internal compiler error: in final_scan_insn, at final.c:2650
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I used a mipsisa32r2-sde-elf toolchain for this, configured without an
assembler.  If you configure properly with an assembler, then it isn't
necessary to give the -mrelax-pic-calls and -mexplicit-relocs options.  All you
need it -mabicalls and -G 0.

The problem is in mips_annotate_pic_calls.  It looks for a CALL rtx, and then
modifies it.  Unfortunately, a function returning complex has a call insn with
2 CALL rtx.  Because only one was modified, we end up with unrecognizable RTL. 
We either need to disable the optimization in this case, or extend it to work
with a call insn with more than one CALL rtx.  The first one is easier, the
second one is preferable.


-- 
           Summary: -mrelax-pic-calls fails with complex types
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wilson at gcc dot gnu dot org
GCC target triplet: mips*-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43764

Reply via email to