Problems while following the Kaleidoscope JIT Tutorial


So, I am somewhat experienced in writing LLVM passes, but I’ve recently got interested in applying them in a JIT infrastructure. My goal is to apply optimizations on the fly if they are needed using the JIT infrastructure on LLVM. I want to be able to evaluate, for each called function, if a certain optimization is required given the feedback received at runtime.

I’ve run into the Building a JIT Chapter 3 tutorial. I am aware that only the final code listing is updated, but I still think it has an error in the addModule() function.

Error addModule(ThreadSafeModule TSM, ResourceTrackerSP RT = nullptr) {
    if (!RT)
      RT = MainJD.getDefaultResourceTracker();

    return OptimizeLayer.add(RT, std::move(TSM));

Shouldn’t the last line be:

return CODLayer.add(RT, std::move(TSM));

Since we now have a layer for lazy compiling?