Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend affine::normalizeMemRef to return FailureOr<AllocLikeOp> #412

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1690,7 +1690,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 @@ -1744,12 +1744,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
Loading