[Bug target/89627] Miscompiled constructor call

2020-01-27 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627

Jim Wilson  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |wilson at gcc dot 
gnu.org

--- Comment #5 from Jim Wilson  ---
Was fixed in gcc 9 last year.

[Bug target/89627] Miscompiled constructor call

2019-03-18 Thread aburgess at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627

--- Comment #4 from aburgess at gcc dot gnu.org ---
Author: aburgess
Date: Mon Mar 18 10:42:53 2019
New Revision: 269760

URL: https://gcc.gnu.org/viewcvs?rev=269760=gcc=rev
Log:
gcc/riscv: Correctly ignore empty C++ structs when flattening for ABI

This fixes PR target/89627.

The RISC-V ABI document[1] says:

   For the purposes of this section, "struct" refers to a C struct
   with its hierarchy flattened, including any array fields. That is,
   struct { struct { float f[1]; } g[2]; } and struct { float f; float
   g; } are treated the same. Fields containing empty structs or
   unions are ignored while flattening, even in C++, unless they have
   nontrivial copy constructors or destructors.

However, this flattening only applies when one of the fields of the
flattened structure can be placed into a floating point register,
otherwise no flattening occurs.

Currently GCC fails to correctly consider that empty C++ structures
have a non-zero size when constructing the arguments from a flattened
structure, and as a result, trying to pass a C++ structure like this:

  struct sf { struct {} e; float f; };

Doesn't work correctly, GCC fails to take the offset of 'f' within
'sf' into account and will actually pass the space backing 'e' as the
contents of 'f'.

This patch fixes this so that 'f' will be passed correctly.  A couple
of new tests are added to cover this functionality.

[1] https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md

gcc/ChangeLog:

PR target/89627
* config/riscv/riscv.c (riscv_pass_fpr_single): Add offset
parameter, and make use of it.
(riscv_get_arg_info): Pass offset to riscv_pass_fpr_single.

gcc/testsuite/ChangeLog:

PR target/89627
* g++.target/riscv/call-with-empty-struct-float.C: New file.
* g++.target/riscv/call-with-empty-struct-int.C: New file.
* g++.target/riscv/call-with-empty-struct.H: New file.
* g++.target/riscv/riscv.exp: New file.

Added:
trunk/gcc/testsuite/g++.target/riscv/
trunk/gcc/testsuite/g++.target/riscv/call-with-empty-struct-float.C
trunk/gcc/testsuite/g++.target/riscv/call-with-empty-struct-int.C
trunk/gcc/testsuite/g++.target/riscv/call-with-empty-struct.H
trunk/gcc/testsuite/g++.target/riscv/riscv.exp
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/riscv/riscv.c
trunk/gcc/testsuite/ChangeLog

[Bug target/89627] Miscompiled constructor call

2019-03-10 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627

--- Comment #3 from Andreas Schwab  ---
Here are the test results with the patch:
.

[Bug target/89627] Miscompiled constructor call

2019-03-08 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627

--- Comment #2 from Andreas Schwab  ---
FWIW this has been extracted from the swig testsuite.

https://build.opensuse.org/package/live_build_log/openSUSE:Factory:RISCV/swig/standard/riscv64

[ 3650s]
["/home/abuild/rpmbuild/BUILD/swig-3.0.12/Examples/test-suite/ruby/swig_assert.rb:138:in
`block in swig_assert_each_line'"]: FAILED EQUALITY: halved.to_a == dv.to_a was
[0.0, 0.25, 0.75, 1.25, 1.5, 1.75, 2.0, 2.25] not [0.0, Infinity, Infinity,
Infinity, Infinity, Infinity, Infinity, Infinity]
[ 3650s]from
/home/abuild/rpmbuild/BUILD/swig-3.0.12/Examples/test-suite/ruby/swig_assert.rb:135:in
`each'
[ 3650s]
/home/abuild/rpmbuild/BUILD/swig-3.0.12/Examples/test-suite/ruby/swig_assert.rb:135:in
`swig_assert_each_line'
[ 3650s] ./li_std_vector_runme.rb:224:in `'
[ 3650s] make[1]: *** [Makefile:48: li_std_vector.cpptest] Error 1

[Bug target/89627] Miscompiled constructor call

2019-03-07 Thread wilson at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627

Jim Wilson  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-03-08
 Ever confirmed|0   |1

--- Comment #1 from Jim Wilson  ---
This is the same problem that Andrew Burgess just reported.  He found it while
looking at gdb testsuite failures.  He reported it against the psABI
https://github.com/riscv/riscv-elf-psabi-doc/issues/88
This has a link to a patch, but the patch is trying to fix the ABI which is
wrong.  We only need the last two hunks of the patch which fix a bug in
riscv_pass_fpr_single.

https://github.com/T-J-Teru/gcc/commit/ae183138a618a01acf2cf009544d4ce0dda61ab9

I'm waiting for Andrew to submit the patch so I can approve it.