[llvm] d1a7630 - [JITLink] Fix symbol comparator in LinkGraph::dump.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun May 16 10:13:14 PDT 2021


Author: Lang Hames
Date: 2021-05-16T10:11:58-07:00
New Revision: d1a7630369bc489ca85e7fd0e05119a6d6f09039

URL: https://github.com/llvm/llvm-project/commit/d1a7630369bc489ca85e7fd0e05119a6d6f09039
DIFF: https://github.com/llvm/llvm-project/commit/d1a7630369bc489ca85e7fd0e05119a6d6f09039.diff

LOG: [JITLink] Fix symbol comparator in LinkGraph::dump.

The existing implementation did not provide a strict weak ordering.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
index cb1bb80373dca..13c932f420f1b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -237,12 +237,12 @@ void LinkGraph::dump(raw_ostream &OS) {
   // relevance.
   for (auto &KV : BlockSymbols)
     llvm::sort(KV.second, [](const Symbol *LHS, const Symbol *RHS) {
-      if (LHS->getOffset() < RHS->getOffset())
-        return true;
-      if (LHS->getLinkage() < RHS->getLinkage())
-        return true;
-      if (LHS->getScope() < RHS->getScope())
-        return true;
+      if (LHS->getOffset() != RHS->getOffset())
+        return LHS->getOffset() < RHS->getOffset();
+      if (LHS->getLinkage() != RHS->getLinkage())
+        return LHS->getLinkage() < RHS->getLinkage();
+      if (LHS->getScope() != RHS->getScope())
+        return LHS->getScope() < RHS->getScope();
       if (LHS->hasName()) {
         if (!RHS->hasName())
           return true;


        


More information about the llvm-commits mailing list