Skip to content

Commit e964634

Browse files
committed
codegen: update type of x after type-assert
Later code likes to see that the type is consistent with the cgval and the unbox. (cherry picked from commit e1e5a46)
1 parent 7b18f9c commit e964634

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/intrinsics.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ static jl_cgval_t emit_runtime_pointerset(jl_codectx_t &ctx, ArrayRef<jl_cgval_t
800800
static jl_cgval_t emit_pointerset(jl_codectx_t &ctx, ArrayRef<jl_cgval_t> argv)
801801
{
802802
const jl_cgval_t &e = argv[0];
803-
const jl_cgval_t &x = argv[1];
803+
jl_cgval_t x = argv[1];
804804
const jl_cgval_t &i = argv[2];
805805
const jl_cgval_t &align = argv[3];
806806

@@ -823,6 +823,9 @@ static jl_cgval_t emit_pointerset(jl_codectx_t &ctx, ArrayRef<jl_cgval_t> argv)
823823
return jl_cgval_t();
824824
}
825825
emit_typecheck(ctx, x, ety, "pointerset");
826+
x = update_julia_type(ctx, x, ety);
827+
if (x.typ == jl_bottom_type)
828+
return jl_cgval_t();
826829

827830
Value *idx = emit_unbox(ctx, ctx.types().T_size, i, (jl_value_t*)jl_long_type);
828831
Value *im1 = ctx.builder.CreateSub(idx, ConstantInt::get(ctx.types().T_size, 1));
@@ -966,7 +969,7 @@ static jl_cgval_t emit_atomic_pointerop(jl_codectx_t &ctx, intrinsic f, ArrayRef
966969
bool ismodifyfield = f == atomic_pointermodify;
967970
const jl_cgval_t undefval;
968971
const jl_cgval_t &e = argv[0];
969-
const jl_cgval_t &x = isreplacefield || ismodifyfield ? argv[2] : argv[1];
972+
jl_cgval_t x = isreplacefield || ismodifyfield ? argv[2] : argv[1];
970973
const jl_cgval_t &y = isreplacefield || ismodifyfield ? argv[1] : undefval;
971974
const jl_cgval_t &ord = isreplacefield || ismodifyfield ? argv[3] : argv[2];
972975
const jl_cgval_t &failord = isreplacefield ? argv[4] : undefval;
@@ -1008,8 +1011,12 @@ static jl_cgval_t emit_atomic_pointerop(jl_codectx_t &ctx, intrinsic f, ArrayRef
10081011
emit_error(ctx, msg);
10091012
return jl_cgval_t();
10101013
}
1011-
if (!ismodifyfield)
1014+
if (!ismodifyfield) {
10121015
emit_typecheck(ctx, x, ety, std::string(jl_intrinsic_name((int)f)));
1016+
x = update_julia_type(ctx, x, ety);
1017+
if (x.typ == jl_bottom_type)
1018+
return jl_cgval_t();
1019+
}
10131020

10141021
size_t nb = jl_datatype_size(ety);
10151022
if ((nb & (nb - 1)) != 0 || nb > MAX_POINTERATOMIC_SIZE) {

0 commit comments

Comments
 (0)