Skip to content

Commit cbf1643

Browse files
committed
[MLIR][Affine] Drop assumptions of surrounding builtin.func op in Utils/LoopUtils
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.
1 parent 1b23ebe commit cbf1643

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
@@ -1936,8 +1936,8 @@ static LogicalResult generateCopy(
19361936
*nBegin = begin;
19371937
*nEnd = end;
19381938

1939-
func::FuncOp f = begin->getParentOfType<func::FuncOp>();
1940-
OpBuilder topBuilder(f.getBody());
1939+
auto f = begin->getParentOfType<FunctionOpInterface>();
1940+
OpBuilder topBuilder(f.getFunctionBody());
19411941
Value zeroIndex = topBuilder.create<arith::ConstantIndexOp>(f.getLoc(), 0);
19421942

19431943
*sizeInBytes = 0;
@@ -1956,8 +1956,9 @@ static LogicalResult generateCopy(
19561956
OpBuilder &b = region.isWrite() ? epilogue : prologue;
19571957

19581958
// Builder to create constants at the top level.
1959-
auto func = copyPlacementBlock->getParent()->getParentOfType<func::FuncOp>();
1960-
OpBuilder top(func.getBody());
1959+
auto func =
1960+
copyPlacementBlock->getParent()->getParentOfType<FunctionOpInterface>();
1961+
OpBuilder top(func.getFunctionBody());
19611962

19621963
auto loc = region.loc;
19631964
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)