authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-28 23:35:11-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-01-28 23:36:43-06:00
log2f239e3dbd809df3e4cdd10189986aa09d912b48
treeb0dea2bb23f39e3f6796f11ee977e33706e8c354
parent13259acbc3a9bf87db7245daf8132a7194264c51

Add a spill to while optional


1 files changed, 3 insertions(+), 1 deletions(-)

src/ir.cpp+3-1
...@@ -8222,6 +8222,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no...@@ -8222,6 +8222,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no
8222 ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol,8222 ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol,
8223 true, false, false, is_comptime);8223 true, false, false, is_comptime);
8224 Scope *child_scope = payload_var->child_scope;8224 Scope *child_scope = payload_var->child_scope;
8225 ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, child_scope);
8225 IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope,8226 IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope,
8226 LValPtr, nullptr);8227 LValPtr, nullptr);
8227 if (maybe_val_ptr == irb->codegen->invalid_inst_src)8228 if (maybe_val_ptr == irb->codegen->invalid_inst_src)
...@@ -8244,7 +8245,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no...@@ -8244,7 +8245,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no
8244 is_comptime);8245 is_comptime);
82458246
8246 ir_set_cursor_at_end_and_append_block(irb, body_block);8247 ir_set_cursor_at_end_and_append_block(irb, body_block);
8247 IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false);8248 IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, &spill_scope->base, symbol_node, maybe_val_ptr, false, false);
8248 IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ?8249 IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ?
8249 ir_build_ref_src(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr;8250 ir_build_ref_src(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr;
8250 ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr);8251 ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr);
...@@ -8260,6 +8261,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no...@@ -8260,6 +8261,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no
8260 loop_scope->incoming_values = &incoming_values;8261 loop_scope->incoming_values = &incoming_values;
8261 loop_scope->lval = lval;8262 loop_scope->lval = lval;
8262 loop_scope->peer_parent = peer_parent;8263 loop_scope->peer_parent = peer_parent;
8264 loop_scope->spill_scope = spill_scope;
82638265
8264 // Note the body block of the loop is not the place that lval and result_loc are used -8266 // Note the body block of the loop is not the place that lval and result_loc are used -
8265 // it's actually in break statements, handled similarly to return statements.8267 // it's actually in break statements, handled similarly to return statements.