[llvm] e731867 - [JITLink] Deterministic JITDylib symbol table dumps
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 14:12:36 PDT 2023
Author: Stefan Gränitz
Date: 2023-03-22T22:12:15+01:00
New Revision: e73186796db97633332434da69c4e9057e460a59
URL: https://github.com/llvm/llvm-project/commit/e73186796db97633332434da69c4e9057e460a59
DIFF: https://github.com/llvm/llvm-project/commit/e73186796db97633332434da69c4e9057e460a59.diff
LOG: [JITLink] Deterministic JITDylib symbol table dumps
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
Added:
Modified:
llvm/lib/ExecutionEngine/Orc/Core.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 82fa4bed914e..9b6712818363 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -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() &&
More information about the llvm-commits
mailing list