[Mlir-commits] [mlir] 56774bd - [mlir] Replace deprecated 'getAttrs'
Marius Brehler
llvmlistbot at llvm.org
Fri Feb 26 05:53:48 PST 2021
Author: Marius Brehler
Date: 2021-02-26T14:52:40+01:00
New Revision: 56774bdda5788e48dce1ae87de1ff378918e318e
URL: https://github.com/llvm/llvm-project/commit/56774bdda5788e48dce1ae87de1ff378918e318e
DIFF: https://github.com/llvm/llvm-project/commit/56774bdda5788e48dce1ae87de1ff378918e318e.diff
LOG: [mlir] Replace deprecated 'getAttrs'
'getAttrs' has been explicitly marked deprecated. This patch refactors
to use Operation::getAttrs().
Reviewed By: csigg
Differential Revision: https://reviews.llvm.org/D97546
Added:
Modified:
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
index c0fde0e2eecb..08339530f2d6 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
@@ -56,7 +56,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp,
// Create the new function operation. Only copy those attributes that are
// not specific to function modeling.
SmallVector<NamedAttribute, 4> attributes;
- for (const auto &attr : gpuFuncOp.getAttrs()) {
+ for (const auto &attr : gpuFuncOp->getAttrs()) {
if (attr.first == SymbolTable::getSymbolAttrName() ||
attr.first == impl::getTypeAttrName() ||
attr.first == gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName())
diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
index 544487bf2302..8e985465cb8b 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -194,7 +194,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
funcOp.getLoc(), funcOp.getName(),
rewriter.getFunctionType(signatureConverter.getConvertedTypes(),
llvm::None));
- for (const auto &namedAttr : funcOp.getAttrs()) {
+ for (const auto &namedAttr : funcOp->getAttrs()) {
if (namedAttr.first == impl::getTypeAttrName() ||
namedAttr.first == SymbolTable::getSymbolAttrName())
continue;
diff --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index e970d82c86df..7bc510068aef 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -28,7 +28,7 @@ struct RegionOpConversion : public ConvertOpToLLVMPattern<OpType> {
matchAndRewrite(OpType curOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
auto newOp = rewriter.create<OpType>(curOp.getLoc(), TypeRange(), operands,
- curOp.getAttrs());
+ curOp->getAttrs());
rewriter.inlineRegionBefore(curOp.region(), newOp.region(),
newOp.region().end());
if (failed(rewriter.convertRegionTypes(&newOp.region(),
diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
index c011dfde2ab0..e756a3744f64 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
@@ -520,7 +520,7 @@ static LogicalResult processParallelLoop(
// Propagate custom user defined optional attributes, that can be used at
// later stage, such as extension data for GPU kernel dispatch
- for (const auto &namedAttr : parallelOp.getAttrs()) {
+ for (const auto &namedAttr : parallelOp->getAttrs()) {
if (namedAttr.first == gpu::getMappingAttrName() ||
namedAttr.first == ParallelOp::getOperandSegmentSizeAttr())
continue;
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 0b28d2589a46..ce2590f2cdfa 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1216,7 +1216,8 @@ static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) {
auto type = funcOp.getType();
SmallVector<NamedAttribute, 4> attributes;
- filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/false, attributes);
+ filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/false,
+ attributes);
auto wrapperFuncOp = rewriter.create<LLVM::LLVMFuncOp>(
loc, llvm::formatv("_mlir_ciface_{0}", funcOp.getName()).str(),
typeConverter.convertFunctionTypeCWrapper(type), LLVM::Linkage::External,
@@ -1265,7 +1266,8 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
assert(wrapperType && "unexpected type conversion failure");
SmallVector<NamedAttribute, 4> attributes;
- filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/false, attributes);
+ filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/false,
+ attributes);
// Create the auxiliary function.
auto wrapperFunc = builder.create<LLVM::LLVMFuncOp>(
@@ -1343,7 +1345,7 @@ struct FuncOpConversionBase : public ConvertOpToLLVMPattern<FuncOp> {
// Propagate argument attributes to all converted arguments obtained after
// converting a given original argument.
SmallVector<NamedAttribute, 4> attributes;
- filterFuncAttributes(funcOp.getAttrs(), /*filterArgAttrs=*/true,
+ filterFuncAttributes(funcOp->getAttrs(), /*filterArgAttrs=*/true,
attributes);
for (unsigned i = 0, e = funcOp.getNumArguments(); i < e; ++i) {
auto attr = impl::getArgAttrDict(funcOp, i);
@@ -2127,7 +2129,7 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
rewriter);
auto newOp = rewriter.create<LLVM::CallOp>(
callOp.getLoc(), packedResult ? TypeRange(packedResult) : TypeRange(),
- promoted, callOp.getAttrs());
+ promoted, callOp->getAttrs());
SmallVector<Value, 4> results;
if (numResults < 2) {
@@ -3034,7 +3036,7 @@ struct OneToOneLLVMTerminatorLowering
matchAndRewrite(SourceOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
rewriter.replaceOpWithNewOp<TargetOp>(op, operands, op->getSuccessors(),
- op.getAttrs());
+ op->getAttrs());
return success();
}
};
@@ -3082,12 +3084,12 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
// If ReturnOp has 0 or 1 operand, create it and return immediately.
if (numArguments == 0) {
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), ValueRange(),
- op.getAttrs());
+ op->getAttrs());
return success();
}
if (numArguments == 1) {
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(
- op, TypeRange(), updatedOperands, op.getAttrs());
+ op, TypeRange(), updatedOperands, op->getAttrs());
return success();
}
@@ -3103,7 +3105,7 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
rewriter.getI64ArrayAttr(i));
}
rewriter.replaceOpWithNewOp<LLVM::ReturnOp>(op, TypeRange(), packed,
- op.getAttrs());
+ op->getAttrs());
return success();
}
};
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 242c86ba7ea3..7a56e6202e86 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -2556,7 +2556,7 @@ static void print(spirv::ModuleOp moduleOp, OpAsmPrinter &printer) {
elidedAttrs.push_back(spirv::ModuleOp::getVCETripleAttrName());
}
- printer.printOptionalAttrDictWithKeyword(moduleOp.getAttrs(), elidedAttrs);
+ printer.printOptionalAttrDictWithKeyword(moduleOp->getAttrs(), elidedAttrs);
printer.printRegion(moduleOp.body(), /*printEntryBlockArgs=*/false,
/*printBlockTerminators=*/false);
}
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index ff8c2b79c3de..a91244eef23c 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -498,7 +498,7 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> operands,
: TypeRange()));
// Copy over all attributes other than the function name and type.
- for (const auto &namedAttr : funcOp.getAttrs()) {
+ for (const auto &namedAttr : funcOp->getAttrs()) {
if (namedAttr.first != impl::getTypeAttrName() &&
namedAttr.first != SymbolTable::getSymbolAttrName())
newFuncOp->setAttr(namedAttr.first, namedAttr.second);
diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index 3ed13bacf66a..b6af6c978b37 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -804,9 +804,9 @@ static void print(OpAsmPrinter &p, StringAttrPrettyNameOp op) {
}
if (namesDisagree)
- p.printOptionalAttrDictWithKeyword(op.getAttrs());
+ p.printOptionalAttrDictWithKeyword(op->getAttrs());
else
- p.printOptionalAttrDictWithKeyword(op.getAttrs(), {"names"});
+ p.printOptionalAttrDictWithKeyword(op->getAttrs(), {"names"});
}
// We set the SSA name in the asm syntax to the contents of the name
More information about the Mlir-commits
mailing list