Skip to content

Commit 1c7720e

Browse files
committed
Revert "[MLIR][OpenMP] Add a new AutomapToTargetData conversion pass in FIR (llvm#153048)"
This reverts commit 4e6d510.
1 parent d66a28f commit 1c7720e

File tree

8 files changed

+39
-278
lines changed

8 files changed

+39
-278
lines changed

flang/include/flang/Optimizer/OpenMP/Passes.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,4 @@ def GenericLoopConversionPass
112112
];
113113
}
114114

115-
def AutomapToTargetDataPass
116-
: Pass<"omp-automap-to-target-data", "::mlir::ModuleOp"> {
117-
let summary = "Insert OpenMP target data operations for AUTOMAP variables";
118-
let description = [{
119-
Inserts `omp.target_enter_data` and `omp.target_exit_data` operations to
120-
map variables marked with the `AUTOMAP` modifier when their allocation
121-
or deallocation is detected in the FIR.
122-
}];
123-
let dependentDialects = ["mlir::omp::OpenMPDialect"];
124-
}
125-
126115
#endif //FORTRAN_OPTIMIZER_OPENMP_PASSES

flang/include/flang/Support/OpenMP-utils.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
#ifndef FORTRAN_SUPPORT_OPENMP_UTILS_H_
1010
#define FORTRAN_SUPPORT_OPENMP_UTILS_H_
1111

12-
#include "flang/Optimizer/Builder/DirectivesCommon.h"
13-
#include "flang/Optimizer/Builder/FIRBuilder.h"
14-
#include "flang/Optimizer/Builder/HLFIRTools.h"
15-
#include "flang/Optimizer/Dialect/FIRType.h"
1612
#include "flang/Semantics/symbol.h"
1713

18-
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
1914
#include "mlir/IR/Builders.h"
2015
#include "mlir/IR/Value.h"
2116

@@ -77,35 +72,6 @@ struct EntryBlockArgs {
7772
/// \param [in] region - Empty region in which to create the entry block.
7873
mlir::Block *genEntryBlock(
7974
mlir::OpBuilder &builder, const EntryBlockArgs &args, mlir::Region &region);
80-
81-
// Returns true if the variable has a dynamic size and therefore requires
82-
// bounds operations to describe its extents.
83-
inline bool needsBoundsOps(mlir::Value var) {
84-
assert(mlir::isa<mlir::omp::PointerLikeType>(var.getType()) &&
85-
"only pointer like types expected");
86-
mlir::Type t = fir::unwrapRefType(var.getType());
87-
if (mlir::Type inner = fir::dyn_cast_ptrOrBoxEleTy(t))
88-
return fir::hasDynamicSize(inner);
89-
return fir::hasDynamicSize(t);
90-
}
91-
92-
// Generate MapBoundsOp operations for the variable if required.
93-
inline void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
94-
llvm::SmallVectorImpl<mlir::Value> &boundsOps) {
95-
mlir::Location loc = var.getLoc();
96-
fir::factory::AddrAndBoundsInfo info =
97-
fir::factory::getDataOperandBaseAddr(builder, var,
98-
/*isOptional=*/false, loc);
99-
fir::ExtendedValue exv =
100-
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr},
101-
/*contiguousHint=*/true)
102-
.first;
103-
llvm::SmallVector<mlir::Value> tmp =
104-
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
105-
mlir::omp::MapBoundsType>(
106-
builder, info, exv, /*dataExvIsAssumedSize=*/false, loc);
107-
llvm::append_range(boundsOps, tmp);
108-
}
10975
} // namespace Fortran::common::openmp
11076

11177
#endif // FORTRAN_SUPPORT_OPENMP_UTILS_H_

flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp

Lines changed: 0 additions & 130 deletions
This file was deleted.

flang/lib/Optimizer/OpenMP/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
22

