Skip to content

Commit

Permalink
[Flang][OpenMP] Added TODO checks for unsupported map types
Browse files Browse the repository at this point in the history
This patch adds TODO checks for unspported types in the map clause for OpenMP Target directives.

Example of unsupported code:

implicit none
character(len=10) :: str1, str2(5,5)

type t
  character(len=10) :: str1, str2(5,5)
end type t
type(t) :: v

!$omp target enter data map(to: str2(2,5))
!$omp target enter data map(to: v%str1)
!$omp target enter data map(to: v%str2)
!$omp target enter data map(to: v%str2(1,2))

end

Differential Revision: https://reviews.llvm.org/D146292
  • Loading branch information
TIFitis committed Mar 27, 2023
1 parent c3ee525 commit a1717a3
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions flang/lib/Lower/OpenMP.cpp
Expand Up @@ -683,7 +683,8 @@ createTargetDataOp(Fortran::lower::AbstractConverter &converter,
llvm::SmallVector<mlir::IntegerAttr> mapTypes;

auto addMapClause = [&firOpBuilder, &converter, &mapOperands,
&mapTypes](const auto &mapClause) {
&mapTypes](const auto &mapClause,
mlir::Location &currentLocation) {
auto mapType = std::get<Fortran::parser::OmpMapType::Type>(
std::get<std::optional<Fortran::parser::OmpMapType>>(mapClause->v.t)
->t);
Expand Down Expand Up @@ -725,10 +726,26 @@ createTargetDataOp(Fortran::lower::AbstractConverter &converter,
mapTypeBits));

llvm::SmallVector<mlir::Value> mapOperand;
/// Check for unsupported map operand types.
for (const Fortran::parser::OmpObject &ompObject :
std::get<Fortran::parser::OmpObjectList>(mapClause->v.t).v) {
if (Fortran::parser::Unwrap<Fortran::parser::ArrayElement>(ompObject) ||
Fortran::parser::Unwrap<Fortran::parser::StructureComponent>(
ompObject))
TODO(currentLocation,
"OMPD_target_data for Array Expressions or Structure Components");
}
genObjectList(std::get<Fortran::parser::OmpObjectList>(mapClause->v.t),
converter, mapOperand);

for (mlir::Value mapOp : mapOperand) {
/// Check for unsupported map operand types.
mlir::Type checkType = mapOp.getType();
if (auto refType = checkType.dyn_cast<fir::ReferenceType>())
checkType = refType.getElementType();
if (checkType.isa<fir::BoxType>())
TODO(currentLocation, "OMPD_target_data MapOperand BoxType");

mapOperands.push_back(mapOp);
mapTypes.push_back(mapTypeAttr);
}
Expand Down Expand Up @@ -764,7 +781,7 @@ createTargetDataOp(Fortran::lower::AbstractConverter &converter,
nowaitAttr = firOpBuilder.getUnitAttr();
} else if (const auto &mapClause =
std::get_if<Fortran::parser::OmpClause::Map>(&clause.u)) {
addMapClause(mapClause);
addMapClause(mapClause, currentLocation);
} else {
TODO(currentLocation, "OMPD_target unhandled clause");
}
Expand Down

0 comments on commit a1717a3

Please sign in to comment.