diff options
Diffstat (limited to 'src/passes/ReorderLocals.cpp')
-rw-r--r-- | src/passes/ReorderLocals.cpp | 5 |
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(); } |