[llvm-branch-commits] [flang] [Flang][OpenMP] Derived type explicit allocatable member mapping (PR #96266)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 29 05:49:08 PDT 2024
================
@@ -189,85 +295,60 @@ generateMemberPlacementIndices(const Object &object,
indices = llvm::SmallVector<int>{llvm::reverse(indices)};
}
-void addChildIndexAndMapToParent(
- const omp::Object &object,
- std::map<const semantics::Symbol *,
- llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
- mlir::omp::MapInfoOp &mapOp, semantics::SemanticsContext &semaCtx) {
- std::optional<evaluate::DataRef> dataRef = ExtractDataRef(object.ref());
- assert(dataRef.has_value() &&
- "DataRef could not be extracted during mapping of derived type "
- "cannot proceed");
- const semantics::Symbol *parentSym = &dataRef->GetFirstSymbol();
- assert(parentSym && "Could not find parent symbol during lower of "
- "a component member in OpenMP map clause");
+void addChildIndexAndMapToParent(const omp::Object &object,
+ OmpMapMemberIndicesData &parentMemberIndices,
+ mlir::omp::MapInfoOp &mapOp,
+ semantics::SemanticsContext &semaCtx) {
llvm::SmallVector<int> indices;
generateMemberPlacementIndices(object, indices, semaCtx);
- parentMemberIndices[parentSym].push_back({indices, mapOp});
+ parentMemberIndices.memberPlacementIndices.push_back(indices);
+ parentMemberIndices.memberMap.push_back(mapOp);
}
-static void calculateShapeAndFillIndices(
- llvm::SmallVectorImpl<int64_t> &shape,
- llvm::SmallVectorImpl<OmpMapMemberIndicesData> &memberPlacementData) {
- shape.push_back(memberPlacementData.size());
- size_t largestIndicesSize =
- std::max_element(memberPlacementData.begin(), memberPlacementData.end(),
- [](auto a, auto b) {
- return a.memberPlacementIndices.size() <
- b.memberPlacementIndices.size();
- })
- ->memberPlacementIndices.size();
- shape.push_back(largestIndicesSize);
-
- // DenseElementsAttr expects a rectangular shape for the data, so all
- // index lists have to be of the same length, this emplaces -1 as filler.
- for (auto &v : memberPlacementData) {
- if (v.memberPlacementIndices.size() < largestIndicesSize) {
- auto *prevEnd = v.memberPlacementIndices.end();
- v.memberPlacementIndices.resize(largestIndicesSize);
- std::fill(prevEnd, v.memberPlacementIndices.end(), -1);
- }
+llvm::SmallVector<int>
----------------
skatrak wrote:
I think it would be better to take an `llvm::SmallVectorImpl<int> &` output argument.
https://github.com/llvm/llvm-project/pull/96266
More information about the llvm-branch-commits
mailing list