mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Merge pull request #5827 from jakubtomsu/5826-fix
[LLVM Backend] Prefer the type pointer over LLVMTypeRef when looking up struct_field_remapping (Fix 5826)
This commit is contained in:
@@ -981,9 +981,12 @@ gb_internal lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t)
|
|||||||
|
|
||||||
mutex_lock(&m->types_mutex);
|
mutex_lock(&m->types_mutex);
|
||||||
|
|
||||||
auto *field_remapping = map_get(&m->struct_field_remapping, cast(void *)struct_type);
|
// NOTE(jakub): It's very important to check the type pointer first,
|
||||||
|
// because two disctinct but similar structs can end up with the same LLVMTypeRef after interning.
|
||||||
|
// (For example struct{u16,u8} looks identical to LLVM as struct{u16,u8,u8} once padding fields are inserted.)
|
||||||
|
auto *field_remapping = map_get(&m->struct_field_remapping, cast(void *)t);
|
||||||
if (field_remapping == nullptr) {
|
if (field_remapping == nullptr) {
|
||||||
field_remapping = map_get(&m->struct_field_remapping, cast(void *)t);
|
field_remapping = map_get(&m->struct_field_remapping, cast(void *)struct_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&m->types_mutex);
|
mutex_unlock(&m->types_mutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user