This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Functions returning structure with float on sparc64
- To: gcc at gcc dot gnu dot org
- Subject: Functions returning structure with float on sparc64
- From: Olivier Hainque <hainque at act-europe dot fr>
- Date: Thu, 25 Jan 2001 16:39:00 +0100 (CET)
Hello all,
A similar message has been sent to gcc-bugs a while ago, but perhaps this was
not the right list.
We basically have strange (well, from our point of view) assembly code
generated for sparc64 from the following code :
/* db.c */
typedef struct {
float f;
int i;
int j;
} datablock_t;
datablock_t datablock (void);
datablock_t datablock (void)
{
datablock_t db;
/* f not initialized to avoid extra assembly
* instructions in the report below.
*/
db.i = 11;
db.j = 22;
return db;
}
-> It looks like the j field is simply not accounted for in the return value
(excerpts of asm below).
This has first been observed on a cross port with snapshot 2.97 20010102, as
well as with a recent snapshot of the subreg-byte branch targetted to sparcv9
- solaris2.8. We suspect this could be observed with any sparc64 target.
Asm excerpts (O0/O2) follow, for a compiler targetted to sparc64-wrs-vxworks
target and hosted on sparc-sun-solaris2.5.1.
Configured with:
--with-gnu-as --disable-nls --prefix=... --target=sparc64-wrs-vxworks
Thanks in advance for any comment and/or help you can provide,
Kind Regards,
Olivier
$ sparc64-wrs-vxworks-gcc -S db.c
1 .file "db.c"
2 gcc2_compiled.:
3 .section ".text"
4 .align 4
5 .global datablock
6 .type datablock,#function
7 .proc 010
8 datablock:
9 !#PROLOGUE# 0
10 save %sp, -224, %sp
11 !#PROLOGUE# 1
12 mov 11, %g2
13 st %g2, [%fp-28]
14 mov 22, %g2
15 st %g2, [%fp-24]
16 ld [%fp-32], %f0
17 ld [%fp-28], %i0
18 return %i7+8
19 nop
20 .LLfe1:
21 .size datablock,.LLfe1-datablock
22 .ident "GCC: (GNU) 2.97 20010102 (experimental)"
This is yet more obvious with optimization on (O2) :
1 .file "db.c"
2 gcc2_compiled.:
3 .section ".text"
4 .align 4
5 .global datablock
6 .type datablock,#function
7 .proc 010
8 datablock:
9 !#PROLOGUE# 0
10 add %sp, -224, %sp
11 !#PROLOGUE# 1
12 mov 11, %o0
13 ld [%sp+192], %f0
14 retl
15 sub %sp, -224, %sp
16 .LLfe1:
17 .size datablock,.LLfe1-datablock
18 .ident "GCC: (GNU) 2.97 20010102 (experimental)"