@@ -30,6 +30,8 @@ namespace bufferization {
30
30
} // namespace bufferization
31
31
} // namespace mlir
32
32
33
+ #define DEBUG_TYPE " bufferize"
34
+
33
35
using namespace mlir ;
34
36
using namespace mlir ::bufferization;
35
37
@@ -436,23 +438,33 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
436
438
BufferizationRewriter rewriter (op->getContext (), erasedOps, toMemrefOps,
437
439
worklist, options, opFilter);
438
440
for (unsigned i = 0 ; i < worklist.size (); ++i) {
439
- Operation *op = worklist[i];
441
+ Operation *nextOp = worklist[i];
440
442
// Skip ops that were erased.
441
- if (erasedOps.contains (op ))
443
+ if (erasedOps.contains (nextOp ))
442
444
continue ;
443
445
// Skip ops that are not bufferizable or not allowed.
444
- auto bufferizableOp = options.dynCastBufferizableOp (op );
446
+ auto bufferizableOp = options.dynCastBufferizableOp (nextOp );
445
447
if (!bufferizableOp)
446
448
continue ;
447
- if (opFilter && !opFilter->isOpAllowed (op ))
449
+ if (opFilter && !opFilter->isOpAllowed (nextOp ))
448
450
continue ;
449
451
// Skip ops that no longer have tensor semantics.
450
- if (!hasTensorSemantics (op ))
452
+ if (!hasTensorSemantics (nextOp ))
451
453
continue ;
452
454
// 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 " );
456
468
}
457
469
458
470
// Fold all to_memref(to_tensor(x)) pairs.
0 commit comments