🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Tom Quinn Fri, 23 Sep 1988 14:54
bug in sparc gcc 1.28
#1715
Author: Tom Quinn
Date: Fri, 23 Sep 1988 14:54
77 lines
2809 bytes
The following code will compile incorrectly with the "-O" and
"-fforce-addr" flags.  This is on a Sun4/110 running SunOs 4.0.
The resulting object will generate a Bus Error at line 27 because it
is doing a "std" (store double) with an address that is not aligned on
an 8 byte boundary.  It looks like the "-fforce-addr" flag is a bad
idea on sparc, since it causes an extra register to be used, and it
wastes a cycle on an add, which would have no cost if done as register
+ offset in the store instruction.

The compile:
gcc -S -g -v -O -fforce-addr  -sun4 -c  axis.c
gcc version 1.28
 /usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dsparc -Dsun -Dunix -D__OPTIMIZE__ axis.c /tmp/cca16875.cpp
GNU CPP version 1.28
 /usr/local/lib/gcc-cc1 /tmp/cca16875.cpp -quiet -dumpbase axis.c -fforce-addr -g -O -version -o axis.s
GNU C version 1.28 (sparc) compiled by GNU C version 1.28.

The relavent assembler:
...
.stabn 68,0,27,LM12
LM12:
	sub %sp,32,%sp
	add %sp,92,%o0		<<< Bad idea, sp is 8-byte aligned, o0
				    is therefore NOT aligned
	ld [%fp-20],%f8
	fstod %f8,%f6
	std %f6,[%fp-8]
	ldd [%fp-8],%l6
	fstod %f2,%f6
	std %f6,[%fp-8]
	ldd [%fp-8],%l4
	set _xsmall,%l2
	ld [%l2],%f2
	set _xbig,%l3
	ld [%l3],%f4
	fstod %f4,%f4
	std %f4,[%o0]		<<< Horrible death occurs here.
...

The code:
------------------------------------------------------------------------
extern float 
  	     fx1,fx2;      
extern int   gx1,gx2,gy1,gy2;      
extern double pow();
void angle(),
     ltype();
static float xsmall = 0.,
	     xbig   = 0.;
box(labelxl, labelxu)
int labelxl, labelxu;
{
   float a1,a2;
    ltype(0);
    angle(0.);
    if(xsmall < 0) {                        
       if(fabs(fx1) > 37 || fabs(fx2) > 37) {
	  msg("|x-limits| are too large for logarithmic axes\n");
	  a1 = fx1; a2 =fx2;
	  xsmall = 0;
       } else {
	  a1 = pow(10.,fx1);
	  a2 = pow(10.,fx2);
       }
    } else {				 
       a1 = fx1; a2 =fx2;
    }
    (void)axis(a1,a2,xsmall,xbig,gx1,gy1,gx2-gx1,labelxl,0); /* bombs here */
    (void)axis(a1,a2,xsmall,xbig,gx1,gy2,gx2-gx1,labelxu,1);
}
---------------------
Tom Quinn                 Canadian Institute for Theoretical Astrophysics
trq@moose.cita.toronto.edu
SOON TO BE trq@moose.cita.utoronto.ca
UUCP   - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA   - trq%moose.cita.toronto.edu@relay.cs.net
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads