@@ -542,6 +542,14 @@ static llvm::omp::ProcBindKind getProcBindKind(omp::ClauseProcBindKind kind) {
542
542
// / with entry block arguments is converted to LLVM. In this case \p blockArgs
543
543
// / are (part of) of the OpenMP region's entry arguments and \p operands are
544
544
// / (part of) of the operands to the OpenMP op containing the region.
545
+ // /
546
+ // / This function assumes that \p operands belong to the enclosing op of the
547
+ // / block containing \p blockArgs:
548
+ // / ```
549
+ // / enclosing_op(operands) {
550
+ // / block(blockArgs)
551
+ // / }
552
+ // / ```
545
553
static void forwardArgs (LLVM::ModuleTranslation &moduleTranslation,
546
554
omp::BlockArgOpenMPOpInterface blockArgIface) {
547
555
llvm::SmallVector<std::pair<Value, BlockArgument>> blockArgsPairs;
@@ -5300,7 +5308,6 @@ convertTargetDeviceOp(Operation *op, llvm::IRBuilderBase &builder,
5300
5308
return convertHostOrTargetOperation (op, builder, moduleTranslation);
5301
5309
}
5302
5310
5303
-
5304
5311
static LogicalResult
5305
5312
convertTargetOpsInNest (Operation *op, llvm::IRBuilderBase &builder,
5306
5313
LLVM::ModuleTranslation &moduleTranslation) {
@@ -5323,8 +5330,8 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
5323
5330
5324
5331
// Non-target ops might nest target-related ops, therefore, we
5325
5332
// translate them as non-OpenMP scopes. Translating them is needed by
5326
- // nested target-related ops since they might LLVM values defined in
5327
- // their parent non-target ops.
5333
+ // nested target-related ops since they might need LLVM values defined
5334
+ // in their parent non-target ops.
5328
5335
if (isa<omp::OpenMPDialect>(oper->getDialect ()) &&
5329
5336
oper->getParentOfType <LLVM::LLVMFuncOp>() &&
5330
5337
!oper->getRegions ().empty ()) {
@@ -5333,6 +5340,8 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
5333
5340
forwardArgs (moduleTranslation, blockArgsIface);
5334
5341
5335
5342
if (auto loopNest = dyn_cast<omp::LoopNestOp>(oper)) {
5343
+ assert (builder.GetInsertBlock () &&
5344
+ " No insert block is set for the builder" );
5336
5345
for (auto iv : loopNest.getIVs ()) {
5337
5346
// Create fake allocas just to maintain IR validity.
5338
5347
moduleTranslation.mapValue (
@@ -5342,6 +5351,10 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
5342
5351
}
5343
5352
5344
5353
for (Region ®ion : oper->getRegions ()) {
5354
+ // Regions are fake in the sense that they are not a truthful
5355
+ // translation of the OpenMP construct being converted (e.g. no
5356
+ // OpenMP runtime calls will be generated). We just need this to
5357
+ // prepare the kernel invocation args.
5345
5358
auto result = convertOmpOpRegions (
5346
5359
region, oper->getName ().getStringRef ().str () + " .fake.region" ,
5347
5360
builder, moduleTranslation);
0 commit comments