Skip to content

Commit

Permalink
Simplify getArgAttrDict/getResultAttrDict by removing unnecessary checks
Browse files Browse the repository at this point in the history
There is a slight change in behavior: if the arg dictionnary is empty
then we return this empty dictionnary instead of a null attribute.
This is more consistent with accessing it through:

  ArrayAttr args_attr = func_op.getAllArgAttrs();
  args_attr[num].cast<DictionnaryAttr>() ...

Differential Revision: https://reviews.llvm.org/D104189
  • Loading branch information
joker-eph committed Jun 12, 2021
1 parent 2db64e1 commit 152c987
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mlir/lib/IR/FunctionSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ DictionaryAttr mlir::function_like_impl::getArgAttrDict(Operation *op,
ArrayAttr attrs = op->getAttrOfType<ArrayAttr>(getArgDictAttrName());
DictionaryAttr argAttrs =
attrs ? attrs[index].cast<DictionaryAttr>() : DictionaryAttr();
return (argAttrs && !argAttrs.empty()) ? argAttrs : DictionaryAttr();
return argAttrs;
}

DictionaryAttr mlir::function_like_impl::getResultAttrDict(Operation *op,
unsigned index) {
ArrayAttr attrs = op->getAttrOfType<ArrayAttr>(getResultDictAttrName());
DictionaryAttr resAttrs =
attrs ? attrs[index].cast<DictionaryAttr>() : DictionaryAttr();
return (resAttrs && !resAttrs.empty()) ? resAttrs : DictionaryAttr();
return resAttrs;
}

void mlir::function_like_impl::detail::setArgResAttrDict(
Expand Down

0 comments on commit 152c987

Please sign in to comment.