[Bug target/35225] [4.2 regression] gcc segfaults when building GTK+ code with -O2 -fPIC for SH4

kkojima at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Feb 18 04:36:00 GMT 2008



------- Comment #3 from kkojima at gcc dot gnu dot org  2008-02-18 04:36 -------
It seems that sh.c:find_barrier doesn't handle a corner case
which occurs with the testcase.  Although the given testcases
don't fail on 4.3, it'd be a hidden issue even on trunk.  Now
I'm testing the patch below.
I'll apply it on trunk first and then 4.2/4.3 if it survives
with usual tests after we are out of a current critical section
for branching.

diff -uprN ORIG/gcc-4_2-branch/gcc/config/sh/sh.c
LOCAL/gcc-4_2-branch/gcc/config/sh/sh.c
--- ORIG/gcc-4_2-branch/gcc/config/sh/sh.c      2008-01-18 22:11:17.000000000
+0900
+++ LOCAL/gcc-4_2-branch/gcc/config/sh/sh.c     2008-02-18 11:25:56.000000000
+0900
@@ -3530,6 +3530,7 @@ find_barrier (int num_mova, rtx mova, rt
   rtx barrier_before_mova = 0, found_barrier = 0, good_barrier = 0;
   int si_limit;
   int hi_limit;
+  rtx orig = from;

   /* For HImode: range is 510, add 4 because pc counts from address of
      second instruction after this one, subtract 2 for the jump instruction
@@ -3753,7 +3754,8 @@ find_barrier (int num_mova, rtx mova, rt
       /* If we exceeded the range, then we must back up over the last
         instruction we looked at.  Otherwise, we just need to undo the
         NEXT_INSN at the end of the loop.  */
-      if (count_hi > hi_limit || count_si > si_limit)
+      if (PREV_INSN (from) != orig
+         && (count_hi > hi_limit || count_si > si_limit))
        from = PREV_INSN (PREV_INSN (from));
       else
        from = PREV_INSN (from);


-- 

kkojima at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kkojima at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-02-18 04:36:05
               date|                            |


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



More information about the Gcc-bugs mailing list