From 5e92b256da863b10254c5932b1ff7278bc83f57c Mon Sep 17 00:00:00 2001 From: Robert Konicar Date: Thu, 26 Oct 2023 15:08:00 +0200 Subject: [PATCH] cg: Fix triggering of an mlir assertion. --- lib/vast/CodeGen/CodeGenFunction.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vast/CodeGen/CodeGenFunction.cpp b/lib/vast/CodeGen/CodeGenFunction.cpp index 95bfb553e9..816a40a41c 100644 --- a/lib/vast/CodeGen/CodeGenFunction.cpp +++ b/lib/vast/CodeGen/CodeGenFunction.cpp @@ -118,7 +118,10 @@ namespace vast::cg operation get_last_effective_operation(auto &block) { auto last = &block.back(); if (auto scope = mlir::dyn_cast< core::ScopeOp >(last)) { - return get_last_effective_operation(scope.getBody().back()); + auto &last_block = scope.getBody().back(); + // Getting last op of empty block triggers MLIR assert + if (!last_block.empty()) + return get_last_effective_operation(last_block); } return last;