[Mlir-commits] [mlir] 6eca195 - Don't store nullptrs in mlir::FuncOp::getAll*Attrs' result
Tres Popp
llvmlistbot at llvm.org
Thu Nov 25 06:12:39 PST 2021
Author: Tres Popp
Date: 2021-11-25T15:12:29+01:00
New Revision: 6eca1957eeee0a0c12c4b7156f58b184630e2118
URL: https://github.com/llvm/llvm-project/commit/6eca1957eeee0a0c12c4b7156f58b184630e2118
DIFF: https://github.com/llvm/llvm-project/commit/6eca1957eeee0a0c12c4b7156f58b184630e2118.diff
LOG: Don't store nullptrs in mlir::FuncOp::getAll*Attrs' result
These methods for results and arguments would create an ArrayRef full
of nullptrs when there were no argument attributes. This is problematic
because this result could not be passed to the FuncOp::build creator
without causing a segfault. Now the list will have empty attributes.
Differential Revision: https://reviews.llvm.org/D114358
Added:
Modified:
mlir/include/mlir/IR/FunctionSupport.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index d86500fffa972..cc086abd1b86d 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -390,7 +390,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
auto argAttrRange = argAttrs.template getAsRange<DictionaryAttr>();
result.append(argAttrRange.begin(), argAttrRange.end());
} else {
- result.resize(getNumArguments());
+ result.append(getNumArguments(),
+ DictionaryAttr::get(this->getOperation()->getContext()));
}
}
@@ -479,7 +480,8 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
auto argAttrRange = argAttrs.template getAsRange<DictionaryAttr>();
result.append(argAttrRange.begin(), argAttrRange.end());
} else {
- result.resize(getNumResults());
+ result.append(getNumResults(),
+ DictionaryAttr::get(this->getOperation()->getContext()));
}
}
More information about the Mlir-commits
mailing list