Skip to content

Commit

Permalink
codegen: add missing ssavalue check for store hoisting (#48939)
Browse files Browse the repository at this point in the history
Fix #48917
  • Loading branch information
gbaraldi authored Mar 8, 2023
1 parent 9b8d778 commit 9ef2c90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5284,7 +5284,7 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaidx_
jl_cgval_t res = emit_call(ctx, ex, expr_t, is_promotable);
// some intrinsics (e.g. typeassert) can return a wider type
// than what's actually possible
if (is_promotable && res.promotion_point) {
if (is_promotable && res.promotion_point && res.promotion_ssa == -1) {
res.promotion_ssa = ssaidx_0based;
}
res = update_julia_type(ctx, res, expr_t);
Expand Down
4 changes: 4 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,7 @@ function F48394(a, b, i)
end
@test F48394(X48394(nothing,true), Y48394(nothing, missing), true)
@test occursin("llvm.trap", get_llvm(F48394, Tuple{X48394, Y48394, Bool}))

# issue 48917, hoisting load to above the parent
f48917(x, w) = (y = (a=1, b=x); z = (; a=(a=(1, w), b=(3, y))))
@test f48917(1,2) == (a = (a = (1, 2), b = (3, (a = 1, b = 1))),)

0 comments on commit 9ef2c90

Please sign in to comment.