I would like to understand how LLVM decides what size memory regions allocated with alloca
should have. As can be seen in this example, when generating code for x86-64 it appears to always select a size that is an odd multiple of 8 bytes:
%0 = alloca [ 88 x i8] ; Allocates 88 bytes
%1 = alloca [ 96 x i8] ;
%2 = alloca [100 x i8] ; All allocate 104 bytes
%3 = alloca [104 x i8] ;
%4 = alloca [105 x i8] ; Allocates 120 bytes
So is this really the pattern that the code generator follows? And if so, why? Why not prefer even multiples of 8 or any multiple?
I tripped over this seemingly odd behaviour while trying to answer this question. It feels however as though I'm missing something regarding the size of the allocations.