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;