aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-12-27 11:53:01 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-12-27 11:53:01 +0000
commitde761cbdd39ed4ba036fc42c4b572abdd9da88d3 (patch)
tree48bce895d171264ef15128d49f417b7c7fee9880 /src
parent40eab9991efbd090d2b473f5f121859c544f5d6b (diff)
Remove temporary tuple fix alloca instructions if they are never used
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend_opt.cpp10
-rw-r--r--src/llvm_backend_proc.cpp9
2 files changed, 9 insertions, 10 deletions
diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp
index 4971b1f10..4131f32bf 100644
--- a/src/llvm_backend_opt.cpp
+++ b/src/llvm_backend_opt.cpp
@@ -309,7 +309,15 @@ gb_internal void lb_run_remove_dead_instruction_pass(lbProcedure *p) {
// NOTE(bill): Explicit instructions are set here because some instructions could have side effects
switch (LLVMGetInstructionOpcode(curr_instr)) {
- // case LLVMAlloca:
+ case LLVMAlloca:
+ if (map_get(&p->tuple_fix_map, curr_instr) != nullptr) {
+ // NOTE(bill, 2025-12-27): Remove temporary tuple fix alloca instructions
+ // if they are never used
+ removal_count += 1;
+ LLVMInstructionEraseFromParent(curr_instr);
+ was_dead_instructions = true;
+ }
+ break;
case LLVMLoad:
if (LLVMGetVolatile(curr_instr)) {
break;
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index 27167aefd..216d600da 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -1212,15 +1212,6 @@ gb_internal lbValue lb_emit_call(lbProcedure *p, lbValue value, Array<lbValue> c
}
tuple_fix_values[ret_count-1] = result;
- #if 0
- for (isize j = 0; j < ret_count; j++) {
- tuple_geps[j] = lb_emit_struct_ep(p, result_ptr, cast(i32)j);
- }
- for (isize j = 0; j < ret_count; j++) {
- lb_emit_store(p, tuple_geps[j], tuple_fix_values[j]);
- }
- #endif
-
result = lb_emit_load(p, result_ptr);
lbTupleFix tf = {tuple_fix_values};