From a10487057269d93ca1e59b6b1034aa7f7d0a5630 Mon Sep 17 00:00:00 2001 From: Jiahan Xie Date: Sat, 16 Nov 2024 21:41:23 -0500 Subject: [PATCH] account for empty memory size --- lib/Conversion/SCFToCalyx/SCFToCalyx.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp b/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp index c1d22fad4926..dd502bbfae6d 100644 --- a/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp +++ b/lib/Conversion/SCFToCalyx/SCFToCalyx.cpp @@ -322,8 +322,10 @@ class BuildOpGroups : public calyx::FuncOpPartialLoweringPattern { jsonOS.value(getState().getExtMemData()); jsonOS.flush(); outFile.close(); - } else + } else { llvm::errs() << "Unable to open file for writing\n"; + return failure(); + } } } @@ -733,6 +735,11 @@ LogicalResult BuildOpGroups::buildOp(PatternRewriter &rewriter, void insertNestedArrayValue(llvm::json::Array &array, const std::vector &indices, size_t index, llvm::json::Value value) { + if (indices.empty()) { + array.emplace_back(std::move(value)); + return; + } + if (index == indices.size() - 1) { // ensure the array is big enough while (array.size() <= static_cast(indices[index])) {