[llvm-branch-commits] [flang] [flang][OpenMP] Use GetOmpDirectiveName to find directive source loca… (PR #150955)
Krzysztof Parzyszek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 28 07:08:18 PDT 2025
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/150955
…tion
>From 0d64559614272cdf5bfa021d7120a273567f1e2d Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Mon, 28 Jul 2025 08:58:06 -0500
Subject: [PATCH] [flang][OpenMP] Use GetOmpDirectiveName to find directive
source location
---
.../lib/Lower/OpenMP/DataSharingProcessor.cpp | 52 +++++--------------
1 file changed, 13 insertions(+), 39 deletions(-)
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 2ac4d9548b65b..2c0cbb2b6168f 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -389,42 +389,16 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
}
}
-static const parser::CharBlock *
-getSource(const semantics::SemanticsContext &semaCtx,
- const lower::pft::Evaluation &eval) {
- const parser::CharBlock *source = nullptr;
-
- auto ompConsVisit = [&](const parser::OpenMPConstruct &x) {
- std::visit(
- common::visitors{
- [&](const parser::OpenMPSectionsConstruct &x) {
- source = &std::get<0>(x.t).source;
- },
- [&](const parser::OpenMPLoopConstruct &x) {
- source = &std::get<0>(x.t).source;
- },
- [&](const parser::OpenMPBlockConstruct &x) {
- source = &std::get<0>(x.t).source;
- },
- [&](const parser::OpenMPCriticalConstruct &x) {
- source = &std::get<0>(x.t).source;
- },
- [&](const parser::OpenMPAtomicConstruct &x) {
- source = &std::get<parser::OmpDirectiveSpecification>(x.t).source;
- },
- [&](const auto &x) { source = &x.source; },
- },
- x.u);
- };
-
- eval.visit(common::visitors{
- [&](const parser::OpenMPConstruct &x) { ompConsVisit(x); },
- [&](const parser::OpenMPDeclarativeConstruct &x) { source = &x.source; },
- [&](const parser::OmpEndLoopDirective &x) { source = &x.source; },
- [&](const auto &x) {},
+static parser::CharBlock getSource(const semantics::SemanticsContext &semaCtx,
+ const lower::pft::Evaluation &eval) {
+ return eval.visit(common::visitors{
+ [&](const parser::OpenMPConstruct &x) {
+ return parser::omp::GetOmpDirectiveName(x).source;
+ },
+ [&](const parser::OpenMPDeclarativeConstruct &x) { return x.source; },
+ [&](const parser::OmpEndLoopDirective &x) { return x.source; },
+ [&](const auto &x) { return parser::CharBlock{}; },
});
-
- return source;
}
static void collectPrivatizingConstructs(
@@ -518,11 +492,11 @@ void DataSharingProcessor::collectSymbols(
for (const semantics::Scope &child : scope->children())
collectScopes(&child);
};
- const parser::CharBlock *source =
- clauses.empty() ? getSource(semaCtx, eval) : &clauses.front().source;
+ parser::CharBlock source =
+ clauses.empty() ? getSource(semaCtx, eval) : clauses.front().source;
const semantics::Scope *curScope = nullptr;
- if (source && !source->empty()) {
- curScope = &semaCtx.FindScope(*source);
+ if (!source.empty()) {
+ curScope = &semaCtx.FindScope(source);
collectScopes(curScope);
}
// Collect all symbols referenced in the evaluation being processed,
More information about the llvm-branch-commits
mailing list