diff options
| author | gingerBill <bill@gingerbill.org> | 2023-03-16 15:16:17 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-03-16 15:16:17 +0000 |
| commit | 8dc70f797cf8b4315d689ce94ab004faadb015b7 (patch) | |
| tree | 5429d9d7aa8a6071761b993de0a25ff6be0c84e7 /src/llvm_backend_expr.cpp | |
| parent | 2cf8a9da6f7becfe7c8d279af4cc81b02dd706b6 (diff) | |
Increase use of `temporary_allocator()` where possible
Diffstat (limited to 'src/llvm_backend_expr.cpp')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 3676847b4..028e90f51 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -1072,7 +1072,9 @@ gb_internal lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbV Type *ft = base_complex_elem_type(type); if (op == Token_Quo) { - auto args = array_make<lbValue>(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make<lbValue>(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1146,7 +1148,9 @@ gb_internal lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbV return lb_addr_load(p, res); } else if (op == Token_Mul) { - auto args = array_make<lbValue>(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make<lbValue>(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1156,7 +1160,9 @@ gb_internal lbValue lb_emit_arith(lbProcedure *p, TokenKind op, lbValue lhs, lbV default: GB_PANIC("Unknown float type"); break; } } else if (op == Token_Quo) { - auto args = array_make<lbValue>(permanent_allocator(), 2); + TEMPORARY_ALLOCATOR_GUARD(); + + auto args = array_make<lbValue>(temporary_allocator(), 2); args[0] = lhs; args[1] = rhs; @@ -1647,8 +1653,10 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (are_types_identical(src, t_cstring) && are_types_identical(dst, t_string)) { + TEMPORARY_ALLOCATOR_GUARD(); + lbValue c = lb_emit_conv(p, value, t_cstring); - auto args = array_make<lbValue>(permanent_allocator(), 1); + auto args = array_make<lbValue>(temporary_allocator(), 1); args[0] = c; lbValue s = lb_emit_runtime_call(p, "cstring_to_string", args); return lb_emit_conv(p, s, dst); @@ -1792,6 +1800,8 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (is_type_integer_128bit(dst)) { + TEMPORARY_ALLOCATOR_GUARD(); + auto args = array_make<lbValue>(temporary_allocator(), 1); args[0] = value; char const *call = "fixunsdfdi"; @@ -1825,6 +1835,8 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) { } if (is_type_integer_128bit(src)) { + TEMPORARY_ALLOCATOR_GUARD(); + auto args = array_make<lbValue>(temporary_allocator(), 1); args[0] = value; char const *call = "floattidf"; @@ -2219,16 +2231,17 @@ gb_internal lbValue lb_compare_records(lbProcedure *p, TokenKind op_kind, lbValu } GB_PANIC("invalid operator"); } + TEMPORARY_ALLOCATOR_GUARD(); if (is_type_simple_compare(type)) { // TODO(bill): Test to see if this is actually faster!!!! - auto args = array_make<lbValue>(permanent_allocator(), 3); + auto args = array_make<lbValue>(temporary_allocator(), 3); args[0] = lb_emit_conv(p, left_ptr, t_rawptr); args[1] = lb_emit_conv(p, right_ptr, t_rawptr); args[2] = lb_const_int(p->module, t_int, type_size_of(type)); res = lb_emit_runtime_call(p, "memory_equal", args); } else { lbValue value = lb_equal_proc_for_type(p->module, type); - auto args = array_make<lbValue>(permanent_allocator(), 2); + auto args = array_make<lbValue>(temporary_allocator(), 2); args[0] = lb_emit_conv(p, left_ptr, t_rawptr); args[1] = lb_emit_conv(p, right_ptr, t_rawptr); res = lb_emit_call(p, value, args); @@ -4052,6 +4065,8 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lbAddr v = lb_add_local_generated(p, type, true); + TEMPORARY_ALLOCATOR_GUARD(); + Type *et = nullptr; switch (bt->kind) { case Type_Array: et = bt->Array.elem; break; @@ -4247,7 +4262,7 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { i64 item_count = gb_max(cl->max_count, cl->elems.count); { - auto args = array_make<lbValue>(permanent_allocator(), 5); + auto args = array_make<lbValue>(temporary_allocator(), 5); args[0] = lb_emit_conv(p, lb_addr_get_ptr(p, v), t_rawptr); args[1] = size; args[2] = align; @@ -4267,7 +4282,7 @@ gb_internal lbAddr lb_build_addr_compound_lit(lbProcedure *p, Ast *expr) { lb_build_addr_compound_lit_assign_array(p, temp_data); { - auto args = array_make<lbValue>(permanent_allocator(), 6); + auto args = array_make<lbValue>(temporary_allocator(), 6); args[0] = lb_emit_conv(p, v.addr, t_rawptr); args[1] = size; args[2] = align; |