[Mlir-commits] [flang] [mlir] [mlir][NFC] Minor cleanup around `ModuleOp` usage (PR #110498)
Matthias Springer
llvmlistbot at llvm.org
Mon Sep 30 05:12:17 PDT 2024
https://github.com/matthias-springer updated https://github.com/llvm/llvm-project/pull/110498
>From cd9d1678180d119d1429e057d77bdef4c0cbdf89 Mon Sep 17 00:00:00 2001
From: Matthias Springer <mspringer at nvidia.com>
Date: Mon, 30 Sep 2024 14:00:11 +0200
Subject: [PATCH] [mlir][IR] Add `SingleBlock` trait to
`ModuleOp`/`GPUModuleOp`
The region is already declared as `SizedRegion<1>`, but this will add an additional `getBlock()` convenience function to `ModuleOp`.
---
flang/lib/Lower/OpenMP/DataSharingProcessor.cpp | 3 +--
.../BufferizationToMemRef/BufferizationToMemRef.cpp | 3 +--
.../Dialect/Bufferization/Transforms/LowerDeallocations.cpp | 3 +--
mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp | 4 ++--
4 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 5f4138e0f63e73..23a171c6576389 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -478,8 +478,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
return existingPrivatizer;
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
- firOpBuilder.setInsertionPoint(&moduleOp.getBodyRegion().front(),
- moduleOp.getBodyRegion().front().begin());
+ firOpBuilder.setInsertionPointToStart(moduleOp.getBody());
auto result = firOpBuilder.create<mlir::omp::PrivateClauseOp>(
symLoc, uniquePrivatizerName, symType,
isFirstPrivate ? mlir::omp::DataSharingClauseType::FirstPrivate
diff --git a/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp b/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp
index f9903071be0842..06aedc5e139d37 100644
--- a/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp
+++ b/mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp
@@ -134,8 +134,7 @@ struct BufferizationToMemRefPass
bufferization::DeallocHelperMap deallocHelperFuncMap;
if (auto module = dyn_cast<ModuleOp>(getOperation())) {
- OpBuilder builder =
- OpBuilder::atBlockBegin(&module.getBodyRegion().front());
+ OpBuilder builder = OpBuilder::atBlockBegin(module.getBody());
// Build dealloc helper function if there are deallocs.
getOperation()->walk([&](bufferization::DeallocOp deallocOp) {
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp b/mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp
index 9e2c91bad7bfdd..31d165ce154070 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp
@@ -391,8 +391,7 @@ struct LowerDeallocationsPass
bufferization::DeallocHelperMap deallocHelperFuncMap;
if (auto module = dyn_cast<ModuleOp>(getOperation())) {
- OpBuilder builder =
- OpBuilder::atBlockBegin(&module.getBodyRegion().front());
+ OpBuilder builder = OpBuilder::atBlockBegin(module.getBody());
// Build dealloc helper function if there are deallocs.
getOperation()->walk([&](bufferization::DeallocOp deallocOp) {
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
index 8be76cac87f297..b7fac163ba5fe3 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
@@ -58,7 +58,7 @@ static gpu::GPUModuleOp genGPUModule(OpBuilder &builder, ModuleOp topModule) {
for (auto op : topModule.getBodyRegion().getOps<gpu::GPUModuleOp>())
return op; // existing
markAsGPUContainer(topModule);
- builder.setInsertionPointToStart(&topModule.getBodyRegion().front());
+ builder.setInsertionPointToStart(topModule.getBody());
return builder.create<gpu::GPUModuleOp>(topModule->getLoc(),
"sparse_kernels");
}
@@ -75,7 +75,7 @@ static gpu::GPUFuncOp genGPUFunc(OpBuilder &builder, gpu::GPUModuleOp gpuModule,
("kernel" + Twine(kernelNumber++)).toStringRef(kernelName);
} while (gpuModule.lookupSymbol(kernelName));
// Then we insert a new kernel with given arguments into the module.
- builder.setInsertionPointToStart(&gpuModule.getBodyRegion().front());
+ builder.setInsertionPointToStart(gpuModule.getBody());
SmallVector<Type> argsTp;
for (auto arg : args)
argsTp.push_back(arg.getType());
More information about the Mlir-commits
mailing list