aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-06-06 10:50:20 +0100
committergingerBill <bill@gingerbill.org>2023-06-06 10:58:36 +0100
commitefb7fd919b140f5da44f608c6b74d8b8e072117d (patch)
treed10f2a099c1268b21e2599ed58cc3dbb3b54a99e /src
parent788f3c22bfb98d2e282c23f2bb276173d2920678 (diff)
Minor fix to internal `using` logic with LLVM causing a compiler bug
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend_const.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index ea25a4594..8149b1eda 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -107,7 +107,11 @@ gb_internal LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) {
case LLVMPointerTypeKind:
return LLVMConstPointerCast(val, dst);
case LLVMStructTypeKind:
- return LLVMConstBitCast(val, dst);
+ // GB_PANIC("%s -> %s", LLVMPrintValueToString(val), LLVMPrintTypeToString(dst));
+ // NOTE(bill): It's not possible to do a bit cast on a struct, why was this code even here in the first place?
+ // It seems mostly to exist to get around the "anonymous -> named" struct assignments
+ // return LLVMConstBitCast(val, dst);
+ return val;
default:
GB_PANIC("Unhandled const cast %s to %s", LLVMPrintTypeToString(src), LLVMPrintTypeToString(dst));
}
@@ -1036,9 +1040,10 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
}
cv_type = cvt->Struct.fields[index]->type;
- if (is_type_struct(cv_type)) {
- auto cv_field_remapping = lb_get_struct_remapping(m, cv_type);
- idx_list[j-1] = cast(unsigned)cv_field_remapping[index];
+ if (is_type_struct(cvt)) {
+ auto cv_field_remapping = lb_get_struct_remapping(m, cvt);
+ unsigned remapped_index = cast(unsigned)cv_field_remapping[index];
+ idx_list[j-1] = remapped_index;
} else {
idx_list[j-1] = cast(unsigned)index;
}