Article View: gnu.gcc.bug
Article #2793sparc struct passing, version 1.36
From: Steven McCanne
Date: Tue, 02 Jan 1990 00:19
Date: Tue, 02 Jan 1990 00:19
86 lines
1797 bytes
1797 bytes
Here is a bug in gcc version 1.36, running on a Sun sparcstation.
The structure below is being passed in only a single register.
Note that the structure is both passed and received in a single register.
struct triple { short a, b, c; };
void
p (e)
struct triple e;
{
printf ("%d %d %d\n", e.a, e.b, e.c);
}
q ()
{
struct triple r = { 1, 2, 3 };
p (r);
}
Output from 'gcc -S':
gcc_compiled.:
.text
LC0:
.ascii "%d %d %d\12\0"
.align 4
.global _p
.proc 1
_p:
!#PROLOGUE# 0
save %sp,-112,%sp
!#PROLOGUE# 1
! Here is the problem.
! The struct is passed in only 1 register.
st %i0,[%fp+68]
ldsh [%fp+68],%o1
ldsh [%fp+70],%o2
! This is garbage, but should be 'e.c'.
ldsh [%fp+72],%o3
sethi %hi(LC0),%o0
or %lo(LC0),%o0,%o0
mov %o1,%o1
mov %o2,%o2
mov %o3,%o3
call _printf,0
nop
L1:
ret
restore
.align 2
LC1:
.half 1
.half 2
.half 3
.align 4
.global _q
.proc 1
_q:
!#PROLOGUE# 0
save %sp,-120,%sp
!#PROLOGUE# 1
add %fp,-24,%o0
sethi %hi(LC1),%o2
or %lo(LC1),%o2,%o2
lduh [%o2+4],%g1
sth %g1,[%o0+4]
lduh [%o2+2],%g1
sth %g1,[%o0+2]
lduh [%o2+0],%g1
sth %g1,[%o0+0]
! Also, P is called with only one reg argument.
ld [%fp-24],%o0
call _p,0
nop
L2:
ret
restore
-------------------------
Steven McCanne
mccanne@helios.ee.lbl.gov
-------------------------
Technical Details
Message-ID:
<9001020019.AA10958@helios.ee.lbl.gov>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!HELIOS.EE.LBL.GOV!mccanneShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!HELIOS.EE.LBL.GOV!mccanne From: mccanne@HELIOS.EE.LBL.GOV (Steven McCanne) Newsgroups: gnu.gcc.bug Subject: sparc struct passing, version 1.36 Message-ID: <9001020019.AA10958@helios.ee.lbl.gov> Date: 2 Jan 90 00:19:39 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 86