[Mlir-commits] [mlir] c0b42ec - [mlir][IR] Deprecate `OpBuilder::create` in favor of free functions (#164649)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 22 11:58:15 PDT 2025
Author: Jakub Kuderski
Date: 2025-10-22T18:58:10Z
New Revision: c0b42ec05344707d94805ec795a7bc8d33a09594
URL: https://github.com/llvm/llvm-project/commit/c0b42ec05344707d94805ec795a7bc8d33a09594
DIFF: https://github.com/llvm/llvm-project/commit/c0b42ec05344707d94805ec795a7bc8d33a09594.diff
LOG: [mlir][IR] Deprecate `OpBuilder::create` in favor of free functions (#164649)
These have been soft-deprecated since July:
https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339
Add a deprecation attribute to prevent new uses from creeping in.
Added:
Modified:
mlir/include/mlir/IR/Builders.h
mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp
Removed:
################################################################################
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,
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