[flang-commits] [flang] [MLIR][OpenMP] Add Lowering support for implicitly linking to default declare mappers (PR #131006)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Thu Mar 13 03:00:08 PDT 2025
================
@@ -933,18 +933,42 @@ void ClauseProcessor::processMapObjects(
mlir::FlatSymbolRefAttr mapperId;
if (!mapperIdNameRef.empty() && !objects.empty()) {
std::string mapperIdName = mapperIdNameRef.str();
- if (mapperIdName == "default") {
- const omp::Object &object = objects.front();
- auto &typeSpec = object.sym()->owner().IsDerivedType()
- ? *object.sym()->owner().derivedTypeSpec()
- : object.sym()->GetType()->derivedTypeSpec();
- mapperIdName = typeSpec.name().ToString() + ".default";
- mapperIdName = converter.mangleName(mapperIdName, *typeSpec.GetScope());
+ if (mapperIdName == "implicit") {
+ if (!mlir::isa<mlir::omp::DeclareMapperOp>(
+ firOpBuilder.getRegion().getParentOp())) {
+ const omp::Object &object = objects.front();
+ const semantics::DerivedTypeSpec *typeSpec = nullptr;
+
+ if (object.sym()->owner().IsDerivedType())
+ typeSpec = object.sym()->owner().derivedTypeSpec();
+ else if (object.sym()->GetType() &&
+ object.sym()->GetType()->category() ==
+ semantics::DeclTypeSpec::TypeDerived)
+ typeSpec = &object.sym()->GetType()->derivedTypeSpec();
----------------
ergawy wrote:
Can you elaborate on why we need differnet approaches to find the `typeSpec` for implicit and default mappers? Can we extract the logic in one lambda for both cases?
Or, even better I think, it seems the logic for initializing `mapperIdName` and `mapperId` for both implicit and default cases is almost identical; with the exception that we assert if we did not find the default mapper AFAICT. Maybe this logic can be extracted in a lambda?
https://github.com/llvm/llvm-project/pull/131006
More information about the flang-commits
mailing list