[Mlir-commits] [mlir] [MLIR][OpenMP] Reduce overhead of target compilation (PR #130945)

Sergio Afonso llvmlistbot at llvm.org
Wed Mar 12 05:34:55 PDT 2025


================
@@ -2025,17 +2025,24 @@ Operation *TargetOp::getInnermostCapturedOmpOp() {
   return capturedOp;
 }
 
-llvm::omp::OMPTgtExecModeFlags TargetOp::getKernelExecFlags() {
+llvm::omp::OMPTgtExecModeFlags
+TargetOp::getKernelExecFlags(std::optional<Operation *> capturedOp) {
   using namespace llvm::omp;
 
+  // Use a cached operation, if passed in. Otherwise, find the innermost
+  // captured operation.
+  if (!capturedOp)
+    capturedOp = getInnermostCapturedOmpOp();
+  assert(*capturedOp == getInnermostCapturedOmpOp() &&
+         "unexpected captured op");
+
----------------
skatrak wrote:

Yes, I guess we won't be using this function on its own that often. As it stands, there's just a single caller that doesn't pass the `capturedOp`.

https://github.com/llvm/llvm-project/pull/130945


More information about the Mlir-commits mailing list