[lld] r325656 - [WebAssembly] Use stable sort when sorting ctore functions

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 16:34:34 PST 2018


Author: sbc
Date: Tue Feb 20 16:34:34 2018
New Revision: 325656

URL: http://llvm.org/viewvc/llvm-project?rev=325656&view=rev
Log:
[WebAssembly] Use stable sort when sorting ctore functions

Patch by Nicholas Wilson!

Modified:
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=325656&r1=325655&r2=325656&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Tue Feb 20 16:34:34 2018
@@ -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() {




More information about the llvm-commits mailing list