Skip to content

Commit f4e0044

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 00de635 commit f4e0044

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
@@ -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
@@ -7603,8 +7603,12 @@ static Expected<Function *> createOutlinedFunction(
76037603
// preceding mapped arguments that refer to the same global that may be
76047604
// seperate segments. To prevent this, we defer global processing until all
76057605
// other processing has been performed.
7606+
<<<<<<< HEAD
76067607
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(
76077608
removeASCastIfPresent(Input))) {
7609+
=======
7610+
if (llvm::isa<llvm::GlobalValue, llvm::GlobalObject, llvm::GlobalVariable>(removeASCastIfPresent(Input))) {
7611+
>>>>>>> 1d1536f712a6 ([Flang][OpenMP] Additional global address space modifications for device)
76087612
DeferredReplacement.push_back(std::make_pair(Input, InputCopy));
76097613
continue;
76107614
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4035,6 +4035,9 @@ static void collectMapDataFromMapOperands(
40354035
}
40364036
}
40374037

4038+
// remember to remove the movebefore that might have been added in one of the
4039+
// PRs and is now deprecated...
4040+
40384041
static int getMapDataMemberIdx(MapInfoData &mapData, omp::MapInfoOp memberOp) {
40394042
auto *res = llvm::find(mapData.MapClause, memberOp);
40404043
assert(res != mapData.MapClause.end() &&
@@ -4086,7 +4089,7 @@ static void sortMapIndices(llvm::SmallVectorImpl<size_t> &indices,
40864089

40874090
static omp::MapInfoOp getFirstOrLastMappedMemberPtr(omp::MapInfoOp mapInfo,
40884091
bool first) {
4089-
ArrayAttr indexAttr = mapInfo.getMembersIndexAttr();
4092+
mlir::ArrayAttr indexAttr = mapInfo.getMembersIndexAttr();
40904093
// Only 1 member has been mapped, we can return it.
40914094
if (indexAttr.size() == 1)
40924095
return cast<omp::MapInfoOp>(mapInfo.getMembers()[0].getDefiningOp());

0 commit comments

Comments
 (0)