@@ -53,6 +53,7 @@ class OpenACCClauseCIREmitter final
53
53
template <typename FriendOpTy> friend class OpenACCClauseCIREmitter ;
54
54
55
55
OpTy &operation;
56
+ mlir::OpBuilder::InsertPoint &recipeInsertLocation;
56
57
CIRGen::CIRGenFunction &cgf;
57
58
CIRGen::CIRGenBuilderTy &builder;
58
59
@@ -148,7 +149,7 @@ class OpenACCClauseCIREmitter final
148
149
mlir::OpBuilder::InsertionGuard guardCase (builder);
149
150
builder.setInsertionPoint (operation.loopOp );
150
151
OpenACCClauseCIREmitter<mlir::acc::LoopOp> loopEmitter{
151
- operation.loopOp , cgf, builder, dirKind, dirLoc};
152
+ operation.loopOp , recipeInsertLocation, cgf, builder, dirKind, dirLoc};
152
153
loopEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
153
154
loopEmitter.Visit (&c);
154
155
}
@@ -159,7 +160,12 @@ class OpenACCClauseCIREmitter final
159
160
mlir::OpBuilder::InsertionGuard guardCase (builder);
160
161
builder.setInsertionPoint (operation.computeOp );
161
162
OpenACCClauseCIREmitter<typename OpTy::ComputeOpTy> computeEmitter{
162
- operation.computeOp , cgf, builder, dirKind, dirLoc};
163
+ operation.computeOp ,
164
+ recipeInsertLocation,
165
+ cgf,
166
+ builder,
167
+ dirKind,
168
+ dirLoc};
163
169
164
170
computeEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
165
171
@@ -358,11 +364,13 @@ class OpenACCClauseCIREmitter final
358
364
}
359
365
360
366
public:
361
- OpenACCClauseCIREmitter (OpTy &operation, CIRGen::CIRGenFunction &cgf,
367
+ OpenACCClauseCIREmitter (OpTy &operation,
368
+ mlir::OpBuilder::InsertPoint &recipeInsertLocation,
369
+ CIRGen::CIRGenFunction &cgf,
362
370
CIRGen::CIRGenBuilderTy &builder,
363
371
OpenACCDirectiveKind dirKind, SourceLocation dirLoc)
364
- : operation(operation), cgf(cgf), builder(builder), dirKind(dirKind ),
365
- dirLoc (dirLoc) {}
372
+ : operation(operation), recipeInsertLocation(recipeInsertLocation ),
373
+ cgf (cgf), builder(builder), dirKind(dirKind), dirLoc(dirLoc) {}
366
374
367
375
void VisitClause (const OpenACCClause &clause) {
368
376
clauseNotImplemented (clause);
@@ -992,8 +1000,8 @@ class OpenACCClauseCIREmitter final
992
1000
auto recipe =
993
1001
OpenACCRecipeBuilder<mlir::acc::PrivateRecipeOp>(cgf, builder)
994
1002
.getOrCreateRecipe (
995
- cgf.getContext (), varExpr, varRecipe. AllocaDecl ,
996
- varRecipe.InitExpr ,
1003
+ cgf.getContext (), recipeInsertLocation, varExpr ,
1004
+ varRecipe.AllocaDecl , varRecipe. InitExpr ,
997
1005
/* temporary=*/ nullptr , OpenACCReductionOperator::Invalid,
998
1006
Decl::castToDeclContext (cgf.curFuncDecl ), opInfo.origType ,
999
1007
opInfo.bounds .size (), opInfo.boundTypes , opInfo.baseType ,
@@ -1039,8 +1047,9 @@ class OpenACCClauseCIREmitter final
1039
1047
OpenACCRecipeBuilder<mlir::acc::FirstprivateRecipeOp>(cgf,
1040
1048
builder)
1041
1049
.getOrCreateRecipe (
1042
- cgf.getContext (), varExpr, varRecipe.AllocaDecl ,
1043
- varRecipe.InitExpr , varRecipe.InitFromTemporary ,
1050
+ cgf.getContext (), recipeInsertLocation, varExpr,
1051
+ varRecipe.AllocaDecl , varRecipe.InitExpr ,
1052
+ varRecipe.InitFromTemporary ,
1044
1053
OpenACCReductionOperator::Invalid,
1045
1054
Decl::castToDeclContext (cgf.curFuncDecl ), opInfo.origType ,
1046
1055
opInfo.bounds .size (), opInfo.boundTypes , opInfo.baseType ,
@@ -1087,8 +1096,8 @@ class OpenACCClauseCIREmitter final
1087
1096
auto recipe =
1088
1097
OpenACCRecipeBuilder<mlir::acc::ReductionRecipeOp>(cgf, builder)
1089
1098
.getOrCreateRecipe (
1090
- cgf.getContext (), varExpr, varRecipe. AllocaDecl ,
1091
- varRecipe.InitExpr ,
1099
+ cgf.getContext (), recipeInsertLocation, varExpr ,
1100
+ varRecipe.AllocaDecl , varRecipe. InitExpr ,
1092
1101
/* temporary=*/ nullptr , clause.getReductionOp (),
1093
1102
Decl::castToDeclContext (cgf.curFuncDecl ), opInfo.origType ,
1094
1103
opInfo.bounds .size (), opInfo.boundTypes , opInfo.baseType ,
@@ -1108,10 +1117,13 @@ class OpenACCClauseCIREmitter final
1108
1117
};
1109
1118
1110
1119
template <typename OpTy>
1111
- auto makeClauseEmitter (OpTy &op, CIRGen::CIRGenFunction &cgf,
1120
+ auto makeClauseEmitter (OpTy &op,
1121
+ mlir::OpBuilder::InsertPoint &recipeInsertLocation,
1122
+ CIRGen::CIRGenFunction &cgf,
1112
1123
CIRGen::CIRGenBuilderTy &builder,
1113
1124
OpenACCDirectiveKind dirKind, SourceLocation dirLoc) {
1114
- return OpenACCClauseCIREmitter<OpTy>(op, cgf, builder, dirKind, dirLoc);
1125
+ return OpenACCClauseCIREmitter<OpTy>(op, recipeInsertLocation, cgf, builder,
1126
+ dirKind, dirLoc);
1115
1127
}
1116
1128
} // namespace
1117
1129
@@ -1124,7 +1136,8 @@ void CIRGenFunction::emitOpenACCClauses(
1124
1136
// Sets insertion point before the 'op', since every new expression needs to
1125
1137
// be before the operation.
1126
1138
builder.setInsertionPoint (op);
1127
- makeClauseEmitter (op, *this , builder, dirKind, dirLoc).emitClauses (clauses);
1139
+ makeClauseEmitter (op, lastRecipeLocation, *this , builder, dirKind, dirLoc)
1140
+ .emitClauses (clauses);
1128
1141
}
1129
1142
1130
1143
#define EXPL_SPEC (N ) \
@@ -1156,7 +1169,8 @@ void CIRGenFunction::emitOpenACCClauses(
1156
1169
// We cannot set the insertion point here and do so in the emitter, but make
1157
1170
// sure we reset it with the 'guard' anyway.
1158
1171
mlir::OpBuilder::InsertionGuard guardCase (builder);
1159
- makeClauseEmitter (inf, *this , builder, dirKind, dirLoc).emitClauses (clauses);
1172
+ makeClauseEmitter (inf, lastRecipeLocation, *this , builder, dirKind, dirLoc)
1173
+ .emitClauses (clauses);
1160
1174
}
1161
1175
1162
1176
#define EXPL_SPEC (N ) \
0 commit comments