Skip to content

Commit

Permalink
[mlir] Make ArrayType shape return smallvector
Browse files Browse the repository at this point in the history
Previously the ArrayRef returned was flagged as returning address of local temporary object. This is a little bit surprising that this works given different return type difference etc and may get reworked (beyond this seemingly satisfying ubsan).

PiperOrigin-RevId: 698466497
  • Loading branch information
jpienaar authored and copybara-github committed Nov 20, 2024
1 parent fb74958 commit a5c5aae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xls/contrib/mlir/IR/xls_ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def Xls_ArrayType : Xls_Type<"Array", [ShapedTypeInterface]> {
];
let extraClassDeclaration = [{
constexpr bool hasRank() { return true; }
::llvm::ArrayRef<int64_t> getShape() const { return getNumElements(); }
::llvm::SmallVector<int64_t> getShape() const {
return ::llvm::SmallVector<int64_t>(1, getNumElements());
}
::mlir::ShapedType cloneWith(std::optional<llvm::ArrayRef<int64_t>> shape,
Type elementType) {
assert(0 && "ArrayType::cloneWith unimplemented!");
Expand Down

0 comments on commit a5c5aae

Please sign in to comment.