Bug 23117 - [4.1 Regression] ICE on valid code while building libgcc
Summary: [4.1 Regression] ICE on valid code while building libgcc
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Steven Bosscher
URL:
Keywords: build, ice-on-valid-code
: 23136 (view as bug list)
Depends on:
Blocks: 17808
  Show dependency treegraph
 
Reported: 2005-07-28 19:54 UTC by Khem Raj
Modified: 2005-07-29 16:31 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-*-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-07-28 23:37:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khem Raj 2005-07-28 19:54:27 UTC
The latest compiler build from CVS sources on 07-28-2005 segfaults while
building libgcc for arm-softfloat target with -O2,O2,Os opt levels. The error
does not happen when -O1 is used

The program compiles fine when I use my host compiler which is gcc version 4.0.1
20050727 (Red Hat 4.0.1-5)

error log
================================

 __do_global_ctors_aux
Analyzing compilation unitPerforming intraprocedural optimizations
Assembling functions:
 __do_global_ctors_aux
/home/kraj/a.c: In function '__do_global_ctors_aux':
/home/kraj/a.c:8: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

====================================

How to reporoduce

gcc -O2 -c testcase.c

testcase.c
====================================
typedef void (*func_ptr) (void);

static func_ptr __CTOR_END__[1] = {(func_ptr) 0 };

static void  __attribute__((used))  __do_global_ctors_aux (void)
{
  func_ptr *p;
  for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
    (*p) ();
}

=======================================================
Comment 1 Andrew Pinski 2005-07-28 20:06:09 UTC
Confirmed, backtrace:
#0  0x007f7a4c in add_branch_dependences (head=0x1e918f0, tail=0x1e918f0) at ../../gcc/sched-
rgn.c:1987
#1  0x007f818c in compute_block_backward_dependences (bb=0) at ../../gcc/sched-rgn.c:2142
#2  0x007f8a80 in schedule_region (rgn=3) at ../../gcc/sched-rgn.c:2290
#3  0x007f9828 in schedule_insns (dump_file=0x0) at ../../gcc/sched-rgn.c:2547
#4  0x007f9e14 in rest_of_handle_sched2 () at ../../gcc/sched-rgn.c:2700
#5  0x0063bbd0 in execute_one_pass (pass=0x8a4e94) at ../../gcc/passes.c:793


This is an RTL optimization bug.
Comment 2 Khem Raj 2005-07-28 22:02:57 UTC
This seems to have been caused by some checkin that went in after 7/27/2005 (i.e
only checkins that went in today 7/28) because when I cvs up -D 2005-07-27 I
dont get the segfault.
Comment 3 Khem Raj 2005-07-28 22:20:19 UTC
(In reply to comment #2)
> This seems to have been caused by some checkin that went in after 7/27/2005 (i.e
> only checkins that went in today 7/28) because when I cvs up -D 2005-07-27 I
> dont get the segfault.

Amends, To narrow it further the problem is caused by some checkin that happened
on 7/27 because upto 0:00 hours it builds ok but not cvs up -D "2005-07-27 23:59"
Comment 4 Andrew Pinski 2005-07-28 22:35:35 UTC
Did the build which worked include the fix for PR rtl-optimization/17808?  You can find out by looking 
at ChangeLog.
Comment 5 Steven Bosscher 2005-07-28 23:31:50 UTC
Try this, like Richard Earnshaw is doing. 
 
Index: sched-rgn.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/sched-rgn.c,v 
retrieving revision 1.99 
diff -u -p -r1.99 sched-rgn.c 
--- sched-rgn.c 27 Jul 2005 16:28:34 -0000      1.99 
+++ sched-rgn.c 28 Jul 2005 23:31:29 -0000 
@@ -1977,17 +1977,17 @@ add_branch_dependences (rtx head, rtx ta 
   if (!reload_completed || ! JUMP_P (tail)) 
     return; 
 
-  insn = PREV_INSN (tail); 
+  insn = tail; 
   while (insn != head) 
     { 
+      insn = PREV_INSN (insn); 
+ 
       /* Note that we want to add this dependency even when 
         sched_insns_conditions_mutex_p returns true.  The whole point 
         is that we _want_ this dependency, even if these insns really 
         are independent.  */ 
       if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == COND_EXEC) 
        add_dependence (tail, insn, REG_DEP_ANTI); 
- 
-      insn = PREV_INSN (insn); 
     } 
 #endif 
 } 
 
Comment 6 Khem Raj 2005-07-29 03:50:31 UTC
The problem indeed was caused by checkin for PR rtl-optimization/17808. I
verified it.

Then I tried the Steven's fix above and I was able to build the GCC and rest of
toolchain.
I havent tested the compiler.
Comment 7 GCC Commits 2005-07-29 09:32:24 UTC
Subject: Bug 23117

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rearnsha@gcc.gnu.org	2005-07-29 09:32:16

Modified files:
	gcc            : ChangeLog sched-rgn.c 

Log message:
	Richard Earnshaw  <richard.earnshaw@arm.com>
	Steven Bosscher  <stevenb@suse.de>
	
	PR rtl-optimization/23117
	* sched-rgn.c (add_branch_dependences): Handle COND_EXEC correctly
	when head == tail.  Tidy comment.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9597&r2=2.9598
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&r1=1.99&r2=1.100

Comment 8 Richard Earnshaw 2005-07-29 09:33:45 UTC
Fixed with suggested patch.
Comment 9 Andrew Pinski 2005-07-29 16:31:59 UTC
*** Bug 23136 has been marked as a duplicate of this bug. ***