aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_const.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-03-09 15:39:41 +0000
committergingerBill <bill@gingerbill.org>2023-03-09 15:39:41 +0000
commit7c0257fcdad00cbb66d1d089715ec0ad684fd4c0 (patch)
treeb950281055dd6635ff24f10fddce8049049d29a9 /src/llvm_backend_const.cpp
parent9af6d6c9c69bb3f913e08a309d389737ca09080e (diff)
Fix value elision on declaration
Diffstat (limited to 'src/llvm_backend_const.cpp')
-rw-r--r--src/llvm_backend_const.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index 3da768cd1..286c01f74 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -484,7 +484,14 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
LLVMValueRef indices[2] = {llvm_zero(m), llvm_zero(m)};
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);
+
+ lbAddr slice = {};
+ if (p->current_elision_hint.addr.value && are_types_identical(lb_addr_type(p->current_elision_hint), type)) {
+ slice = p->current_elision_hint;
+ p->current_elision_hint = {};
+ } else {
+ 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});