forked from OSchip/llvm-project
[MachinePipeliner] Fix risky iterator usage R++, --R
When we calculate MII, we use two loops, one with iterator R++ to check whether we can reserve the resource, then --R to move back the iterator to do reservation. This is risky, as R++, --R may not point to the same element at all. The can cause wrong MII. Differential Revision: https://reviews.llvm.org/D63536 llvm-svn: 364353
This commit is contained in:
parent
c32d307a49
commit
fee855b5bc
|
@ -1012,17 +1012,13 @@ unsigned SwingSchedulerDAG::calculateResMII() {
|
|||
});
|
||||
for (unsigned C = 0; C < NumCycles; ++C)
|
||||
while (RI != RE) {
|
||||
if ((*RI++)->canReserveResources(*MI)) {
|
||||
if ((*RI)->canReserveResources(*MI)) {
|
||||
(*RI)->reserveResources(*MI);
|
||||
++ReservedCycles;
|
||||
break;
|
||||
}
|
||||
RI++;
|
||||
}
|
||||
// Start reserving resources using existing DFAs.
|
||||
for (unsigned C = 0; C < ReservedCycles; ++C) {
|
||||
--RI;
|
||||
(*RI)->reserveResources(*MI);
|
||||
}
|
||||
|
||||
LLVM_DEBUG(dbgs() << "ReservedCycles:" << ReservedCycles
|
||||
<< ", NumCycles:" << NumCycles << "\n");
|
||||
// Add new DFAs, if needed, to reserve resources.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
%0 = type { i32, [16 x double] }
|
||||
|
||||
; CHECK: MII = 7 MAX_II = 17
|
||||
; CHECK: MII = 8 MAX_II = 18
|
||||
|
||||
define dso_local fastcc void @_ZN3povL9polysolveEiPdS0_() unnamed_addr #0 {
|
||||
br label %1
|
||||
|
|
Loading…
Reference in New Issue