aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LocalStackSlotAllocation.cpp
diff options
context:
space:
mode:
authorMandeep Singh Grang <mgrang@codeaurora.org>2016-10-18 00:11:19 +0000
committerMandeep Singh Grang <mgrang@codeaurora.org>2016-10-18 00:11:19 +0000
commite82678a65724887ba8352af4eadb969c4dd50a01 (patch)
treefef12ff9554f2466a95bcb1d547d309214b40e22 /llvm/lib/CodeGen/LocalStackSlotAllocation.cpp
parent6ff82bd0ec7ddfd991cb8e57e2dfbf23f068c992 (diff)
downloadllvm-e82678a65724887ba8352af4eadb969c4dd50a01.zip
llvm-e82678a65724887ba8352af4eadb969c4dd50a01.tar.gz
llvm-e82678a65724887ba8352af4eadb969c4dd50a01.tar.bz2
Fix differences in codegen between Linux and Windows toolchains
Summary: There are differences in codegen between Linux and Windows due to: 1. Using std::sort which uses quicksort which is a non-stable sort. 2. Iterating over Set data structure where the iteration order is non deterministic. Reviewers: arsenm, grosbach, junbuml, zinob, MatzeB Subscribers: MatzeB, wdng Differential Revision: https://reviews.llvm.org/D25695 llvm-svn: 284441
Diffstat (limited to 'llvm/lib/CodeGen/LocalStackSlotAllocation.cpp')
-rw-r--r--llvm/lib/CodeGen/LocalStackSlotAllocation.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/LocalStackSlotAllocation.cpp b/llvm/lib/CodeGen/LocalStackSlotAllocation.cpp
index 6cb59a6..b86406e 100644
--- a/llvm/lib/CodeGen/LocalStackSlotAllocation.cpp
+++ b/llvm/lib/CodeGen/LocalStackSlotAllocation.cpp
@@ -55,7 +55,8 @@ namespace {
FrameRef(MachineBasicBlock::iterator I, int64_t Offset, int Idx) :
MI(I), LocalOffset(Offset), FrameIdx(Idx) {}
bool operator<(const FrameRef &RHS) const {
- return LocalOffset < RHS.LocalOffset;
+ return std::tie(LocalOffset, FrameIdx) <
+ std::tie(RHS.LocalOffset, RHS.FrameIdx);
}
MachineBasicBlock::iterator getMachineInstr() const { return MI; }
int64_t getLocalOffset() const { return LocalOffset; }
@@ -318,8 +319,9 @@ bool LocalStackSlotPass::insertFrameReferenceRegisters(MachineFunction &Fn) {
}
}
- // Sort the frame references by local offset
- array_pod_sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end());
+ // Sort the frame references by local offset.
+ // Use frame index as a tie-breaker in case MI's have the same offset.
+ std::sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end());
MachineBasicBlock *Entry = &Fn.front();