Skip to content

Commit e85924f

Browse files
kuharaokblast
authored andcommitted
[mlir][IR] Deprecate OpBuilder::create in favor of free functions (llvm#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.
1 parent f3f29e8 commit e85924f

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

mlir/include/mlir/IR/Builders.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ class OpBuilder : public Builder {
502502
public:
503503
/// Create an operation of specific op type at the current insertion point.
504504
template <typename OpTy, typename... Args>
505+
[[deprecated("Use OpTy::create instead")]]
505506
OpTy create(Location location, Args &&...args) {
506507
OperationState state(location,
507508
getCheckRegisteredInfo<OpTy>(location.getContext()));
@@ -517,9 +518,9 @@ class OpBuilder : public Builder {
517518
/// the results of the operation.
518519
///
519520
/// Note: This performs opportunistic eager folding during IR construction.
520-
/// The folders are designed to operate efficiently on canonical IR, which
521+
/// The folders are designed to operate efficiently on canonical IR, which
521522
/// this API does not enforce. Complete folding isn't only expected in the
522-
/// context of canonicalization which intertwine folders with pattern
523+
/// context of canonicalization which intertwine folders with pattern
523524
/// rewrites until fixed-point.
524525
template <typename OpTy, typename... Args>
525526
void createOrFold(SmallVectorImpl<Value> &results, Location location,

mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ class PrepareForOMPOffloadPrivatizationPass
205205
assert(!region.empty() && "region cannot be empty");
206206
LLVM::LLVMFuncOp func = createFuncOpForRegion(
207207
loc, mod, region, funcName, rewriter, returnsValue);
208-
auto call = rewriter.create<LLVM::CallOp>(loc, func, args);
208+
auto call = LLVM::CallOp::create(rewriter, loc, func, args);
209209
return call.getResult();
210210
};
211211

212212
Value moldArg, newArg;
213213
if (isPrivatizedByValue) {
214-
moldArg = rewriter.create<LLVM::LoadOp>(loc, varType, varPtr);
215-
newArg = rewriter.create<LLVM::LoadOp>(loc, varType, heapMem);
214+
moldArg = LLVM::LoadOp::create(rewriter, loc, varType, varPtr);
215+
newArg = LLVM::LoadOp::create(rewriter, loc, varType, heapMem);
216216
} else {
217217
moldArg = varPtr;
218218
newArg = heapMem;
@@ -234,7 +234,7 @@ class PrepareForOMPOffloadPrivatizationPass
234234
{moldArg, initializedVal}, /*returnsValue=*/true);
235235

236236
if (isPrivatizedByValue)
237-
(void)rewriter.create<LLVM::StoreOp>(loc, initializedVal, heapMem);
237+
(void)LLVM::StoreOp::create(rewriter, loc, initializedVal, heapMem);
238238

239239
// clone origOp, replace all uses of varPtr with heapMem and
240240
// erase origOp.
@@ -275,8 +275,8 @@ class PrepareForOMPOffloadPrivatizationPass
275275
// targetOp.
276276
if (isPrivatizedByValue) {
277277
rewriter.setInsertionPoint(targetOp);
278-
auto newPrivVar = rewriter.create<LLVM::LoadOp>(mapInfoOp.getLoc(),
279-
varType, heapMem);
278+
auto newPrivVar = LLVM::LoadOp::create(rewriter, mapInfoOp.getLoc(),
279+
varType, heapMem);
280280
newPrivVars.push_back(newPrivVar);
281281
}
282282

@@ -294,7 +294,7 @@ class PrepareForOMPOffloadPrivatizationPass
294294
cleanupTaskOp = omp::TaskOp::create(rewriter, loc, taskOperands);
295295
Block *taskBlock = rewriter.createBlock(&cleanupTaskOp.getRegion());
296296
rewriter.setInsertionPointToEnd(taskBlock);
297-
rewriter.create<omp::TerminatorOp>(cleanupTaskOp.getLoc());
297+
omp::TerminatorOp::create(rewriter, cleanupTaskOp.getLoc());
298298
}
299299
rewriter.setInsertionPointToStart(
300300
&*cleanupTaskOp.getRegion().getBlocks().begin());
@@ -307,8 +307,8 @@ class PrepareForOMPOffloadPrivatizationPass
307307
LLVM::lookupOrCreateFreeFn(rewriter, mod);
308308
assert(llvm::succeeded(freeFunc) &&
309309
"Could not find free in the module");
310-
(void)rewriter.create<LLVM::CallOp>(loc, freeFunc.value(),
311-
ValueRange{heapMem});
310+
(void)LLVM::CallOp::create(rewriter, loc, freeFunc.value(),
311+
ValueRange{heapMem});
312312
}
313313
}
314314
assert(newPrivVars.size() == privateVars.size() &&
@@ -390,11 +390,11 @@ class PrepareForOMPOffloadPrivatizationPass
390390
const DataLayout &dl = DataLayout(mod);
391391
std::int64_t distance = getSizeInBytes(dl, varType);
392392

393-
Value sizeBytes = rewriter.create<LLVM::ConstantOp>(
394-
loc, mallocFn.getFunctionType().getParamType(0), distance);
393+
Value sizeBytes = LLVM::ConstantOp::create(
394+
rewriter, loc, mallocFn.getFunctionType().getParamType(0), distance);
395395

396396
auto mallocCallOp =
397-
rewriter.create<LLVM::CallOp>(loc, mallocFn, ValueRange{sizeBytes});
397+
LLVM::CallOp::create(rewriter, loc, mallocFn, ValueRange{sizeBytes});
398398
return mallocCallOp.getResult();
399399
}
400400

0 commit comments

Comments
 (0)