Skip to content

Commit 3ca5d05

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 ed4b52f commit 3ca5d05

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

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

975974
#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
@@ -7585,8 +7585,12 @@ static Expected<Function *> createOutlinedFunction(
75857585
// preceding mapped arguments that refer to the same global that may be
75867586
// seperate segments. To prevent this, we defer global processing until all
75877587
// other processing has been performed.
7588+
<<<<<<< HEAD
75887589
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(
75897590
removeASCastIfPresent(Input))) {
7591+
=======
7592+
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(removeASCastIfPresent(Input))) {
7593+
>>>>>>> 1d1536f712a6 ([Flang][OpenMP] Additional global address space modifications for device)
75907594
DeferredReplacement.push_back(std::make_pair(Input, InputCopy));
75917595
continue;
75927596
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3992,6 +3992,9 @@ static void collectMapDataFromMapOperands(
39923992
}
39933993
}
39943994

3995+
// remember to remove the movebefore that might have been added in one of the
3996+
// PRs and is now deprecated...
3997+
39953998
static int getMapDataMemberIdx(MapInfoData &mapData, omp::MapInfoOp memberOp) {
39963999
auto *res = llvm::find(mapData.MapClause, memberOp);
39974000
assert(res != mapData.MapClause.end() &&
@@ -4049,7 +4052,7 @@ static void sortMapIndices(llvm::SmallVectorImpl<size_t> &indices,
40494052

40504053
static omp::MapInfoOp getFirstOrLastMappedMemberPtr(omp::MapInfoOp mapInfo,
40514054
bool first) {
4052-
ArrayAttr indexAttr = mapInfo.getMembersIndexAttr();
4055+
mlir::ArrayAttr indexAttr = mapInfo.getMembersIndexAttr();
40534056
// Only 1 member has been mapped, we can return it.
40544057
if (indexAttr.size() == 1)
40554058
return cast<omp::MapInfoOp>(mapInfo.getMembers()[0].getDefiningOp());

0 commit comments

Comments
 (0)