@@ -4557,11 +4557,10 @@ static std::optional<int64_t> extractConstInteger(Value value) {
45574557// / function for the target region, so that they can be used to initialize the
45584558// / corresponding global `ConfigurationEnvironmentTy` structure.
45594559static void
4560- initTargetDefaultAttrs (omp::TargetOp targetOp,
4560+ initTargetDefaultAttrs (omp::TargetOp targetOp, Operation *capturedOp,
45614561 llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs &attrs,
45624562 bool isTargetDevice) {
45634563 // TODO: Handle constant 'if' clauses.
4564- Operation *capturedOp = targetOp.getInnermostCapturedOmpOp ();
45654564
45664565 Value numThreads, numTeamsLower, numTeamsUpper, threadLimit;
45674566 if (!isTargetDevice) {
@@ -4643,7 +4642,7 @@ initTargetDefaultAttrs(omp::TargetOp targetOp,
46434642 combinedMaxThreadsVal = maxThreadsVal;
46444643
46454644 // Update kernel bounds structure for the `OpenMPIRBuilder` to use.
4646- attrs.ExecFlags = targetOp.getKernelExecFlags ();
4645+ attrs.ExecFlags = targetOp.getKernelExecFlags (capturedOp );
46474646 attrs.MinTeams = minTeamsVal;
46484647 attrs.MaxTeams .front () = maxTeamsVal;
46494648 attrs.MinThreads = 1 ;
@@ -4659,10 +4658,9 @@ initTargetDefaultAttrs(omp::TargetOp targetOp,
46594658static void
46604659initTargetRuntimeAttrs (llvm::IRBuilderBase &builder,
46614660 LLVM::ModuleTranslation &moduleTranslation,
4662- omp::TargetOp targetOp,
4661+ omp::TargetOp targetOp, Operation *capturedOp,
46634662 llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs &attrs) {
4664- omp::LoopNestOp loopOp = castOrGetParentOfType<omp::LoopNestOp>(
4665- targetOp.getInnermostCapturedOmpOp ());
4663+ omp::LoopNestOp loopOp = castOrGetParentOfType<omp::LoopNestOp>(capturedOp);
46664664 unsigned numLoops = loopOp ? loopOp.getNumLoops () : 0 ;
46674665
46684666 Value numThreads, numTeamsLower, numTeamsUpper, teamsThreadLimit;
@@ -4689,7 +4687,8 @@ initTargetRuntimeAttrs(llvm::IRBuilderBase &builder,
46894687 if (numThreads)
46904688 attrs.MaxThreads = moduleTranslation.lookupValue (numThreads);
46914689
4692- if (targetOp.getKernelExecFlags () != llvm::omp::OMP_TGT_EXEC_MODE_GENERIC) {
4690+ if (targetOp.getKernelExecFlags (capturedOp) !=
4691+ llvm::omp::OMP_TGT_EXEC_MODE_GENERIC) {
46934692 llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder ();
46944693 attrs.LoopTripCount = nullptr ;
46954694
@@ -4938,12 +4937,15 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
49384937
49394938 llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs runtimeAttrs;
49404939 llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs defaultAttrs;
4941- initTargetDefaultAttrs (targetOp, defaultAttrs, isTargetDevice);
4940+ Operation *targetCapturedOp = targetOp.getInnermostCapturedOmpOp ();
4941+ initTargetDefaultAttrs (targetOp, targetCapturedOp, defaultAttrs,
4942+ isTargetDevice);
49424943
49434944 // Collect host-evaluated values needed to properly launch the kernel from the
49444945 // host.
49454946 if (!isTargetDevice)
4946- initTargetRuntimeAttrs (builder, moduleTranslation, targetOp, runtimeAttrs);
4947+ initTargetRuntimeAttrs (builder, moduleTranslation, targetOp,
4948+ targetCapturedOp, runtimeAttrs);
49474949
49484950 // Pass host-evaluated values as parameters to the kernel / host fallback,
49494951 // except if they are constants. In any case, map the MLIR block argument to
0 commit comments