mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-22 05:34:59 -07:00
Minimize stack wastage with compound literals defining variables
This commit is contained in:
@@ -460,6 +460,8 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
|
||||
LLVMValueRef ptr = LLVMBuildInBoundsGEP2(p->builder, llvm_type, array_data, indices, 2, "");
|
||||
LLVMValueRef len = LLVMConstInt(lb_type(m, t_int), count, true);
|
||||
lbAddr slice = lb_add_local_generated(p, type, false);
|
||||
map_set(&m->exact_value_compound_literal_addr_map, value.value_compound, slice);
|
||||
|
||||
lb_fill_slice(p, slice, {ptr, alloc_type_pointer(elem)}, {len, t_int});
|
||||
return lb_addr_load(p, slice);
|
||||
}
|
||||
@@ -1042,6 +1044,8 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
|
||||
GB_ASSERT(is_local);
|
||||
lbProcedure *p = m->curr_procedure;
|
||||
lbAddr v = lb_add_local_generated(p, res.type, true);
|
||||
map_set(&m->exact_value_compound_literal_addr_map, value.value_compound, v);
|
||||
|
||||
LLVMBuildStore(p->builder, constant_value, v.addr.value);
|
||||
for (isize i = 0; i < value_count; i++) {
|
||||
LLVMValueRef val = old_values[i];
|
||||
|
||||
Reference in New Issue
Block a user