Skip to content

Commit 4a0b8c3

Browse files
authored
[MLIR][Affine] Drop assumptions of surrounding builtin.func op in Utils/LoopUtils (#116324)
Drop assumptions of surrounding builtin.func op in affine LoopUtils and Utils. There are use cases of affine fusion or affine transformation in other func-like ops. In the context of #116042
1 parent b3909f4 commit 4a0b8c3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,8 @@ static LogicalResult generateCopy(
19411941
*nBegin = begin;
19421942
*nEnd = end;
19431943

1944-
func::FuncOp f = begin->getParentOfType<func::FuncOp>();
1945-
OpBuilder topBuilder(f.getBody());
1944+
auto f = begin->getParentOfType<FunctionOpInterface>();
1945+
OpBuilder topBuilder(f.getFunctionBody());
19461946
Value zeroIndex = topBuilder.create<arith::ConstantIndexOp>(f.getLoc(), 0);
19471947

19481948
*sizeInBytes = 0;
@@ -1961,8 +1961,9 @@ static LogicalResult generateCopy(
19611961
OpBuilder &b = region.isWrite() ? epilogue : prologue;
19621962

19631963
// Builder to create constants at the top level.
1964-
auto func = copyPlacementBlock->getParent()->getParentOfType<func::FuncOp>();
1965-
OpBuilder top(func.getBody());
1964+
auto func =
1965+
copyPlacementBlock->getParent()->getParentOfType<FunctionOpInterface>();
1966+
OpBuilder top(func.getFunctionBody());
19661967

19671968
auto loc = region.loc;
19681969
auto memref = region.memref;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,11 @@ LogicalResult mlir::affine::replaceAllMemRefUsesWith(
13911391
std::unique_ptr<PostDominanceInfo> postDomInfo;
13921392
if (domOpFilter)
13931393
domInfo = std::make_unique<DominanceInfo>(
1394-
domOpFilter->getParentOfType<func::FuncOp>());
1394+
domOpFilter->getParentOfType<FunctionOpInterface>());
13951395

13961396
if (postDomOpFilter)
13971397
postDomInfo = std::make_unique<PostDominanceInfo>(
1398-
postDomOpFilter->getParentOfType<func::FuncOp>());
1398+
postDomOpFilter->getParentOfType<FunctionOpInterface>());
13991399

14001400
// Walk all uses of old memref; collect ops to perform replacement. We use a
14011401
// DenseSet since an operation could potentially have multiple uses of a

0 commit comments

Comments
 (0)