aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_const.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-02-17 14:26:22 +0000
committergingerBill <bill@gingerbill.org>2023-02-17 14:26:22 +0000
commit99460c9e3293738607764d2c3d0cecddd7576e01 (patch)
treee5b1b4b76f5b7de47f93f1a5044ede9d6887402e /src/llvm_backend_const.cpp
parentd86df8321c2461651379aa280e6b78a73e71f9b1 (diff)
Minimize stack wastage with compound literals defining variables
Diffstat (limited to 'src/llvm_backend_const.cpp')
-rw-r--r--src/llvm_backend_const.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index fc1598024..72c2a0495 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -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];