diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index b06dff1260638e..aa82cf38c45db8 100644 --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -2491,10 +2491,19 @@ void ExecutionSession::OL_applyQueryPhase1( } } - // If we get here then we've moved on to the next JITDylib. - LLVM_DEBUG(dbgs() << "Phase 1 moving to next JITDylib.\n"); - ++IPLS->CurSearchOrderIndex; - IPLS->NewJITDylib = true; + if (IPLS->DefGeneratorCandidates.empty() && + IPLS->DefGeneratorNonCandidates.empty()) { + // Early out if there are no remaining symbols. + LLVM_DEBUG(dbgs() << "All symbols matched.\n"); + IPLS->CurSearchOrderIndex = IPLS->SearchOrder.size(); + break; + } else { + // If we get here then we've moved on to the next JITDylib with candidates + // remaining. + LLVM_DEBUG(dbgs() << "Phase 1 moving to next JITDylib.\n"); + ++IPLS->CurSearchOrderIndex; + IPLS->NewJITDylib = true; + } } // Remove any weakly referenced candidates that could not be found/generated.