From 32411a0db4fbde19269bd6dcf92f731e7448c835 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Mon, 22 Apr 2024 19:14:18 -0400 Subject: [PATCH] inlining: Use tfunc for inserted `isa`/`and` calls 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. 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. --- 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 d6853d83b61bc..c5b8d0ecbc897 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))