diff options
| author | gingerBill <bill+github@gingerbill.org> | 2016-08-10 20:05:45 +0100 |
|---|---|---|
| committer | gingerBill <bill+github@gingerbill.org> | 2016-08-10 20:07:24 +0100 |
| commit | 4c467b118d12ca6fabd018e4c0295096fa4d399b (patch) | |
| tree | bc0ce39d34805d32b736ac2c37a38dd42202dbcb /src/codegen/codegen.cpp | |
| parent | 153c27c7556ebef0c98055d87937b942d198f629 (diff) | |
copy(...)
Diffstat (limited to 'src/codegen/codegen.cpp')
| -rw-r--r-- | src/codegen/codegen.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/codegen/codegen.cpp b/src/codegen/codegen.cpp index 7af2c01cd..cde7951df 100644 --- a/src/codegen/codegen.cpp +++ b/src/codegen/codegen.cpp @@ -46,6 +46,8 @@ void ssa_gen_code(ssaGen *s) { ssaModule *m = &s->module; CheckerInfo *info = m->info; gbAllocator a = m->allocator; + ssaProcedure dummy_proc = {}; + dummy_proc.module = m; gb_for_array(i, info->entities.entries) { auto *entry = &info->entities.entries[i]; @@ -61,7 +63,14 @@ void ssa_gen_code(ssaGen *s) { } break; case Entity_Variable: { - ssaValue *g = ssa_make_value_global(a, e, NULL); + ssaValue *value = ssa_build_expr(&dummy_proc, decl->init_expr); + if (value->kind == ssaValue_Instr) { + ssaInstr *i = &value->instr; + if (i->kind == ssaInstr_Load) { + value = i->load.address; + } + } + ssaValue *g = ssa_make_value_global(a, e, value); map_set(&m->values, hash_pointer(e), g); map_set(&m->members, hash_string(name), g); } break; |