From eb34afde4bc26593c1c8f91f6290a2a39cf7bf00 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 20 Jan 2019 17:45:02 +0100 Subject: [PATCH] amd64: align on 16 bytes instead of 8 Some instructions emitted by LLVM (like movaps) expect 16-byte alignment, while the allocator assumed that 8-byte alignment is good enough. TODO: this issue came to light with LLVM optimizing a complex128 store to the movaps instruction, which must be aligned. It looks like this means that the <2 x double> IR type is actually 16-byte aligned instead of 8-byte like a double. If this is the case, the alignment of complex numbers needs to be updated in the whole compiler. --- src/runtime/arch_amd64.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/arch_amd64.go b/src/runtime/arch_amd64.go index db784327..9fcb739e 100644 --- a/src/runtime/arch_amd64.go +++ b/src/runtime/arch_amd64.go @@ -5,7 +5,9 @@ const GOARCH = "amd64" // The bitness of the CPU (e.g. 8, 32, 64). const TargetBits = 64 -// Align on word boundary. +// Align a pointer. +// Note that some amd64 instructions (like movaps) expect 16-byte aligned +// memory, thus the result must be 16-byte aligned. func align(ptr uintptr) uintptr { - return (ptr + 7) &^ 7 + return (ptr + 15) &^ 15 }