mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Do not need an extra local copy for the slices
This commit is contained in:
@@ -808,16 +808,25 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb
|
|||||||
|
|
||||||
unsigned alignment = cast(unsigned)gb_max(type_align_of(t), 16);
|
unsigned alignment = cast(unsigned)gb_max(type_align_of(t), 16);
|
||||||
|
|
||||||
|
|
||||||
|
bool do_local_copy = false;
|
||||||
|
if (do_local_copy) {
|
||||||
|
array_data = llvm_alloca(p, llvm_type, alignment);
|
||||||
|
|
||||||
LLVMValueRef local_copy = llvm_alloca(p, LLVMTypeOf(backing_array.value), alignment);
|
LLVMValueRef local_copy = llvm_alloca(p, LLVMTypeOf(backing_array.value), alignment);
|
||||||
LLVMBuildStore(p->builder, backing_array.value, local_copy);
|
LLVMBuildStore(p->builder, backing_array.value, local_copy);
|
||||||
|
|
||||||
array_data = llvm_alloca(p, llvm_type, alignment);
|
|
||||||
|
|
||||||
LLVMBuildMemCpy(p->builder,
|
LLVMBuildMemCpy(p->builder,
|
||||||
array_data, alignment,
|
array_data, alignment,
|
||||||
local_copy, alignment,
|
local_copy, alignment,
|
||||||
LLVMConstInt(lb_type(m, t_int), type_size_of(t), false)
|
LLVMConstInt(lb_type(m, t_int), type_size_of(t), false)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
array_data = llvm_alloca(p, LLVMTypeOf(backing_array.value), alignment);
|
||||||
|
LLVMBuildStore(p->builder, backing_array.value, array_data);
|
||||||
|
|
||||||
|
array_data = LLVMBuildPointerCast(p->builder, array_data, LLVMPointerType(llvm_type, 0), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user