From 3205dc9c54e49d4bc57c9cbfcb9163407b097580 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 19 Feb 2016 14:12:04 -0800 Subject: ensure a stable sort in ReorderLocals --- src/passes/ReorderLocals.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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> { 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(); } -- cgit v1.2.3