This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

egcs-1.1.1 (gcc 2.91.60) cross compiler code generation bug with optimization


Hi,

First I know that it is a very old version of the
compiler and the bug has been fixed in latter
versions. I have tried the code with v 2.95.2 and
there is no problem.

But for various reasons, upgrading is not an option
for now. So the help I need, if someone remembers and
has the time to answer is: Is there a patch for this
version of the combiler that fixes this bug. Or which
was the earliest version (after 2.91.60) that fixed
this problem.

The description of the problem is as follows:
Compiler is egcs 1.1.1 or gcc 2.91.60
Configured with: --target=ppc-eabi --disable-multilib
--with-libs=<the libs of a proprietary real time OS>
--with-headers=<the header files of the proprietary
real time OS>

It is a cross compiler hosted on SPARC with Solaris
2.5

The problem appears when compiling with the -fpic
option (for relocatable code) and optimization -O2 or
-O3.

What seems to happen is that after a certain number of
assignments the code generator tries to use all the
registers available and ends up using the register
that holds the pointer to the data for data and then
immediately after again as a pointer with out
restoring the value.

The code to recreate the bug is:

----  Start C Code ----
int n01 ;
int n02 ;
int n03 ;
int n04 ;
int n05 ;
int n06 ;
int n07 ;
int n08 ;
int n09 ;
int n10 ;
int n11 ;
int n12 ;
int n13 ;
int n14 ;
int n15 ;
int n16 ;
int n17 ;
int n18 ;
int n19 ;
int n20 ;
int n21 ;
int n22 ;
int n23 ;
int n24 ;
int n25 ;
int n26 ;
int n27 ;

int *tab[27] ;


void testfunc() {

  tab[0] = &n01 ;
  tab[1] = &n02 ;
  tab[2] = &n03 ;
  tab[3] = &n04 ;
  tab[4] = &n05 ;
  tab[5] = &n06 ;
  tab[6] = &n07 ;
  tab[7] = &n08 ;
  tab[8] = &n09 ;
  tab[9] = &n10 ;
  tab[10] = &n11 ;
  tab[11] = &n12 ;
  tab[12] = &n13 ;
  tab[13] = &n14 ;
  tab[14] = &n15 ;
  tab[15] = &n16 ;
  tab[16] = &n17 ;
  tab[17] = &n18 ;
  tab[18] = &n19 ;
  tab[19] = &n20 ;
  tab[20] = &n21 ;
  tab[21] = &n22 ;
  tab[22] = &n23 ;
  tab[23] = &n24 ;
  tab[24] = &n25 ;
  tab[25] = &n26 ;
  tab[26] = &n27 ;
}

---- End C code ---

The resulting assembly (with my comments) is:

---- Start Assembly ----
        .file   "my2ndbug_00.c"
gcc2_compiled.:
        .section        ".text"
        .align 2
        .globl testfunc
        .type    testfunc,@function
testfunc:
        stwu 1,-80(1)
        mflr 0
        stw 14,8(1)
        stw 15,12(1)
        stw 16,16(1)
        stw 17,20(1)
        stw 18,24(1)
        stw 19,28(1)
        stw 20,32(1)
        stw 21,36(1)
        stw 22,40(1)
        stw 23,44(1)
        stw 24,48(1)
        stw 25,52(1)
        stw 26,56(1)
        stw 27,60(1)
        stw 28,64(1)
        stw 29,68(1)
        stw 30,72(1)
        stw 31,76(1)
        stw 0,84(1)
        bl _GLOBAL_OFFSET_TABLE_@local-4
        mflr 9			<----- reg 9 is the 					      
pointer
        lwz 11,tab1@got(9)
        lwz 0,n07@got(9)
        lwz 3,n10@got(9)
        stw 0,24(11)
        lwz 0,n11@got(9)
        mtctr 3
        lwz 10,tab2@got(9)
        stw 0,40(11)
        lwz 8,tab3@got(9)
        lwz 3,n21@got(9)
        lwz 0,n25@got(9)
        lwz 18,n01@got(9)
        lwz 17,n02@got(9)
        lwz 16,n03@got(9)
        lwz 15,n04@got(9)
        lwz 14,n05@got(9)
        lwz 12,n06@got(9)
        lwz 31,n08@got(9)
        lwz 30,n09@got(9)
        lwz 7,n12@got(9)
        lwz 26,n13@got(9)
        lwz 25,n14@got(9)
        lwz 24,n15@got(9)
        lwz 23,n16@got(9)
        lwz 22,n17@got(9)
        lwz 21,n18@got(9)
        lwz 20,n19@got(9)
        lwz 19,n20@got(9)
        lwz 6,n22@got(9)
        lwz 5,n23@got(9)
        lwz 4,n24@got(9)
        lwz 29,n26@got(9)
        lwz 28,n27@got(9)
        lwz 27,n28@got(9)
        lwz 9,n29@got(9)	<- reg 9 used for data
        stw 3,32(10)
        stw 0,12(8)
        lwz 3,n30@got(9)	<- reg 9 used as 					  
pointer but now it 					   contains the data 					  
from previous load
        stw 7,44(11)
        stw 3,32(8)
        mfctr 0
        stw 18,0(11)
        stw 17,4(11)
        stw 16,8(11)
        stw 15,12(11)
        stw 14,16(11)
        stw 12,20(11)
        stw 31,28(11)
        stw 30,32(11)
        stw 0,36(11)
        stw 26,0(10)
        stw 25,4(10)
        stw 24,8(10)
        stw 23,12(10)
        stw 22,16(10)
        stw 21,20(10)
        stw 20,24(10)
        stw 19,28(10)
        stw 6,0(8)
        stw 5,4(8)
        stw 4,8(8)
        stw 29,16(8)
        stw 28,20(8)
        stw 27,24(8)
        stw 9,28(8)
        lwz 0,84(1)
        mtlr 0
        lwz 14,8(1)
        lwz 15,12(1)
        lwz 16,16(1)
        lwz 17,20(1)
        lwz 18,24(1)
        lwz 19,28(1)
        lwz 20,32(1)
        lwz 21,36(1)
        lwz 22,40(1)
        lwz 23,44(1)
        lwz 24,48(1)
        lwz 25,52(1)
        lwz 26,56(1)
        lwz 27,60(1)
        lwz 28,64(1)
        lwz 29,68(1)
        lwz 30,72(1)
        lwz 31,76(1)
        la 1,80(1)
        blr
.Lfe1:
        .size    testfunc,.Lfe1-testfunc
        .comm   tab1,48,4
        .comm   tab2,36,4
        .comm   tab3,36,4
        .ident  "GCC: (GNU) egcs-2.91.60 19981201
(egcs-1.1.1 release)"

---- End Assembly ----

Does anyone out there remberer if there is a patch for
this bug and where it is? Or any other relevant info.

Thanks in advance (even for just reading it)

Dimitris

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]