[MCA] Fix crash in `EntryStage::cycleEnd` when there are no instructions.
authorClement Courbet <courbet@google.com>
Thu, 2 Mar 2023 12:34:43 +0000 (13:34 +0100)
committerClement Courbet <courbet@google.com>
Thu, 2 Mar 2023 12:43:26 +0000 (13:43 +0100)
llvm/lib/MCA/Stages/EntryStage.cpp

index 6b3fbb8..5c82ce7 100644 (file)
@@ -67,7 +67,8 @@ llvm::Error EntryStage::cycleResume() {
 
 llvm::Error EntryStage::cycleEnd() {
   // Find the first instruction which hasn't been retired.
-  auto Range = make_range(&Instructions[NumRetired], Instructions.end());
+  auto Range =
+      make_range(Instructions.begin() + NumRetired, Instructions.end());
   auto It = find_if(Range, [](const std::unique_ptr<Instruction> &I) {
     return !I->isRetired();
   });