Skip to content

Commit dd603f0

Browse files
committed
Fix win64 ABI for non-power-of-two size structs
1 parent 551cd52 commit dd603f0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/abi_win64.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,30 @@ struct AbiState {
4444

4545
const AbiState default_abi_state = {};
4646

47+
// whether the argument can be passed in register
48+
static bool win64_reg_size(size_t size)
49+
{
50+
return size <= 2 || size == 4 || size == 8;
51+
}
52+
4753
bool use_sret(AbiState *state, jl_datatype_t *dt)
4854
{
4955
size_t size = jl_datatype_size(dt);
50-
if (size <= 8 || is_native_simd_type(dt))
56+
if (win64_reg_size(size) || is_native_simd_type(dt))
5157
return false;
5258
return true;
5359
}
5460

5561
void needPassByRef(AbiState *state, jl_datatype_t *dt, bool *byRef, bool *inReg)
5662
{
5763
size_t size = jl_datatype_size(dt);
58-
if (size > 8)
59-
*byRef = true;
64+
*byRef = !win64_reg_size(size);
6065
}
6166

6267
Type *preferred_llvm_type(jl_datatype_t *dt, bool isret)
6368
{
6469
size_t size = jl_datatype_size(dt);
65-
if (size > 0 && size <= 8 && !jl_is_bitstype(dt))
70+
if (size > 0 && win64_reg_size(size) && !jl_is_bitstype(dt))
6671
return Type::getIntNTy(jl_LLVMContext, size*8);
6772
return NULL;
6873
}

0 commit comments

Comments
 (0)