Skip to content

Commit c186543

Browse files
committed
[MLIR][OpenMP] Introduce overlapped record type map support
This PR introduces a new additional type of map lowering for record types that Clang currently supports, in which a user can map a top-level record type and then individual members with different mapping, effectively creating a sort of "overlapping" mapping that we attempt to cut around. This is currently most predominantly used in Fortran, when mapping descriptors and there data, we map the descriptor and its data with separate map modifiers and "cut around" the pointer data, so that wedo not overwrite it unless the runtime deems it a neccesary action based on its reference counting mechanism. However, it is a mechanism that will come in handy/trigger when a user explitily maps a record type (derived type or structure) and then explicitly maps a member with a different map type. These additions were predominantly in the OpenMPToLLVMIRTranslation.cpp file and phase, however, one Flang test that checks end-to-end IR compilation (as far as we care for now at least) was altered. 2/3 required PRs to enable declare target to mapping, should look at PR 3/3 to check for full green passes (this one will fail a number due to some dependencies). Co-authored-by: Raghu Maddhipatla [email protected]
1 parent 1f35e37 commit c186543

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ void genLifetimeEnd(mlir::OpBuilder &builder, mlir::Location loc,
970970
mlir::Value getDescriptorWithNewBaseAddress(fir::FirOpBuilder &builder,
971971
mlir::Location loc, mlir::Value box,
972972
mlir::Value newAddr);
973-
974973
} // namespace fir::factory
975974

976975
#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7957,8 +7957,12 @@ static Expected<Function *> createOutlinedFunction(
79577957
// preceding mapped arguments that refer to the same global that may be
79587958
// seperate segments. To prevent this, we defer global processing until all
79597959
// other processing has been performed.
7960+
<<<<<<< HEAD
79607961
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(
79617962
removeASCastIfPresent(Input))) {
7963+
=======
7964+
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(removeASCastIfPresent(Input))) {
7965+
>>>>>>> 1d1536f712a6 ([Flang][OpenMP] Additional global address space modifications for device)
79627966
DeferredReplacement.push_back(std::make_pair(Input, InputCopy));
79637967
continue;
79647968
}

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,9 @@ static void collectMapDataFromMapOperands(
41864186
}
41874187
}
41884188

4189+
// remember to remove the movebefore that might have been added in one of the
4190+
// PRs and is now deprecated...
4191+
41894192
static int getMapDataMemberIdx(MapInfoData &mapData, omp::MapInfoOp memberOp) {
41904193
auto *res = llvm::find(mapData.MapClause, memberOp);
41914194
assert(res != mapData.MapClause.end() &&
@@ -4235,8 +4238,8 @@ static void sortMapIndices(llvm::SmallVector<size_t> &indices,
42354238
});
42364239
}
42374240

4238-
static mlir::omp::MapInfoOp
4239-
getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
4241+
static omp::MapInfoOp getFirstOrLastMappedMemberPtr(omp::MapInfoOp mapInfo,
4242+
bool first) {
42404243
mlir::ArrayAttr indexAttr = mapInfo.getMembersIndexAttr();
42414244
// Only 1 member has been mapped, we can return it.
42424245
if (indexAttr.size() == 1)

0 commit comments

Comments
 (0)