authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-25 16:46:40+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-02-25 21:59:19+01:00
log4b14384989362f93cd014628810c63b5cd9d3fff
treecb5e572df14eb14a29bd035450d9e54cb2a52afc
parent1b8ed7842cc09ff687aa7386bf3af8565055a8d1

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


2 files changed, 6 insertions(+), 1 deletions(-)

src/arch/aarch64/CodeGen.zig+5
...@@ -786,6 +786,11 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u...@@ -786,6 +786,11 @@ fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u
786/// Use a pointer instruction as the basis for allocating stack memory.786/// Use a pointer instruction as the basis for allocating stack memory.
787fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {787fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
788 const elem_ty = self.air.typeOfIndex(inst).elemType();788 const elem_ty = self.air.typeOfIndex(inst).elemType();
789
790 if (!elem_ty.hasRuntimeBits()) {
791 return self.allocMem(inst, @sizeOf(usize), @alignOf(usize));
792 }
793
789 const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {794 const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {
790 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty});795 return self.fail("type '{}' too big to fit into stack frame", .{elem_ty});
791 };796 };
src/arch/x86_64/CodeGen.zig+1-1
...@@ -852,7 +852,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {...@@ -852,7 +852,7 @@ fn allocMemPtr(self: *Self, inst: Air.Inst.Index) !u32 {
852 const elem_ty = ptr_ty.elemType();852 const elem_ty = ptr_ty.elemType();
853853
854 if (!elem_ty.hasRuntimeBits()) {854 if (!elem_ty.hasRuntimeBits()) {
855 return self.allocMem(inst, 8, 8);855 return self.allocMem(inst, @sizeOf(usize), @alignOf(usize));
856 }856 }
857857
858 const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {858 const abi_size = math.cast(u32, elem_ty.abiSize(self.target.*)) catch {