Skip to content

Commit eb34afd

Browse files
committed
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.
1 parent 63f2a3d commit eb34afd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/arch_amd64.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const GOARCH = "amd64"
55
// The bitness of the CPU (e.g. 8, 32, 64).
66
const TargetBits = 64
77

8-
// Align on word boundary.
8+
// Align a pointer.
9+
// Note that some amd64 instructions (like movaps) expect 16-byte aligned
10+
// memory, thus the result must be 16-byte aligned.
911
func align(ptr uintptr) uintptr {
10-
return (ptr + 7) &^ 7
12+
return (ptr + 15) &^ 15
1113
}

0 commit comments

Comments
 (0)