]> granicus.if.org Git - llvm/commit
[MachinePipeliner] Avoid indeterminate order in FuncUnitSorter
authorJinsong Ji <jji@us.ibm.com>
Fri, 9 Aug 2019 14:10:57 +0000 (14:10 +0000)
committerJinsong Ji <jji@us.ibm.com>
Fri, 9 Aug 2019 14:10:57 +0000 (14:10 +0000)
commitbc67d9d1a33c35e1fd917dad88df076c2ff3639c
tree92a82133b5540bf0b72bdf7404f9ed911fc64d8a
parentb2f93fd3ba882347489676d1b35abdc9e07e8ac4
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368441 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachinePipeliner.cpp
test/CodeGen/PowerPC/sms-cpy-1.ll [new file with mode: 0644]