public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/33359]  New: [4.3 Regression] libgcc is miscompiled on SH
@ 2007-09-08 21:36 kkojima at gcc dot gnu dot org
  2007-09-08 21:38 ` [Bug target/33359] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2007-09-08 21:36 UTC (permalink / raw)
  To: gcc-bugs

Trunk fails for sh-elf during compiling libgcc with a missing
local label:

/exp/ldroot/dodes/xsh-elf-gcc-orig/./gcc/xgcc
-B/exp/ldroot/dodes/xsh-elf-gcc-orig/./gcc/ -B/usr/local/sh-unknown-elf/bin/
-B/usr/local/sh-unknown-elf/lib/ -isystem /usr/local/sh-unknown-elf/include
-isystem /usr/local/sh-unknown-elf/sys-include -O2 -g -O2 -O2  -O2 -g -O2  
-DIN_GCC -DCROSS_DIRECTORY_STRUCTURE   -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem
./include   -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED   -I. -I. -I../.././gcc
-I../../../ORIG/trunk/libgcc -I../../../ORIG/trunk/libgcc/.
-I../../../ORIG/trunk/libgcc/../gcc -I../../../ORIG/trunk/libgcc/../include 
-DHAVE_CC_TLS -o _muldc3.o -MT _muldc3.o -MD -MP -MF _muldc3.dep -DL_muldc3 -c
../../../ORIG/trunk/libgcc/../gcc/libgcc2.c \

/tmp/ccghCTLN.s: Assembler messages:
/tmp/ccghCTLN.s:782: Error: displacement to undefined symbol .L162 overflows
12-bit field

I've found that it started after

r128224 | lauras | 2007-09-07 11:58:06 +0900 (Fri, 07 Sep 2007) | 25 lines

2007-09-05  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

        * regrename.c (copyprop_hardreg_forward_1): New variable next. Use
        FOR_BB_INSNS_SAFE instead of for loop.
        * cse.c (cse_extended_basic_block): Likewise.
        * postreload.c (reload_cse_regs_1): New variable next. Make sure
        that the for loop does not invoke NEXT_INSN on a deleted insn.
        * function.c (instantiate_virtual_regs): Likewise.
        * lower-subreg.c (remove_retval_note): Likewise.
        (decompose_multiword_subregs): Use FOR_BB_INSNS_SAFE instead of
        FOR_BB_INSNS.
        * emit-rtl.c (remove_insn): Set NEXT_INSN and PREV_INSN to NULL on
        a deleted insn.
        * cfgrtl.c (delete_insn): Set JUMP_LABEL to NULL on a deleted
        insn, if it's a jump.
        (try_redirect_by_replacing_jump): New variable jump_p. Call
        tablejump_p before delete_insn_chain.
        * reload1.c (reload): New variable next. Make sure that the for
        loop does not invoke NEXT_INSN on a deleted insn.
        (fixup_eh_region_note): Make the loop terminate if i becomes NULL.
        (delete_output_reload): New variable prev. Make sure the the for
        loops do not invoke PREV_INSN on a deleted insn.

Reverting a hunk in the patch:

--- TMP/gcc-128223/gcc/emit-rtl.c       2007-09-08 17:52:26.000000000 +0900
+++ TMP/gcc-128224/gcc/emit-rtl.c       2007-09-08 17:08:27.000000000 +0900
@@ -3688,6 +3688,8 @@ remove_insn (rtx insn)
       if (BB_END (bb) == insn)
        BB_END (bb) = prev;
     }
+  NEXT_INSN (insn) = NULL;
+  PREV_INSN (insn) = NULL;
 }

 /* Append CALL_FUSAGE to the CALL_INSN_FUNCTION_USAGE for CALL_INSN.  */

gets rid of the above failure.  Although I can't specify
the problematic part in the SH back end yet, it looks there
are other places which assume that NEXT_INSN and PREV_INSN
aren't cleared with remove_insn.
For example, jump.c:delete_related_insns uses NEXT_INSN (insn)
after delete_insn (insn) which may call remove_insn.


-- 
           Summary: [4.3 Regression] libgcc is miscompiled on SH
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kkojima at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sh-elf


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
@ 2007-09-08 21:38 ` pinskia at gcc dot gnu dot org
  2007-09-09 22:38 ` kkojima at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-08 21:38 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
   Target Milestone|---                         |4.3.0


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
  2007-09-08 21:38 ` [Bug target/33359] " pinskia at gcc dot gnu dot org
@ 2007-09-09 22:38 ` kkojima at gcc dot gnu dot org
  2007-09-17  2:22 ` kkojima at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2007-09-09 22:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kkojima at gcc dot gnu dot org  2007-09-09 22:37 -------
Fixed with r128284 which reverts r128224.


-- 

kkojima at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
  2007-09-08 21:38 ` [Bug target/33359] " pinskia at gcc dot gnu dot org
  2007-09-09 22:38 ` kkojima at gcc dot gnu dot org
@ 2007-09-17  2:22 ` kkojima at gcc dot gnu dot org
  2007-09-17 22:27 ` lauras at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2007-09-17  2:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kkojima at gcc dot gnu dot org  2007-09-17 02:22 -------
I've looked at the issue for gc-improv branch.  I'd like to
add Laurynas to the CC list.

