File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/dev/engine/internal/llvm Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ void LLVMCompilerContext::initJit()
5858
5959 // Optimize
6060 const auto &functions = m_module->getFunctionList ();
61+ std::vector<std::string> functionNames;
6162
6263 llvm::PassBuilder passBuilder;
6364 llvm::LoopAnalysisManager loopAnalysisManager;
@@ -83,6 +84,8 @@ void LLVMCompilerContext::initJit()
8384 // Run the O3 pipeline for specific functions
8485 for (llvm::Function &func : m_module->functions ()) {
8586 if (!func.isDeclaration ()) {
87+ functionNames.push_back (func.getName ().str ());
88+
8689 if (func.hasExternalLinkage () && !func.hasFnAttribute (llvm::Attribute::OptimizeNone)) {
8790#ifndef NDEBUG
8891 std::cout << " debug: optimizing function: " << functionNames.back () << std::endl;
@@ -104,6 +107,14 @@ void LLVMCompilerContext::initJit()
104107 llvm::errs () << " error: failed to add module '" << name << " ' to JIT: " << toString (std::move (err)) << " \n " ;
105108 return ;
106109 }
110+
111+ // Lookup functions to JIT-compile ahead of time
112+ for (const std::string &name : functionNames) {
113+ #ifndef NDEBUG
114+ std::cout << " debug: looking up function: " << name << std::endl;
115+ #endif
116+ lookupFunction<void *>(name);
117+ }
107118}
108119
109120bool LLVMCompilerContext::jitInitialized () const
You can’t perform that action at this time.
0 commit comments