Skip to content

Commit bdd5e15

Browse files
committed
handle some review comments
1 parent 2b6b9c1 commit bdd5e15

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ static llvm::omp::ProcBindKind getProcBindKind(omp::ClauseProcBindKind kind) {
542542
/// with entry block arguments is converted to LLVM. In this case \p blockArgs
543543
/// are (part of) of the OpenMP region's entry arguments and \p operands are
544544
/// (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+
/// ```
545553
static void forwardArgs(LLVM::ModuleTranslation &moduleTranslation,
546554
omp::BlockArgOpenMPOpInterface blockArgIface) {
547555
llvm::SmallVector<std::pair<Value, BlockArgument>> blockArgsPairs;
@@ -5300,7 +5308,6 @@ convertTargetDeviceOp(Operation *op, llvm::IRBuilderBase &builder,
53005308
return convertHostOrTargetOperation(op, builder, moduleTranslation);
53015309
}
53025310

5303-
53045311
static LogicalResult
53055312
convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
53065313
LLVM::ModuleTranslation &moduleTranslation) {
@@ -5323,8 +5330,8 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
53235330

53245331
// Non-target ops might nest target-related ops, therefore, we
53255332
// 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.
53285335
if (isa<omp::OpenMPDialect>(oper->getDialect()) &&
53295336
oper->getParentOfType<LLVM::LLVMFuncOp>() &&
53305337
!oper->getRegions().empty()) {
@@ -5333,6 +5340,8 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
53335340
forwardArgs(moduleTranslation, blockArgsIface);
53345341

53355342
if (auto loopNest = dyn_cast<omp::LoopNestOp>(oper)) {
5343+
assert(builder.GetInsertBlock() &&
5344+
"No insert block is set for the builder");
53365345
for (auto iv : loopNest.getIVs()) {
53375346
// Create fake allocas just to maintain IR validity.
53385347
moduleTranslation.mapValue(
@@ -5342,6 +5351,10 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
53425351
}
53435352

53445353
for (Region &region : 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.
53455358
auto result = convertOmpOpRegions(
53465359
region, oper->getName().getStringRef().str() + ".fake.region",
53475360
builder, moduleTranslation);

0 commit comments

Comments
 (0)