Function Inlining is not working correctly on agni
Tapple Gao
The compiler on agni is not doing as much function inlining as the CLI tools. Take this script:
print(gcinfo())
local function b() return "hello" end
print(gcinfo())
print(b())
Variable
b
should be inlined awayOn simulator version Luau 2026-01-30.21516666911 , this prints
[4:56 PM] Object: 1.4521484375
[4:56 PM] Object: 1.4716796875
[4:56 PM] Object: hello
The two numbers are different, so something entered memory in-between the two gcinfo calls
However, when run locally, it prints:
$ ./slua inlinetest.luau
39
39
hello
The two numbers are the same, indicating nothing happened in memory in-between the two calls.
Looking at the bytecode compiled locally:
$ ./slua-compile inlinetest.luau
Function 0 (b):
2: local function b() return "hello" end
LOADK R0 K0 ['hello']
RETURN R0 1
Function 1 (??):
1: print(gcinfo())
GETIMPORT R0 1 [print]
GETIMPORT R1 3 [gcinfo]
CALL R1 0 -1
CALL R0 -1 0
2: local function b() return "hello" end
DUPCLOSURE R0 K4 ['b']
3: print(gcinfo())
GETIMPORT R1 1 [print]
GETIMPORT R2 3 [gcinfo]
CALL R2 0 -1
CALL R1 -1 0
4: print(b())
GETIMPORT R1 1 [print]
MOVE R2 R0
CALL R2 0 -1
CALL R1 -1 0
5:
RETURN R0 0
On the final print call, it's not calling function
b
, it does seem to be calling b
, not just moving "hello" to a register. hmm. The gcinfo calls above sure made it look inlined away. I can't grab the bytecode for the simulator-compiled script, but it's seems to be doing something differently
Log In