Skip to content

Commit 1f6dc03

Browse files
Ian AtolKristofferC
authored andcommitted
Fix 44921 by properly setting Vboxed field (#44942)
(cherry picked from commit 4c858f8)
1 parent 09e14a4 commit 1f6dc03

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
@@ -1790,14 +1790,15 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
17901790
boxv = ctx.builder.CreateSelect(
17911791
ctx.builder.CreateAnd(wasboxed, isboxed), v.Vboxed, boxv);
17921792
}
1793+
Value *slotv;
1794+
MDNode *tbaa;
17931795
if (v.V == NULL) {
17941796
// v.V might be NULL if it was all ghost objects before
1795-
return jl_cgval_t(boxv, NULL, false, typ, new_tindex, ctx.tbaa());
1797+
slotv = NULL;
1798+
tbaa = ctx.tbaa().tbaa_const;
17961799
}
17971800
else {
17981801
Value *isboxv = ctx.builder.CreateIsNotNull(boxv);
1799-
Value *slotv;
1800-
MDNode *tbaa;
18011802
if (v.ispointer()) {
18021803
slotv = v.V;
18031804
tbaa = v.tbaa;
@@ -1810,12 +1811,12 @@ static jl_cgval_t convert_julia_type_union(jl_codectx_t &ctx, const jl_cgval_t &
18101811
slotv = ctx.builder.CreateSelect(isboxv,
18111812
decay_derived(ctx, boxv),
18121813
decay_derived(ctx, emit_bitcast(ctx, slotv, boxv->getType())));
1813-
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
1814-
assert(boxv->getType() == ctx.types().T_prjlvalue);
1815-
newv.Vboxed = boxv;
1816-
newv.tbaa = tbaa;
1817-
return newv;
18181814
}
1815+
jl_cgval_t newv = jl_cgval_t(slotv, NULL, false, typ, new_tindex, ctx.tbaa());
1816+
assert(boxv->getType() == ctx.types().T_prjlvalue);
1817+
newv.Vboxed = boxv;
1818+
newv.tbaa = tbaa;
1819+
return newv;
18191820
}
18201821
}
18211822
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)