aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_general.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-11-23 23:32:34 +0000
committergingerBill <bill@gingerbill.org>2022-11-23 23:32:34 +0000
commitd6cb105d5f29506fc64abbccf8767a79539de1ae (patch)
tree92eab1aece72bdad5a1993f53d3b774152c391e2 /src/llvm_backend_general.cpp
parent5ac36b5f25435a495d8516d5c9df06c09d3ca20e (diff)
Fix LLVM type cycle nonsense with procedure types
Diffstat (limited to 'src/llvm_backend_general.cpp')
-rw-r--r--src/llvm_backend_general.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index 050168e8e..af9a6904f 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -1987,7 +1987,15 @@ LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
}
field_remapping[field_index] = cast(i32)fields.count;
- array_add(&fields, lb_type(m, field->type));
+
+ Type *field_type = field->type;
+ if (is_type_proc(field_type)) {
+ // NOTE(bill, 2022-11-23): Prevent type cycle declaration (e.g. vtable) of procedures
+ // because LLVM is dumb with procedure types
+ field_type = t_rawptr;
+ }
+
+ array_add(&fields, lb_type(m, field_type));
if (!type->Struct.is_packed) {
padding_offset = align_formula(padding_offset, type_align_of(field->type));