5.7.7.8 Align-functions Option

The -falign-functions=n:m:n2:m2 option aligns the start of functions to the next power of two greater than n, skipping up to m-1 bytes. This ensures that at least the first m bytes of the function can be fetched by the CPU without crossing an n-byte alignment boundary.

All arguments are optional. Arguments preceding any argument that is specified are mandatory. If m is not specified, it defaults to n. The -fno-align-functions form of this option is equivalent to -falign-functions=1, which implies that the function is not aligned. If n is not specified or is zero, the option performs no additional alignment other than the usual alignment by 4 for code using the ARM instruction set or by 2 for code using the Thumb instruction set. For PIC32C/SAM devices, nmust not exceed 64. If n is not a power of 2, the alignment value is rounded up.

For instance, -falign-functions=32 aligns functions to the next 32-byte boundary; -falign-functions=24 aligns functions to the next 32-byte boundary but only if this can be done by skipping no more than 23 bytes; -falign-functions=32:7 aligns to the next 32-byte boundary only if this can be done by skipping 6 bytes or fewer.

The second pair of n2:m2 values allows you to specify a secondary alignment: -falign-functions=64:7:32:3 aligns to the next 64-byte boundary if this can be done by skipping 6 bytes or fewer, otherwise aligns to the next 32-byte boundary if this can be done by skipping 2 bytes or fewer. If m2 is not specified, it defaults to n2.

This option is automatically enabled at optimization levels -O2 and -O3.