[Issue 18928] extern(C++) bad codegen, wrong calling convention
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 1 19:12:26 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18928
--- Comment #3 from Manu <turkeyman at gmail.com> ---
You'll have to relate these 2 lines to the .cpp file (attached) in main()
Calling code in main():
// static call...
auto x = addUser(test, "test");
00007FF74843C587 lea rdx,[string "test" (07FF748448D44h)]
00007FF74843C58E mov rcx,qword ptr [test]
00007FF74843C592 call addUser (07FF74840C735h)
00007FF74843C597 mov dword ptr [rbp+104h],eax
00007FF74843C59D mov eax,dword ptr [rbp+104h]
00007FF74843C5A3 mov dword ptr [x],eax
// virtual call...
x = test->addUser("test");
00007FF74843C5A6 mov rax,qword ptr [test]
00007FF74843C5AA mov rax,qword ptr [rax]
00007FF74843C5AD lea r8,[string "test" (07FF748448D44h)]
00007FF74843C5B4 lea rdx,[rbp+124h] // what is? RVO return address?
00007FF74843C5BB mov rcx,qword ptr [test]
00007FF74843C5BF call qword ptr [rax]
00007FF74843C5C1 mov eax,dword ptr [rax]
00007FF74843C5C3 mov dword ptr [x],eax
This is the C++ code calling into D; it appears C++ makes a static call
differently to a virtual call? I suspect RDX in the virtual call is the RVO
return address? I wonder why the static-call doesn't follow the same call
convention?
I can attach the DMD disassembly? But it's probably easier to build that
yourself.
This might reveal that the VC ABI has RVO rules that we don't understand?
--
More information about the Digitalmars-d-bugs
mailing list