Date: Sun, 12 Jan 2020 13:04:03 -0800 From: Mark Millard <marklmi@yahoo.com> To: Justin Hibbits <chmeeedalf@gmail.com>, "bdragon@freebsd.org" <bdragon@FreeBSD.org>, FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org> Cc: John Baldwin <jhb@freebsd.org>, Piotr Kubaj <pkubaj@anongoth.pl> Subject: head -r356426 32-bit powerpc : clang vs gcc9 C-ABI: *not* the same: clang is doing -maix-struct-return style Message-ID: <36708113-6EA9-4684-9735-973FB8483BFC@yahoo.com> References: <36708113-6EA9-4684-9735-973FB8483BFC.ref@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
system-clang (C) handles returning example struct based on it being on the stack (-maix-struct-return style); gcc9 via registers r3 and r4 (-msvr4-struct-return style). So this somewhat tracks what was observed for the C++ ABI. The evidence from on a old G4 PowerMac3,6 . . . The source code: # more just_struct.c struct two { int a,b; }; struct two f(void) { struct two r=3D { 0, 1}; return r; } # cc -std=3Dc99 -pedantic -g -O2 -c just_struct.c # objdump -d --prefix-addresses just_struct.o | more just_struct.o: file format elf32-powerpc-freebsd Disassembly of section .text: 00000000 <f> li r4,1 00000004 <f+0x4> stw r4,4(r3) 00000008 <f+0x8> li r4,0 0000000c <f+0xc> stw r4,0(r3) 00000010 <f+0x10> blr So it expect r3 to point to the space the caller provided, probably via stack space. This appears to be -maix-struct-return style. # /usr/local/bin/powerpc-unknown-freebsd13.0-gcc9 -std=3Dc99 -pedantic = -g -O2 -c just_struct.c # objdump -d --prefix-addresses just_struct.o | more just_struct.o: file format elf32-powerpc-freebsd Disassembly of section .text: 00000000 <f> li r3,0 00000004 <f+0x4> li r4,1 00000008 <f+0x8> blr So it returned via register r3 and r4. This appears to be -msvr4-struct-return style. # gcc9 -std=3Dc99 -pedantic -g -O2 -c just_struct.c # objdump -d --prefix-addresses just_struct.o | more just_struct.o: file format elf32-powerpc-freebsd Disassembly of section .text: 00000000 <f> li r3,0 00000004 <f+0x4> li r4,1 00000008 <f+0x8> blr So it returned via register r3 and r4. This appears to be -msvr4-struct-return style. So is clang using the aix ABI the right ABI? Or does GCC need to change? =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36708113-6EA9-4684-9735-973FB8483BFC>