aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorJinsong Ji <jji@us.ibm.com>2019-08-09 14:10:57 +0000
committerJinsong Ji <jji@us.ibm.com>2019-08-09 14:10:57 +0000
commit6349ce5ca52790ed98a7fee4fda8e8d71afa7a01 (patch)
treede4c9c2d94a87dc8aace7a2de1971e2b5cca1de9 /llvm/lib/CodeGen/MachinePipeliner.cpp
parent8819a734ae51de245dd73515b25d7159275e06e6 (diff)
downloadllvm-6349ce5ca52790ed98a7fee4fda8e8d71afa7a01.zip
llvm-6349ce5ca52790ed98a7fee4fda8e8d71afa7a01.tar.gz
llvm-6349ce5ca52790ed98a7fee4fda8e8d71afa7a01.tar.bz2
[MachinePipeliner] Avoid indeterminate order in FuncUnitSorter
Summary: This is exposed by adding a new testcase in PowerPC in https://reviews.llvm.org/rL367732 The testcase got different output on different platform, hence breaking buildbots. The problem is that we get differnt FuncUnitOrder when calculateResMII. The root cause is: 1. Two MachineInstr might get SAME priority(MFUsx) from minFuncUnits. 2. Current comparison operator() will return `MFUs1 > MFUs2`. 3. We use iterators for MachineInstr, so the input to FuncUnitSorter might be different on differnt platform due to the iterator nature. So for two MI with same MFU, their order is actually depends on the iterator order, which is platform (implemtation) dependent. This is risky, and may cause cross-compiling problems. The fix is to check make sure we assign a determine order when they are equal. Reviewers: bcahoon, hfinkel, jmolloy Subscribers: nemanjai, hiraditya, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65992 llvm-svn: 368441
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachinePipeliner.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 897f1ab..ca7d694 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -958,7 +958,7 @@ struct FuncUnitSorter {
unsigned F1 = 0, F2 = 0;
unsigned MFUs1 = minFuncUnits(IS1, F1);
unsigned MFUs2 = minFuncUnits(IS2, F2);
- if (MFUs1 == 1 && MFUs2 == 1)
+ if (MFUs1 == MFUs2)
return Resources.lookup(F1) < Resources.lookup(F2);
return MFUs1 > MFUs2;
}