Skip to content

Commit

Permalink
cg: Make variable re-initialization guard more sensible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko authored and xlauko committed Jan 4, 2024
1 parent f6eb784 commit faaac6f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/vast/CodeGen/CodeGenDeclVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ namespace vast::cg {
if (decl->hasInit()) {
auto declared = mlir::dyn_cast< hl::VarDeclOp >(var_decl);
auto &initializer = declared.getInitializer();
if (initializer.op_begin() == initializer.op_end()) {

assert(initializer.hasOneBlock());
// If the initializer isn't empty it means that we are revisiting
// already declared variable. Skip the initialization as we
// only want to return the variable.
if (initializer.front().empty()) {
auto guard = insertion_guard();
set_insertion_point_to_start(&declared.getInitializer());

Expand Down

0 comments on commit faaac6f

Please sign in to comment.