From faba440c5d7a33cf9b64ed7ee2b5a3a5e0a8fe07 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 6 Jan 2023 00:22:34 +0000 Subject: [PATCH] ir: Respect GlobalRef lattice elements 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 717a4eec102c2..ab513d3fd18ec 100644 --- a/base/compiler/ssair/irinterp.jl +++ b/base/compiler/ssair/irinterp.jl @@ -253,6 +253,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()