Skip to content

Commit

Permalink
cg: Fix triggering of an mlir assertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko committed Oct 26, 2023
1 parent c2bcae6 commit ffbbcc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/vast/CodeGen/CodeGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ namespace vast::cg
}

operation get_last_effective_operation(auto &block) {
if (block.empty()) {
return {};
}
auto last = &block.back();
if (auto scope = mlir::dyn_cast< core::ScopeOp >(last)) {
return get_last_effective_operation(scope.getBody().back());
Expand All @@ -130,7 +133,10 @@ namespace vast::cg
auto &last_block = fn.getBody().back();
auto missing_return = [&] (auto &block) {
if (codegen.has_insertion_block()) {
return block.empty() || !get_last_effective_operation(block)->template hasTrait< core::return_trait >();
if (auto op = get_last_effective_operation(block)) {
return !op->template hasTrait< core::return_trait >();
}
return true;
}

return false;
Expand Down

0 comments on commit ffbbcc7

Please sign in to comment.