Skip to content

Commit 3fa51e9

Browse files
authored
codegen: fix bug in jl_set_ptls_rng (#59427)
This is not an Int64Ty, but can be converted to one, which made this code brittle. It also appears that no other ccall optimization makes this mistake, so this was the only one that needed to be fixed.
1 parent b30e7eb commit 3fa51e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ccall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,8 +1707,8 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
17071707
const int rng_offset = offsetof(jl_tls_states_t, rngseed);
17081708
Value *rng_ptr = ctx.builder.CreateInBoundsGEP(getInt8Ty(ctx.builder.getContext()), ptls_p, ConstantInt::get(ctx.types().T_size, rng_offset / sizeof(int8_t)));
17091709
setName(ctx.emission_context, rng_ptr, "rngseed_ptr");
1710-
assert(argv[0].V->getType() == getInt64Ty(ctx.builder.getContext()));
1711-
auto store = ctx.builder.CreateAlignedStore(argv[0].V, rng_ptr, Align(sizeof(void*)));
1710+
Value *val64 = emit_unbox(ctx, getInt64Ty(ctx.builder.getContext()), argv[0], (jl_value_t*)jl_uint64_type);
1711+
auto store = ctx.builder.CreateAlignedStore(val64, rng_ptr, Align(sizeof(void*)));
17121712
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_gcframe);
17131713
ai.decorateInst(store);
17141714
return ghostValue(ctx, jl_nothing_type);

0 commit comments

Comments
 (0)