On Thu, Jun 07, 2018 at 12:01:00AM -0400, Ravi Pokala wrote: > > I believe the theory is that the compiler (remember, this is > > __builtin_memset) can optimize away portions of the zeroing, or can > > optimize zeroing for small sizes. > > Ahhh! I didn't consider that the compiler would be doing analysis of the > larger context, and potentially skipping zeroing parts that are set > immediately after the call.
Clang does this. It does make for some quite interesting object code, but the result is that zeroing with __builtin_memset() is basically free for mostly-initialized structures. -- Brooks
signature.asc
Description: PGP signature