public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102027] New: ABI break when using vector type in function arg/return value
@ 2021-08-23 18:10 mpolacek at gcc dot gnu.org
  2021-08-23 18:10 ` [Bug target/102027] [11/12 Regression] " mpolacek at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-08-23 18:10 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
@ 2021-08-23 18:10 ` mpolacek at gcc dot gnu.org
  2021-08-23 18:49 ` ubizjak at gmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-08-23 18:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI
            Summary|ABI break when using vector |[11/12 Regression] ABI
                   |type in function arg/return |break when using vector
                   |value                       |type in function arg/return
                   |                            |value
   Target Milestone|---                         |11.3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
  2021-08-23 18:10 ` [Bug target/102027] [11/12 Regression] " mpolacek at gcc dot gnu.org
@ 2021-08-23 18:49 ` ubizjak at gmail dot com
  2021-08-23 19:12 ` ubizjak at gmail dot com
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-23 18:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #1 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Marek Polacek from comment #0)
> 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.

Strange, changes in the referred revision do not touch any of the ABI-definning
functions.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
  2021-08-23 18:10 ` [Bug target/102027] [11/12 Regression] " mpolacek at gcc dot gnu.org
  2021-08-23 18:49 ` ubizjak at gmail dot com
@ 2021-08-23 19:12 ` ubizjak at gmail dot com
  2021-08-23 19:58 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ubizjak at gmail dot com @ 2021-08-23 19:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
gcc-11 does:

0000000000000000 <check2237>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # b
<check2237+0xb>
                        7: R_X86_64_PC32        check2237_ret-0x4
   b:   66 48 0f 6e c0          movq   %rax,%xmm0
  10:   5d                      pop    %rbp
  11:   c3                      retq   

and for reference, clang-12:

0000000000000000 <check2237>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 8b 04 25 00 00 00    mov    0x0,%rax
   b:   00 
                        8: R_X86_64_32S check2237_ret
   c:   48 89 45 f8             mov    %rax,-0x8(%rbp)
  10:   f2 0f 10 45 f8          movsd  -0x8(%rbp),%xmm0
  15:   5d                      pop    %rbp
  16:   c3                      retq   

These are the same.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-08-23 19:12 ` ubizjak at gmail dot com
@ 2021-08-23 19:58 ` pinskia at gcc dot gnu.org
  2021-08-23 20:25 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23 19:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-23
     Ever confirmed|0                           |1

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There are calls to vector_mode_supported_p in stor-layout which changes the
TYPE_MODE of the RECORD_TYPE depending on if vector_mode_supported_p returns
true or not and classify_argument depends on TYPE_MODE in some cases ....

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-08-23 19:58 ` pinskia at gcc dot gnu.org
@ 2021-08-23 20:25 ` hjl.tools at gmail dot com
  2021-08-24  1:47 ` hjl.tools at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2021-08-23 20:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> There are calls to vector_mode_supported_p in stor-layout which changes the
> TYPE_MODE of the RECORD_TYPE depending on if vector_mode_supported_p returns
> true or not and classify_argument depends on TYPE_MODE in some cases ....

We need to issue a ABI change warning.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-08-23 20:25 ` hjl.tools at gmail dot com
@ 2021-08-24  1:47 ` hjl.tools at gmail dot com
  2021-08-24  1:50 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2021-08-24  1:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> There are calls to vector_mode_supported_p in stor-layout which changes the

It sounds odd to me since vector_mode_supported_p can change overtime.

> TYPE_MODE of the RECORD_TYPE depending on if vector_mode_supported_p returns
> true or not and classify_argument depends on TYPE_MODE in some cases ....

I am not sure if we can fix it in backend alone.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-08-24  1:47 ` hjl.tools at gmail dot com
@ 2021-08-24  1:50 ` pinskia at gcc dot gnu.org
  2021-08-24  7:12 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-24  1:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #5)
