optimize_mode_switching SEGV'ing on SH

Jason R Thorpe thorpej@wasabisystems.com
Thu May 16 18:42:00 GMT 2002


Tonight while building a compiler targeted to shle-netbsdelf (see patches
posted recently), I ran into lcm.c not compiling due to a typo inside
a chunk of code wrapped in #ifdef NORMAL_MODE.

I change the code to what seemed like the obvious intent (lose the "s"
on "last_basic_blocks"), and the resulting compiler croaked building
libgcc.  Looking at the code in question again (with a brain freshly
fuled by some dinner), my "obvious fix" didn't seem so obvious anymore,
so I reverted it.  Attached is a patch that seems more likely to be
correct, but the compiler still fails:

dr-evil:thorpej 189$ gdb ./cc1 ./cc1.core 
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
Core was generated by `cc1'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.elf_so...done.
Loaded symbols for /usr/libexec/ld.elf_so
Reading symbols from /usr/lib/libintl.so.0...done.
Loaded symbols for /usr/lib/libintl.so.0
Reading symbols from /usr/lib/libc.so.12...done.
Loaded symbols for /usr/lib/libc.so.12
#0  0x8222699 in optimize_mode_switching (file=0x0)
    at ../../../gcc/gcc/lcm.c:1168
1168                info[bb->sindex].seginfo->mode = mode;
Breakpoint 1 at 0x80a990f: file ../../../gcc/gcc/diagnostic.c, line 1446.
Breakpoint 2 at 0x482a8829
Breakpoint 3 at 0x482a9164
(gdb) print last_basic_block
$1 = 4
(gdb) print bb->sindex
$2 = 3
(gdb) print info[bb->sindex]
$3 = {seginfo = 0x0, computing = 0}
(gdb) 

In context:

	bb = EXIT_BLOCK_PTR;
	info[bb->sindex].seginfo->mode = mode;

Since I reverted the change I had made earlier, the file corrently
does not compile for any target that defines NORMAL_MODE (seems like
SH is the only target in this category).

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: lcm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lcm.c,v
retrieving revision 1.41
diff -u -r1.41 lcm.c
--- lcm.c	17 May 2002 01:33:16 -0000	1.41
+++ lcm.c	17 May 2002 01:42:19 -0000
@@ -1065,7 +1065,7 @@
   if (VARRAY_SIZE (basic_block_info) < last_basic_block)
     VARRAY_GROW (basic_block_info, last_basic_block);
   BASIC_BLOCK (last_basic_block - 1) = EXIT_BLOCK_PTR;
-  EXIT_BLOCK_PTR->sindex = last_basic_blocks;
+  EXIT_BLOCK_PTR->sindex = last_basic_block - 1;
 #endif
 
   /* Create the bitmap vectors.  */


More information about the Gcc-bugs mailing list