This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/38151] structures with _Complex arguments are not passed correctly
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Nov 2008 17:07:30 -0000
- Subject: [Bug target/38151] structures with _Complex arguments are not passed correctly
- References: <bug-38151-11113@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #22 from ubizjak at gmail dot com 2008-11-22 17:07 -------
Aliasing problems, gcc shoots himself in the foot...
When container consists of registers in different modes (due to
X86_64_INTEGERSI_CLASS optimization):
(parallel:BLK [
(expr_list:REG_DEP_TRUE (reg:DI 0 ax)
(const_int 0 [0x0]))
(expr_list:REG_DEP_TRUE (reg:SI 1 dx)
(const_int 8 [0x8]))
])
then ix86_gimplify_va_arg happily creates code with invalid aliasing (from
_.gimple dump):
addr.0 = &va_arg_tmp.3;
> addr.4 = (long unsigned int *) addr.0;
int_addr.5 = (long unsigned int *) int_addr.1;
D.1615 = *int_addr.5;
*addr.4 = D.1615;
> addr.6 = (unsigned int *) addr.0;
D.1617 = addr.6 + 8;
We access addr.0 as (long unsigned int *) and as (unsigned int *. Following
optimization passes are more than happy to remove the second access.
So to prove my point, testcase compiled with -fno-strict-aliasing works OK.
These problems also apply to FPmode parameters passing through SSE regs, so
following patch moves registers from register area to tmp area in generic mode
that fits argument passing registers best: DImode for integer and V4SFmode for
SSE registers. This avoids aliasing problems.
Index: i386.c
===================================================================
--- i386.c (revision 142120)
+++ i386.c (working copy)
@@ -6750,7 +6750,8 @@ ix86_gimplify_va_arg (tree valist, tree
{
rtx slot = XVECEXP (container, 0, i);
rtx reg = XEXP (slot, 0);
- enum machine_mode mode = GET_MODE (reg);
+ enum machine_mode mode
+ = SSE_REGNO_P (REGNO (reg)) ? V4SFmode : DImode;
tree piece_type = lang_hooks.types.type_for_mode (mode, 1);
tree addr_type = build_pointer_type (piece_type);
tree src_addr, src;
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ubizjak at gmail dot com
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2008-11-16 20:58:10 |2008-11-22 17:07:30
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38151