@@ -425,6 +425,7 @@ class OpenACCClauseCIREmitter final
425425 &recipe.getCopyRegion (), recipe.getCopyRegion ().end (),
426426 {mainOp.getType (), mainOp.getType ()}, {loc, loc});
427427 builder.setInsertionPointToEnd (&recipe.getCopyRegion ().back ());
428+ CIRGenFunction::LexicalScope ls (cgf, loc, block);
428429
429430 mlir::BlockArgument fromArg = block->getArgument (0 );
430431 mlir::BlockArgument toArg = block->getArgument (1 );
@@ -457,21 +458,19 @@ class OpenACCClauseCIREmitter final
457458 RecipeTy recipe, const VarDecl *varRecipe,
458459 const VarDecl *temporary) {
459460 assert (varRecipe && " Required recipe variable not set?" );
460- if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
461- // We haven't implemented the 'init' recipe for Reduction yet, so NYI
462- // it.
463- cgf.cgm .errorNYI (exprRange, " OpenACC Reduction recipe init" );
464- }
465461
466462 CIRGenFunction::AutoVarEmission tempDeclEmission{
467463 CIRGenFunction::AutoVarEmission::invalid ()};
468464 CIRGenFunction::DeclMapRevertingRAII declMapRAII{cgf, varRecipe};
469465
470466 // Do the 'init' section of the recipe IR, which does an alloca, then the
471467 // initialization (except for firstprivate).
472- builder.createBlock (&recipe.getInitRegion (), recipe.getInitRegion ().end (),
473- {mainOp.getType ()}, {loc});
468+ mlir::Block *block = builder.createBlock (&recipe.getInitRegion (),
469+ recipe.getInitRegion ().end (),
470+ {mainOp.getType ()}, {loc});
474471 builder.setInsertionPointToEnd (&recipe.getInitRegion ().back ());
472+ CIRGenFunction::LexicalScope ls (cgf, loc, block);
473+
475474 tempDeclEmission =
476475 cgf.emitAutoVarAlloca (*varRecipe, builder.saveInsertionPoint ());
477476
@@ -496,6 +495,13 @@ class OpenACCClauseCIREmitter final
496495 cgf.cgm .errorNYI (exprRange, " private default-init recipe" );
497496 }
498497 cgf.emitAutoVarInit (tempDeclEmission);
498+ } else if constexpr (std::is_same_v<RecipeTy,
499+ mlir::acc::ReductionRecipeOp>) {
500+ // Unlike Private, the recipe here is always required as it has to do
501+ // init, not just 'default' init.
502+ if (!varRecipe->getInit ())
503+ cgf.cgm .errorNYI (exprRange, " reduction init recipe" );
504+ cgf.emitAutoVarInit (tempDeclEmission);
499505 }
500506
501507 mlir::acc::YieldOp::create (builder, locEnd);
@@ -527,6 +533,7 @@ class OpenACCClauseCIREmitter final
527533 &recipe.getCombinerRegion (), recipe.getCombinerRegion ().end (),
528534 {mainOp.getType (), mainOp.getType ()}, {loc, loc});
529535 builder.setInsertionPointToEnd (&recipe.getCombinerRegion ().back ());
536+ CIRGenFunction::LexicalScope ls (cgf, loc, block);
530537
531538 mlir::BlockArgument lhsArg = block->getArgument (0 );
532539
@@ -544,6 +551,7 @@ class OpenACCClauseCIREmitter final
544551 mlir::Block *block = builder.createBlock (
545552 &destroyRegion, destroyRegion.end (), {mainOp.getType ()}, {loc});
546553 builder.setInsertionPointToEnd (&destroyRegion.back ());
554+ CIRGenFunction::LexicalScope ls (cgf, loc, block);
547555
548556 mlir::Type elementTy =
549557 mlir::cast<cir::PointerType>(mainOp.getType ()).getPointee ();
0 commit comments