diff --git a/mlir/lib/Analysis/DataFlowAnalysis.cpp b/mlir/lib/Analysis/DataFlowAnalysis.cpp --- a/mlir/lib/Analysis/DataFlowAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlowAnalysis.cpp @@ -12,6 +12,8 @@ #include "mlir/Interfaces/ControlFlowInterfaces.h" #include "llvm/ADT/SmallPtrSet.h" +#include + using namespace mlir; using namespace mlir::detail; @@ -165,7 +167,7 @@ template void markAllPessimisticFixpoint(Operation *op, ValuesT values) { markAllPessimisticFixpoint(values); - opWorklist.push_back(op); + opWorklist.push(op); } template void markAllPessimisticFixpointAndVisitUsers(ValuesT values) { @@ -195,10 +197,10 @@ DenseSet> executableEdges; /// A worklist containing blocks that need to be processed. - SmallVector blockWorklist; + std::queue blockWorklist; /// A worklist of operations that need to be processed. - SmallVector opWorklist; + std::queue opWorklist; /// The callable operations that have their argument/result state tracked. DenseMap callableLatticeState; @@ -229,12 +231,18 @@ void ForwardDataFlowSolver::solve() { while (!blockWorklist.empty() || !opWorklist.empty()) { // Process any operations in the op worklist. - while (!opWorklist.empty()) - visitUsers(*opWorklist.pop_back_val()); + while (!opWorklist.empty()) { + Operation *nextOp = opWorklist.front(); + opWorklist.pop(); + visitUsers(*nextOp); + } // Process any blocks in the block worklist. - while (!blockWorklist.empty()) - visitBlock(blockWorklist.pop_back_val()); + while (!blockWorklist.empty()) { + Block *nextBlock = blockWorklist.front(); + blockWorklist.pop(); + visitBlock(nextBlock); + } } } @@ -368,7 +376,7 @@ // Visit the current operation. if (analysis.visitOperation(op, operandLattices) == ChangeResult::Change) - opWorklist.push_back(op); + opWorklist.push(op); // `visitOperation` is required to define all of the result lattices. assert(llvm::none_of( @@ -477,7 +485,7 @@ // region operation can provide information for certain results that // aren't part of the control flow. if (succArgs.size() != results.size()) { - opWorklist.push_back(parentOp); + opWorklist.push(parentOp); if (succArgs.empty()) { markAllPessimisticFixpoint(results); continue; @@ -713,7 +721,7 @@ ChangeResult ForwardDataFlowSolver::markBlockExecutable(Block *block) { bool marked = executableBlocks.insert(block).second; if (marked) - blockWorklist.push_back(block); + blockWorklist.push(block); return marked ? ChangeResult::Change : ChangeResult::NoChange; } @@ -749,7 +757,7 @@ void ForwardDataFlowSolver::join(Operation *owner, AbstractLatticeElement &to, const AbstractLatticeElement &from) { if (to.join(from) == ChangeResult::Change) - opWorklist.push_back(owner); + opWorklist.push(owner); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp --- a/mlir/lib/Transforms/SCCP.cpp +++ b/mlir/lib/Transforms/SCCP.cpp @@ -23,6 +23,9 @@ #include "mlir/Pass/Pass.h" #include "mlir/Transforms/FoldUtils.h" #include "mlir/Transforms/Passes.h" +#include "llvm/Support/Debug.h" + +#define DEBUG_TYPE "sccp" using namespace mlir; @@ -70,6 +73,9 @@ ChangeResult visitOperation(Operation *op, ArrayRef *> operands) final { + + LLVM_DEBUG(llvm::dbgs() << "SCCP: Visiting operation: " << *op << "\n"); + // Don't try to simulate the results of a region operation as we can't // guarantee that folding will be out-of-place. We don't allow in-place // folds as the desire here is for simulated execution, and not general