From d45d707434f0298883cc9b8219902f8f93b358ec Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Fri, 24 Jun 2022 21:03:00 +0200 Subject: [PATCH] [flang] Explicitly map host associated symbols Explicitly map host associated symbols in DoConcurrent with shared locality-spec, clauses in OpenMP/OpenACC. The mapping of host-assoc symbols is set to their parent SymbolBox. This is achieved through a new interface function in the AbstractConverter. This was already upstream for OpenMP. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128518 Co-authored-by: Kiran Chandramohan --- flang/lib/Lower/OpenACC.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 533680e967db..260db752d3e6 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -35,20 +35,30 @@ getDesignatorNameIfDataRef(const Fortran::parser::Designator &designator) { static void genObjectList(const Fortran::parser::AccObjectList &objectList, Fortran::lower::AbstractConverter &converter, llvm::SmallVectorImpl &operands) { + auto addOperands = [&](Fortran::lower::SymbolRef sym) { + const auto variable = converter.getSymbolAddress(sym); + // TODO: Might need revisiting to handle for non-shared clauses + if (variable) { + operands.push_back(variable); + } else { + if (const auto *details = + sym->detailsIf()) + operands.push_back(converter.getSymbolAddress(details->symbol())); + } + }; + for (const auto &accObject : objectList.v) { - std::visit( - Fortran::common::visitors{ - [&](const Fortran::parser::Designator &designator) { - if (const auto *name = getDesignatorNameIfDataRef(designator)) { - const auto variable = converter.getSymbolAddress(*name->symbol); - operands.push_back(variable); - } - }, - [&](const Fortran::parser::Name &name) { - const auto variable = converter.getSymbolAddress(*name.symbol); - operands.push_back(variable); - }}, - accObject.u); + std::visit(Fortran::common::visitors{ + [&](const Fortran::parser::Designator &designator) { + if (const auto *name = + getDesignatorNameIfDataRef(designator)) { + addOperands(*name->symbol); + } + }, + [&](const Fortran::parser::Name &name) { + addOperands(*name.symbol); + }}, + accObject.u); } }