https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027
Bug ID: 102027
Summary: ABI break when using vector type in function
arg/return value
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
We have an ABI break. Discovered by
Running
/root/rpmbuild/BUILD/gcc-11.2.1-20210728/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp
...
FAIL: tmpdir-gcc.dg-struct-layout-1/t025 c_compat_x_tst.o-c_compat_y_alt.o
execute
FAIL: tmpdir-gcc.dg-struct-layout-1/t025 c_compat_x_alt.o-c_compat_y_tst.o
execute
Started with r11-263.
$ cat m.c
extern void test2237();
int main() { test2237(); }
$ cat x.c
#include "x.h"
extern struct U2SF check2237();
void test2237() { check2237(); }
$ cat y.c
#include "x.h"
struct U2SF check2237_ret;
struct U2SF check2237() {
return check2237_ret;
}
$ cat x.h
struct U2SF {
__attribute__((__vector_size__(2 * sizeof(float)))) float v;
};
$ xgcc-11 -c m.c
$ xgcc-11 -c x.c
$ xgcc-10 -c y.c
$ xgcc-11 m.o x.o y.o -o foo
./foo
Segmentation fault (core dumped)
while
$ xgcc-11 -c y.c
$ xgcc-11 m.o x.o y.o -o foo
$ ./foo
# OK
$ gdb ./foo
(gdb) r
Starting program: /home/mpolacek/x/trunk/gcc/foo
Program received signal SIGSEGV, Segmentation fault.
0x000000000040113f in check2237 ()
(gdb) bt
#0 0x000000000040113f in check2237 ()
#1 0x0000000000401129 in test2237 ()
#2 0x0000000000401114 in main ()
(gdb) disas
Dump of assembler code for function check2237:
0x000000000040112c <+0>: push %rbp
0x000000000040112d <+1>: mov %rsp,%rbp
0x0000000000401130 <+4>: mov %rdi,-0x8(%rbp)
0x0000000000401134 <+8>: mov -0x8(%rbp),%rax
0x0000000000401138 <+12>: mov 0x2ef1(%rip),%rdx # 0x404030
<check2237_ret>
=> 0x000000000040113f <+19>: mov %rdx,(%rax)
0x0000000000401142 <+22>: mov -0x8(%rbp),%rax
0x0000000000401146 <+26>: pop %rbp
0x0000000000401147 <+27>: ret
End of assembler dump.