@@ -2625,52 +2625,37 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
2625
2625
" Expected derived type" );
2626
2626
2627
2627
std::string mapperNameStr;
2628
- if (mapperName.has_value ())
2628
+ if (mapperName.has_value ()) {
2629
2629
mapperNameStr = mapperName->ToString ();
2630
- else
2631
2630
mapperNameStr =
2632
- " default_" + varType.declTypeSpec ->derivedTypeSpec ().name ().ToString ();
2631
+ converter.mangleName (mapperNameStr, mapperName->symbol ->owner ());
2632
+ } else {
2633
+ mapperNameStr =
2634
+ varType.declTypeSpec ->derivedTypeSpec ().name ().ToString () + " .default" ;
2635
+ mapperNameStr = converter.mangleName (
2636
+ mapperNameStr, *varType.declTypeSpec ->derivedTypeSpec ().GetScope ());
2637
+ }
2638
+
2639
+ // Save insert point just after the DeclMapperOp.
2640
+ mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint ();
2641
+
2642
+ firOpBuilder.setInsertionPointToStart (converter.getModuleOp ().getBody ());
2633
2643
auto mlirType = converter.genType (varType.declTypeSpec ->derivedTypeSpec ());
2634
2644
auto declMapperOp = firOpBuilder.create <mlir::omp::DeclareMapperOp>(
2635
2645
loc, mapperNameStr, mlirType);
2646
+ converter.getMLIRSymbolTable ()->insert (declMapperOp);
2636
2647
auto ®ion = declMapperOp.getRegion ();
2637
-
2638
- // Save insert point just after the DeclMapperOp.
2639
- mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint ();
2640
2648
firOpBuilder.createBlock (®ion);
2641
- auto varVal =
2642
- firOpBuilder.createTemporaryAlloc (loc, mlirType, varName.ToString ());
2649
+ auto varVal = region.addArgument (firOpBuilder.getRefType (mlirType), loc);
2643
2650
converter.bindSymbol (*varName.symbol , varVal);
2644
2651
2645
- // Insert dummy instruction to remember the insertion position. The
2646
- // marker will be deleted by clean up passes since there are no uses.
2647
- // Remembering the position for further insertion is important since
2648
- // there are hlfir.declares inserted above while setting block arguments
2649
- // and new code from the body should be inserted after that.
2650
- mlir::Value undefMarker =
2651
- firOpBuilder.create <fir::UndefOp>(loc, firOpBuilder.getIndexType ());
2652
-
2653
- // Create blocks for unstructured regions. This has to be done since
2654
- // blocks are initially allocated with the function as the parent region.
2655
- if (eval.lowerAsUnstructured ()) {
2656
- lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp, mlir::omp::YieldOp>(
2657
- firOpBuilder, eval.getNestedEvaluations ());
2658
- }
2659
-
2660
- firOpBuilder.create <mlir::omp::TerminatorOp>(loc);
2661
-
2662
- // Set the insertion point after the marker.
2663
- firOpBuilder.setInsertionPointAfter (undefMarker.getDefiningOp ());
2664
- genNestedEvaluations (converter, eval);
2665
-
2666
2652
// Populate the declareMapper region with the map information.
2667
2653
mlir::omp::DeclareMapperInfoOperands clauseOps;
2668
2654
const auto *clauseList{
2669
2655
parser::Unwrap<parser::OmpClauseList>(declareMapperConstruct.t )};
2670
2656
List<Clause> clauses = makeClauses (*clauseList, semaCtx);
2671
2657
ClauseProcessor cp (converter, semaCtx, clauses);
2672
2658
cp.processMap (loc, stmtCtx, clauseOps);
2673
-
2674
2659
firOpBuilder.create <mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars );
2675
2660
2676
2661
// Restore the insert point to just after the DeclareMapperOp.
0 commit comments