[llvm] 94830bf - [WebAssembly] Use SetVector to stabilize iteration order after D120365

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 00:02:11 PDT 2023


Author: Fangrui Song
Date: 2023-07-20T00:02:06-07:00
New Revision: 94830bf56cb660feb3ee7ead39cc0fbb70e0c0b5

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

LOG: [WebAssembly] Use SetVector to stabilize iteration order after D120365

StringMap iteration order is not guaranteed to be deterministic
(https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h).

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
    llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
    llvm/test/CodeGen/WebAssembly/functype-emission.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
index 58f7163d7b8198..f8a328f13eded7 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
@@ -15,7 +15,7 @@
 #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/SetVector.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include <cassert>
 
@@ -110,7 +110,7 @@ class MachineModuleInfoWasm : public MachineModuleInfoImpl {
 public:
   MachineModuleInfoWasm(const MachineModuleInfo &) {}
 
-  StringSet<> MachineSymbolsUsed;
+  SetVector<StringRef> MachineSymbolsUsed;
 };
 
 } // end namespace llvm

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
index f0002494a95178..b9e6e0f534198f 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -303,8 +303,8 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) {
   // only find symbols that have been used. Unused symbols from globals will
   // not be found here.
   MachineModuleInfoWasm &MMIW = MMI->getObjFileInfo<MachineModuleInfoWasm>();
-  for (const auto &Name : MMIW.MachineSymbolsUsed) {
-    auto *WasmSym = cast<MCSymbolWasm>(getOrCreateWasmSymbol(Name.getKey()));
+  for (StringRef Name : MMIW.MachineSymbolsUsed) {
+    auto *WasmSym = cast<MCSymbolWasm>(getOrCreateWasmSymbol(Name));
     if (WasmSym->isFunction()) {
       // TODO(wvo): is there any case where this overlaps with the call to
       // emitFunctionType in the loop below?

diff  --git a/llvm/test/CodeGen/WebAssembly/functype-emission.ll b/llvm/test/CodeGen/WebAssembly/functype-emission.ll
index 617267a216c63e..bd18288fcf8626 100644
--- a/llvm/test/CodeGen/WebAssembly/functype-emission.ll
+++ b/llvm/test/CodeGen/WebAssembly/functype-emission.ll
@@ -3,8 +3,8 @@
 ; Demonstrates that appropriate .functype directives are emitted for defined
 ; functions, declared functions, and any libcalls.
 
-; CHECK: .functype __unordtf2 (i64, i64, i64, i64) -> (i32)
 ; CHECK: .functype __multi3 (i32, i64, i64, i64, i64) -> ()
+; CHECK: .functype __unordtf2 (i64, i64, i64, i64) -> (i32)
 ; CHECK: .functype defined_fun_1 (f64) -> (i64)
 ; CHECK: .functype defined_fun_2 (f64, i32) -> (i64)
 ; CHECK: .functype declared_fun (i32, f32, i64) -> (i32)


        


More information about the llvm-commits mailing list