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:
- Two MachineInstr might get SAME priority(MFUsx) from minFuncUnits.
- Current comparison operator() will return MFUs1 > MFUs2.
- 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.