Skip to content

Commit

Permalink
Extend affine::normalizeMemRef to return FailureOr<AllocLikeOp>, wher…
Browse files Browse the repository at this point in the history
…e AllocLikeOp is the normalized memref.alloca or memref.alloc (#412)

Co-authored-by: Lin-Ya Yu <lin-ya.yu@amd.com>
  • Loading branch information
linyayAmd and Lin-Ya Yu authored Dec 11, 2024
1 parent 2babd7e commit 5d0d0ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/Affine/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ LogicalResult replaceAllMemRefUsesWith(Value oldMemRef, Value newMemRef,
/// and updates all its indexing uses. Returns failure if any of its uses
/// escape (while leaving the IR in a valid state).
template <typename AllocLikeOp>
LogicalResult normalizeMemRef(AllocLikeOp *op);
extern template LogicalResult
FailureOr<AllocLikeOp> normalizeMemRef(AllocLikeOp *op);
extern template FailureOr<memref::AllocaOp>
normalizeMemRef<memref::AllocaOp>(memref::AllocaOp *op);
extern template LogicalResult
extern template FailureOr<memref::AllocOp>
normalizeMemRef<memref::AllocOp>(memref::AllocOp *op);

/// Normalizes `memrefType` so that the affine layout map of the memref is
Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/Dialect/Affine/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ static void createNewDynamicSizes(MemRefType oldMemRefType,

// TODO: Currently works for static memrefs with a single layout map.
template <typename AllocLikeOp>
LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
FailureOr<AllocLikeOp> mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
MemRefType memrefType = allocOp->getType();
OpBuilder b(*allocOp);

Expand Down Expand Up @@ -1743,12 +1743,12 @@ LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
}));
oldMemRef.replaceAllUsesWith(newAlloc);
allocOp->erase();
return success();
return newAlloc;
}

template LogicalResult
template FailureOr<memref::AllocaOp>
mlir::affine::normalizeMemRef<memref::AllocaOp>(memref::AllocaOp *op);
template LogicalResult
template FailureOr<memref::AllocOp>
mlir::affine::normalizeMemRef<memref::AllocOp>(memref::AllocOp *op);

MemRefType mlir::affine::normalizeMemRefType(MemRefType memrefType) {
Expand Down

0 comments on commit 5d0d0ff

Please sign in to comment.