diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-02-25 16:46:40 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-02-25 21:59:19 +0100 |
| commit | 4b14384989362f93cd014628810c63b5cd9d3fff (patch) | |
| tree | cb5e572df14eb14a29bd035450d9e54cb2a52afc /src | |
| parent | 1b8ed7842cc09ff687aa7386bf3af8565055a8d1 (diff) | |
| download | zig-4b14384989362f93cd014628810c63b5cd9d3fff.tar.gz zig-4b14384989362f93cd014628810c63b5cd9d3fff.zip | |
aarch64: check if type has runtime bits before allocating mem ptr
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/aarch64/CodeGen.zig | 5 | ||||
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index 2b863fd359..dc64e77f81 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -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}); }; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index f7713a4e69..25dc8d81aa 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -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 { |
