From 3ce1e9428b96339c516da926657f830bfb4d4c9a Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 14 Dec 2021 18:30:24 +1100 Subject: [PATCH] [ORC] Add early-out to OL_applyQueryPhase1. If all symbols in a lookup match before we reach the end of the search order then bail out of the search-order loop early. This should reduce unnecessary contention on the session lock and improve readability of the debug logs. --- llvm/lib/ExecutionEngine/Orc/Core.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp index b06dff1..aa82cf3 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. -- 2.7.4