Skip to content

Commit

Permalink
[JITLink] Deterministic JITDylib symbol table dumps
Browse files Browse the repository at this point in the history
Sort symbols before dumping so we get a deterministic order and can check them in tests.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D146658
  • Loading branch information
weliveindetail committed Mar 22, 2023
1 parent 473e9ad commit e731867
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions llvm/lib/ExecutionEngine/Orc/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,16 +1438,23 @@ void JITDylib::dump(raw_ostream &OS) {
OS << "Link order: " << LinkOrder << "\n"
<< "Symbol table:\n";

for (auto &KV : Symbols) {
// Sort symbols so we get a deterministic order and can check them in tests.
std::vector<std::pair<SymbolStringPtr, SymbolTableEntry *>> SymbolsSorted;
for (auto &KV : Symbols)
SymbolsSorted.emplace_back(KV.first, &KV.second);
std::sort(SymbolsSorted.begin(), SymbolsSorted.end(),
[](const auto &L, const auto &R) { return *L.first < *R.first; });

for (auto &KV : SymbolsSorted) {
OS << " \"" << *KV.first << "\": ";
if (auto Addr = KV.second.getAddress())
if (auto Addr = KV.second->getAddress())
OS << Addr;
else
OS << "<not resolved> ";

OS << " " << KV.second.getFlags() << " " << KV.second.getState();
OS << " " << KV.second->getFlags() << " " << KV.second->getState();

if (KV.second.hasMaterializerAttached()) {
if (KV.second->hasMaterializerAttached()) {
OS << " (Materializer ";
auto I = UnmaterializedInfos.find(KV.first);
assert(I != UnmaterializedInfos.end() &&
Expand Down

0 comments on commit e731867

Please sign in to comment.