Skip to content

Commit 5d0d0ff

Browse files
linyayAmdLin-Ya Yu
andauthored
Extend affine::normalizeMemRef to return FailureOr<AllocLikeOp>, where AllocLikeOp is the normalized memref.alloca or memref.alloc (#412)
Co-authored-by: Lin-Ya Yu <[email protected]>
1 parent 2babd7e commit 5d0d0ff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

mlir/include/mlir/Dialect/Affine/Utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ LogicalResult replaceAllMemRefUsesWith(Value oldMemRef, Value newMemRef,
247247
/// and updates all its indexing uses. Returns failure if any of its uses
248248
/// escape (while leaving the IR in a valid state).
249249
template <typename AllocLikeOp>
250-
LogicalResult normalizeMemRef(AllocLikeOp *op);
251-
extern template LogicalResult
250+
FailureOr<AllocLikeOp> normalizeMemRef(AllocLikeOp *op);
251+
extern template FailureOr<memref::AllocaOp>
252252
normalizeMemRef<memref::AllocaOp>(memref::AllocaOp *op);
253-
extern template LogicalResult
253+
extern template FailureOr<memref::AllocOp>
254254
normalizeMemRef<memref::AllocOp>(memref::AllocOp *op);
255255

256256
/// Normalizes `memrefType` so that the affine layout map of the memref is

mlir/lib/Dialect/Affine/Utils/Utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ static void createNewDynamicSizes(MemRefType oldMemRefType,
16891689

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

@@ -1743,12 +1743,12 @@ LogicalResult mlir::affine::normalizeMemRef(AllocLikeOp *allocOp) {
17431743
}));
17441744
oldMemRef.replaceAllUsesWith(newAlloc);
17451745
allocOp->erase();
1746-
return success();
1746+
return newAlloc;
17471747
}
17481748

1749-
template LogicalResult
1749+
template FailureOr<memref::AllocaOp>
17501750
mlir::affine::normalizeMemRef<memref::AllocaOp>(memref::AllocaOp *op);
1751-
template LogicalResult
1751+
template FailureOr<memref::AllocOp>
17521752
mlir::affine::normalizeMemRef<memref::AllocOp>(memref::AllocOp *op);
17531753

17541754
MemRefType mlir::affine::normalizeMemRefType(MemRefType memrefType) {

0 commit comments

Comments
 (0)