@@ -3132,52 +3132,37 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
31323132 " Expected derived type" );
31333133
31343134 std::string mapperNameStr;
3135- if (mapperName.has_value ())
3135+ if (mapperName.has_value ()) {
31363136 mapperNameStr = mapperName->ToString ();
3137- else
31383137 mapperNameStr =
3139- " default_" + varType.declTypeSpec ->derivedTypeSpec ().name ().ToString ();
3138+ converter.mangleName (mapperNameStr, mapperName->symbol ->owner ());
3139+ } else {
3140+ mapperNameStr =
3141+ varType.declTypeSpec ->derivedTypeSpec ().name ().ToString () + " .default" ;
3142+ mapperNameStr = converter.mangleName (
3143+ mapperNameStr, *varType.declTypeSpec ->derivedTypeSpec ().GetScope ());
3144+ }
3145+
3146+ // Save insert point just after the DeclMapperOp.
3147+ mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint ();
3148+
3149+ firOpBuilder.setInsertionPointToStart (converter.getModuleOp ().getBody ());
31403150 auto mlirType = converter.genType (varType.declTypeSpec ->derivedTypeSpec ());
31413151 auto declMapperOp = firOpBuilder.create <mlir::omp::DeclareMapperOp>(
31423152 loc, mapperNameStr, mlirType);
3153+ converter.getMLIRSymbolTable ()->insert (declMapperOp);
31433154 auto ®ion = declMapperOp.getRegion ();
3144-
3145- // Save insert point just after the DeclMapperOp.
3146- mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint ();
31473155 firOpBuilder.createBlock (®ion);
3148- auto varVal =
3149- firOpBuilder.createTemporaryAlloc (loc, mlirType, varName.ToString ());
3156+ auto varVal = region.addArgument (firOpBuilder.getRefType (mlirType), loc);
31503157 converter.bindSymbol (*varName.symbol , varVal);
31513158
3152- // Insert dummy instruction to remember the insertion position. The
3153- // marker will be deleted by clean up passes since there are no uses.
3154- // Remembering the position for further insertion is important since
3155- // there are hlfir.declares inserted above while setting block arguments
3156- // and new code from the body should be inserted after that.
3157- mlir::Value undefMarker =
3158- firOpBuilder.create <fir::UndefOp>(loc, firOpBuilder.getIndexType ());
3159-
3160- // Create blocks for unstructured regions. This has to be done since
3161- // blocks are initially allocated with the function as the parent region.
3162- if (eval.lowerAsUnstructured ()) {
3163- lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp, mlir::omp::YieldOp>(
3164- firOpBuilder, eval.getNestedEvaluations ());
3165- }
3166-
3167- firOpBuilder.create <mlir::omp::TerminatorOp>(loc);
3168-
3169- // Set the insertion point after the marker.
3170- firOpBuilder.setInsertionPointAfter (undefMarker.getDefiningOp ());
3171- genNestedEvaluations (converter, eval);
3172-
31733159 // Populate the declareMapper region with the map information.
31743160 mlir::omp::DeclareMapperInfoOperands clauseOps;
31753161 const auto *clauseList{
31763162 parser::Unwrap<parser::OmpClauseList>(declareMapperConstruct.t )};
31773163 List<Clause> clauses = makeClauses (*clauseList, semaCtx);
31783164 ClauseProcessor cp (converter, semaCtx, clauses);
31793165 cp.processMap (loc, stmtCtx, clauseOps);
3180-
31813166 firOpBuilder.create <mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars );
31823167
31833168 // Restore the insert point to just after the DeclareMapperOp.
0 commit comments