Bug 64243 - Passing and returning structures with single member of floating type via SSE registers is wrong on Windows x86-64 ABI
Summary: Passing and returning structures with single member of floating type via SSE ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ABI, wrong-code
: 86727 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-09 16:43 UTC by Krzysztof Surdacki
Modified: 2020-12-30 21:20 UTC (History)
2 users (show)

See Also:
Host:
Target: mingw
Build:
Known to work: 9.3.1
Known to fail: 8.4.1
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Surdacki 2014-12-09 16:43:27 UTC
Two types of structures:

struct TestFloat { float x; };
struct TestDouble { double x; };

are passed and returned via SSE registers which is wrong in Windows x86-64 ABI.
According to Microsoft documentation:
http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
http://msdn.microsoft.com/en-us/library/7572ztz4.aspx
and code generated by MSVS2013 analysis, this kind of structures should be passed via integer registers (RCX, RDX, R8, and R9) and returned in RAX register.
Comment 1 Richard Biener 2018-07-30 09:37:37 UTC
*** Bug 86727 has been marked as a duplicate of this bug. ***
Comment 2 Bart Janssens 2018-07-30 10:05:37 UTC
Any chance that this can be upgraded to "confirmed"? Seems this has been around for a while...
Comment 3 Bart Janssens 2020-12-29 23:16:30 UTC
We are still having this issue, it now manifests in cross-compiled binaries used in the Julia ecosystem, see: https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/315
Comment 4 Uroš Bizjak 2020-12-30 08:02:34 UTC
Adding CC.
Comment 5 Uroš Bizjak 2020-12-30 09:06:33 UTC
This is fixed in gcc-11:

--cut here--
struct TestFloat { float x; };
struct TestDouble { double x; };

struct TestFloat foo (struct TestFloat x) { return x; }
struct TestDouble bar (struct TestDouble x) { return x; }
--cut here--

gcc -O2:

foo:
        movl    %ecx, %eax
        ret

bar:
        movq    %rcx, %rax
        ret
Comment 6 Uroš Bizjak 2020-12-30 09:25:42 UTC
Fixed in gcc-9.
Comment 7 Bart Janssens 2020-12-30 21:20:15 UTC
Thanks, confirmed that this is also working on GCC 10.2. Unfortunately the latest in our compiler images is 9.1, and that seems to be still affected, so we'll have to upgrade.