Skip to content

Commit 726bbd7

Browse files
authored
Fix regression in generic_bitcast with Union{} arguments. (#47605)
1 parent 25b2746 commit 726bbd7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/intrinsics.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,12 @@ static jl_cgval_t emit_intrinsic(jl_codectx_t &ctx, intrinsic f, jl_value_t **ar
11341134

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

11401145
// this forces everything to use runtime-intrinsics (e.g. for testing)

test/compiler/codegen.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,3 +785,8 @@ f_isa_type(@nospecialize(x)) = isa(x, Type)
785785
# Issue #47247
786786
f47247(a::Ref{Int}, b::Nothing) = setfield!(a, :x, b)
787787
@test_throws TypeError f47247(Ref(5), nothing)
788+
789+
@testset "regression in generic_bitcast: should support Union{} values" begin
790+
f(x) = Core.bitcast(UInt64, x)
791+
@test occursin("llvm.trap", get_llvm(f, Tuple{Union{}}))
792+
end

0 commit comments

Comments
 (0)