HomeFreeBSD

MFC r328237:

Description

MFC r328237:
Use the __alloc_size2 attribute where relevant.

This follows the documented use in GCC. It is basically only relevant for
calloc(3), reallocarray(3) and mallocarray(9).

NOTE: Without this change clang 5.0.1 can produce incorrect optimisation code for static processing of data using the allocated object. For example this has been seen compiling the mlx4 core module, which allocates a fixed size array which is then sorted by a fixed order loop. The optimised result, -O2, is incorrect unless this patch is in place.

Suggested by: Mark Millard
Reference: https://docs.freebsd.org/cgi/mid.cgi?9DE674C6-EAA3-4E8A-906F-446E74D82FC4

Details

Provenance
hselaskyAuthored on
Parents
rS328972: add retpoline compiler and linker feature flags
Branches
Unknown
Tags
Unknown