[Mlir-commits] [mlir] ec64038 - [mlir][MemRef] NFC - Add debug information to MultiBuffer.cpp
Nicolas Vasilache
llvmlistbot at llvm.org
Thu Feb 16 07:20:05 PST 2023
Author: Nicolas Vasilache
Date: 2023-02-16T07:19:58-08:00
New Revision: ec640382fc9378961697e2daa512a24ecac36fcb
URL: https://github.com/llvm/llvm-project/commit/ec640382fc9378961697e2daa512a24ecac36fcb
DIFF: https://github.com/llvm/llvm-project/commit/ec640382fc9378961697e2daa512a24ecac36fcb.diff
LOG: [mlir][MemRef] NFC - Add debug information to MultiBuffer.cpp
Added:
Modified:
mlir/lib/Dialect/MemRef/Transforms/MultiBuffer.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/MemRef/Transforms/MultiBuffer.cpp b/mlir/lib/Dialect/MemRef/Transforms/MultiBuffer.cpp
index c70b210b59489..e094f5a5d454d 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/MultiBuffer.cpp
+++ b/mlir/lib/Dialect/MemRef/Transforms/MultiBuffer.cpp
@@ -15,9 +15,14 @@
#include "mlir/Dialect/MemRef/Transforms/Passes.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
+#include "llvm/Support/Debug.h"
using namespace mlir;
+#define DEBUG_TYPE "memref-transforms"
+#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
+#define DBGSNL() (llvm::dbgs() << "\n")
+
/// Return true if the op fully overwrite the given `buffer` value.
static bool overrideBuffer(Operation *op, Value buffer) {
auto copyOp = dyn_cast<memref::CopyOp>(op);
@@ -79,33 +84,46 @@ static Value getOrCreateValue(OpFoldResult res, OpBuilder &builder,
// uses and requires updating subview ops.
FailureOr<memref::AllocOp> mlir::memref::multiBuffer(memref::AllocOp allocOp,
unsigned multiplier) {
+ LLVM_DEBUG(DBGS() << "Try multibuffer: " << allocOp << "\n");
DominanceInfo dom(allocOp->getParentOp());
LoopLikeOpInterface candidateLoop;
for (Operation *user : allocOp->getUsers()) {
auto parentLoop = user->getParentOfType<LoopLikeOpInterface>();
- if (!parentLoop)
+ if (!parentLoop) {
+ LLVM_DEBUG(DBGS() << "Skip user: no parent loop\n");
return failure();
- /// Make sure there is no loop carried dependency on the allocation.
- if (!overrideBuffer(user, allocOp.getResult()))
+ }
+ /// Make sure there is no loop-carried dependency on the allocation.
+ if (!overrideBuffer(user, allocOp.getResult())) {
+ LLVM_DEBUG(DBGS() << "Skip user: found loop-carried dependence\n");
continue;
+ }
// If this user doesn't dominate all the other users keep looking.
if (llvm::any_of(allocOp->getUsers(), [&](Operation *otherUser) {
return !dom.dominates(user, otherUser);
- }))
+ })) {
+ LLVM_DEBUG(DBGS() << "Skip user: does not dominate all other users\n");
continue;
+ }
candidateLoop = parentLoop;
break;
}
- if (!candidateLoop)
+ if (!candidateLoop) {
+ LLVM_DEBUG(DBGS() << "Skip alloc: no candidate loop\n");
return failure();
+ }
std::optional<Value> inductionVar = candidateLoop.getSingleInductionVar();
std::optional<OpFoldResult> lowerBound = candidateLoop.getSingleLowerBound();
std::optional<OpFoldResult> singleStep = candidateLoop.getSingleStep();
- if (!inductionVar || !lowerBound || !singleStep)
+ if (!inductionVar || !lowerBound || !singleStep) {
+ LLVM_DEBUG(DBGS() << "Skip alloc: no single iv, lb or step\n");
return failure();
+ }
- if (!dom.dominates(allocOp.getOperation(), candidateLoop))
+ if (!dom.dominates(allocOp.getOperation(), candidateLoop)) {
+ LLVM_DEBUG(DBGS() << "Skip alloc: does not dominate candidate loop\n");
return failure();
+ }
OpBuilder builder(candidateLoop);
SmallVector<int64_t, 4> newShape(1, multiplier);
More information about the Mlir-commits
mailing list