> (In reply to Andrew Pinski from comment #3)
> > There are calls to vector_mode_supported_p in stor-layout which changes the
> 
> It sounds odd to me since vector_mode_supported_p can change overtime.
> 
> > TYPE_MODE of the RECORD_TYPE depending on if vector_mode_supported_p returns
> > true or not and classify_argument depends on TYPE_MODE in some cases ....
> 
> I am not sure if we can fix it in backend alone.

Most back-ends moved away from looking at TYPE_MODE for argument passing long
time ago. I can understand why you might want to stay with that I don't think
anyone should depend on TYPE_MODE for argument passing any more.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-08-24  1:50 ` pinskia at gcc dot gnu.org
@ 2021-08-24  7:12 ` rguenth at gcc dot gnu.org
  2021-08-24 13:08 ` hjl.tools at gmail dot com
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-24  7:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
            Version|unknown                     |11.2.1
             Target|                            |x86_64-*-*
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, it would be nice to transition away from relying on TYPE_MODE for argument
passing.  Does the psABI say anything about this case or is it in the area of
implementation defined behavior?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-08-24  7:12 ` rguenth at gcc dot gnu.org
@ 2021-08-24 13:08 ` hjl.tools at gmail dot com
  2022-04-21  7:50 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2021-08-24 13:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Richard Biener from comment #7)
> Yes, it would be nice to transition away from relying on TYPE_MODE for
> argument passing.  Does the psABI say anything about this case or is it in
> the area of implementation defined behavior?

Arguments of types _Float16, float, double, _Decimal32, _Decimal64 and
__m64 are in class SSE.  V2SF is covered by __m64.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-08-24 13:08 ` hjl.tools at gmail dot com
@ 2022-04-21  7:50 ` rguenth at gcc dot gnu.org
  2023-04-17 15:15 ` [Bug target/102027] [11/12/13/14 " woodard at redhat dot com
  2023-05-29 10:05 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21  7:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |11.4

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12/13/14 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-04-21  7:50 ` rguenth at gcc dot gnu.org
@ 2023-04-17 15:15 ` woodard at redhat dot com
  2023-05-29 10:05 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: woodard at redhat dot com @ 2023-04-17 15:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

--- Comment #10 from Ben Woodard <woodard at redhat dot com> ---
Currently Libabigail is not able to detect this kind of ABI break. We would be
able to detect this if https://dwarfstd.org/issues/221105.1.html were
implemented. As mentioned in the DWARF issue, this would also other languages
and may even simplify some work that debuggers need to do. Since it is just an
ignorable attribute, can we start supporting it even before it is standardized.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug target/102027] [11/12/13/14 Regression] ABI break when using vector type in function arg/return value
  2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2023-04-17 15:15 ` [Bug target/102027] [11/12/13/14 " woodard at redhat dot com
@ 2023-05-29 10:05 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102027

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-05-29 10:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 18:10 [Bug target/102027] New: ABI break when using vector type in function arg/return value mpolacek at gcc dot gnu.org
2021-08-23 18:10 ` [Bug target/102027] [11/12 Regression] " mpolacek at gcc dot gnu.org
2021-08-23 18:49 ` ubizjak at gmail dot com
2021-08-23 19:12 ` ubizjak at gmail dot com
2021-08-23 19:58 ` pinskia at gcc dot gnu.org
2021-08-23 20:25 ` hjl.tools at gmail dot com
2021-08-24  1:47 ` hjl.tools at gmail dot com
2021-08-24  1:50 ` pinskia at gcc dot gnu.org
2021-08-24  7:12 ` rguenth at gcc dot gnu.org
2021-08-24 13:08 ` hjl.tools at gmail dot com
2022-04-21  7:50 ` rguenth at gcc dot gnu.org
2023-04-17 15:15 ` [Bug target/102027] [11/12/13/14 " woodard at redhat dot com
2023-05-29 10:05 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).