33
add_flang_library(FlangOpenMPTransforms
4-
AutomapToTargetData.cpp
54
DoConcurrentConversion.cpp
65
FunctionFiltering.cpp
76
GenericLoopConversion.cpp

flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
3030
#include "flang/Optimizer/HLFIR/HLFIROps.h"
3131
#include "flang/Optimizer/OpenMP/Passes.h"
32-
#include "flang/Support/OpenMP-utils.h"
3332

3433
#include "mlir/Dialect/Func/IR/FuncOps.h"
3534
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
@@ -48,7 +47,6 @@ namespace flangomp {
4847
} // namespace flangomp
4948

5049
using namespace mlir;
51-
using namespace Fortran::common::openmp;
5250

5351
namespace {
5452
class MapsForPrivatizedSymbolsPass
@@ -195,5 +193,38 @@ class MapsForPrivatizedSymbolsPass
195193
}
196194
}
197195
}
196+
// As the name suggests, this function examines var to determine if
197+
// it has dynamic size. If true, this pass'll have to extract these
198+
// bounds from descriptor of var and add the bounds to the resultant
199+
// MapInfoOp.
200+
bool needsBoundsOps(mlir::Value var) {
201+
assert(mlir::isa<omp::PointerLikeType>(var.getType()) &&
202+
"needsBoundsOps can deal only with pointer types");
203+
mlir::Type t = fir::unwrapRefType(var.getType());
204+
// t could be a box, so look inside the box
205+
auto innerType = fir::dyn_cast_ptrOrBoxEleTy(t);
206+
if (innerType)
207+
return fir::hasDynamicSize(innerType);
208+
return fir::hasDynamicSize(t);
209+
}
210+
211+
void genBoundsOps(fir::FirOpBuilder &builder, mlir::Value var,
212+
llvm::SmallVector<mlir::Value> &boundsOps) {
213+
mlir::Location loc = var.getLoc();
214+
fir::factory::AddrAndBoundsInfo info =
215+
fir::factory::getDataOperandBaseAddr(builder, var,
216+
/*isOptional=*/false, loc);
217+
fir::ExtendedValue extendedValue =
218+
hlfir::translateToExtendedValue(loc, builder, hlfir::Entity{info.addr},
219+
/*continguousHint=*/true)
220+
.first;
221+
llvm::SmallVector<mlir::Value> boundsOpsVec =
222+
fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
223+
mlir::omp::MapBoundsType>(
224+
builder, info, extendedValue,
225+
/*dataExvIsAssumedSize=*/false, loc);
226+
for (auto bounds : boundsOpsVec)
227+
boundsOps.push_back(bounds);
228+
}
198229
};
199230
} // namespace

flang/lib/Optimizer/Passes/Pipelines.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ void createOpenMPFIRPassPipeline(mlir::PassManager &pm,
316316
pm.addPass(flangomp::createDoConcurrentConversionPass(
317317
opts.doConcurrentMappingKind == DoConcurrentMappingKind::DCMK_Device));
318318

319-
// The MapsForPrivatizedSymbols and AutomapToTargetDataPass pass need to run
320-
// before MapInfoFinalizationPass because they create new MapInfoOp
321-
// instances, typically for descriptors. MapInfoFinalizationPass adds
322-
// MapInfoOp instances for the descriptors underlying data which is necessary
323-
// to access the data on the offload target device.
319+
// The MapsForPrivatizedSymbols pass needs to run before
320+
// MapInfoFinalizationPass because the former creates new
321+
// MapInfoOp instances, typically for descriptors.
322+
// MapInfoFinalizationPass adds MapInfoOp instances for the descriptors
323+
// underlying data which is necessary to access the data on the offload
324+
// target device.
324325
pm.addPass(flangomp::createMapsForPrivatizedSymbolsPass());
325-
pm.addPass(flangomp::createAutomapToTargetDataPass());
326326
pm.addPass(flangomp::createMapInfoFinalizationPass());
327327
pm.addPass(flangomp::createMarkDeclareTargetPass());
328328
pm.addPass(flangomp::createGenericLoopConversionPass());

flang/test/Transforms/omp-automap-to-target-data.fir

Lines changed: 0 additions & 58 deletions
This file was deleted.

offload/test/offloading/fortran/declare-target-automap.f90

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)