Skip to content

Commit 6db73fa

Browse files
authored
[SandboxVec][Scheduler] Fix clear() to clear all state (#124214)
This patch fixes the scheduler's clear() function to also clear the ReadyList. Not doing so is a bug and results in crashes when the ReadyList contains stale instructions, because it was never clered.
1 parent f3d2e75 commit 6db73fa

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ class DependencyGraph {
417417
DAGInterval = {};
418418
}
419419
#ifndef NDEBUG
420+
/// \Returns true if the DAG's state is clear. Used in assertions.
421+
bool empty() const {
422+
bool IsEmpty = InstrToNodeMap.empty();
423+
assert(IsEmpty == DAGInterval.empty() &&
424+
"Interval and InstrToNodeMap out of sync!");
425+
return IsEmpty;
426+
}
420427
void print(raw_ostream &OS) const;
421428
LLVM_DUMP_METHOD void dump() const;
422429
#endif // NDEBUG

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ class Scheduler {
164164
Bndls.clear();
165165
// TODO: clear view once it lands.
166166
DAG.clear();
167+
ReadyList.clear();
167168
ScheduleTopItOpt = std::nullopt;
169+
assert(Bndls.empty() && DAG.empty() && ReadyList.empty() &&
170+
!ScheduleTopItOpt && "Expected empty state!");
168171
}
169172

170173
#ifndef NDEBUG

0 commit comments

Comments
 (0)