[clang] [clang] Automatic initialization for small struct fields (PR #229584)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 08:50:48 PDT 2026
vitalybuka wrote:
> -ftrivial-auto-var-init-max-size is a tradeoff, similar to weaker variants of stack protectors. You set it because full initialization costs too much performance or codesize, and you can't add `__attribute__((uninitialized))` to the hotspots for whatever reason.
>
> Some patterns are more likely to cause issues, so it probably makes sense to try to target those specific patterns. Prioritizing non-array members is probably reasonable. Prioritizing pointers is probably also reasonable. Floating-point numbers are less likely to cause issues. Not sure if anyone has done research into this sort of thing.
@efriedma-quic Before going to deeper review, can you please clarify if you against this change in behavior?
To me, it's not ideal but improvement: if we skip large arrays anyway, intuitively initializing surrounding fields seems like improvement?
Cons: is that now it will be slightly harder to reason about what is initialized or not, but it was not obvious with -ftrivial-auto-var-init-max-size anyway.
https://github.com/llvm/llvm-project/pull/229584
More information about the cfe-commits
mailing list