@@ -3132,52 +3132,37 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
3132
3132
" Expected derived type" );
3133
3133
3134
3134
std::string mapperNameStr;
3135
- if (mapperName.has_value ())
3135
+ if (mapperName.has_value ()) {
3136
3136
mapperNameStr = mapperName->ToString ();
3137
- else
3138
3137
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 ());
3140
3150
auto mlirType = converter.genType (varType.declTypeSpec ->derivedTypeSpec ());
3141
3151
auto declMapperOp = firOpBuilder.create <mlir::omp::DeclareMapperOp>(
3142
3152
loc, mapperNameStr, mlirType);
3153
+ converter.getMLIRSymbolTable ()->insert (declMapperOp);
3143
3154
auto ®ion = declMapperOp.getRegion ();
3144
-
3145
- // Save insert point just after the DeclMapperOp.
3146
- mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint ();
3147
3155
firOpBuilder.createBlock (®ion);
3148
- auto varVal =
3149
- firOpBuilder.createTemporaryAlloc (loc, mlirType, varName.ToString ());
3156
+ auto varVal = region.addArgument (firOpBuilder.getRefType (mlirType), loc);
3150
3157
converter.bindSymbol (*varName.symbol , varVal);
3151
3158
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
-
3173
3159
// Populate the declareMapper region with the map information.
3174
3160
mlir::omp::DeclareMapperInfoOperands clauseOps;
3175
3161
const auto *clauseList{
3176
3162
parser::Unwrap<parser::OmpClauseList>(declareMapperConstruct.t )};
3177
3163
List<Clause> clauses = makeClauses (*clauseList, semaCtx);
3178
3164
ClauseProcessor cp (converter, semaCtx, clauses);
3179
3165
cp.processMap (loc, stmtCtx, clauseOps);
3180
-
3181
3166
firOpBuilder.create <mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars );
3182
3167
3183
3168
// Restore the insert point to just after the DeclareMapperOp.
0 commit comments