-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Attribute/pragma to mark CTFE only code? #4789
Comments
@thewilsonator proposed this 7 years ago in https://forum.dlang.org/thread/uyngcsrgeemiwbudslyo@forum.dlang.org - for dlang in general, no LDC-specific language extension. I don't know how that thread ended. And https://forum.dlang.org/thread/kvjxgutuxyrkstjylqpt@forum.dlang.org proposed skipping codegen for I'd prefer a general solution, but that's not a requirement I think - feel free to hack around and see if you can get it to work. If you can then demonstrate significant compile-time improvements for a (hopefully public) project, we'll probably adopt it. In the best case, the hard numbers then convince upstream to adopt it too. |
Would be nice indeed. In general, I think a magic attribute will be nicer to work with than a pragma. (for example, you can do |
you can do |
I've created dlang/dmd#20858 with the front end part of it. Adding codegen skip on top is trivial. If dmd people say it's a no-go, I guess for LDC-specific solution I'll have to switch back to UDA instead of using a full-fledged function attribute... |
I've posted my proposal to the dip.ideas forum: https://forum.dlang.org/post/veqgighfeexaxrgpwnuj@forum.dlang.org We'll see how it goes. |
Would it be possible to add a pragma or attribute to mark CTFE-only code, such that it is omitted from the code generation? Our project uses CTFE a lot, most of the functions are templated and many of them are instantiated widely. This results in non trivial codegen cost + LLVM compilation cost just to produce some code that is going to be later thrown away during linking.
I think the implementation could be damn straightforward (but I might be missing something): just skip codegen if we see that attribute/pragma. That could result in LLVM complaining about missing symbols, if some other function that references this one was codegened, so a better implementation would also enforce that CTFE-only functions could only be referenced from another CTFE-only functions.
I'm happy to work on the implementation, if there is an approval of the idea.
The text was updated successfully, but these errors were encountered: