Skip to content

Commit c4bca6c

Browse files
committed
Post-merge fixes
1 parent 33834ce commit c4bca6c

File tree

6 files changed

+44
-66
lines changed

6 files changed

+44
-66
lines changed

flang/include/flang/Lower/OpenMP/Utils.h

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -98,62 +98,50 @@ struct OmpMapParentAndMemberData {
9898
// Placement of the member in the member vector.
9999
llvm::SmallVector<mlir::omp::MapInfoOp> memberMap;
100100

101-
// The list of associated parent object symbols. used to track data we
102-
// need for various parent processing tasks when performing member
103-
// mapping, the main example currently being re-evaluating the parent
104-
// maps bounds at the final step of map processing, where we need to
105-
// keep a hold of all of the omp::Object's which contain array bounds
106-
// for the respective parent to calculate the final bounds from.
107-
//
108-
// As an Example:
109-
//
110-
// !$omp target map(tofrom: alloca_dtype_arr(2)%array_i,
111-
// alloca_dtype_arr(3)%array_i)
112-
//
113-
// parentObjList will contain alloca_dtype_arr(3) as well as
114-
// alloca_dtype_arr(2).
115-
ObjectList parentObjList;
101+
bool isDuplicateMemberMapInfo(llvm::SmallVectorImpl<int64_t> &memberIndices) {
102+
return llvm::find_if(memberPlacementIndices, [&](auto &memberData) {
103+
return llvm::equal(memberIndices, memberData);
104+
}) != memberPlacementIndices.end();
105+
}
106+
107+
void addChildIndexAndMapToParent(const omp::Object &object,
108+
mlir::omp::MapInfoOp &mapOp,
109+
semantics::SemanticsContext &semaCtx);
116110
};
117111

112+
mlir::omp::MapInfoOp
113+
createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
114+
mlir::Value baseAddr, mlir::Value varPtrPtr,
115+
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
116+
llvm::ArrayRef<mlir::Value> members,
117+
mlir::ArrayAttr membersIndex, uint64_t mapType,
118+
mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
119+
bool partialMap = false);
120+
121+
void insertChildMapInfoIntoParent(
122+
Fortran::lower::AbstractConverter &converter,
123+
Fortran::semantics::SemanticsContext &semaCtx,
124+
Fortran::lower::StatementContext &stmtCtx,
125+
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
126+
llvm::SmallVectorImpl<mlir::Value> &mapOperands,
127+
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms);
128+
118129
void generateMemberPlacementIndices(
119130
const Object &object, llvm::SmallVectorImpl<int64_t> &indices,
120131
Fortran::semantics::SemanticsContext &semaCtx);
121132

122133
bool isMemberOrParentAllocatableOrPointer(
123134
const Object &object, Fortran::semantics::SemanticsContext &semaCtx);
124135

125-
bool isDuplicateMemberMapInfo(OmpMapParentAndMemberData &parentMembers,
126-
llvm::SmallVectorImpl<int64_t> &memberIndices);
127-
128-
mlir::omp::MapInfoOp createMapInfoOp(
129-
fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value baseAddr,
130-
mlir::Value varPtrPtr, std::string name, mlir::ArrayRef<mlir::Value> bounds,
131-
mlir::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
132-
uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
133-
mlir::Type retTy, bool partialMap = false);
134-
135136
mlir::Value createParentSymAndGenIntermediateMaps(
136137
mlir::Location clauseLocation, Fortran::lower::AbstractConverter &converter,
137138
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
138-
omp::ObjectList &objectList, llvm::SmallVector<int64_t> &indices,
139-
OmpMapParentAndMemberData &parentMemberIndices, std::string asFortran,
139+
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
140+
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
140141
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits);
141142

142-
omp::ObjectList gatherObjects(omp::Object obj,
143-
semantics::SemanticsContext &semaCtx);
144-
145-
void addChildIndexAndMapToParent(const omp::Object &object,
146-
OmpMapParentAndMemberData &parentMemberIndices,
147-
mlir::omp::MapInfoOp &mapOp,
148-
semantics::SemanticsContext &semaCtx);
149-
150-
void insertChildMapInfoIntoParent(
151-
Fortran::lower::AbstractConverter &converter,
152-
Fortran::semantics::SemanticsContext &semaCtx,
153-
Fortran::lower::StatementContext &stmtCtx,
154-
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
155-
llvm::SmallVectorImpl<mlir::Value> &mapOperands,
156-
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &mapSymbols);
143+
omp::ObjectList gatherObjectsOf(omp::Object derivedTypeMember,
144+
semantics::SemanticsContext &semaCtx);
157145

158146
mlir::Type getLoopVarType(lower::AbstractConverter &converter,
159147
std::size_t loopVarTypeSize);

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,8 @@ static void genLoopOp(lower::AbstractConverter &converter,
19181918
DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval,
19191919
/*shouldCollectPreDeterminedSymbols=*/true,
19201920
/*useDelayedPrivatization=*/true, &symTable);
1921-
dsp.processStep1(&loopClauseOps);
1921+
dsp.processStep1();
1922+
dsp.processStep2(&loopClauseOps);
19221923

19231924
mlir::omp::LoopNestOperands loopNestClauseOps;
19241925
llvm::SmallVector<const semantics::Symbol *> iv;

flang/lib/Lower/OpenMP/Utils.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,6 @@ void insertChildMapInfoIntoParent(
583583
info.rawInput.getType(),
584584
/*partialMap=*/true);
585585

586-
extendBoundsFromMultipleSubscripts(converter, stmtCtx, mapOp,
587-
indices.second.parentObjList);
588586
mapOperands.push_back(mapOp);
589587
mapSyms.push_back(indices.first.sym());
590588
}

flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,6 @@ class MapInfoFinalizationPass
319319
return newDescParentMapOp;
320320
}
321321

322-
323-
324-
325322
// We add all mapped record members not directly used in the target region
326323
// to the block arguments in front of their parent and we place them into
327324
// the map operands list for consistency.
@@ -373,50 +370,47 @@ class MapInfoFinalizationPass
373370
if (!mapClauseOwner)
374371
return;
375372

376-
auto addOperands = [&](mlir::MutableOperandRange &mutableOpRange,
373+
auto addOperands = [&](mlir::MutableOperandRange &mapVarsArr,
377374
mlir::Operation *directiveOp,
378375
unsigned blockArgInsertIndex = 0) {
379-
if (!llvm::is_contained(mutableOpRange.getAsOperandRange(),
380-
op.getResult()))
376+
if (!llvm::is_contained(mapVarsArr.getAsOperandRange(), op.getResult()))
381377
return;
382378

383379
// There doesn't appear to be a simple way to convert MutableOperandRange
384380
// to a vector currently, so we instead use a for_each to populate our
385381
// vector.
386382
llvm::SmallVector<mlir::Value> newMapOps;
387-
newMapOps.reserve(mutableOpRange.size());
383+
newMapOps.reserve(mapVarsArr.size());
388384
llvm::for_each(
389-
mutableOpRange.getAsOperandRange(),
385+
mapVarsArr.getAsOperandRange(),
390386
[&newMapOps](mlir::Value oper) { newMapOps.push_back(oper); });
391387

392388
for (auto mapMember : op.getMembers()) {
393-
if (llvm::is_contained(mutableOpRange.getAsOperandRange(), mapMember))
389+
if (llvm::is_contained(mapVarsArr.getAsOperandRange(), mapMember))
394390
continue;
395391
newMapOps.push_back(mapMember);
396392
if (directiveOp) {
397393
directiveOp->getRegion(0).insertArgument(
398394
blockArgInsertIndex, mapMember.getType(), mapMember.getLoc());
399395
blockArgInsertIndex++;
400396
}
401-
newMapOps.push_back(mapVar.get());
402397
}
403398

404-
mutableOpRange.assign(newMapOps);
399+
mapVarsArr.assign(newMapOps);
405400
};
406401

407402
auto argIface =
408403
llvm::dyn_cast<mlir::omp::BlockArgOpenMPOpInterface>(target);
409404

410405
if (auto mapClauseOwner =
411406
llvm::dyn_cast<mlir::omp::MapClauseOwningOpInterface>(target)) {
412-
mlir::MutableOperandRange mapMutableOpRange =
413-
mapClauseOwner.getMapVarsMutable();
407+
mlir::MutableOperandRange mapVarsArr = mapClauseOwner.getMapVarsMutable();
414408
unsigned blockArgInsertIndex =
415409
argIface
416410
? argIface.getMapBlockArgsStart() + argIface.numMapBlockArgs()
417411
: 0;
418412
addOperands(
419-
mapMutableOpRange,
413+
mapVarsArr,
420414
llvm::dyn_cast_or_null<mlir::omp::TargetOp>(argIface.getOperation()),
421415
blockArgInsertIndex);
422416
}

flang/test/Semantics/OpenMP/combined-constructs.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=11
22

33
program main
44
implicit none

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,13 +3242,10 @@ static llvm::omp::OpenMPOffloadMappingFlags mapParentWithMembers(
32423242
auto mapOp = dyn_cast<omp::MapInfoOp>(mapData.MapClause[mapDataIndex]);
32433243
int firstMemberIdx = getMapDataMemberIdx(
32443244
mapData, getFirstOrLastMappedMemberPtr(mapOp, true));
3245-
int lastMemberIdx = getMapDataMemberIdx(
3246-
mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
3247-
3248-
// NOTE/TODO: Should perhaps use OriginalValue here instead of Pointers to
3249-
// avoid offset or any manipulations interfering with the calculation.
32503245
lowAddr = builder.CreatePointerCast(mapData.Pointers[firstMemberIdx],
32513246
builder.getPtrTy());
3247+
int lastMemberIdx = getMapDataMemberIdx(
3248+
mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
32523249
highAddr = builder.CreatePointerCast(
32533250
builder.CreateGEP(mapData.BaseType[lastMemberIdx],
32543251
mapData.Pointers[lastMemberIdx], builder.getInt64(1)),
@@ -3280,7 +3277,7 @@ static llvm::omp::OpenMPOffloadMappingFlags mapParentWithMembers(
32803277
ompBuilder.setCorrectMemberOfFlag(mapFlag, memberOfFlag);
32813278
combinedInfo.Types.emplace_back(mapFlag);
32823279
combinedInfo.DevicePointers.emplace_back(
3283-
mapData.DevicePointers[mapDataIndex]);
3280+
llvm::OpenMPIRBuilder::DeviceInfoTy::None);
32843281
combinedInfo.Names.emplace_back(LLVM::createMappingInformation(
32853282
mapData.MapClause[mapDataIndex]->getLoc(), ompBuilder));
32863283
combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIndex]);

0 commit comments

Comments
 (0)