[Mlir-commits] [mlir] [mlir][acc] Introduce createAndPopulate for recipe creation (PR #162917)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 14 07:05:52 PDT 2025


================
@@ -1050,6 +1197,66 @@ LogicalResult acc::PrivateRecipeOp::verifyRegions() {
   return success();
 }
 
+std::optional<PrivateRecipeOp>
+PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
+                                   StringRef recipeName, Value var,
+                                   StringRef varName, ValueRange bounds) {
+
+  // Check if a symbol with this name already exists in the symbol table.
+  // If it does - don't assume that we can just reuse the existing one.
+  Operation *parentOp = builder.getInsertionBlock()->getParentOp();
+  if (parentOp &&
+      SymbolTable::lookupNearestSymbolFrom(
----------------
jeanPerier wrote:

I am pondering if you need to thread a SymbolTable* to allow for fast lookups (the lookup you have is linear with the number of symbol defined in the module, so if createAndPopulate was to be called a lot (>1000 times), that would be a compilation perf issue), but I am thinking that in practice most caller caller would likely lookup for the recipe in the module before trying to create it, so createAndPopulate should be called once per type being privatized, and I do not imagine that being more than a 100 (probably often less).

It should be up to the caller to use a SymbolTable depending on the context (we are likely not doing it in FIR OpenACC lowering right now, and we just may if we find compilation perf issues there).

So I think that is OK. Just writing this to let you double check.

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


More information about the Mlir-commits mailing list