mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-30 17:21:49 -07:00
Merge pull request #3855 from laytan/master
Fix two LLVM assertion failures
This commit is contained in:
@@ -94,9 +94,6 @@ gb_internal LLVMValueRef llvm_const_cast(LLVMValueRef val, LLVMTypeRef dst) {
|
||||
LLVMTypeKind kind = LLVMGetTypeKind(dst);
|
||||
switch (kind) {
|
||||
case LLVMPointerTypeKind:
|
||||
if (LB_USE_NEW_PASS_SYSTEM) {
|
||||
return val;
|
||||
}
|
||||
return LLVMConstPointerCast(val, dst);
|
||||
case LLVMStructTypeKind:
|
||||
// GB_PANIC("%s -> %s", LLVMPrintValueToString(val), LLVMPrintTypeToString(dst));
|
||||
@@ -179,6 +176,7 @@ gb_internal LLVMValueRef llvm_const_named_struct_internal(LLVMTypeRef t, LLVMVal
|
||||
for (unsigned i = 0; i < elem_count; i++) {
|
||||
LLVMTypeRef elem_type = LLVMStructGetTypeAtIndex(t, i);
|
||||
values[i] = llvm_const_cast(values[i], elem_type);
|
||||
GB_ASSERT_MSG(elem_type == LLVMTypeOf(values[i]), "%s != %s", LLVMPrintTypeToString(LLVMTypeOf(values[i])), LLVMPrintTypeToString(elem_type));
|
||||
}
|
||||
return LLVMConstNamedStruct(t, values, value_count);
|
||||
}
|
||||
|
||||
@@ -1109,9 +1109,13 @@ gb_internal lbValue lb_emit_load(lbProcedure *p, lbValue value) {
|
||||
Type *t = type_deref(value.type);
|
||||
LLVMValueRef v = LLVMBuildLoad2(p->builder, lb_type(p->module, t), value.value, "");
|
||||
|
||||
u64 is_packed = lb_get_metadata_custom_u64(p->module, value.value, ODIN_METADATA_IS_PACKED);
|
||||
if (is_packed != 0) {
|
||||
LLVMSetAlignment(v, 1);
|
||||
// If it is not an instruction it isn't a GEP, so we don't need to track alignment in the metadata,
|
||||
// which is not possible anyway (only LLVM instructions can have metadata).
|
||||
if (LLVMIsAInstruction(value.value)) {
|
||||
u64 is_packed = lb_get_metadata_custom_u64(p->module, value.value, ODIN_METADATA_IS_PACKED);
|
||||
if (is_packed != 0) {
|
||||
LLVMSetAlignment(v, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return lbValue{v, t};
|
||||
|
||||
Reference in New Issue
Block a user