[llvm] [CodeGen] Add complete-schedule search strategy API (PR #220644)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 14:10:53 PDT 2026


================
@@ -0,0 +1,244 @@
+//===- MachineSchedSearch.cpp - Complete schedule search ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGen/MachineSchedSearch.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Sequence.h"
+#include <algorithm>
+#include <functional>
+#include <queue>
+#include <vector>
+
+using namespace llvm;
+
+MachineSchedCompleteScheduleOptimizer::
+    ~MachineSchedCompleteScheduleOptimizer() = default;
+
+MachineSchedSearchRegion::MachineSchedSearchRegion(ArrayRef<SUnit> Nodes)
+    : Nodes(Nodes), Predecessors(Nodes.size()), Successors(Nodes.size()) {
+  DenseMap<const SUnit *, unsigned> Ordinals;
+  for (auto [Ordinal, SU] : enumerate(Nodes))
+    Ordinals[&SU] = Ordinal;
+
+  for (auto [Ordinal, SU] : enumerate(Nodes)) {
+    for (const SDep &Pred : SU.Preds) {
+      const SUnit *PredSU = Pred.getSUnit();
+      if (Pred.isWeak() || PredSU->isBoundaryNode())
+        continue;
+      auto PredOrdinal = Ordinals.find(PredSU);
+      assert(PredOrdinal != Ordinals.end() &&
+             "predecessor must belong to the scheduling region");
+      if (PredOrdinal == Ordinals.end())
+        continue;
----------------
arsenm wrote:

You assert and then continue, it shouldn't be both 

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


More information about the llvm-commits mailing list