Standardize the definition and usage of getAllArgAttrs between FuncOp and Function.
authorRiver Riddle <riverriddle@google.com>
Mon, 1 Jul 2019 17:53:31 +0000 (10:53 -0700)
committerjpienaar <jpienaar@google.com>
Mon, 1 Jul 2019 18:39:12 +0000 (11:39 -0700)
PiperOrigin-RevId: 255988352

mlir/include/mlir/IR/Function.h
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/Transforms/DialectConversion.cpp

index e11a45b..0b04fb7 100644 (file)
@@ -232,8 +232,8 @@ public:
   }
 
   /// Return all argument attributes of this function.
-  MutableArrayRef<NamedAttributeList> getAllArgAttrs() {
-    return impl->argAttrs;
+  void getAllArgAttrs(SmallVectorImpl<NamedAttributeList> &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<DictionaryAttr> &result) {
+  void getAllArgAttrs(SmallVectorImpl<NamedAttributeList> &result) {
     for (unsigned i = 0, e = getNumArguments(); i != e; ++i)
       result.emplace_back(getArgAttrDict(i));
   }
index 346d35a..52f54fe 100644 (file)
@@ -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); });
   }
index 84f00b9..9916c9e 100644 (file)
@@ -1148,10 +1148,13 @@ LogicalResult mlir::applyConversionPatterns(
   FunctionConverter funcConverter(ctx, target, patterns, &converter);
 
   // Try to convert each of the functions within the module.
+  SmallVector<NamedAttributeList, 4> 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();