[PATCH] D44873: [WebAssembly] Change std::sort to llvm::sort in response to r327219
Mandeep Singh Grang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 24 11:42:15 PDT 2018
mgrang created this revision.
mgrang added reviewers: sunfish, RKSimon.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff, jfb.
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.
To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.
Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer the comments section in https://reviews.llvm.org/D44363 for a list of all the required patches.
Repository:
rL LLVM
https://reviews.llvm.org/D44873
Files:
lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
Index: lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
+++ lib/Target/WebAssembly/WebAssemblyRegColoring.cpp
@@ -115,16 +115,16 @@
// registers), by weight next, and then by position.
// TODO: Investigate more intelligent sorting heuristics. For starters, we
// should try to coalesce adjacent live intervals before non-adjacent ones.
- std::sort(SortedIntervals.begin(), SortedIntervals.end(),
- [MRI](LiveInterval *LHS, LiveInterval *RHS) {
- if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg))
- return MRI->isLiveIn(LHS->reg);
- if (LHS->weight != RHS->weight)
- return LHS->weight > RHS->weight;
- if (LHS->empty() || RHS->empty())
- return !LHS->empty() && RHS->empty();
- return *LHS < *RHS;
- });
+ llvm::sort(SortedIntervals.begin(), SortedIntervals.end(),
+ [MRI](LiveInterval *LHS, LiveInterval *RHS) {
+ if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg))
+ return MRI->isLiveIn(LHS->reg);
+ if (LHS->weight != RHS->weight)
+ return LHS->weight > RHS->weight;
+ if (LHS->empty() || RHS->empty())
+ return !LHS->empty() && RHS->empty();
+ return *LHS < *RHS;
+ });
DEBUG(dbgs() << "Coloring register intervals:\n");
SmallVector<unsigned, 16> SlotMapping(SortedIntervals.size(), -1u);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44873.139724.patch
Type: text/x-patch
Size: 1593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180324/60c781be/attachment.bin>
More information about the llvm-commits
mailing list