Author: Vasileios Porpodas Date: 2026-11-17T22:22:01-08:00 New Revision: b4c0d4ce71f7a93da3abb2bcd201f0eddb6242ad
URL: https://github.com/llvm/llvm-project/commit/b4c0d4ce71f7a93da3abb2bcd201f0eddb6242ad DIFF: https://github.com/llvm/llvm-project/commit/b4c0d4ce71f7a93da3abb2bcd201f0eddb6242ad.diff LOG: Revert "[SandboxVec][DAG] Implement verifier (#242051)" This reverts commit 554cb782f3b83de0a5c2d934e48bf9fd026eb5db. Added: Modified: llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h index d8e60c6ff06dc..f68ba69df78cd 100644 --- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h +++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h @@ -150,11 +150,9 @@ class LLVM_ABI DGNode { // TODO: Use a PointerIntPair for SubclassID and I. /// For isa/dyn_cast etc. DGNodeID SubclassID; - /// The number of unscheduled successors in the bottom-up scheduling direction - /// (or predecessors in top-down). A value of 0 means that all its dependent - /// nodes have been scheduled so this node is ready to be scheduled. Optional - /// represents whether the value is meaningless, e.g., after a node gets - /// scheduled. + /// The number of unscheduled successors (predecessors) depending on the + /// scheduling direction. Optional represents whether the value is + /// meaningless, e.g., after a node gets scheduled. std::optional<unsigned> UnscheduledDeps = 0; /// This is true if this node has been scheduled. bool Scheduled = false; @@ -300,7 +298,6 @@ class LLVM_ABI DGNode { Instruction *getInstruction() const { return I; } #ifndef NDEBUG - void verify(DependencyGraph &DAG) const; virtual void print(raw_ostream &OS, bool PrintDeps = true) const; friend raw_ostream &operator<<(raw_ostream &OS, DGNode &N) { N.print(OS); @@ -456,7 +453,6 @@ class DependencyGraph { Interval<Instruction> DAGInterval; SchedDirection Dir; - friend void DGNode::verify(DependencyGraph &DAG) const; // For Dir. Context *Ctx = nullptr; Scheduler *Sched = nullptr; @@ -580,7 +576,6 @@ class DependencyGraph { DAGInterval = {}; } #ifndef NDEBUG - void verify(); /// \Returns true if the DAG's state is clear. Used in assertions. bool empty() const { bool IsEmpty = InstrToNodeMap.empty(); diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp index f0824be673ecf..ca3e707f78133 100644 --- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp +++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp @@ -152,33 +152,6 @@ DGNode::~DGNode() { } #ifndef NDEBUG -void DGNode::verify(DependencyGraph &DAG) const { - if (!Scheduled) { - assert(UnscheduledDeps.has_value() && "Expected actual value"); - // Check UnscheduledDeps. - switch (DAG.Dir) { - case SchedDirection::BottomUp: { - // UnscheduledDeps counts the number of nodes this node depends on. - unsigned CntUnschedDeps = 0; - for (DGNode *SuccN : succs(DAG)) - if (!SuccN->scheduled()) - ++CntUnschedDeps; - assert(*UnscheduledDeps == CntUnschedDeps && "Inconsistent UnschedDeps"); - break; - } - case SchedDirection::TopDown: { - unsigned CntUnschedDeps = 0; - for (DGNode *PredN : preds(DAG)) - if (!PredN->scheduled()) - ++CntUnschedDeps; - assert(*UnscheduledDeps == CntUnschedDeps && "Inconsistent UnschedDeps"); - break; - } - } - } else { - assert(!UnscheduledDeps.has_value() && "Expected nullopt"); - } -} void DGNode::print(raw_ostream &OS, bool PrintDeps) const { OS << *I << " Unsched:"; if (UnscheduledDeps) @@ -195,8 +168,6 @@ void MemDGNode::print(raw_ostream &OS, bool PrintDeps) const { static constexpr unsigned Indent = 4; for (auto *Pred : MemPreds) OS.indent(Indent) << "<-" << *Pred->getInstruction() << "\n"; - for (auto *Succ : MemSuccs) - OS.indent(Indent) << "->" << *Succ->getInstruction() << "\n"; } } #endif // NDEBUG @@ -531,67 +502,10 @@ void DependencyGraph::notifyCreateInstr(Instruction *I) { scanAndAddDeps(BelowN, Interval<MemDGNode>(MemN, MemN)); } } - // scanAndAddDeps() updates UnscheduledDeps only for mem dependencies. - // During regular DAG creation the UnscheduledDeps for def-used dependencies - // are handled by setDefUseUnscheduledSuccs(NewInterval). - // Since we are not following that path we need to update UnscheduledDeps for - // def-use deps here. - if (!N->scheduled()) { - switch (Dir) { - case SchedDirection::BottomUp: - for (Value *Op : I->operands()) { - Instruction *OpI = dyn_cast<Instruction>(Op); - if (OpI == nullptr) - continue; - DGNode *OpN = getNode(OpI); - if (OpN == nullptr) - continue; - if (!OpN->scheduled()) - OpN->incrUnscheduledDeps(); - } - for (User *U : I->users()) { - Instruction *UI = dyn_cast<Instruction>(U); - if (UI == nullptr) - continue; - DGNode *UN = getNode(UI); - if (UN == nullptr) - continue; - if (!UN->scheduled()) - N->incrUnscheduledDeps(); - } - break; - case SchedDirection::TopDown: - for (Value *Op : I->operands()) { - Instruction *OpI = dyn_cast<Instruction>(Op); - if (OpI == nullptr) - continue; - DGNode *OpN = getNode(OpI); - if (OpN == nullptr) - continue; - if (!OpN->scheduled()) - N->incrUnscheduledDeps(); - } - for (User *U : I->users()) { - Instruction *UI = dyn_cast<Instruction>(U); - if (UI == nullptr) - continue; - DGNode *UN = getNode(UI); - if (UN == nullptr) - continue; - if (!UN->scheduled()) - N->incrUnscheduledDeps(); - } - break; - } - } if (Sched != nullptr) { Sched->notifyCreateInstrAfterDAGUpdates(N); } -#ifndef NDEBUG - // TODO: Remove some of the verifiers eventually to save compilation time. - verify(); -#endif } void DependencyGraph::notifyMoveInstr(Instruction *I, const BBIterator &To) { @@ -662,10 +576,6 @@ void DependencyGraph::notifyMoveInstr(Instruction *I, const BBIterator &To) { MemN->setNextNode( getMemDGNodeAfter(BeforeToN, /*IncludingN=*/true, /*SkipN=*/MemN)); } -#ifndef NDEBUG - // TODO: Remove some of the verifiers eventually to save compilation time. - verify(); -#endif } void DependencyGraph::notifyEraseInstr(Instruction *I) { @@ -676,12 +586,6 @@ void DependencyGraph::notifyEraseInstr(Instruction *I) { if (N == nullptr) // Early return if there is no DAG node for `I`. return; - -#ifndef NDEBUG - // TODO: Remove some of the verifiers eventually to save compilation time. - verify(); -#endif - if (auto *MemN = dyn_cast<MemDGNode>(getNode(I))) { // Update the MemDGNode chain if this is a memory node. auto *PrevMemN = getMemDGNodeBefore(MemN, /*IncludingN=*/false); @@ -703,28 +607,6 @@ void DependencyGraph::notifyEraseInstr(Instruction *I) { // NOTE: The unscheduled succs for MemNodes get updated be setMemPred(). } - if (!N->scheduled()) { - // Update UnscheduledDeps for def-use edges. The UnscheduledDeps has already - // been updated for the memory dependency edges. - if (Dir == SchedDirection::BottomUp) { - for (Value *Op : I->operands()) { - if (!isa<Instruction>(Op)) - continue; - DGNode *PredN = getNode(cast<Instruction>(Op)); - if (PredN && !PredN->scheduled()) - PredN->decrUnscheduledDeps(); - } - } else if (Dir == SchedDirection::TopDown) { - for (User *U : I->users()) { - if (!isa<Instruction>(U)) - continue; - DGNode *SuccN = getNode(cast<Instruction>(U)); - if (SuccN && !SuccN->scheduled()) - SuccN->decrUnscheduledDeps(); - } - } - } - if (Sched != nullptr) Sched->notifyEraseInstr(I); @@ -883,28 +765,6 @@ Interval<Instruction> DependencyGraph::extend(BndlRef<Instruction *> Instrs) { } #ifndef NDEBUG -void DependencyGraph::verify() { - auto Dependency = [this](DGNode *FromN, DGNode *ToN) { - for (DGNode *FromSuccN : FromN->succs(*this)) { - if (FromSuccN == ToN) - return true; - } - for (DGNode *ToPredN : ToN->preds(*this)) { - if (ToPredN == FromN) - return true; - } - return false; - }; - for (const auto &[I1, NPtr1] : InstrToNodeMap) { - NPtr1->verify(*this); - for (const auto &[I2, NPtr2] : InstrToNodeMap) { - if (Dependency(NPtr1.get(), NPtr2.get())) { - assert(I1->comesBefore(I2) && - "Instruction ordering violates dependency!"); - } - } - } -} void DependencyGraph::print(raw_ostream &OS) const { // InstrToNodeMap is unordered so we need to create an ordered vector. SmallVector<DGNode *> Nodes; diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp index 018b54455c715..5c79930b3398c 100644 --- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp +++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp @@ -115,9 +115,6 @@ void Scheduler::scheduleAndUpdateReadyList(SchedBundle &Bndl) { } N->setScheduled(); } -#ifndef NDEBUG - DAG.verify(); -#endif } void Scheduler::notifyCreateInstrBeforeDAGUpdates(DGNode *N) { @@ -143,10 +140,12 @@ void Scheduler::notifyCreateInstrAfterDAGUpdates(DGNode *N) { if (Dir == SchedDirection::BottomUp) { for (auto *PredN : N->preds(DAG)) { ReadyList.remove(PredN); + PredN->incrUnscheduledDeps(); } } else { for (auto *SuccN : N->succs(DAG)) { ReadyList.remove(SuccN); + SuccN->incrUnscheduledDeps(); } } } @@ -162,18 +161,20 @@ void Scheduler::notifyEraseInstr(Instruction *I) { ReadyList.remove(N); // Also decrement the unscheduledDep counter for the dependents and add them // to the ready list if they become ready. - auto TryAddToReadyList = [this](DGNode *DepN) { + auto UpdateNodeAndTryAddToReadyList = [this, N](DGNode *DepN) { if (DepN->scheduled()) return; + if (!N->scheduled() && !DepN->ready()) + DepN->decrUnscheduledDeps(); if (DepN->ready() && !ReadyList.contains(DepN)) ReadyList.insert(DepN); }; if (Dir == SchedDirection::BottomUp) { for (auto *DepN : N->preds(DAG)) - TryAddToReadyList(DepN); + UpdateNodeAndTryAddToReadyList(DepN); } else if (Dir == SchedDirection::TopDown) { for (auto *DepN : N->succs(DAG)) - TryAddToReadyList(DepN); + UpdateNodeAndTryAddToReadyList(DepN); } } @@ -319,9 +320,6 @@ bool Scheduler::tryScheduleUntil(ArrayRef<Instruction *> Instrs) { ReadyList.insert(RetryN); eraseBundle(InstrsSB); -#ifndef NDEBUG - DAG.verify(); -#endif return false; } _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
