public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* target/5185: Segmentation error in final.c
@ 2001-12-24  6:46 klaus.k.pedersen
  0 siblings, 0 replies; only message in thread
From: klaus.k.pedersen @ 2001-12-24  6:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5185
>Category:       target
>Synopsis:       Segmentation error in final.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 24 06:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Klaus Pedesen
>Release:        gcc-20011203
>Organization:
>Environment:
gcc -v
Reading specs from /usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)
>Description:
While compiling newlib for target=arm-elf with the snapshot 
20011203, the compiler produced an internal error in the function called ratio() in mprec.c. 
 
----
 m-bug.c: In function `ratio':
 m-bug.c:14: internal error: Lagersegmentfejl
 Please submit a full bug report,
 with preprocessed source if appropriate.
 See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
----

I reduced the case to the following (totaly meaningless function):

----
/*
Example from newlib/.../mprec.c
 
Compile with:
 arm-elf-gcc -O1 -c m-bug.c
 
Produces:
 Segmentation error..
*/

double ratio(void)
{
  int k;
  union {
    double d;
    unsigned long i[2];
  } da, db;

  da.i[0] += k * 0x00800000UL;

  return da.d / db.d;
}
----

Calling the compiler directly with:

 /opt/gcc/lib/gcc-lib/arm-elf/3.1/cc1 -lang-c -O2 m-bug.c

Shows that the error is in the following line in alter_subreg in final.c. The problem seems to be that the passed xp isn't of type SUBREG, and y therefor becomes NULL. The error shows up when reading "y->code".

-------
alter_subreg (xp)
     rtx *xp;
{
  rtx x = *xp;
  rtx y = SUBREG_REG (x);
    
  /* simplify_subreg does not remove subreg from volatile references.
     We are required to.  */
->if (GET_CODE (y) == MEM)
    *xp = adjust_address (y, GET_MODE (x), SUBREG_BYTE (x));
  else
    {
-----

A backtrace shows:

---- 
(gdb) backtrace
#0  alter_subreg (xp=0x401bcd58) at ../../gcc-20011203/gcc/final.c:3049
#1  0x080f82b2 in cleanup_subreg_operands (insn=0x401b3e40) at ../../gcc-20011203/gcc/final.c:3019
#2  0x0818e6e3 in reload (first=0x401b3ca0, global=1) at ../../gcc-20011203/gcc/reload1.c:1226
----

Which is in the line shown below:

----
cleanup_subreg_operands (insn)
     rtx insn;
{
  int i;
  extract_insn_cached (insn);
  for (i = 0; i < recog_data.n_operands; i++)
    {
      if (GET_CODE (recog_data.operand[i]) == SUBREG)
->    	recog_data.operand[i] = alter_subreg (recog_data.operand_loc[i]);
      else if (GET_CODE (recog_data.operand[i]) == PLUS
    	       || GET_CODE (recog_data.operand[i]) == MULT
    	       || GET_CODE (recog_data.operand[i]) == MEM)
----

I have no idea how recog_data.operand[i] is related to 
recog_data.operand_loc[i] after looking at the datastructure.

So I added a check in alter_subreg() to verify that the passed "xp" really is of type SUBREG, and was then able to compile the libaray.

(I have no idea if it works though. And it looks a bit wastefull after looking at the other calls to alter_subreg, which already is doing the check).

----
alter_subreg (xp)
     rtx *xp;
{
  rtx x = *xp;
  rtx y;
  
  if (GET_CODE(x) != SUBREG)
  	return x;	
  y = SUBREG_REG (x);
  ...
----

The Arm compiler was configured with :

----
../gcc-20011203/configure --prefix=/opt/gcc --target=arm-elf --enable-languages=c,c++ --with-dwarf2 --enable-target-optspace --with-gnu-ld --with-ld=/opt/gcc/bin/arm-elf-ld --with-gnu-as --with-as=/opt/gcc/bin/arm-elf-as
-----
>How-To-Repeat:
Compile example code with

/opt/gcc/lib/gcc-lib/arm-elf/3.1/cc1 -lang-c -O2 m-bug.c
>Fix:
See general description.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-12-24 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-24  6:46 target/5185: Segmentation error in final.c klaus.k.pedersen

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).