aarch64: check if type has runtime bits before allocating mem ptr

This commit is contained in:
Jakub Konka 2022-02-25 16:46:40 +01:00
parent 1b8ed7842c
commit 4b14384989
2 changed files with 6 additions and 1 deletions

View File

@ -786,6 +786,11 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u
/// Use a pointer instruction as the basis for allocating stack memory.
fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
const elem_ty = self.air.typeOfIndex(inst).elemType();
if (!elem_ty.hasRuntimeBits()) {
return self.allocMem(inst, @sizeOf(usize), @alignOf(usize));
}
const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {
return self.fail("type '{}' too big to fit into stack frame", .{elem_ty});
};

View File

@ -852,7 +852,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
const elem_ty = ptr_ty.elemType();
if (!elem_ty.hasRuntimeBits()) {
return self.allocMem(inst, 8, 8);
return self.allocMem(inst, @sizeOf(usize), @alignOf(usize));
}
const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {