Skip to content

Commit 3ce1e94

Browse files
committed
[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.
1 parent 71e5488 commit 3ce1e94

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

llvm/lib/ExecutionEngine/Orc/Core.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,10 +2491,19 @@ void ExecutionSession::OL_applyQueryPhase1(
24912491
}
24922492
}
24932493

2494-
// If we get here then we've moved on to the next JITDylib.
2495-
LLVM_DEBUG(dbgs() << "Phase 1 moving to next JITDylib.\n");
2496-
++IPLS->CurSearchOrderIndex;
2497-
IPLS->NewJITDylib = true;
2494+
if (IPLS->DefGeneratorCandidates.empty() &&
2495+
IPLS->DefGeneratorNonCandidates.empty()) {
2496+
// Early out if there are no remaining symbols.
2497+
LLVM_DEBUG(dbgs() << "All symbols matched.\n");
2498+
IPLS->CurSearchOrderIndex = IPLS->SearchOrder.size();
2499+
break;
2500+
} else {
2501+
// If we get here then we've moved on to the next JITDylib with candidates
2502+
// remaining.
2503+
LLVM_DEBUG(dbgs() << "Phase 1 moving to next JITDylib.\n");
2504+
++IPLS->CurSearchOrderIndex;
2505+
IPLS->NewJITDylib = true;
2506+
}
24982507
}
24992508

25002509
// Remove any weakly referenced candidates that could not be found/generated.

0 commit comments

Comments
 (0)