Don't create multiple upvalues for the same function
Fixes a performance bug where we would create multiple upvalue slots for the same function. Only the
last one would be used and the first ones would be wasted.
@@ -645,12 +645,14 @@ function Coder:init_upvalues()
for _, v in ipairs(ir.get_srcs(cmd)) do
if v._tag == "ir.Value.Function" then
local f_id = v.id
+ if not self.upvalue_of_function[f_id] then
table.insert(self.upvalues, coder.Upvalue.Function(f_id))
self.upvalue_of_function[f_id] = #self.upvalues
end
end
end
end
+ end
-- Globals
for g_id = 1, #self.module.globals do
