diff options
| author | gingerBill <bill@gingerbill.org> | 2018-10-20 16:34:56 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-10-20 16:34:56 +0100 |
| commit | ce2e23849e21b4014edc895557b598387118cf0b (patch) | |
| tree | e584de903382db0f4ba4b25150b5c95d3e2e5b92 /src/ir.cpp | |
| parent | 099995e7dd5f420f96f8c8be19013d36e54b13d2 (diff) | |
Fix `context` initialization
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5884b2d30..78236bd35 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1759,22 +1759,7 @@ irValue *ir_find_or_generate_context_ptr(irProcedure *proc) { irValue *c = ir_add_local_generated(proc, t_context); ir_push_context_onto_stack(proc, c); ir_emit_store(proc, c, ir_emit_load(proc, proc->module->global_default_context)); - - -#if 1 - Array<irValue *> args = {}; - ir_emit_store(proc, ir_emit_struct_ep(proc, c, 0), ir_emit_package_call(proc, "os", "heap_allocator", args)); - // 1 will be handled later - ir_emit_store(proc, ir_emit_struct_ep(proc, c, 2), ir_emit_package_call(proc, "os", "current_thread_id", args)); - ir_emit_store(proc, ir_emit_struct_ep(proc, c, 3), ir_get_package_value(proc->module, str_lit("runtime"), str_lit("default_assertion_failure_proc"))); - ir_emit_store(proc, ir_emit_struct_ep(proc, c, 4), ir_emit_package_call(proc, "log", "nil_logger", args)); - - array_init(&args, heap_allocator(), 1); - args[0] = ir_get_package_value(proc->module, str_lit("runtime"), str_lit("global_scratch_allocator_data")); - ir_emit_store(proc, ir_emit_struct_ep(proc, c, 1), ir_emit_package_call(proc, "mem", "scratch_allocator", args)); -#else ir_emit_init_context(proc, c); -#endif return c; } @@ -2178,7 +2163,11 @@ void ir_addr_store(irProcedure *proc, irAddr const &addr, irValue *value) { return; } } else if (addr.kind == irAddr_Context) { + irValue *old = ir_emit_load(proc, ir_find_or_generate_context_ptr(proc)); irValue *next = ir_add_local_generated(proc, t_context); + ir_emit_store(proc, next, old); + ir_push_context_onto_stack(proc, next); + if (addr.ctx.sel.index.count > 0) { irValue *lhs = ir_emit_deep_field_gep(proc, next, addr.ctx.sel); irValue *rhs = ir_emit_conv(proc, value, type_deref(ir_type(lhs))); @@ -2189,8 +2178,6 @@ void ir_addr_store(irProcedure *proc, irAddr const &addr, irValue *value) { ir_emit_store(proc, lhs, rhs); } - ir_push_context_onto_stack(proc, next); - return; } |