diff options
| author | Benjamin Feng <benjamin.feng@glassdoor.com> | 2020-01-28 23:35:11 -0600 |
|---|---|---|
| committer | Benjamin Feng <benjamin.feng@glassdoor.com> | 2020-01-28 23:36:43 -0600 |
| commit | 2f239e3dbd809df3e4cdd10189986aa09d912b48 (patch) | |
| tree | b0dea2bb23f39e3f6796f11ee977e33706e8c354 /src/ir.cpp | |
| parent | 13259acbc3a9bf87db7245daf8132a7194264c51 (diff) | |
| download | zig-2f239e3dbd809df3e4cdd10189986aa09d912b48.tar.gz zig-2f239e3dbd809df3e4cdd10189986aa09d912b48.zip | |
Add a spill to while optional
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 631e268f55..69ca32c858 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -8222,6 +8222,7 @@ static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol, true, false, false, is_comptime); Scope *child_scope = payload_var->child_scope; + ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, child_scope); IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, LValPtr, nullptr); 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 is_comptime); ir_set_cursor_at_end_and_append_block(irb, body_block); - IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false); + IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, &spill_scope->base, symbol_node, maybe_val_ptr, false, false); IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ? ir_build_ref_src(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr; 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 loop_scope->incoming_values = &incoming_values; loop_scope->lval = lval; loop_scope->peer_parent = peer_parent; + loop_scope->spill_scope = spill_scope; // Note the body block of the loop is not the place that lval and result_loc are used - // it's actually in break statements, handled similarly to return statements. |
