[Mlir-commits] [mlir] [mlir][IR] Deprecate `OpBuilder::create` in favor of free functions (PR #164649)
    Jakub Kuderski 
    llvmlistbot at llvm.org
       
    Wed Oct 22 11:48:58 PDT 2025
    
    
  
https://github.com/kuhar updated https://github.com/llvm/llvm-project/pull/164649
>From 6a20de7cc652a849c99561076af76f698c8ddd28 Mon Sep 17 00:00:00 2001
From: Jakub Kuderski <jakub at nod-labs.com>
Date: Wed, 22 Oct 2025 11:43:05 -0400
Subject: [PATCH 1/2] [mlir] Deprecate OpBuilder::create in favor of free
 functions
---
 mlir/include/mlir/IR/Builders.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 9205f16f97bbb..3ba6818204ba0 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -502,6 +502,7 @@ class OpBuilder : public Builder {
 public:
   /// Create an operation of specific op type at the current insertion point.
   template <typename OpTy, typename... Args>
+  [[deprecated("Use OpTy::create instead")]]
   OpTy create(Location location, Args &&...args) {
     OperationState state(location,
                          getCheckRegisteredInfo<OpTy>(location.getContext()));
@@ -517,9 +518,9 @@ class OpBuilder : public Builder {
   /// the results of the operation.
   ///
   /// Note: This performs opportunistic eager folding during IR construction.
-  /// The folders are designed to operate efficiently on canonical IR, which 
+  /// The folders are designed to operate efficiently on canonical IR, which
   /// this API does not enforce. Complete folding isn't only expected in the
-  /// context of canonicalization which intertwine folders with pattern 
+  /// context of canonicalization which intertwine folders with pattern
   /// rewrites until fixed-point.
   template <typename OpTy, typename... Args>
   void createOrFold(SmallVectorImpl<Value> &results, Location location,
>From a1e9154ac69c1127da51616a6e2ba171ef3db697 Mon Sep 17 00:00:00 2001
From: Jakub Kuderski <jakub at nod-labs.com>
Date: Wed, 22 Oct 2025 14:48:47 -0400
Subject: [PATCH 2/2] Update openmp
---
 .../OpenMPOffloadPrivatizationPrepare.cpp     | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp b/mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp
index db54eaa2628a8..735b905bffb85 100644
--- a/mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp
+++ b/mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp
@@ -205,14 +205,14 @@ class PrepareForOMPOffloadPrivatizationPass
           assert(!region.empty() && "region cannot be empty");
           LLVM::LLVMFuncOp func = createFuncOpForRegion(
               loc, mod, region, funcName, rewriter, returnsValue);
-          auto call = rewriter.create<LLVM::CallOp>(loc, func, args);
+          auto call = LLVM::CallOp::create(rewriter, loc, func, args);
           return call.getResult();
         };
 
         Value moldArg, newArg;
         if (isPrivatizedByValue) {
-          moldArg = rewriter.create<LLVM::LoadOp>(loc, varType, varPtr);
-          newArg = rewriter.create<LLVM::LoadOp>(loc, varType, heapMem);
+          moldArg = LLVM::LoadOp::create(rewriter, loc, varType, varPtr);
+          newArg = LLVM::LoadOp::create(rewriter, loc, varType, heapMem);
         } else {
           moldArg = varPtr;
           newArg = heapMem;
@@ -234,7 +234,7 @@ class PrepareForOMPOffloadPrivatizationPass
               {moldArg, initializedVal}, /*returnsValue=*/true);
 
         if (isPrivatizedByValue)
-          (void)rewriter.create<LLVM::StoreOp>(loc, initializedVal, heapMem);
+          (void)LLVM::StoreOp::create(rewriter, loc, initializedVal, heapMem);
 
         // clone origOp, replace all uses of varPtr with heapMem and
         // erase origOp.
@@ -275,8 +275,8 @@ class PrepareForOMPOffloadPrivatizationPass
         // targetOp.
         if (isPrivatizedByValue) {
           rewriter.setInsertionPoint(targetOp);
-          auto newPrivVar = rewriter.create<LLVM::LoadOp>(mapInfoOp.getLoc(),
-                                                          varType, heapMem);
+          auto newPrivVar = LLVM::LoadOp::create(rewriter, mapInfoOp.getLoc(),
+                                                 varType, heapMem);
           newPrivVars.push_back(newPrivVar);
         }
 
@@ -294,7 +294,7 @@ class PrepareForOMPOffloadPrivatizationPass
             cleanupTaskOp = omp::TaskOp::create(rewriter, loc, taskOperands);
             Block *taskBlock = rewriter.createBlock(&cleanupTaskOp.getRegion());
             rewriter.setInsertionPointToEnd(taskBlock);
-            rewriter.create<omp::TerminatorOp>(cleanupTaskOp.getLoc());
+            omp::TerminatorOp::create(rewriter, cleanupTaskOp.getLoc());
           }
           rewriter.setInsertionPointToStart(
               &*cleanupTaskOp.getRegion().getBlocks().begin());
@@ -307,8 +307,8 @@ class PrepareForOMPOffloadPrivatizationPass
               LLVM::lookupOrCreateFreeFn(rewriter, mod);
           assert(llvm::succeeded(freeFunc) &&
                  "Could not find free in the module");
-          (void)rewriter.create<LLVM::CallOp>(loc, freeFunc.value(),
-                                              ValueRange{heapMem});
+          (void)LLVM::CallOp::create(rewriter, loc, freeFunc.value(),
+                                     ValueRange{heapMem});
         }
       }
       assert(newPrivVars.size() == privateVars.size() &&
@@ -390,11 +390,11 @@ class PrepareForOMPOffloadPrivatizationPass
     const DataLayout &dl = DataLayout(mod);
     std::int64_t distance = getSizeInBytes(dl, varType);
 
-    Value sizeBytes = rewriter.create<LLVM::ConstantOp>(
-        loc, mallocFn.getFunctionType().getParamType(0), distance);
+    Value sizeBytes = LLVM::ConstantOp::create(
+        rewriter, loc, mallocFn.getFunctionType().getParamType(0), distance);
 
     auto mallocCallOp =
-        rewriter.create<LLVM::CallOp>(loc, mallocFn, ValueRange{sizeBytes});
+        LLVM::CallOp::create(rewriter, loc, mallocFn, ValueRange{sizeBytes});
     return mallocCallOp.getResult();
   }
 
    
    
More information about the Mlir-commits
mailing list