[llvm] 6db73fa - [SandboxVec][Scheduler] Fix clear() to clear all state (#124214)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 21:27:56 PST 2025
Author: vporpo
Date: 2025-01-23T21:27:53-08:00
New Revision: 6db73fa481beb9184ea8f1103e72e7a5c1d82e31
URL: https://github.com/llvm/llvm-project/commit/6db73fa481beb9184ea8f1103e72e7a5c1d82e31
DIFF: https://github.com/llvm/llvm-project/commit/6db73fa481beb9184ea8f1103e72e7a5c1d82e31.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
index 00b53b42e2e572..b2d7c9b8aa8bbc 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
@@ -417,6 +417,13 @@ class DependencyGraph {
DAGInterval = {};
}
#ifndef NDEBUG
+ /// \Returns true if the DAG's state is clear. Used in assertions.
+ bool empty() const {
+ bool IsEmpty = InstrToNodeMap.empty();
+ assert(IsEmpty == DAGInterval.empty() &&
+ "Interval and InstrToNodeMap out of sync!");
+ return IsEmpty;
+ }
void print(raw_ostream &OS) const;
LLVM_DUMP_METHOD void dump() const;
#endif // NDEBUG
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
index 52891c3f7535c9..25432e1396c73f 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
@@ -164,7 +164,10 @@ class Scheduler {
Bndls.clear();
// TODO: clear view once it lands.
DAG.clear();
+ ReadyList.clear();
ScheduleTopItOpt = std::nullopt;
+ assert(Bndls.empty() && DAG.empty() && ReadyList.empty() &&
+ !ScheduleTopItOpt && "Expected empty state!");
}
#ifndef NDEBUG
More information about the llvm-commits
mailing list