aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-02-11 11:13:52 +0000
committergingerBill <bill@gingerbill.org>2018-02-11 11:13:52 +0000
commit0ae3484171ec6f2876c1ff16102c8e92853c6632 (patch)
tree5668ecd8b4cf809ef31de61b55f6806731e91d2a /src/ir.cpp
parent54976c3249065e846ec29588c5c69e7013fe1e8f (diff)
Fix zero value initialization in IR
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index eb9ba8979..c6093948c 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1603,10 +1603,10 @@ void ir_emit_zero_init(irProcedure *p, irValue *address, AstNode *expr) {
irValue **args = gb_alloc_array(a, irValue *, 2);
args[0] = ir_emit_conv(p, address, t_rawptr);
args[1] = ir_const_int(a, type_size_of(a, t));
- ir_emit(p, ir_instr_zero_init(p, address));
if (p->entity->token.string != "__mem_zero") {
ir_emit_global_call(p, "__mem_zero", args, 2, expr);
}
+ ir_emit(p, ir_instr_zero_init(p, address));
}
irValue *ir_emit_comment(irProcedure *p, String text) {
@@ -8033,6 +8033,9 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
irValue *base = ir_type_info(proc, t->Enum.base_type);
ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 0), base);
+ // is_export
+ ir_emit_store(proc, ir_emit_struct_ep(proc, tag, 3), ir_const_bool(a, t->Enum.is_export));
+
if (t->Enum.field_count > 0) {
Entity **fields = t->Enum.fields;
isize count = t->Enum.field_count;
@@ -8342,22 +8345,17 @@ void ir_gen_tree(irGen *s) {
}
}
- if (decl->init_expr != nullptr) {
- if (is_type_any(e->type)) {
- } else {
- TypeAndValue tav = type_and_value_of_expr(info, decl->init_expr);
- if (tav.mode != Addressing_Invalid) {
- if (tav.value.kind != ExactValue_Invalid) {
- ExactValue v = tav.value;
- g->Global.value = ir_add_module_constant(m, tav.type, v);
- }
+ if (decl->init_expr != nullptr && !is_type_any(e->type)) {
+ TypeAndValue tav = type_and_value_of_expr(info, decl->init_expr);
+ if (tav.mode != Addressing_Invalid) {
+ if (tav.value.kind != ExactValue_Invalid) {
+ ExactValue v = tav.value;
+ g->Global.value = ir_add_module_constant(m, tav.type, v);
}
}
}
- // if (g->Global.value == nullptr) {
- array_add(&global_variables, var);
- // }
+ array_add(&global_variables, var);
ir_module_add_value(m, e, g);
map_set(&m->members, hash_string(name), g);