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

Kareem Ergawy llvmlistbot at llvm.org
Wed Mar 12 04:59:57 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");
+
----------------
ergawy wrote:

Can we instead pass `Operation* capturedOp` and force the callers to provide it? Simplifies the function. I think this is not a big deal since the function is called about 3 times in the codebase.

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


More information about the Mlir-commits mailing list