Fix to OdinLLVMBuildTransmute to goto general_end on different sized data

This commit is contained in:
gingerBill
2021-03-25 22:54:49 +00:00
parent c5c82e0551
commit 6271d10af7
+7 -4
View File
@@ -2832,10 +2832,12 @@ LLVMValueRef OdinLLVMBuildTransmute(lbProcedure *p, LLVMValueRef val, LLVMTypeRe
return LLVMBuildZExtOrBitCast(p->builder, val, dst_type, ""); return LLVMBuildZExtOrBitCast(p->builder, val, dst_type, "");
} }
if (src_size != dst_size && (lb_is_type_kind(src_type, LLVMVectorTypeKind) ^ lb_is_type_kind(dst_type, LLVMVectorTypeKind))) { if (src_size != dst_size) {
// Okay if ((lb_is_type_kind(src_type, LLVMVectorTypeKind) ^ lb_is_type_kind(dst_type, LLVMVectorTypeKind))) {
} else { // Okay
GB_ASSERT_MSG(src_size == dst_size, "%s == %s", LLVMPrintTypeToString(src_type), LLVMPrintTypeToString(dst_type)); } else {
goto general_end;
}
} }
LLVMTypeKind src_kind = LLVMGetTypeKind(src_type); LLVMTypeKind src_kind = LLVMGetTypeKind(src_type);
@@ -2856,6 +2858,7 @@ LLVMValueRef OdinLLVMBuildTransmute(lbProcedure *p, LLVMValueRef val, LLVMTypeRe
} }
} }
general_end:;
if (LLVMIsALoadInst(val) && src_size <= dst_size) { if (LLVMIsALoadInst(val) && src_size <= dst_size) {
LLVMValueRef val_ptr = LLVMGetOperand(val, 0); LLVMValueRef val_ptr = LLVMGetOperand(val, 0);
val_ptr = LLVMBuildPointerCast(p->builder, val_ptr, LLVMPointerType(dst_type, 0), ""); val_ptr = LLVMBuildPointerCast(p->builder, val_ptr, LLVMPointerType(dst_type, 0), "");