[llvm-dev] [cfe-dev] [3.8 Release] Please write release notes!

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 3 06:05:22 PST 2016


On Wed, Mar 02, 2016 at 11:34:27PM -0800, John McCall via llvm-dev wrote:
> When that’s not practical, you can instead reduce the alignment requirements
> of the pointer.  If the pointer is to a struct that represents that layout of a
> serialized structure, consider making that struct packed; this will remove any
> implicit internal padding that the compiler might add to the struct and
> reduce its alignment requirement to 1.
> 
>   struct file_header {
>     uint16_t magic_number;
>     uint16_t format_version;
>     uint16_t num_entries;
>   } __attribute__((packed));

If we want to include this example, it is likely a good idea to point
out that packed and aligned can be combined, i.e. if you know that the
file_header copies are going to be at an aligned location, adding the
attribute results in significantly better code on platforms like ARM
with strict alignment.

Joerg


More information about the llvm-dev mailing list