nitter
Logo
Tavis Ormandy
@taviso
29 Sep 2021
I learned something interesting today, gcc doesn't know memalign() returns aligned pointers (notice all the movdqus). This caused some very confusing benchmark results 😆. The solution was to use aligned_alloc() or __builtin_assume_aligned(). godbolt.org/z/j6vboqcME

Compiler Explorer - C (x86-64 gcc 11.2)

uint32_t array[16] __attribute__((aligned(32))); void * copy_into_buffer1(void) { uint32_t *b = aligned_alloc(32, sizeof(array)); // Gcc *does* know it can use movdqa here return memcpy(b, array,...

godbolt.org
3
9
71
PaX Team @paxteam
30 Sep 2021
Replying to @taviso
as other said already: godbolt.org/z/5o4s9fqP5

Compiler Explorer - C (x86-64 gcc 11.2)

uint32_t array[16] __attribute__((aligned(32))); void *memalign(size_t alignment, size_t size) __attribute__((alloc_align(1))); void * copy_into_buffer1(void) { uint32_t *b = aligned_alloc(32,...

godbolt.org

Sep 30, 2021 · 5:13 AM UTC

2