diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp @@ -210,9 +210,9 @@ MemRefDependenceGraph(Block &block) : block(block) {} - // Initializes the dependence graph based on operations in 'f'. + // Initializes the dependence graph based on operations in `block'. // Returns true on success, false otherwise. - bool init(Block *block); + bool init(); // Returns the graph node for 'id'. Node *getNode(unsigned id) { @@ -773,14 +773,14 @@ // Assigns each node in the graph a node id based on program order in 'f'. // TODO: Add support for taking a Block arg to construct the // dependence graph at a different depth. -bool MemRefDependenceGraph::init(Block *block) { +bool MemRefDependenceGraph::init() { LLVM_DEBUG(llvm::dbgs() << "--- Initializing MDG ---\n"); // Map from a memref to the set of ids of the nodes that have ops accessing // the memref. DenseMap> memrefAccesses; DenseMap forToNodeMap; - for (Operation &op : *block) { + for (Operation &op : block) { if (auto forOp = dyn_cast(op)) { // Create graph node 'id' to represent top-level 'forOp' and record // all loads and store accesses it contains. @@ -859,8 +859,8 @@ for (Value value : opInst->getResults()) { for (Operation *user : value.getUsers()) { // Ignore users outside of the block. - if (block->getParent()->findAncestorOpInRegion(*user)->getBlock() != - block) + if (block.getParent()->findAncestorOpInRegion(*user)->getBlock() != + &block) continue; SmallVector loops; getAffineForIVs(*user, &loops); @@ -2032,8 +2032,10 @@ /// Run fusion on `block`. void LoopFusion::runOnBlock(Block *block) { MemRefDependenceGraph g(*block); - if (!g.init(block)) + if (!g.init()) { + LLVM_DEBUG(llvm::dbgs() << "MDG init failed"); return; + } std::optional fastMemorySpaceOpt; if (fastMemorySpace.hasValue())