From 29b8feb615c9850f43b9ed5efb83e4ebed72d4da Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 21 Feb 2018 00:34:34 +0000 Subject: [PATCH] [WebAssembly] Use stable sort when sorting ctore functions Patch by Nicholas Wilson! llvm-svn: 325656 --- lld/wasm/Writer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index ffb987ea5b77..6ffce929bb06 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -871,10 +871,10 @@ void Writer::calculateInitFunctions() { } // Sort in order of priority (lowest first) so that they are called // in the correct order. - std::sort(InitFunctions.begin(), InitFunctions.end(), - [](const WasmInitFunc &L, const WasmInitFunc &R) { - return L.Priority < R.Priority; - }); + std::stable_sort(InitFunctions.begin(), InitFunctions.end(), + [](const WasmInitFunc &L, const WasmInitFunc &R) { + return L.Priority < R.Priority; + }); } void Writer::run() {