[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 Aug 12 08:42:15 PDT 2024
================
@@ -175,99 +271,63 @@ getComponentObject(std::optional<Object> object,
return getComponentObject(baseObj.value(), semaCtx);
}
-static void
-generateMemberPlacementIndices(const Object &object,
- llvm::SmallVectorImpl<int> &indices,
- semantics::SemanticsContext &semaCtx) {
+void generateMemberPlacementIndices(const Object &object,
+ llvm::SmallVectorImpl<int64_t> &indices,
+ semantics::SemanticsContext &semaCtx) {
auto compObj = getComponentObject(object, semaCtx);
while (compObj) {
- indices.push_back(getComponentPlacementInParent(compObj->sym()));
+ int64_t index = getComponentPlacementInParent(compObj->sym());
+ assert(index >= 0);
+ indices.push_back(index);
compObj =
getComponentObject(getBaseObject(compObj.value(), semaCtx), semaCtx);
}
- indices = llvm::SmallVector<int>{llvm::reverse(indices)};
+ indices = llvm::SmallVector<int64_t>{llvm::reverse(indices)};
----------------
skatrak wrote:
Nit: How about doing the reversal in place to avoid allocations? Some combination of `llvm::zip_equal(indices, llvm::reverse(indices))` and `std::swap` perhaps?
https://github.com/llvm/llvm-project/pull/96266
More information about the llvm-branch-commits
mailing list