diff options
| author | gingerBill <bill@gingerbill.org> | 2022-07-24 20:22:50 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-07-24 20:22:50 +0100 |
| commit | e6ab4f48567175cc192a658fb6d7b067e38912d8 (patch) | |
| tree | 0090f00932eff38514622702419322340ed4fd1b /src/llvm_backend_utility.cpp | |
| parent | c8ab1b7ee1b1ba6444a057c6afa6a9d6eb7a7dae (diff) | |
Force memset instead of store zeroinitializer when the value is large
Diffstat (limited to 'src/llvm_backend_utility.cpp')
| -rw-r--r-- | src/llvm_backend_utility.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp index 2fa43bb0a..88ec2f22c 100644 --- a/src/llvm_backend_utility.cpp +++ b/src/llvm_backend_utility.cpp @@ -50,14 +50,14 @@ lbValue lb_correct_endianness(lbProcedure *p, lbValue value) { return value; } -void lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile) { +LLVMValueRef lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len, unsigned alignment, bool is_volatile) { bool is_inlinable = false; i64 const_len = 0; if (LLVMIsConstant(len)) { const_len = cast(i64)LLVMConstIntGetSExtValue(len); // TODO(bill): Determine when it is better to do the `*.inline` versions - if (const_len <= 4*build_context.word_size) { + if (const_len <= lb_max_zero_init_size()) { is_inlinable = true; } } @@ -83,7 +83,7 @@ void lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len args[2] = LLVMBuildIntCast2(p->builder, len, types[1], /*signed*/false, ""); args[3] = LLVMConstInt(LLVMInt1TypeInContext(p->module->ctx), is_volatile, false); - LLVMBuildCall(p->builder, ip, args, gb_count_of(args), ""); + return LLVMBuildCall(p->builder, ip, args, gb_count_of(args), ""); } else { LLVMValueRef ip = lb_lookup_runtime_procedure(p->module, str_lit("memset")).value; @@ -92,7 +92,7 @@ void lb_mem_zero_ptr_internal(lbProcedure *p, LLVMValueRef ptr, LLVMValueRef len args[1] = LLVMConstInt(LLVMInt32TypeInContext(p->module->ctx), 0, false); args[2] = LLVMBuildIntCast2(p->builder, len, types[1], /*signed*/false, ""); - LLVMBuildCall(p->builder, ip, args, gb_count_of(args), ""); + return LLVMBuildCall(p->builder, ip, args, gb_count_of(args), ""); } } |