Skip to content

Commit

Permalink
[WebAssembly] Use SetVector to stabilize iteration order after D120365
Browse files Browse the repository at this point in the history
StringMap iteration order is not guaranteed to be deterministic
(https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h).
  • Loading branch information
MaskRay committed Jul 20, 2023
1 parent 47ccfd7 commit 94830bf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/CodeGen/MachineModuleInfoImpls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -110,7 +110,7 @@ class MachineModuleInfoWasm : public MachineModuleInfoImpl {
public:
MachineModuleInfoWasm(const MachineModuleInfo &) {}

StringSet<> MachineSymbolsUsed;
SetVector<StringRef> MachineSymbolsUsed;
};

} // end namespace llvm
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/WebAssembly/functype-emission.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 94830bf

Please sign in to comment.