aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_utility.cpp
diff options
context:
space:
mode:
authorjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2025-10-18 16:18:58 +0200
committerjakubtomsu <66876057+jakubtomsu@users.noreply.github.com>2025-10-18 16:18:58 +0200
commitc21453acc598ca1ec755d6e88c9c7f0e1db51da6 (patch)
tree5fad9dc861668464a91cf289911f053f6b4a5eaa /src/llvm_backend_utility.cpp
parent91750e2f1b512a1a460065e6db8cb43101cb4f90 (diff)
comment
Diffstat (limited to 'src/llvm_backend_utility.cpp')
-rw-r--r--src/llvm_backend_utility.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/llvm_backend_utility.cpp b/src/llvm_backend_utility.cpp
index 4a760c594..c7b4170e9 100644
--- a/src/llvm_backend_utility.cpp
+++ b/src/llvm_backend_utility.cpp
@@ -981,6 +981,9 @@ gb_internal lbStructFieldRemapping lb_get_struct_remapping(lbModule *m, Type *t)
mutex_lock(&m->types_mutex);
+ // 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) {
field_remapping = map_get(&m->struct_field_remapping, cast(void *)struct_type);