From c38e7cd76ad5576a52e4726f78229e8c6e5cc212 Mon Sep 17 00:00:00 2001 From: Cody Tapscott <84105208+topolarity@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:28:42 -0400 Subject: [PATCH] inlining: Use tfunc for inserted `isa`/`and` calls (#54209) The motivation for this is the same as #54105, where the return types being filled in by inference can in general be imprecise when running the compiler with an extended lattice. Note that this PR is very incomplete. There are at least 6+ more places in `inlining.jl` where we hard-code return types that will need similar treatment, but for now this resolves some downstream bugs from these imprecise types. --- base/compiler/ssair/inlining.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index a0f7b0258929d..4b6bc8fe071d4 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -545,12 +545,14 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs:: aft <: mft && continue # Generate isa check isa_expr = Expr(:call, isa, argexprs[i], mft) - ssa = insert_node_here!(compact, NewInstruction(isa_expr, Bool, line)) + isa_type = isa_tfunc(optimizer_lattice(interp), argextype(argexprs[i], compact), Const(mft)) + ssa = insert_node_here!(compact, NewInstruction(isa_expr, isa_type, line)) if cond === true cond = ssa else and_expr = Expr(:call, and_int, cond, ssa) - cond = insert_node_here!(compact, NewInstruction(and_expr, Bool, line)) + and_type = and_int_tfunc(optimizer_lattice(interp), argextype(cond, compact), isa_type) + cond = insert_node_here!(compact, NewInstruction(and_expr, and_type, line)) end end insert_node_here!(compact, NewInstruction(GotoIfNot(cond, next_cond_bb), Union{}, line))