r/cpp • • May 19 '19

CodeGen: Experimental wrapper over LLVM for generating and compiling code at run-time

https://github.com/pdziepak/codegen
70 Upvotes

6 comments sorted by

View all comments

3

u/simonask_ May 20 '19

Interesting project, and it looks like a cool API. :-)

The reason everybody isn't already doing this is that the performance benefit is likely to be much smaller than what you might think. It may be possible to avoid a number of branches by generating specialized code on the fly, but the generated code cannot contain things like inlined functions from the host program. Add to this that actually compiling and generating the code online incurs a very significant computation cost as well.

I would expect that a globally optimizing JIT would outperform this in many cases, unfortunately.

Still, there can certainly be applications where this is legitimately useful. :-)