Skip to content

Commit 5ac5d19

Browse files
authored
tests/codegen/mangling.d: change argument type of naked_dFunc to int (#4661)
Avoid issues on x86 with the calling convention by having an int argument, which can be passed through a register, therefore, lifting the burden of cleaning the stack, instead of a double. Signed-off-by: Andrei Horodniceanu <[email protected]>
1 parent 93afbfa commit 5ac5d19

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tests/codegen/inputs/mangling_definitions.d

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ version(AsmX86)
4646
else
4747
static assert(naked_cppFunc.mangleof == "_ZN15cpp_naked_funcs13naked_cppFuncEd");
4848

49-
int naked_dFunc(double a) { asm { naked; ret; } }
50-
static assert(naked_dFunc.mangleof == "_D11definitions11naked_dFuncFdZi");
49+
// Pass an int instead of a double due to x86 calling convetion
50+
// See: https://github.com/ldc-developers/ldc/pull/4661
51+
int naked_dFunc(int a) { asm { naked; ret; } }
52+
static assert(naked_dFunc.mangleof == "_D11definitions11naked_dFuncFiZi");
5153
}

tests/codegen/mangling.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ version(AsmX86)
6161
extern(C++, decl_cpp_naked_funcs) pragma(mangle, nakedCppFuncMangle)
6262
int decl_naked_cppFunc(double a);
6363

64-
pragma(mangle, "_D11definitions11naked_dFuncFdZi")
65-
int decl_naked_dFunc(double a);
64+
pragma(mangle, "_D11definitions11naked_dFuncFiZi")
65+
int decl_naked_dFunc(int a);
6666
}
6767

6868
// Interfacing with C via pragma(mangle, …), without having to take care
@@ -84,7 +84,7 @@ void main()
8484
{
8585
decl_naked_cFunc(1.0);
8686
decl_naked_cppFunc(2.0);
87-
decl_naked_dFunc(3.0);
87+
decl_naked_dFunc(3);
8888
}
8989

9090
assert(decl_cos(0.0) == 1.0);

0 commit comments

Comments
 (0)