aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_const.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm_backend_const.cpp')
-rw-r--r--src/llvm_backend_const.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index 8db6e2a1f..8149b1eda 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -1,6 +1,6 @@
gb_internal bool lb_is_const(lbValue value) {
LLVMValueRef v = value.value;
- if (is_type_untyped_nil(value.type) || is_type_untyped_undef(value.type)) {
+ if (is_type_untyped_nil(value.type)) {
// TODO(bill): Is this correct behaviour?
return true;
}
@@ -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;
}