mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Extra checks to reduce mem.zero calls
This commit is contained in:
+10
-6
@@ -2740,12 +2740,16 @@ void ir_value_set_debug_location(irProcedure *proc, irValue *v) {
|
|||||||
void ir_emit_zero_init(irProcedure *p, irValue *address, Ast *expr) {
|
void ir_emit_zero_init(irProcedure *p, irValue *address, Ast *expr) {
|
||||||
gbAllocator a = ir_allocator();
|
gbAllocator a = ir_allocator();
|
||||||
Type *t = type_deref(ir_type(address));
|
Type *t = type_deref(ir_type(address));
|
||||||
auto args = array_make<irValue *>(a, 2);
|
isize sz = type_size_of(t);
|
||||||
args[0] = ir_emit_conv(p, address, t_rawptr);
|
if (!(gb_is_power_of_two(sz) && sz <= build_context.max_align)) {
|
||||||
args[1] = ir_const_int(type_size_of(t));
|
// TODO(bill): Is this a good idea?
|
||||||
AstPackage *pkg = get_core_package(p->module->info, str_lit("mem"));
|
auto args = array_make<irValue *>(a, 2);
|
||||||
if (p->entity != nullptr && p->entity->token.string != "zero" && p->entity->pkg != pkg) {
|
args[0] = ir_emit_conv(p, address, t_rawptr);
|
||||||
irValue *v = ir_emit_package_call(p, "mem", "zero", args, expr, ProcInlining_no_inline);
|
args[1] = ir_const_int(type_size_of(t));
|
||||||
|
AstPackage *pkg = get_core_package(p->module->info, str_lit("mem"));
|
||||||
|
if (p->entity != nullptr && p->entity->token.string != "zero" && p->entity->pkg != pkg) {
|
||||||
|
irValue *v = ir_emit_package_call(p, "mem", "zero", args, expr, ProcInlining_no_inline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ir_emit(p, ir_instr_zero_init(p, address));
|
ir_emit(p, ir_instr_zero_init(p, address));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1109,7 +1109,7 @@ void ir_print_instr(irFileBuffer *f, irModule *m, irValue *value) {
|
|||||||
ir_print_exact_value(f, m, empty_exact_value, type);
|
ir_print_exact_value(f, m, empty_exact_value, type);
|
||||||
ir_write_str_lit(f, ", ");
|
ir_write_str_lit(f, ", ");
|
||||||
ir_print_type(f, m, type);
|
ir_print_type(f, m, type);
|
||||||
ir_fprintf(f, "* %%%d", instr->ZeroInit.address->index);
|
ir_fprintf(f, "* %%%d, align 1", instr->ZeroInit.address->index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user