llvm: fix crashes when loading a struct field
The result of buildStructGEP is not always a GEP (sorry), so we can't use getGEPResultElementType on it. Closes #14641
This commit is contained in:
committed by
Veikka Tuominen
parent
ff97bd21c3
commit
0543def52f
@@ -5558,7 +5558,7 @@ pub const FuncGen = struct {
|
||||
|
||||
return fg.loadByRef(payload_ptr, payload_ty, payload_ty.abiAlignment(target), false);
|
||||
}
|
||||
const load_inst = fg.builder.buildLoad(payload_ptr.getGEPResultElementType(), payload_ptr, "");
|
||||
const load_inst = fg.builder.buildLoad(err_union_llvm_ty.structGetTypeAtIndex(offset), payload_ptr, "");
|
||||
load_inst.setAlignment(payload_ty.abiAlignment(target));
|
||||
return load_inst;
|
||||
}
|
||||
@@ -6792,7 +6792,7 @@ pub const FuncGen = struct {
|
||||
|
||||
return self.loadByRef(payload_ptr, payload_ty, payload_ty.abiAlignment(target), false);
|
||||
}
|
||||
const load_inst = self.builder.buildLoad(payload_ptr.getGEPResultElementType(), payload_ptr, "");
|
||||
const load_inst = self.builder.buildLoad(err_union_llvm_ty.structGetTypeAtIndex(offset), payload_ptr, "");
|
||||
load_inst.setAlignment(payload_ty.abiAlignment(target));
|
||||
return load_inst;
|
||||
}
|
||||
@@ -8580,7 +8580,7 @@ pub const FuncGen = struct {
|
||||
}
|
||||
const tag_index = @boolToInt(layout.tag_align < layout.payload_align);
|
||||
const tag_field_ptr = self.builder.buildStructGEP(llvm_un_ty, union_handle, tag_index, "");
|
||||
return self.builder.buildLoad(tag_field_ptr.getGEPResultElementType(), tag_field_ptr, "");
|
||||
return self.builder.buildLoad(llvm_un_ty.structGetTypeAtIndex(tag_index), tag_field_ptr, "");
|
||||
} else {
|
||||
if (layout.payload_size == 0) {
|
||||
return union_handle;
|
||||
|
||||
@@ -254,9 +254,6 @@ pub const Value = opaque {
|
||||
pub const addFunctionAttr = ZigLLVMAddFunctionAttr;
|
||||
extern fn ZigLLVMAddFunctionAttr(Fn: *Value, attr_name: [*:0]const u8, attr_value: [*:0]const u8) void;
|
||||
|
||||
pub const getGEPResultElementType = ZigLLVMGetGEPResultElementType;
|
||||
extern fn ZigLLVMGetGEPResultElementType(GEP: *Value) *Type;
|
||||
|
||||
pub const addByValAttr = ZigLLVMAddByValAttr;
|
||||
extern fn ZigLLVMAddByValAttr(Fn: *Value, ArgNo: c_uint, type: *Type) void;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user