aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-09-07 00:12:15 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-09-07 00:13:12 -0400
commitd1a98ccff481183d7fc53e45a902ef273c3d6aeb (patch)
treeb03efbb135bae39fcf6968b505ad67e4c6a33bda /src/ir.cpp
parent9ca8d9e21ad657b023c23db5c440fb79a3303771 (diff)
downloadzig-d1a98ccff481183d7fc53e45a902ef273c3d6aeb.tar.gz
zig-d1a98ccff481183d7fc53e45a902ef273c3d6aeb.zip
implement spills when expressions used across suspend points
closes #3077
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 53ce2d89e1..1a0aad36e9 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3364,6 +3364,7 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco
case ScopeIdCompTime:
case ScopeIdRuntime:
case ScopeIdTypeOf:
+ case ScopeIdExpr:
scope = scope->parent;
continue;
case ScopeIdDeferExpr:
@@ -3420,6 +3421,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o
case ScopeIdCompTime:
case ScopeIdRuntime:
case ScopeIdTypeOf:
+ case ScopeIdExpr:
scope = scope->parent;
continue;
case ScopeIdDeferExpr:
@@ -8158,7 +8160,15 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc
result_loc = no_result_loc();
ir_build_reset_result(irb, scope, node, result_loc);
}
- IrInstruction *result = ir_gen_node_raw(irb, node, scope, lval, result_loc);
+ Scope *child_scope;
+ if (irb->exec->is_inline ||
+ (irb->exec->fn_entry != nullptr && irb->exec->fn_entry->child_scope == scope))
+ {
+ child_scope = scope;
+ } else {
+ child_scope = create_expr_scope(irb->codegen, node, scope);
+ }
+ IrInstruction *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc);
if (result == irb->codegen->invalid_instruction) {
if (irb->exec->first_err_trace_msg == nullptr) {
irb->exec->first_err_trace_msg = irb->codegen->trace_err;