@@ -58,7 +58,7 @@ void LLVMCompilerContext::initJit()
58
58
59
59
// Optimize
60
60
const auto &functions = m_module->getFunctionList ();
61
- std::vector<std::string> functionNames ;
61
+ std::vector<std::string> lookupNames ;
62
62
63
63
llvm::PassBuilder passBuilder;
64
64
llvm::LoopAnalysisManager loopAnalysisManager;
@@ -84,17 +84,19 @@ void LLVMCompilerContext::initJit()
84
84
// Run the O3 pipeline for specific functions
85
85
for (llvm::Function &func : m_module->functions ()) {
86
86
if (!func.isDeclaration ()) {
87
- functionNames.push_back (func.getName ().str ());
88
-
89
- if (func.hasExternalLinkage () && !func.hasFnAttribute (llvm::Attribute::OptimizeNone)) {
87
+ if (func.hasExternalLinkage ()) {
88
+ lookupNames.push_back (func.getName ().str ());
89
+
90
+ if (func.hasFnAttribute (llvm::Attribute::OptimizeNone)) {
91
+ // Remove this attribute to avoid JIT hangs
92
+ // TODO: Optimize all functions, maybe it doesn't take so long
93
+ func.removeFnAttr (llvm::Attribute::OptimizeNone);
94
+ } else {
90
95
#ifndef NDEBUG
91
- std::cout << " debug: optimizing function: " << functionNames. back () << std::endl;
96
+ std::cout << " debug: optimizing function: " << func. getName (). str () << std::endl;
92
97
#endif
93
- functionPassManager.run (func, functionAnalysisManager);
94
- } else if (func.hasFnAttribute (llvm::Attribute::OptimizeNone)) {
95
- // Remove this attribute to avoid JIT hangs
96
- // TODO: Optimize all functions, maybe it doesn't take so long
97
- func.removeFnAttr (llvm::Attribute::OptimizeNone);
98
+ functionPassManager.run (func, functionAnalysisManager);
99
+ }
98
100
}
99
101
}
100
102
}
@@ -109,7 +111,7 @@ void LLVMCompilerContext::initJit()
109
111
}
110
112
111
113
// Lookup functions to JIT-compile ahead of time
112
- for (const std::string &name : functionNames ) {
114
+ for (const std::string &name : lookupNames ) {
113
115
#ifndef NDEBUG
114
116
std::cout << " debug: looking up function: " << name << std::endl;
115
117
#endif
0 commit comments