Skip to content

Commit 4c858f8

Browse files
author
Ian Atol
authored
Fix 44921 by properly setting Vboxed field (#44942)
1 parent 990c21a commit 4c858f8

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

src/codegen.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,14 +1864,15 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
18641864
boxv = ctx.builder.CreateSelect(
18651865
ctx.builder.CreateAnd(wasboxed, isboxed), v.Vboxed, boxv);
18661866
}
1867+
Value *slotv;
1868+
MDNode *tbaa;
18671869
if (v.V == NULL) {
18681870
// v.V might be NULL if it was all ghost objects before
1869-
return jl_cgval_t(boxv, NULL, false, typ, new_tindex, ctx.tbaa());
1871+
slotv = NULL;
1872+
tbaa = ctx.tbaa().tbaa_const;
18701873
}
18711874
else {
18721875
Value *isboxv = ctx.builder.CreateIsNotNull(boxv);
1873-
Value *slotv;
1874-
MDNode *tbaa;
18751876
if (v.ispointer()) {
18761877
slotv = v.V;
18771878
tbaa = v.tbaa;
@@ -1884,12 +1885,12 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
18841885
slotv = ctx.builder.CreateSelect(isboxv,
18851886
decay_derived(ctx, boxv),
18861887
decay_derived(ctx, emit_bitcast(ctx, slotv, boxv->getType())));
1887-
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
1888-
assert(boxv->getType() == ctx.types().T_prjlvalue);
1889-
newv.Vboxed = boxv;
1890-
newv.tbaa = tbaa;
1891-
return newv;
18921888
}
1889+
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
1890+
assert(boxv->getType() == ctx.types().T_prjlvalue);
1891+
newv.Vboxed = boxv;
1892+
newv.tbaa = tbaa;
1893+
return newv;
18931894
}
18941895
}
18951896
else {

test/compiler/codegen.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,23 @@ function f42645()
702702
end
703703
@test ((f42645()::B42645).y::A42645{Int}).x
704704

705+
struct A44921{T}
706+
x::T
707+
end
708+
function f44921(a)
709+
if a == :x
710+
A44921(_f) # _f purposefully undefined
711+
elseif a == :p
712+
g44921(a)
713+
end
714+
end
715+
function g44921(a)
716+
if !@isdefined _f # just needs to be some non constprop-able condition
717+
A44921(())
718+
end
719+
end
720+
@test f44921(:p) isa A44921
721+
705722
# issue #43123
706723
@noinline cmp43123(a::Some, b::Some) = something(a) === something(b)
707724
@noinline cmp43123(a, b) = a[] === b[]

0 commit comments

Comments
 (0)