This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/86387] [RISCV][ABI] GCC fails to sign/zero-ext integers as necessary for passing/returning int+fp structs on with hard-float ABIs
- From: "asb at lowrisc dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 03 Jul 2018 12:55:18 +0000
- Subject: [Bug target/86387] [RISCV][ABI] GCC fails to sign/zero-ext integers as necessary for passing/returning int+fp structs on with hard-float ABIs
- Auto-submitted: auto-generated
- References: <bug-86387-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86387
Alex Bradbury <asb at lowrisc dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[RISCV][ABI] GCC fails to |[RISCV][ABI] GCC fails to
|sign/zero-ext integers as |sign/zero-ext integers as
|necessary for return of |necessary for
|int+fp structs in with |passing/returning int+fp
|hard-float ABIs |structs on with hard-float
| |ABIs
--- Comment #1 from Alex Bradbury <asb at lowrisc dot org> ---
Changing title as this bug affects both return and argument passing. I could
create a separate bug report if preferred, but the issues seem so closely
related it might make most sense to keep here.
No sign or zero-extension takes place in the following example, but as-per the
ABI it should.
I actually sought clarification on this aspect of the ABI last September, to
perhaps this is a regression in GCC behaviour?
https://github.com/riscv/riscv-elf-psabi-doc/issues/37
$ cat foo.c
#include <stdint.h>
struct s_u8_f { uint8_t i; float f; };
struct s_i8_f { int8_t i; float f; };
void must_receive_zext_arg(struct s_u8_f);
void must_receive_sext_arg(struct s_i8_f);
void should_zext_arg(int8_t i, float f) {
struct s_u8_f s;
s.i = i;
s.f = f;
must_receive_zext_arg(s);
}
void should_sext_arg(uint8_t i, float f) {
struct s_i8_f s;
s.i = i;
s.f = f;
must_receive_sext_arg(s);
}
./riscv32-unknown-elf-gcc -march=rv32imf -mabi=ilp32f foo.c -S -o - -O1
.file "foo.c"
.option nopic
.text
.align 2
.globl should_zext_arg
.type should_zext_arg, @function
should_zext_arg:
addi sp,sp,-32
sw ra,28(sp)
call must_receive_zext_arg
lw ra,28(sp)
addi sp,sp,32
jr ra
.size should_zext_arg, .-should_zext_arg
.align 2
.globl should_sext_arg
.type should_sext_arg, @function
should_sext_arg:
addi sp,sp,-32
sw ra,28(sp)
call must_receive_sext_arg
lw ra,28(sp)
addi sp,sp,32
jr ra
.size should_sext_arg, .-should_sext_arg
.ident "GCC: (GNU) 9.0.0 20180703 (experimental)"