@@ -58,6 +58,13 @@ namespace {
5858class MapInfoFinalizationPass
5959 : public flangomp::impl::MapInfoFinalizationPassBase<
6060 MapInfoFinalizationPass> {
61+ public:
62+ MapInfoFinalizationPass () = default ;
63+
64+ MapInfoFinalizationPass (
65+ const flangomp::MapInfoFinalizationPassOptions &options)
66+ : MapInfoFinalizationPassBase(options) {}
67+
6168 // / Helper class tracking a members parent and its
6269 // / placement in the parents member list
6370 struct ParentAndPlacement {
@@ -954,17 +961,20 @@ class MapInfoFinalizationPass
954961 // within a target region. At which point we map the relevant descriptor
955962 // data and the runtime should correctly associate the data with the
956963 // descriptor and bind together and allow clean mapping and execution.
957- func->walk ([&](mlir::omp::MapInfoOp op) {
958- if (fir::isTypeWithDescriptor (op.getVarType ()) ||
959- mlir::isa_and_present<fir::BoxAddrOp>(
960- op.getVarPtr ().getDefiningOp ())) {
961- mlir::Operation *targetUser = getFirstTargetUser (op);
962- assert (targetUser && " expected user of map operation was not found" );
963- builder.setInsertionPoint (op);
964- removeTopLevelDescriptor (op, builder, targetUser);
965- addImplictDescriptorMapToTargetDataOp (op, builder, targetUser);
966- }
967- });
964+ if (deferDescMapping) {
965+ func->walk ([&](mlir::omp::MapInfoOp op) {
966+ if (fir::isTypeWithDescriptor (op.getVarType ()) ||
967+ mlir::isa_and_present<fir::BoxAddrOp>(
968+ op.getVarPtr ().getDefiningOp ())) {
969+ mlir::Operation *targetUser = getFirstTargetUser (op);
970+ assert (targetUser &&
971+ " expected user of map operation was not found" );
972+ builder.setInsertionPoint (op);
973+ removeTopLevelDescriptor (op, builder, targetUser);
974+ addImplictDescriptorMapToTargetDataOp (op, builder, targetUser);
975+ }
976+ });
977+ }
968978
969979 // Wait until after we have generated all of our maps to add them onto
970980 // the target's block arguments, simplifying the process as there would be
@@ -977,5 +987,11 @@ class MapInfoFinalizationPass
977987 });
978988 }
979989};
980-
981990} // namespace
991+
992+ std::unique_ptr<mlir::Pass>
993+ flangomp::createMapInfoFinalizationPass (bool deferDescMap) {
994+ MapInfoFinalizationPassOptions options;
995+ options.deferDescMapping = deferDescMap;
996+ return std::make_unique<MapInfoFinalizationPass>(options);
997+ }
0 commit comments