https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79717
Bug ID: 79717
Summary: [bug/not bug] [windows] ms_abi floating data type
calling convention
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rudyy.id at gmail dot com
Target Milestone: ---
Before I start, let me give you something:
1. I already report this on
https://sourceware.org/bugzilla/show_bug.cgi?id=21197 .
They say I should go here.
2. This is about ms_abi x64 calling convention.
Specified: this is about floating data type parameter passing.
More specified: this is about "long double" floating data type.
3. Since this is about ms_abi x64,
Let me quote something from
https://msdn.microsoft.com/en-us/library/ms235286.aspx :
"The x87 register stack is unused. It may be used by the callee,
but must be considered volatile across function calls.
All floating point operations are done using the 16 XMM registers.
Integer arguments are passed in registers RCX, RDX, R8, and R9.
Floating point arguments are passed in XMM0L, XMM1L, XMM2L, and XMM3L."
4. I already check some of ms binaries, it is the same like ms say on number 3.
5. I don't really care about this since I didn't use gnuc so often and
I'm already take care my problem by using simple inline assembler.
But, since I'm already report this on number 1 and I'm already check in some
microsoft binaries, why not post it again.
6. Compiler+linker "gcc 6.3-release and binutils 2.27-release" and
"gcc 6.3+rev. 245043 and binutils 2.27+git 1273da0".
7. This isn't about structure like the bug 64243 or 41013 or ...
Now lets go into our real problem.
Test case:
----------
long double testldcall(long double value) {
return (value + value); /* ms_abi only see "value" in xmm register */
/* not a pointer for "value" */
}
int main() {
long double a = 2.3;
a = testldcall(a); /* gas passing 'a' into 'testldcall' as a "pointer to
value a" */
/* not as a "value of a" */
}
Lets take a look a log from another c source I'm build using gnuc compiler:
---------------------------------------------------------------------------
/* xmm6 is long double */
69660 2e392 0F29B424 movaps XMMWORD PTR 256[rsp], xmm6
69660 00010000
/* xmm6 in the stack */
69661 2e39a 488DAC24 lea rbp, 256[rsp]
69661 00010000
/* rcx is a pointer into xmm6 in the stack */
69662 2e3a2 4889E9 mov rcx, rbp
/* call ms_abi dll 'ldclass' */
/* is this correct? it is not according number 3 and */
/* it is not according what I read from ms_abi dll 'ldclass' */
69663 2e3a5 FF150000 call [QWORD PTR .refptr.__imp__ldclass[rip]]
Now you see whats the problem, don't you?
GAs passing any 'long double' data type not as a value but a pointer into where
the value are.
In ms_abi, like I quote on number 3 above, using xmm register for passing all
floating data type.
It means its require a value not a pointer where the value are.
GAs did good job on 'float' and 'double', but didn't do the same job for 'long
double'.