[llvm] [SandboxVec][Scheduler] Fix clear() to clear all state (PR #124214)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 16:35:40 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: vporpo (vporpo)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/124214.diff
2 Files Affected:
- (modified) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h (+7)
- (modified) llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h (+3)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/124214
More information about the llvm-commits
mailing list