aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
authorFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-08-01 13:36:43 +0200
committerFrancesco Petrogalli <francesco.petrogalli@apple.com>2023-08-01 14:00:37 +0200
commitcd921e0fd79cd9bd2ab2ee1820476810847f5516 (patch)
tree2fc2771aca5da52f639dd610eac55a29f4560b28 /llvm/lib/CodeGen/MachineScheduler.cpp
parent1416614c5147dad8415bd014740ddf59e9f171f2 (diff)
downloadllvm-cd921e0fd79cd9bd2ab2ee1820476810847f5516.zip
llvm-cd921e0fd79cd9bd2ab2ee1820476810847f5516.tar.gz
llvm-cd921e0fd79cd9bd2ab2ee1820476810847f5516.tar.bz2
[MISched] Do not erase resource booking history for subunits.
When dealing with the subunits of a resource group, we should reset the subunits availability at the first avaiable cycle of the resource that contains the subunits. Previously, the reset operation was returning cycle 0, effectively erasing the booking history of the subunits. Without this change, when using intervals for models have make use of subunits, the erasing of resource booking for subunits can raise the assertion "A resource is being overwritten" in `ResourceSegments::add`. The test added in the patch is one of such cases. Reviewed By: andreadb Differential Revision: https://reviews.llvm.org/D156530
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index ba54324..556f003 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -2331,20 +2331,24 @@ SchedBoundary::getNextResourceCycle(const MCSchedClassDesc *SC, unsigned PIdx,
"Cannot have zero instances of a ProcResource");
if (isUnbufferedGroup(PIdx)) {
- // If any subunits are used by the instruction, report that the resource
- // group is available at 0, effectively removing the group record from
- // hazarding and basing the hazarding decisions on the subunit records.
- // Otherwise, choose the first available instance from among the subunits.
- // Specifications which assign cycles to both the subunits and the group or
- // which use an unbuffered group with buffered subunits will appear to
- // schedule strangely. In the first case, the additional cycles for the
- // group will be ignored. In the second, the group will be ignored
- // entirely.
+ // If any subunits are used by the instruction, report that the
+ // subunits of the resource group are available at the first cycle
+ // in which the unit is available, effectively removing the group
+ // record from hazarding and basing the hazarding decisions on the
+ // subunit records. Otherwise, choose the first available instance
+ // from among the subunits. Specifications which assign cycles to
+ // both the subunits and the group or which use an unbuffered
+ // group with buffered subunits will appear to schedule
+ // strangely. In the first case, the additional cycles for the
+ // group will be ignored. In the second, the group will be
+ // ignored entirely.
for (const MCWriteProcResEntry &PE :
make_range(SchedModel->getWriteProcResBegin(SC),
SchedModel->getWriteProcResEnd(SC)))
if (ResourceGroupSubUnitMasks[PIdx][PE.ProcResourceIdx])
- return std::make_pair(0u, StartIndex);
+ return std::make_pair(
+ getNextResourceCycleByInstance(StartIndex, Cycles, StartAtCycle),
+ StartIndex);
auto SubUnits = SchedModel->getProcResource(PIdx)->SubUnitsIdxBegin;
for (unsigned I = 0, End = NumberOfInstances; I < End; ++I) {