It seems the following back end patch fix the error in #0
on r128224.

--- ORIG/gc-improv/gcc/config/sh/sh.c   2007-09-14 08:56:42.000000000 +0900
+++ LOCAL/gc-improv/gcc/config/sh/sh.c  2007-09-14 09:41:59.000000000 +0900
@@ -4480,7 +4480,7 @@ gen_far_branch (struct far_branch *bp)
     emit_barrier_after (jump);
   emit_label_after (bp->near_label, insn);
   JUMP_LABEL (jump) = bp->far_label;
-  ok = invert_jump (insn, label, 1);
+  ok = invert_jump (insn, label, 0);
   gcc_assert (ok);

   /* If we are branching around a jump (rather than a return), prevent

though I get an another error during compiling libiberty/hashtab.c.
A reduced testcase is

unsigned int searches;
unsigned int collisions;

double
htab_collisions (void)
{
  if (searches == 0)
    return 0.0;
  return (double) collisions / (double) searches;
}

which segfaults in final.c:insn_current_reference_address
with a null NEXT_INSN (PREV_INSN (branch)) at -O2.
This problem seems to be generic for the architectures with
delayed branch slots.  In the problematic case, the insn
just before the delayed branch is splitted, i.e. insn A in

 (insn A P B ...)
 (insn B A N (seq [
        (jump_insn C A D ... )
        (insn D C N ...)
        ]))

is splitted to insn_1, insn_2, ... and insn_n with try_split.
try_split inserts insn_1, insn_2, ..., insn_n to just after
insn A

 (insn A P B ...)
 (insn_1        A1 A A2)
 (insn_2 A2 A1 A3)
 ...
 (insn_n An An-1 B)
 (insn B An N (seq [
        (jump_insn C A D ... )
        (insn D C N ...)
        ]))

then deletes insn A with delete_insn.  Thus the inner jump insn
in insn B has a bad PREV_INSN.  It seems that the following
patch fix this issue.

--- ORIG/gc-improv/gcc/emit-rtl.c       2007-09-14 08:56:59.000000000 +0900
+++ LOCAL/gc-improv/gcc/emit-rtl.c      2007-09-14 13:55:58.000000000 +0900
@@ -3368,6 +3368,14 @@ try_split (rtx pat, rtx trial, int last)
        }
     }

+  /* When the AFTER insn is a sequence, fix PREV_INSN of the first insn
+     of that sequence.  */
+  if (after)
+    {
+      if (NONJUMP_INSN_P (after) && GET_CODE (PATTERN (after)) == SEQUENCE)
+       PREV_INSN (XVECEXP (PATTERN (after), 0, 0)) = insn_last;
+    }
+
   tem = emit_insn_after_setloc (seq, trial, INSN_LOCATOR (trial));

   delete_insn (trial);

With these patches, SH is built successfully on r128224.
The latter patch is tested also for i686-pc-linux-gnu on
trunk (revision 128522) with bootstrap and the top level
"make -k check" with no new regressions.


-- 

kkojima at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |laurynas dot biveinis at
                   |                            |gmail dot com


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-09-17  2:22 ` kkojima at gcc dot gnu dot org
@ 2007-09-17 22:27 ` lauras at gcc dot gnu dot org
  2007-09-17 23:01 ` pinskia at gcc dot gnu dot org
  2007-09-18  0:03 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: lauras at gcc dot gnu dot org @ 2007-09-17 22:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from lauras at gcc dot gnu dot org  2007-09-17 22:27 -------
Thanks for helping with this issue. Do you want to commit this to gc-improv
branch?

(Removing pinskia from CC, as this must be spam to him)


-- 

lauras at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|pinskia at gcc dot gnu dot  |
                   |org                         |


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-09-17 22:27 ` lauras at gcc dot gnu dot org
@ 2007-09-17 23:01 ` pinskia at gcc dot gnu dot org
  2007-09-18  0:03 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-17 23:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2007-09-17 23:00 -------
(In reply to comment #3)
> (Removing pinskia from CC, as this must be spam to him)

Not really since gmail actually threads nicely and remove dups and I am
subscribed to gcc-bugs@ anyways :).  The main reason why I CC myself is to make
sure I see the important bugs (like this one).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/33359] [4.3 Regression] libgcc is miscompiled on SH
  2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-09-17 23:01 ` pinskia at gcc dot gnu dot org
@ 2007-09-18  0:03 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2007-09-18  0:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kkojima at gcc dot gnu dot org  2007-09-18 00:02 -------
(In reply to comment #3)
> Do you want to commit this to gc-improv branch?

Yes.  If you are OK, I'll send it to gcc-patches for gc-improv.


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-09-18  0:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-08 21:36 [Bug target/33359] New: [4.3 Regression] libgcc is miscompiled on SH kkojima at gcc dot gnu dot org
2007-09-08 21:38 ` [Bug target/33359] " pinskia at gcc dot gnu dot org
2007-09-09 22:38 ` kkojima at gcc dot gnu dot org
2007-09-17  2:22 ` kkojima at gcc dot gnu dot org
2007-09-17 22:27 ` lauras at gcc dot gnu dot org
2007-09-17 23:01 ` pinskia at gcc dot gnu dot org
2007-09-18  0:03 ` kkojima at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).