Skip to content

Commit 5c4a1f2

Browse files
committed
Revert "[flang][OpenMP] Translate OpenMP scopes when compiling for target device (llvm#130078)"
This reverts commit e737b84.
1 parent b27b523 commit 5c4a1f2

File tree

2 files changed

+9
-192
lines changed

2 files changed

+9
-192
lines changed

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

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "llvm/Frontend/OpenMP/OMPConstants.h"
3131
#include "llvm/Frontend/OpenMP/OMPDeviceConstants.h"
3232
#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
33-
#include "llvm/IR/Constants.h"
3433
#include "llvm/IR/DebugInfoMetadata.h"
3534
#include "llvm/IR/DerivedTypes.h"
3635
#include "llvm/IR/IRBuilder.h"
@@ -543,20 +542,6 @@ static llvm::omp::ProcBindKind getProcBindKind(omp::ClauseProcBindKind kind) {
543542
llvm_unreachable("Unknown ClauseProcBindKind kind");
544543
}
545544

546-
/// Maps block arguments from \p blockArgIface (which are MLIR values) to the
547-
/// corresponding LLVM values of \p the interface's operands. This is useful
548-
/// when an OpenMP region with entry block arguments is converted to LLVM. In
549-
/// this case the block arguments are (part of) of the OpenMP region's entry
550-
/// arguments and the operands are (part of) of the operands to the OpenMP op
551-
/// containing the region.
552-
static void forwardArgs(LLVM::ModuleTranslation &moduleTranslation,
553-
omp::BlockArgOpenMPOpInterface blockArgIface) {
554-
llvm::SmallVector<std::pair<Value, BlockArgument>> blockArgsPairs;
555-
blockArgIface.getBlockArgsPairs(blockArgsPairs);
556-
for (auto [var, arg] : blockArgsPairs)
557-
moduleTranslation.mapValue(arg, moduleTranslation.lookupValue(var));
558-
}
559-
560545
/// Helper function to map block arguments defined by ignored loop wrappers to
561546
/// LLVM values and prevent any uses of those from triggering null pointer
562547
/// dereferences.
@@ -569,10 +554,17 @@ convertIgnoredWrapper(omp::LoopWrapperInterface opInst,
569554
// Map block arguments directly to the LLVM value associated to the
570555
// corresponding operand. This is semantically equivalent to this wrapper not
571556
// being present.
557+
auto forwardArgs =
558+
[&moduleTranslation](omp::BlockArgOpenMPOpInterface blockArgIface) {
559+
llvm::SmallVector<std::pair<Value, BlockArgument>> blockArgsPairs;
560+
blockArgIface.getBlockArgsPairs(blockArgsPairs);
561+
for (auto [var, arg] : blockArgsPairs)
562+
moduleTranslation.mapValue(arg, moduleTranslation.lookupValue(var));
563+
};
564+
572565
return llvm::TypeSwitch<Operation *, LogicalResult>(opInst)
573566
.Case([&](omp::SimdOp op) {
574-
forwardArgs(moduleTranslation,
575-
cast<omp::BlockArgOpenMPOpInterface>(*op));
567+
forwardArgs(cast<omp::BlockArgOpenMPOpInterface>(*op));
576568
op.emitWarning() << "simd information on composite construct discarded";
577569
return success();
578570
})
@@ -5811,46 +5803,6 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
58115803
return WalkResult::interrupt();
58125804
return WalkResult::skip();
58135805
}
5814-
5815-
// Non-target ops might nest target-related ops, therefore, we
5816-
// translate them as non-OpenMP scopes. Translating them is needed by
5817-
// nested target-related ops since they might need LLVM values defined
5818-
// in their parent non-target ops.
5819-
if (isa<omp::OpenMPDialect>(oper->getDialect()) &&
5820-
oper->getParentOfType<LLVM::LLVMFuncOp>() &&
5821-
!oper->getRegions().empty()) {
5822-
if (auto blockArgsIface =
5823-
dyn_cast<omp::BlockArgOpenMPOpInterface>(oper))
5824-
forwardArgs(moduleTranslation, blockArgsIface);
5825-
5826-
if (auto loopNest = dyn_cast<omp::LoopNestOp>(oper)) {
5827-
assert(builder.GetInsertBlock() &&
5828-
"No insert block is set for the builder");
5829-
for (auto iv : loopNest.getIVs()) {
5830-
// Map iv to an undefined value just to keep the IR validity.
5831-
moduleTranslation.mapValue(
5832-
iv, llvm::PoisonValue::get(
5833-
moduleTranslation.convertType(iv.getType())));
5834-
}
5835-
}
5836-
5837-
for (Region &region : oper->getRegions()) {
5838-
// Regions are fake in the sense that they are not a truthful
5839-
// translation of the OpenMP construct being converted (e.g. no
5840-
// OpenMP runtime calls will be generated). We just need this to
5841-
// prepare the kernel invocation args.
5842-
auto result = convertOmpOpRegions(
5843-
region, oper->getName().getStringRef().str() + ".fake.region",
5844-
builder, moduleTranslation);
5845-
if (failed(handleError(result, *oper)))
5846-
return WalkResult::interrupt();
5847-
5848-
builder.SetInsertPoint(result.get(), result.get()->end());
5849-
}
5850-
5851-
return WalkResult::skip();
5852-
}
5853-
58545806
return WalkResult::advance();
58555807
}).wasInterrupted();
58565808
return failure(interrupted);

mlir/test/Target/LLVMIR/openmp-target-nesting-in-host-ops.mlir

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)