Bug 23050 – Incorrect disassembly of code with -vasm and 0xBE and 0xBF opcodes

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-04-24T06:33:31Z
Last change time
2022-04-29T04:57:55Z
Keywords
disassembler, pull
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2022-04-24T06:33:31Z
Given: import core.simd; void main() { } unittest { align(16) double[2] A = [56.0, -74.0]; } unittest { double[2] A = [56.0, -75.0]; double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr); assert(R.array == A); } compiling it with -O -unittest -vasm gives: _Dmain: 0000: 31 C0 xor EAX,EAX 0002: C3 ret _D4test17__unittest_L12_C1FZv: 0000: F2 0F 10 05 FC FF FF FF movsd XMM0,[0FFFFFFFCh][RIP] 0008: F2 0F 10 0D FC FF FF FF movsd XMM1,[0FFFFFFFCh][RIP] 0010: C3 ret _D4test17__unittest_L17_C1FZv: 0000: 55 push RBP 0001: 48 8B EC mov RBP,RSP 0004: 48 83 EC 30 sub RSP,030h 0008: F2 0F 10 05 FC FF FF FF movsd XMM0,[0FFFFFFFCh][RIP] 0010: F2 48 0F 11 45 E0 movsd -020h[RBP],XMM0 0016: F2 0F 10 0D FC FF FF FF movsd XMM1,[0FFFFFFFCh][RIP] 001e: F2 48 0F 11 4D E8 movsd -018h[RBP],XMM1 0024: 66 0F 10 55 E0 movupd XMM2,-020h[RBP] 0029: 66 0F 29 55 F0 movapd -010h[RBP],XMM2 002e: 41 B8 00 00 00 00 mov EAX,0 0034: 48 8D 4D E0 lea RCX,-020h[RBP] 0038: B8 02 00 00 00 mov EAX,2 003d: 48 89 C2 mov RDX,RAX 0040: 48 89 55 D8 mov -028h[RBP],RDX 0044: 48 8D 55 F0 lea RDX,-010h[RBP] 0048: BF 02 00 00 00 mov EAX,2 004d: 48 89 D6 mov RSI,RDX 0050: 48 8B 55 D8 mov RDX,-028h[RBP] 0054: E8 00 00 00 00 call L0 0059: 85 C0 test EAX,EAX 005b: 75 0F jne L6c 005d: BE 15 00 00 00 mov EAX,015h !!!! 0062: BF 00 00 00 00 mov EAX,0 !!!! 0067: E8 00 00 00 00 call L0 006c: 48 8B E5 mov RSP,RBP 006f: 5D pop RBP 0070: C3 ret main: 0000: 55 push RBP 0001: 48 8B EC mov RBP,RSP 0004: 48 83 EC 10 sub RSP,010h 0008: 89 7D F0 mov -010h[RBP],EDI 000b: 48 89 75 F8 mov -8[RBP],RSI 000f: BA 00 00 00 00 mov EAX,0 0014: 48 8B 75 F8 mov RSI,-8[RBP] 0018: 8B 7D F0 mov EDI,-010h[RBP] 001b: E8 00 00 00 00 call L0 0020: 48 8B E5 mov RSP,RBP 0023: 5D pop RBP 0024: C3 ret _D4test9__modtestFZv: 0000: 55 push RBP 0001: 48 8B EC mov RBP,RSP 0004: E8 00 00 00 00 call L0 0009: E8 00 00 00 00 call L0 000e: 5D pop RBP 000f: C3 ret The lines marked with !!!! are incorrect.
Comment #1 by bugzilla — 2022-04-28T22:21:20Z
Note that obj2asm gives: 005d: BE 12 00 00 00 mov ESI,012h 0062: BF 00 00 00 00 mov EDI,offset FLAT:_TMP4@32 Note that the object code is 12 instead of 15, too.
Comment #2 by dlang-bot — 2022-04-28T22:39:33Z
@WalterBright created dlang/dmd pull request #14037 "fix Issue 23050 - Incorrect disassembly of code with -vasm and 0xBE a…" fixing this issue: - fix Issue 23050 - Incorrect disassembly of code with -vasm and 0xBE and 0xBF opcodes https://github.com/dlang/dmd/pull/14037
Comment #3 by dlang-bot — 2022-04-29T04:57:55Z
dlang/dmd pull request #14037 "fix Issue 23050 - Incorrect disassembly of code with -vasm and 0xBE a…" was merged into master: - 45f28d39f6b63fe4f709f82913032ef8c3c490b5 by Walter Bright: fix Issue 23050 - Incorrect disassembly of code with -vasm and 0xBE and 0xBF opcodes https://github.com/dlang/dmd/pull/14037