aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineScheduler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineScheduler.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineScheduler.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index f40e918..f6d03f5 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -4275,6 +4275,12 @@ unsigned ResourceSegments::getFirstAvailableAt(
assert(std::is_sorted(std::begin(_Intervals), std::end(_Intervals),
sortIntervals) &&
"Cannot execute on an un-sorted set of intervals.");
+
+ // Zero resource usage is allowed by TargetSchedule.td but we do not construct
+ // a ResourceSegment interval for that situation.
+ if (AcquireAtCycle == Cycle)
+ return CurrCycle;
+
unsigned RetCycle = CurrCycle;
ResourceSegments::IntervalTy NewInterval =
IntervalBuilder(RetCycle, AcquireAtCycle, ReleaseAtCycle);
@@ -4294,8 +4300,16 @@ unsigned ResourceSegments::getFirstAvailableAt(
void ResourceSegments::add(ResourceSegments::IntervalTy A,
const unsigned CutOff) {
- assert(A.first < A.second && "Cannot add empty resource usage");
+ assert(A.first <= A.second && "Cannot add negative resource usage");
assert(CutOff > 0 && "0-size interval history has no use.");
+ // Zero resource usage is allowed by TargetSchedule.td, in the case that the
+ // instruction needed the resource to be available but does not use it.
+ // However, ResourceSegment represents an interval that is closed on the left
+ // and open on the right. It is impossible to represent an empty interval when
+ // the left is closed. Do not add it to Intervals.
+ if (A.first == A.second)
+ return;
+
assert(all_of(_Intervals,
[&A](const ResourceSegments::IntervalTy &Interval) -> bool {
return !intersects(A, Interval);