[llvm] [CodeGen][MISched] Handle empty sized resource usage. (PR #75951)

Francesco Petrogalli via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 02:19:22 PST 2024


================
@@ -4285,8 +4291,16 @@ unsigned ResourceSegments::getFirstAvailableAt(
 
 void ResourceSegments::add(ResourceSegments::IntervalTy A,
                            const unsigned CutOff) {
-  assert(A.first < A.second && "Cannot add empty resource usage");
-  assert(CutOff > 0 && "0-size interval history has no use.");
+  assert(A.first <= A.second && "Cannot add negative resource usage");
+
+  // 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 || CutOff == 0)
----------------
fpetrogalli wrote:

What's the `|| CutOff == 0` for?

https://github.com/llvm/llvm-project/pull/75951


More information about the llvm-commits mailing list