summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/ReorderLocals.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/passes/ReorderLocals.cpp b/src/passes/ReorderLocals.cpp
index 80256e24d..1b5e998c4 100644
--- a/src/passes/ReorderLocals.cpp
+++ b/src/passes/ReorderLocals.cpp
@@ -32,7 +32,10 @@ struct ReorderLocals : public WalkerPass<WasmWalker<ReorderLocals, void>> {
void visitFunction(Function *curr) {
sort(curr->locals.begin(), curr->locals.end(), [this](NameType a, NameType b) -> bool {
- return this->counts[a.name] > this->counts[b.name];
+ if (this->counts[a.name] == this->counts[b.name]) {
+ return strcmp(a.name.str, b.name.str) > 0;
+ }
+ return this->counts[a.name] > this->counts[b.name];
});
counts.clear();
}