mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Merge pull request #5812 from Kelimion/data-alignment
Set minimum #load(file, type) alignment to 16 bytes
This commit is contained in:
@@ -2995,11 +2995,12 @@ gb_internal lbValue lb_find_or_add_entity_string_byte_slice_with_type(lbModule *
|
|||||||
} else {
|
} else {
|
||||||
ptr = LLVMConstNull(lb_type(m, t_u8_ptr));
|
ptr = LLVMConstNull(lb_type(m, t_u8_ptr));
|
||||||
}
|
}
|
||||||
|
i64 align = MINIMUM_SLICE_ALIGNMENT;
|
||||||
if (!is_type_u8_slice(slice_type)) {
|
if (!is_type_u8_slice(slice_type)) {
|
||||||
Type *bt = base_type(slice_type);
|
Type *bt = base_type(slice_type);
|
||||||
Type *elem = bt->Slice.elem;
|
Type *elem = bt->Slice.elem;
|
||||||
i64 sz = type_size_of(elem);
|
i64 sz = type_size_of(elem);
|
||||||
i64 align = type_align_of(elem);
|
align = gb_max(type_align_of(elem), align);
|
||||||
GB_ASSERT(sz > 0);
|
GB_ASSERT(sz > 0);
|
||||||
GB_ASSERT(align > 0);
|
GB_ASSERT(align > 0);
|
||||||
|
|
||||||
@@ -3054,11 +3055,12 @@ gb_internal lbValue lb_find_or_add_entity_string16_slice_with_type(lbModule *m,
|
|||||||
} else {
|
} else {
|
||||||
ptr = LLVMConstNull(lb_type(m, t_u8_ptr));
|
ptr = LLVMConstNull(lb_type(m, t_u8_ptr));
|
||||||
}
|
}
|
||||||
|
i64 align = MINIMUM_SLICE_ALIGNMENT;
|
||||||
if (!is_type_u16_slice(slice_type)) {
|
if (!is_type_u16_slice(slice_type)) {
|
||||||
Type *bt = base_type(slice_type);
|
Type *bt = base_type(slice_type);
|
||||||
Type *elem = bt->Slice.elem;
|
Type *elem = bt->Slice.elem;
|
||||||
i64 sz = type_size_of(elem);
|
i64 sz = type_size_of(elem);
|
||||||
i64 align = type_align_of(elem);
|
align = gb_max(type_align_of(elem), align);
|
||||||
GB_ASSERT(sz > 0);
|
GB_ASSERT(sz > 0);
|
||||||
GB_ASSERT(align > 0);
|
GB_ASSERT(align > 0);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ struct Ast;
|
|||||||
struct Scope;
|
struct Scope;
|
||||||
struct Entity;
|
struct Entity;
|
||||||
|
|
||||||
|
// NOTE(Jeroen): Minimum alignment for #load(file, <type>) slices
|
||||||
|
#define MINIMUM_SLICE_ALIGNMENT 16
|
||||||
|
|
||||||
enum BasicKind {
|
enum BasicKind {
|
||||||
Basic_Invalid,
|
Basic_Invalid,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user