@@ -106,7 +106,7 @@ void ExecutionEngine::dumpToObjectFile(StringRef filename) {
106106 }
107107 // Compilation is lazy and it doesn't populate object cache unless requested.
108108 // In case object dump is requested before cache is populated, we need to
109- // force compilation manually.
109+ // force compilation manually.
110110 if (cache->isEmpty ()) {
111111 for (std::string &functionName : functionNames) {
112112 auto result = lookupPacked (functionName);
@@ -400,6 +400,13 @@ ExecutionEngine::create(Operation *m, const ExecutionEngineOptions &options,
400400 return symbolMap;
401401 };
402402 engine->registerSymbols (runtimeSymbolMap);
403+
404+ // Execute the global constructors from the module being processed.
405+ // TODO: Allow JIT initialize for AArch64. Currently there's a bug causing a
406+ // crash for AArch64 see related issue #71963.
407+ if (!engine->jit ->getTargetTriple ().isAArch64 ())
408+ cantFail (engine->jit ->initialize (engine->jit ->getMainJITDylib ()));
409+
403410 return std::move (engine);
404411}
405412
@@ -435,7 +442,6 @@ Expected<void *> ExecutionEngine::lookup(StringRef name) const {
435442
436443Error ExecutionEngine::invokePacked (StringRef name,
437444 MutableArrayRef<void *> args) {
438- initialize ();
439445 auto expectedFPtr = lookupPacked (name);
440446 if (!expectedFPtr)
441447 return expectedFPtr.takeError ();
@@ -445,13 +451,3 @@ Error ExecutionEngine::invokePacked(StringRef name,
445451
446452 return Error::success ();
447453}
448-
449- void ExecutionEngine::initialize () {
450- if (isInitialized)
451- return ;
452- // TODO: Allow JIT initialize for AArch64. Currently there's a bug causing a
453- // crash for AArch64 see related issue #71963.
454- if (!jit->getTargetTriple ().isAArch64 ())
455- cantFail (jit->initialize (jit->getMainJITDylib ()));
456- isInitialized = true ;
457- }
0 commit comments