30
30
#include " llvm/Frontend/OpenMP/OMPConstants.h"
31
31
#include " llvm/Frontend/OpenMP/OMPDeviceConstants.h"
32
32
#include " llvm/Frontend/OpenMP/OMPIRBuilder.h"
33
- #include " llvm/IR/Constants.h"
34
33
#include " llvm/IR/DebugInfoMetadata.h"
35
34
#include " llvm/IR/DerivedTypes.h"
36
35
#include " llvm/IR/IRBuilder.h"
@@ -543,20 +542,6 @@ static llvm::omp::ProcBindKind getProcBindKind(omp::ClauseProcBindKind kind) {
543
542
llvm_unreachable (" Unknown ClauseProcBindKind kind" );
544
543
}
545
544
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
-
560
545
// / Helper function to map block arguments defined by ignored loop wrappers to
561
546
// / LLVM values and prevent any uses of those from triggering null pointer
562
547
// / dereferences.
@@ -569,10 +554,17 @@ convertIgnoredWrapper(omp::LoopWrapperInterface opInst,
569
554
// Map block arguments directly to the LLVM value associated to the
570
555
// corresponding operand. This is semantically equivalent to this wrapper not
571
556
// 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
+
572
565
return llvm::TypeSwitch<Operation *, LogicalResult>(opInst)
573
566
.Case ([&](omp::SimdOp op) {
574
- forwardArgs (moduleTranslation,
575
- cast<omp::BlockArgOpenMPOpInterface>(*op));
567
+ forwardArgs (cast<omp::BlockArgOpenMPOpInterface>(*op));
576
568
op.emitWarning () << " simd information on composite construct discarded" ;
577
569
return success ();
578
570
})
@@ -5811,46 +5803,6 @@ convertTargetOpsInNest(Operation *op, llvm::IRBuilderBase &builder,
5811
5803
return WalkResult::interrupt ();
5812
5804
return WalkResult::skip ();
5813
5805
}
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 ®ion : 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
-
5854
5806
return WalkResult::advance ();
5855
5807
}).wasInterrupted ();
5856
5808
return failure (interrupted);
0 commit comments