You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
auto-inline: any function annotation (even [sideeffects] or a tagging macro) blocks it; an over-budget callee is declined silently #94
Two things keep the interpreter's auto-inliner (options auto_inline_functions) away from small, pure functions in generated code:
Any function annotation blocks auto-inlining, except export and unused_argument (ast_inline.cpp, isAnnotated). That includes [sideeffects] and any user function macro that only tags the function (a marker with no call-site semantics). In a C-to-daslang conversion, every converted function carries such a marker, so no converted function is ever auto-inlined, however small. Declines of this kind are logged.
A callee over the node budget (auto_inline_cost, default 32) is declined silently: log_optimization prints nothing for it, so a function that "should" inline gives no hint why it did not.
Repro
optionsgen2requiremathoptionsauto_inline_functions=trueoptionslog_optimization=truedefplain_mul(a, b : int) : int {
return (a*b) >>16
}
[sideeffects]
defmarked_mul(a, b : int) : int {
return (a*b) >>16
}
defbig_div(a, b : int) : int {
if ((abs(a) >>14) >=abs(b)) {
return (a^b) <0 ? -2147483647 : 2147483647
}
letc= (int64(a) <<16l) /int64(b)
letd=c+int64(a) -int64(b) +c*2l-c/3lreturnint(c) +int(d-d)
}
[export]
defmain {
vars=0for (iinrange(1, 10)) {
s+=plain_mul(i, 3)
s+=marked_mul(i, 3)
s+=big_div(i, 3)
}
print("{s}\n")
}
Actual (log_optimization)
AUTO-INLINE plain_mul into main at ann.das:28:13
AUTO-INLINE DECLINED at ann.das:29:13: marked_mul: annotated function [sideeffects]
INLINE: 0 must + 1 auto + 0 invoke-block site(s), 1 declined in module
No line at all for big_div (line 30).
Expected
marked_mul inlines like plain_mul. Splicing a body keeps its effects, so [sideeffects] (which only keeps the call from being dropped or folded) has no call-site semantics the splice would bypass. More generally, a way for a function macro to declare itself inert for inlining, e.g. a flag on AstFunctionAnnotation or a list beside export/unused_argument, so tagging macros do not disable the optimization.
big_div gets a line such as AUTO-INLINE DECLINED at ann.das:30:13: big_div: N nodes over the budget 32 (auto_inline_cost).
Effect seen
In a converted Doom (PureDOOM), 615 of 799 functions carry a tagging function macro, so the fixed-point helpers are never inlined into the renderer loops; the fixed-point division is over the 32-node budget with no log line. Hand-edited copies without the markers moved interpreter fps within run-to-run noise (rough, not an isolated measurement), so this is a report of the mechanism, not of a measured speedup.
Activity