[llvm-branch-commits] [flang] [llvm] [Flang][OpenMP] Prevent re-composition of composite constructs (PR #102613)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 9 07:31:34 PDT 2024
================
@@ -90,38 +83,33 @@ ConstructQueue buildConstructQueue(
Fortran::lower::pft::Evaluation &eval, const parser::CharBlock &source,
llvm::omp::Directive compound, const List<Clause> &clauses) {
- List<UnitConstruct> constructs;
-
ConstructDecomposition decompose(modOp, semaCtx, eval, compound, clauses);
assert(!decompose.output.empty() && "Construct decomposition failed");
- llvm::SmallVector<llvm::omp::Directive> loweringUnits;
- std::ignore =
- llvm::omp::getLeafOrCompositeConstructs(compound, loweringUnits);
- uint32_t version = getOpenMPVersionAttribute(modOp);
-
- int leafIndex = 0;
- for (llvm::omp::Directive dir_id : loweringUnits) {
- llvm::ArrayRef<llvm::omp::Directive> leafsOrSelf =
- llvm::omp::getLeafConstructsOrSelf(dir_id);
- size_t numLeafs = leafsOrSelf.size();
-
- llvm::ArrayRef<UnitConstruct> toMerge{&decompose.output[leafIndex],
- numLeafs};
- auto &uc = constructs.emplace_back(mergeConstructs(version, toMerge));
-
- if (!transferLocations(clauses, uc.clauses)) {
- // If some clauses are left without source information, use the
- // directive's source.
- for (auto &clause : uc.clauses) {
- if (clause.source.empty())
- clause.source = source;
- }
- }
- leafIndex += numLeafs;
+ for (UnitConstruct &uc : decompose.output) {
+ assert(getLeafConstructs(uc.id).empty() && "unexpected compound directive");
+ // If some clauses are left without source information, use the directive's
+ // source.
+ for (auto &clause : uc.clauses)
+ if (clause.source.empty())
+ clause.source = source;
}
- return constructs;
+ return decompose.output;
+}
+
+bool matchLeafSequence(ConstructQueue::const_iterator item,
+ const ConstructQueue &queue,
+ llvm::ArrayRef<llvm::omp::Directive> directives) {
+ for (auto [dir, leaf] :
+ llvm::zip_longest(directives, llvm::make_range(item, queue.end()))) {
+ if (!dir || !leaf)
----------------
skatrak wrote:
`llvm::zip_longest` returns two `std::optional` (for when ranges are not the same size), which is what this is checking, not the actual integer value of the directive. I made some changes to avoid confusion.
https://github.com/llvm/llvm-project/pull/102613
More information about the llvm-branch-commits
mailing list