[PATCH] D146658: [JITLink] Deterministic JITDylib symbol table dumps

Stefan Gränitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 13:28:08 PDT 2023


sgraenitz created this revision.
sgraenitz added a reviewer: lhames.
Herald added subscribers: mgrang, hiraditya.
Herald added a project: All.
sgraenitz requested review of this revision.
Herald added a project: LLVM.

Sort symbols before dumping so we get a deterministic order and can check them in tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146658

Files:
  llvm/lib/ExecutionEngine/Orc/Core.cpp


Index: llvm/lib/ExecutionEngine/Orc/Core.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -1438,16 +1438,23 @@
     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() &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146658.507487.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/906ad647/attachment.bin>


More information about the llvm-commits mailing list