AppleAcceleratorTable: Use MapVector to stabilize iteration order after D153066
authorFangrui Song <i@maskray.me>
Thu, 20 Jul 2023 02:59:13 +0000 (19:59 -0700)
committerFangrui Song <i@maskray.me>
Thu, 20 Jul 2023 02:59:13 +0000 (19:59 -0700)
Use a MapVector to stabilize the order and simplify future changes like
D142862 that change the StringMap hash function.

llvm/test/DebugInfo/Generic/apple-names-hash-collisions.ll
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

index 5664ec9..20dfdec 100644 (file)
 ; FOUND_VARS: DW_AT_name        ("bb")
 ; FOUND_VARS: DW_AT_name        ("cA")
 
+; ALL_ENTRIES: Apple accelerator entries with name = "bb":
+; ALL_ENTRIES: DW_AT_name        ("bb")
 ; ALL_ENTRIES: Apple accelerator entries with name = "cA":
 ; ALL_ENTRIES: DW_AT_name        ("cA")
 ; ALL_ENTRIES: Apple accelerator entries with name = "some_other_hash":
 ; ALL_ENTRIES: DW_AT_name        ("some_other_hash")
 ; ALL_ENTRIES: Apple accelerator entries with name = "int":
 ; ALL_ENTRIES: DW_AT_name        ("int")
-; ALL_ENTRIES: Apple accelerator entries with name = "bb":
-; ALL_ENTRIES: DW_AT_name        ("bb")
 
 @bb = global i32 200, align 4, !dbg !0
 @cA = global i32 10, align 4, !dbg !5
index cdcb5bb..156e10c 100644 (file)
@@ -11,6 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm-dwarfdump.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
@@ -463,7 +464,7 @@ static void filterByAccelName(
 static void findAllApple(
     DWARFContext &DICtx, raw_ostream &OS,
     std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg) {
-  StringMap<llvm::SmallSet<DWARFDie, 2>> NameToDies;
+  MapVector<StringRef, llvm::SmallSet<DWARFDie, 2>> NameToDies;
 
   auto PushDIEs = [&](const AppleAcceleratorTable &Accel) {
     for (const auto &Entry : Accel.entries()) {