Brian Kahne via llvm-dev
2016-Dec-13 20:21 UTC
[llvm-dev] Orc JIT and lazily-loaded modules
Hi, I'm trying to port some code from the original JIT (a project I haven't had a chance to work on for quite a while) to the new Orc JIT. I thought I'd try to use the Kaleidoscope tutorial as a starting point for getting acquainted with the new JIT and so I first tried to add the ability to load an existing bitcode file, then make calls to functions from that file. That was easy to do starting from the example in Chapter 3 of the Orc JIT tutorial if I used parseBitcodeFile to load in the module, but when I switched over to using getLazyBitcodeModule, I ran into problems: The functions in the loaded module weren't materialized before moveFunctionBody tried to copy the function into a new module in order to JIT them. That then led to an assertion failure. I was able to work around this by creating a new function pass, run by the pass manager in KaleidoscopeJIT, which looks up any called functions, sees if they're from the loaded module, and then materializes them. Is this the best way to handle JITing code from a lazily loaded module or is there a better way to handle this? It seems like this could be handled easily by moveFunctionBody if it just did something like: if (OrigF.isMaterializable()) { OrigF.materialize(); } Is there a way to add a hook into the JIT to handle this kind of materialization? Thanks, Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161213/f30e917e/attachment.html>