Skip to content

Commit

Permalink
Fix 44921 by properly setting Vboxed field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Atol committed Apr 11, 2022
1 parent 1fe7cfa commit f5d8ce3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1864,14 +1864,15 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
boxv = ctx.builder.CreateSelect(
ctx.builder.CreateAnd(wasboxed, isboxed), v.Vboxed, boxv);
}
Value *slotv;
MDNode *tbaa;
if (v.V == NULL) {
// v.V might be NULL if it was all ghost objects before
return jl_cgval_t(boxv, NULL, false, typ, new_tindex, ctx.tbaa());
slotv = NULL;
tbaa = ctx.tbaa().tbaa_const;
}
else {
Value *isboxv = ctx.builder.CreateIsNotNull(boxv);
Value *slotv;
MDNode *tbaa;
if (v.ispointer()) {
slotv = v.V;
tbaa = v.tbaa;
Expand All @@ -1884,12 +1885,12 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
slotv = ctx.builder.CreateSelect(isboxv,
decay_derived(ctx, boxv),
decay_derived(ctx, emit_bitcast(ctx, slotv, boxv->getType())));
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
assert(boxv->getType() == ctx.types().T_prjlvalue);
newv.Vboxed = boxv;
newv.tbaa = tbaa;
return newv;
}
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
assert(boxv->getType() == ctx.types().T_prjlvalue);
newv.Vboxed = boxv;
newv.tbaa = tbaa;
return newv;
}
}
else {
Expand Down
17 changes: 17 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,23 @@ function f42645()
end
@test ((f42645()::B42645).y::A42645{Int}).x

struct A44921{T}
x::T
end
function f44921(a)
if a == :x
A44921(_f) # _f purposefully undefined
elseif a == :p
g44921(a)
end
end
function g44921(a)
if !any([])
A44921(())
end
end
@test f44921(:p) isa A44921

# issue #43123
@noinline cmp43123(a::Some, b::Some) = something(a) === something(b)
@noinline cmp43123(a, b) = a[] === b[]
Expand Down

0 comments on commit f5d8ce3

Please sign in to comment.