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

Razvan Lupusoru llvmlistbot at llvm.org
Tue Oct 14 09:53:19 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(
----------------
razvanlupusoru wrote:

Great point Jean!

As I thought about the idea of threading through the SymbolTable to this API, it already suggests that the caller is doing some SymbolTable handling. Thus it seems of little value to push this responsibility to the API to make sure it is unique - thus I restored previous code and updated the API description to note that a unique name must be passed in.

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


More information about the Mlir-commits mailing list