[llvm] f8f4235 - [JITLink] Use MapVector to stabilize iteration order

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 17:51:36 PDT 2024


Author: Fangrui Song
Date: 2024-06-19T17:51:32-07:00
New Revision: f8f4235612b9668bbcbb6a58634fcb756794045e

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

LOG: [JITLink] Use MapVector to stabilize iteration order

Otherwise LinkGraph::dump output could change
(llvm/test/ExecutionEngine/JITLink/x86-64/COFF_pdata_strip.s) when
llvm::hash_value(StringRef) changes.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index 4ce0c8d9fd17e..8fe53760a852d 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/FunctionExtras.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
@@ -847,7 +848,7 @@ class SectionRange {
 
 class LinkGraph {
 private:
-  using SectionMap = DenseMap<StringRef, std::unique_ptr<Section>>;
+  using SectionMap = MapVector<StringRef, std::unique_ptr<Section>>;
   using ExternalSymbolMap = StringMap<Symbol *>;
   using AbsoluteSymbolSet = DenseSet<Symbol *>;
   using BlockSet = DenseSet<Block *>;
@@ -1543,7 +1544,7 @@ class LinkGraph {
   unsigned PointerSize;
   llvm::endianness Endianness;
   GetEdgeKindNameFunction GetEdgeKindName = nullptr;
-  DenseMap<StringRef, std::unique_ptr<Section>> Sections;
+  MapVector<StringRef, std::unique_ptr<Section>> Sections;
   ExternalSymbolMap ExternalSymbols;
   AbsoluteSymbolSet AbsoluteSymbols;
   orc::shared::AllocActions AAs;


        


More information about the llvm-commits mailing list