diff options
author | Jinsong Ji <jji@us.ibm.com> | 2019-06-25 21:50:56 +0000 |
---|---|---|
committer | Jinsong Ji <jji@us.ibm.com> | 2019-06-25 21:50:56 +0000 |
commit | fee855b5bc1abe1f3f89e977ce4c81cf9bdbc2e4 (patch) | |
tree | ff2566663bd7c94f3c6bab1aeb22e5740477aeb6 /llvm/lib/CodeGen/MachinePipeliner.cpp | |
parent | c32d307a49f5255602e7543e64e6c38a7f536abc (diff) | |
download | bcm5719-llvm-fee855b5bc1abe1f3f89e977ce4c81cf9bdbc2e4.tar.gz bcm5719-llvm-fee855b5bc1abe1f3f89e977ce4c81cf9bdbc2e4.zip |
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachinePipeliner.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 570ed4aadab..167c05f9ef4 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -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. |