From b76fdcc3de4183a4dab019aacd335a5f944542ea Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 6 Jan 2023 17:50:40 -0500 Subject: [PATCH] ir: Respect GlobalRef lattice elements (#48151) Currently IncrementalCompact recomputes the type of globals on every iteration. There is not much reason to do this - the type of a global cannot change. In addition, external abstract interpreters may want to inject custom, more precise lattice elements for globals, which should be respected. Overall, this should be both faster and better for external absint, though of course GlobalRefs now need to be inserted into the IR with the correct type. If there's any callsites that don't do that, those would have to be updated. --- base/compiler/ssair/ir.jl | 1 - base/compiler/ssair/irinterp.jl | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/base/compiler/ssair/ir.jl b/base/compiler/ssair/ir.jl index 0f86945b15b88..5a5d98ac4539c 100644 --- a/base/compiler/ssair/ir.jl +++ b/base/compiler/ssair/ir.jl @@ -1244,7 +1244,6 @@ function process_node!(compact::IncrementalCompact, result_idx::Int, inst::Instr ssa_rename[idx] = stmt else result[result_idx][:inst] = stmt - result[result_idx][:type] = argextype(stmt, compact) result[result_idx][:flag] = flag result_idx += 1 end diff --git a/base/compiler/ssair/irinterp.jl b/base/compiler/ssair/irinterp.jl index 92e130a65cc75..856cd3b9eff14 100644 --- a/base/compiler/ssair/irinterp.jl +++ b/base/compiler/ssair/irinterp.jl @@ -265,6 +265,8 @@ function reprocess_instruction!(interp::AbstractInterpreter, rt = tmeet(typeinf_lattice(interp), argextype(inst.val, ir), widenconst(inst.typ)) elseif inst === nothing return false + elseif isa(inst, GlobalRef) + # GlobalRef is not refinable else ccall(:jl_, Cvoid, (Any,), inst) error()