@@ -30,6 +30,8 @@ namespace bufferization {
3030} // namespace bufferization
3131} // namespace mlir
3232
33+ #define DEBUG_TYPE " bufferize"
34+
3335using namespace mlir ;
3436using namespace mlir ::bufferization;
3537
@@ -436,23 +438,33 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
436438 BufferizationRewriter rewriter (op->getContext (), erasedOps, toMemrefOps,
437439 worklist, options, opFilter);
438440 for (unsigned i = 0 ; i < worklist.size (); ++i) {
439- Operation *op = worklist[i];
441+ Operation *nextOp = worklist[i];
440442 // Skip ops that were erased.
441- if (erasedOps.contains (op ))
443+ if (erasedOps.contains (nextOp ))
442444 continue ;
443445 // Skip ops that are not bufferizable or not allowed.
444- auto bufferizableOp = options.dynCastBufferizableOp (op );
446+ auto bufferizableOp = options.dynCastBufferizableOp (nextOp );
445447 if (!bufferizableOp)
446448 continue ;
447- if (opFilter && !opFilter->isOpAllowed (op ))
449+ if (opFilter && !opFilter->isOpAllowed (nextOp ))
448450 continue ;
449451 // Skip ops that no longer have tensor semantics.
450- if (!hasTensorSemantics (op ))
452+ if (!hasTensorSemantics (nextOp ))
451453 continue ;
452454 // Bufferize the op.
453- rewriter.setInsertionPoint (op);
454- if (failed (bufferizableOp.bufferize (rewriter, options)))
455- return op->emitError (" failed to bufferize op" );
455+ LLVM_DEBUG (llvm::dbgs ()
456+ << " //===-------------------------------------------===//\n "
457+ << " IR after bufferizing: " << nextOp->getName () << " \n " );
458+ rewriter.setInsertionPoint (nextOp);
459+ if (failed (bufferizableOp.bufferize (rewriter, options))) {
460+ LLVM_DEBUG (llvm::dbgs ()
461+ << " failed to bufferize\n "
462+ << " //===-------------------------------------------===//\n " );
463+ return nextOp->emitError (" failed to bufferize op" );
464+ }
465+ LLVM_DEBUG (llvm::dbgs ()
466+ << *op
467+ << " \n //===-------------------------------------------===//\n " );
456468 }
457469
458470 // Fold all to_memref(to_tensor(x)) pairs.
0 commit comments