← Back to index
|
Original Bugzilla link
Bug 9239 – x86_64 ABI: 3 byte structs are never enregistered
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-28T19:26:29Z
Last change time
2018-10-05T18:31:56Z
Assigned to
No Owner
Creator
David Nadlinger
Blocks
5570
Comments
Comment #0
by code — 2012-12-28T19:26:29Z
The following example shows the problem: --- struct RGB { char r, g, b; }; void foo(RGB c); void bar() { RGB c; c.r = 1; c.g = 2; c.b = 3; foo(c); } --- Compiled with Clang: --- 0000000000000000 <_Z3barv>: 0: bf 01 02 03 00 mov edi,0x30201 5: e9 00 00 00 00 jmp a <_Z3barv+0xa> --- Compiled with DMD (Git master): --- 0000000000000000 <_D4test3barFZv>: 0: 55 push rbp 1: 48 8b ec mov rbp,rsp 4: 48 83 ec 10 sub rsp,0x10 8: 48 be 00 00 00 00 00 movabs rsi,0x0 f: 00 00 00 12: 48 8d 7d f8 lea rdi,[rbp-0x8] 16: a4 movs BYTE PTR es:[rdi],BYTE PTR ds:[rsi] 17: a4 movs BYTE PTR es:[rdi],BYTE PTR ds:[rsi] 18: a4 movs BYTE PTR es:[rdi],BYTE PTR ds:[rsi] 19: c6 45 f8 01 mov BYTE PTR [rbp-0x8],0x1 1d: c6 45 f9 02 mov BYTE PTR [rbp-0x7],0x2 21: c6 45 fa 03 mov BYTE PTR [rbp-0x6],0x3 25: 48 83 ec 08 sub rsp,0x8 29: ff 75 f8 push QWORD PTR [rbp-0x8] 2c: e8 00 00 00 00 call 31 <_D4test3barFZv+0x31> 31: 48 83 c4 10 add rsp,0x10 35: 48 8b e5 mov rsp,rbp 38: 5d pop rbp 39: c3 ret ---
Comment #1
by kinke — 2018-10-02T19:49:34Z
This works for me with DMD 2.082.0 on Linux x64:
https://run.dlang.io/is/A5a5U1
mov byte ptr -8[RBP],1 mov byte ptr -7[RBP],2 mov byte ptr -6[RBP],3 mov EDI,-8[RBP] call _Z3foo3RGB@PLT32