[PATCH] Fix bootstrap failure on mips-sgi-irix6.5 (reorg.c)

Eric Botcazou ebotcazou@libertysurf.fr
Mon Jul 5 08:00:00 GMT 2004


Hi,

This patch fixes the bootstrap failure on mips-sgi-irix6.5 introduced by my 
"RTL prologue/epilogue for SPARC" patch and reported by David.  The 
problematic change was the one applied to reorg.c.

The problem: bootstrap fails on sparc-sun-solaris2.8 with the pre-patched 
reorg.c because the pass creates jumps to outside the function, more 
precisely right after the return.  This originates in find_end_label: when 
there is no end label yet, the function always creates one, either just 
before a RETURN or, if it doesn't find any, at the end of the insn chain and 
then emits a new RETURN if the target defines HAVE_return.

The failure conditions are as follows: on targets with RTL epilogue, no 
RETURN pattern and an internal RETURN that has a delay slot, find_end_label 
will skip a filled RETURN (since it is wrapped up in a SEQUENCE) and emit a 
trailing label right after it, which will be used as the target of a jump.

My original patch tweaked find_end_label to let it detect filled RETURNs.  
However this proved wrong because the callers of find_end_label expect it 
to return a label that has the following property: it is placed just before 
the epilogue or a bare RETURN insn, so that another bare RETURN can be
turned into a jump to the label unconditionally.

This caused the miscompilation of maybe_set_unchanging on mips-sgi-irix6.5:

.L20:
        j       $31
        nop

        .align  3
.L14:
        lbu     $7,12($5)
        lw      $9,%got_disp(tree_code_type)($11)
        li      $3,99                   # 0x63
        andi    $2,$7,0x00ff
        addu    $2,$2,$9
        lbu     $4,0($2)
        bne     $4,$3,.L20
        nop

...

.L17:
        li      $2,1                    # 0x1
        dsll    $2,$2,37
        or      $3,$3,$2
.L21
        j       $31
        sd      $3,0($10)


The bne .L20 was redirected to .L21 by relax_delay_slots.


This patch introduces a failure mode for find_end_label instead: when it 
can't create a new label, it simply returns 0.  All the callers are adjusted 
accordingly.  There may still be a potential problem with the function, see 
the comment in the patch.

Bootstrapped/regtested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8 by 
me and mips-sgi-irix6.5 (c,c++,objc) by David (thanks!), after reverting the 
original patch.  I verified there is no change in the gcc.c-torture/compile 
testsuite at -O2 on both SPARC platforms.  OK for mainline?


2004-07-05  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR bootstrap/16326
	* reorg.c (find_end_label): If HAVE_epilogue and !HAVE_return,
	return 0 instead of creating a label at the end of the insn chain.
	(optimize_skip): Account for the failure mode of find_end_label.
	(fill_simple_delay_slots): Likewise.
	(fill_slots_from_thread): Likewise.
	(relax_delay_slots): Likewise.


--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sparc_reorg-2.diff
Type: text/x-diff
Size: 7956 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040705/e9607eed/attachment.bin>


More information about the Gcc-patches mailing list