diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -918,14 +918,12 @@ MLIRContext *context, std::optional location, ConstShapeOp::Adaptor adaptor, SmallVectorImpl &inferredReturnTypes) { Builder b(context); - const Properties *prop = &adaptor.getProperties(); + const Properties prop = adaptor.getProperties(); DenseIntElementsAttr shape; // TODO: this is only exercised by the Python bindings codepath which does not // support properties - if (prop) - shape = prop->shape; - else - shape = adaptor.getAttributes().getAs("shape"); + shape = prop.shape ? prop.shape : + adaptor.getAttributes().getAs("shape"); if (!shape) return emitOptionalError(location, "missing shape attribute"); inferredReturnTypes.assign({RankedTensorType::get(