[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 14:12:36 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe73186796db9: [JITLink] Deterministic JITDylib symbol table dumps (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146658/new/

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.507501.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/c82f198c/attachment.bin>


More information about the llvm-commits mailing list