Browse Source

Add bit cast

gingerBill 2 weeks ago
parent
commit
b711e92968
1 changed files with 14 additions and 7 deletions
  1. 14 7
      src/llvm_backend_proc.cpp

+ 14 - 7
src/llvm_backend_proc.cpp

@@ -921,13 +921,20 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue
 				    arg_type != param_type) {
 					LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
 					LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
-					if (arg_kind == param_kind &&
-					    arg_kind == LLVMPointerTypeKind) {
-						// NOTE(bill): LLVM's newer `ptr` only type system seems to fail at times
-						// I don't know why...
-						args[i] = LLVMBuildPointerCast(p->builder, args[i], param_type, "");
-						arg_type = param_type;
-						continue;
+					if (arg_kind == param_kind) {
+						if (arg_kind == LLVMPointerTypeKind) {
+							// NOTE(bill): LLVM's newer `ptr` only type system seems to fail at times
+							// I don't know why...
+							args[i] = LLVMBuildPointerCast(p->builder, args[i], param_type, "");
+							arg_type = param_type;
+							continue;
+						} else if (arg_kind == LLVMStructTypeKind) {
+							if (lb_sizeof(arg_type) == lb_sizeof(param_type)) {
+								args[i]	 = LLVMBuildBitCast(p->builder, args[i], param_type, "");
+								arg_type = param_type;
+								continue;
+							}
+						}
 					}
 				}