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
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:
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 @attribute: to apply it to everything in the scope it creates, e.g. a whole file)
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: