Skip to content

Commit

Permalink
Fix regression in generic_bitcast with Union{} arguments. (#47605)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored Nov 24, 2022
1 parent 25b2746 commit 726bbd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,12 @@ static jl_cgval_t emit_intrinsic(jl_codectx_t &ctx, intrinsic f, jl_value_t **ar

jl_cgval_t *argv = (jl_cgval_t*)alloca(sizeof(jl_cgval_t) * nargs);
for (size_t i = 0; i < nargs; ++i) {
argv[i] = emit_expr(ctx, args[i + 1]);
jl_cgval_t arg = emit_expr(ctx, args[i + 1]);
if (arg.typ == jl_bottom_type) {
// intrinsics generally don't handle buttom values, so bail out early
return jl_cgval_t();
}
argv[i] = arg;
}

// this forces everything to use runtime-intrinsics (e.g. for testing)
Expand Down
5 changes: 5 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -785,3 +785,8 @@ f_isa_type(@nospecialize(x)) = isa(x, Type)
# Issue #47247
f47247(a::Ref{Int}, b::Nothing) = setfield!(a, :x, b)
@test_throws TypeError f47247(Ref(5), nothing)

@testset "regression in generic_bitcast: should support Union{} values" begin
f(x) = Core.bitcast(UInt64, x)
@test occursin("llvm.trap", get_llvm(f, Tuple{Union{}}))
end

0 comments on commit 726bbd7

Please sign in to comment.