Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3947,8 +3947,6 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
else {
strct = emit_static_alloca(ctx, lt);
setName(ctx.emission_context, strct, arg_typename);
if (nargs < nf)
promotion_point = ctx.builder.CreateStore(ctx.builder.CreateFreeze(UndefValue::get(lt)), strct);
if (tracked.count)
undef_derived_strct(ctx, strct, sty, ctx.tbaa().tbaa_stack);
}
Expand Down Expand Up @@ -4104,6 +4102,14 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
}
}
}
if (promotion_point && nargs < nf) {
assert(!init_as_value);
IRBuilderBase::InsertPoint savedIP = ctx.builder.saveIP();
ctx.builder.SetInsertPoint(promotion_point);
promotion_point = cast<FreezeInst>(ctx.builder.CreateFreeze(UndefValue::get(lt)));
ctx.builder.CreateStore(promotion_point, strct);
ctx.builder.restoreIP(savedIP);
}
if (type_is_ghost(lt))
return mark_julia_const(ctx, sty->instance);
else if (init_as_value)
Expand Down
10 changes: 10 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,13 @@ function foonopreds()
pkgid.uuid !== nothing ? pkgid.uuid : false
end
@test foonopreds() !== nothing

# issue 55396
struct Incomplete55396
x::Tuple{Int}
y::Int
@noinline Incomplete55396(x::Int) = new((x,))
end
let x = Incomplete55396(55396)
@test x.x === (55396,)
end