[flang-commits] [flang] [mlir] [mlir][IR] Add `SingleBlock` trait to `ModuleOp`/`GPUModuleOp` (PR #110498)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 30 05:03:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-gpu
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
The region is already declared as `SizedRegion<1>`, but this will add an additional `getBlock()` convenience function to `ModuleOp`.
---
Full diff: https://github.com/llvm/llvm-project/pull/110498.diff
6 Files Affected:
- (modified) flang/lib/Lower/OpenMP/DataSharingProcessor.cpp (+2-2)
- (modified) mlir/include/mlir/Dialect/GPU/IR/GPUOps.td (+2-1)
- (modified) mlir/include/mlir/IR/BuiltinOps.td (+2-2)
- (modified) mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp (+1-2)
- (modified) mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp (+1-2)
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp (+2-2)
``````````diff
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 5f4138e0f63e73..c3ce9662631503 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -478,8 +478,8 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
return existingPrivatizer;
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
- firOpBuilder.setInsertionPoint(&moduleOp.getBodyRegion().front(),
- moduleOp.getBodyRegion().front().begin());
+ firOpBuilder.setInsertionPoint(moduleOp.getBody(),
+ moduleOp.getBody()->begin());
auto result = firOpBuilder.create<mlir::omp::PrivateClauseOp>(
symLoc, uniquePrivatizerName, symType,
isFirstPrivate ? mlir::omp::DataSharingClauseType::FirstPrivate
diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
index 6098eb34d04d52..732391aadab0d4 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
@@ -1380,7 +1380,8 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
def GPU_GPUModuleOp : GPU_Op<"module", [
DataLayoutOpInterface, HasDefaultDLTIDataLayout, IsolatedFromAbove,
- NoRegionArguments, SymbolTable, Symbol] # GraphRegionNoTerminator.traits> {
+ NoRegionArguments, SingleBlock, SymbolTable, Symbol]
+ # GraphRegionNoTerminator.traits> {
let summary = "A top level compilation unit containing code to be run on a GPU.";
let description = [{
GPU module contains code that is intended to be run on a GPU. A host device
diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td
index 56edd7519cd67d..63ba914e219569 100644
--- a/mlir/include/mlir/IR/BuiltinOps.td
+++ b/mlir/include/mlir/IR/BuiltinOps.td
@@ -31,8 +31,8 @@ class Builtin_Op<string mnemonic, list<Trait> traits = []> :
//===----------------------------------------------------------------------===//
def ModuleOp : Builtin_Op<"module", [
- AffineScope, IsolatedFromAbove, NoRegionArguments, SymbolTable, Symbol,
- OpAsmOpInterface
+ AffineScope, IsolatedFromAbove, NoRegionArguments, SingleBlock,
+ SymbolTable, Symbol, OpAsmOpInterface
] # GraphRegionNoTerminator.traits> {
let summary = "A top level container operation";
let description = [{
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());
``````````
</details>
https://github.com/llvm/llvm-project/pull/110498
More information about the flang-commits
mailing list