Skip to content

Commit e59f03e

Browse files
Dev VMclaude
andcommitted
Fix naked_asm_corner_cases.d test for Windows x64 ABI
The multiPath function was using SysV ABI register (EDI) for the first argument, but Windows x64 uses ECX. Add version(Windows) block to use the correct register on each platform. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 130ae8c commit e59f03e

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

tests/codegen/naked_asm_corner_cases.d

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,33 @@ extern(C) int backwardJump() {
8181
// ASM: .LmultiPath_done:
8282
extern(C) int multiPath(int x) {
8383
asm { naked; }
84-
version(D_InlineAsm_X86_64) asm {
85-
// x is in EDI on SysV ABI
86-
test EDI, EDI;
87-
jz path1;
88-
jmp path2;
89-
path1:
90-
mov EAX, 10;
91-
jmp done;
92-
path2:
93-
mov EAX, 20;
94-
done:
95-
ret;
84+
version(D_InlineAsm_X86_64) {
85+
version(Windows) asm {
86+
// x is in ECX on Windows x64 ABI
87+
test ECX, ECX;
88+
jz path1;
89+
jmp path2;
90+
path1:
91+
mov EAX, 10;
92+
jmp done;
93+
path2:
94+
mov EAX, 20;
95+
done:
96+
ret;
97+
}
98+
else asm {
99+
// x is in EDI on SysV ABI
100+
test EDI, EDI;
101+
jz path1;
102+
jmp path2;
103+
path1:
104+
mov EAX, 10;
105+
jmp done;
106+
path2:
107+
mov EAX, 20;
108+
done:
109+
ret;
110+
}
96111
}
97112
}
98113

0 commit comments

Comments
 (0)