Skip to content

Commit

Permalink
[MLIR][Affine] Drop assumptions of surrounding builtin.func op in Uti…
Browse files Browse the repository at this point in the history
…ls/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.
  • Loading branch information
bondhugula committed Nov 15, 2024
1 parent 1b23ebe commit cbf1643
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,8 +1936,8 @@ static LogicalResult generateCopy(
*nBegin = begin;
*nEnd = end;

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

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

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

auto loc = region.loc;
auto memref = region.memref;
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Affine/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,11 +1391,11 @@ LogicalResult mlir::affine::replaceAllMemRefUsesWith(
std::unique_ptr<PostDominanceInfo> postDomInfo;
if (domOpFilter)
domInfo = std::make_unique<DominanceInfo>(
domOpFilter->getParentOfType<func::FuncOp>());
domOpFilter->getParentOfType<FunctionOpInterface>());

if (postDomOpFilter)
postDomInfo = std::make_unique<PostDominanceInfo>(
postDomOpFilter->getParentOfType<func::FuncOp>());
postDomOpFilter->getParentOfType<FunctionOpInterface>());

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

0 comments on commit cbf1643

Please sign in to comment.