[Mlir-commits] [mlir] 152c987 - Simplify getArgAttrDict/getResultAttrDict by removing unnecessary checks
Mehdi Amini
llvmlistbot at llvm.org
Sat Jun 12 15:55:53 PDT 2021
Author: Mehdi Amini
Date: 2021-06-12T22:55:31Z
New Revision: 152c9871e6ac7ba2a14dcc64e812b79193421846
URL: https://github.com/llvm/llvm-project/commit/152c9871e6ac7ba2a14dcc64e812b79193421846
DIFF: https://github.com/llvm/llvm-project/commit/152c9871e6ac7ba2a14dcc64e812b79193421846.diff
LOG: Simplify getArgAttrDict/getResultAttrDict by removing unnecessary checks
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
Added:
Modified:
mlir/lib/IR/FunctionSupport.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp
index 2538271373f2a..b8a0ebc3f4a53 100644
--- a/mlir/lib/IR/FunctionSupport.cpp
+++ b/mlir/lib/IR/FunctionSupport.cpp
@@ -40,7 +40,7 @@ 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,
@@ -48,7 +48,7 @@ DictionaryAttr mlir::function_like_impl::getResultAttrDict(Operation *op,
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(
More information about the Mlir-commits
mailing list