-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: possibility to inline a function on the call site #306
Comments
Proposal: possibility to inline a function on the call site. Example:
It makes sense as we have |
before this commit, the optimized IR code that is displayed in --verbose mode is not actually what gets emitted to an object file. that is now corrected, and we make sure to run the alwaysinliner pass even in debug mode, so you can rely on "inline" keyword inlining a function, guaranteed. See #306
Now the alwaysinliner pass always runs in debug mode. However, I noticed that it does not notice and inline functions unless those functions are referenced from exported functions. In practice this will work fine, but if you're messing around and looking at the output of build_obj in debug mode with non-exported functions, you might see some functions that did not get inlined. I asked about it on the LLVM mailing list: http://lists.llvm.org/pipermail/llvm-dev/2017-April/111975.html So now this issue is just the proposal to have the ability to specify inline at the callsite of a function. |
Here's an idea for implementing this feature without any grammar modification: My main issue with the Jai syntax is that it's not clear where parentheses are allowed: var c = inline foo(a, b);
var c = (inline foo)(a, b); // does this work?
var f = inline foo; // is this some special comptime thing
var c = f(a, b); // that expands here? The apparently simple answer that Or we could allow The |
What if
No, expected '(' after 'foo'.
No, expected '(' after 'foo'. |
How about these: inline object.method();
inline handler_functions[comptime command_id]();
inline List(u32)();
inline (List(u32))();
|
I think the syntax in this issue needs some polish. inline math.mulOverflow(); // error: expected function type, found '(namespace)'
inline (math.mulOverflow)(); // works. (except for the parameters.) |
OSdev code can rely on inlining for correctness (e.g. when manipulating the stack), so it should be enabled even when optimizations are off.
The text was updated successfully, but these errors were encountered: