From 694975ddbcb0b809965fd15b42d52c73fe05e281 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 1 Jul 2019 10:53:31 -0700 Subject: [PATCH] Standardize the definition and usage of getAllArgAttrs between FuncOp and Function. PiperOrigin-RevId: 255988352 --- mlir/include/mlir/IR/Function.h | 6 +++--- mlir/lib/IR/AsmPrinter.cpp | 3 --- mlir/lib/Transforms/DialectConversion.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h index e11a45b..0b04fb7 100644 --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -232,8 +232,8 @@ public: } /// Return all argument attributes of this function. - MutableArrayRef getAllArgAttrs() { - return impl->argAttrs; + void getAllArgAttrs(SmallVectorImpl &result) { + result.assign(impl->argAttrs.begin(), impl->argAttrs.end()); } /// Return the specified attribute if present, null otherwise. @@ -465,7 +465,7 @@ public: } /// Return all argument attributes of this function. - void getAllArgAttrs(SmallVectorImpl &result) { + void getAllArgAttrs(SmallVectorImpl &result) { for (unsigned i = 0, e = getNumArguments(); i != e; ++i) result.emplace_back(getArgAttrDict(i)); } diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 346d35a..52f54fe 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -310,9 +310,6 @@ void ModuleState::initialize(Module *module) { visitType(fn.getType()); for (auto attr : fn.getAttrs()) ModuleState::visitAttribute(attr.second); - for (auto attrList : fn.getAllArgAttrs()) - for (auto attr : attrList.getAttrs()) - ModuleState::visitAttribute(attr.second); fn.walk([&](Operation *op) { ModuleState::visitOperation(op); }); } diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index 84f00b9..9916c9e 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -1148,10 +1148,13 @@ LogicalResult mlir::applyConversionPatterns( FunctionConverter funcConverter(ctx, target, patterns, &converter); // Try to convert each of the functions within the module. + SmallVector argAttrs; for (auto func : fns) { + argAttrs.clear(); + func.getAllArgAttrs(argAttrs); + // Convert the function type using the type converter. - auto conversion = - converter.convertSignature(func.getType(), func.getAllArgAttrs()); + auto conversion = converter.convertSignature(func.getType(), argAttrs); if (!conversion) return failure(); -- 2.7.4