[PATCH] D124746: Make BinaryStreamWriter::padToAlignment write blocks vs bytes.
Stella Laurenzo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 7 13:28:48 PDT 2022
stellaraccident added inline comments.
================
Comment at: llvm/lib/Support/BinaryStreamWriter.cpp:100
+ const uint64_t ZerosSize = 64;
+ char Zeros[ZerosSize];
+ std::memset(Zeros, 0, ZerosSize);
----------------
thakis wrote:
> thakis wrote:
> > nit: If you do
> >
> > ```
> > constexpr uint64_t ZerosSize = 64;
> > constexpr char Zeros[ZerosSize] = {};
> > ```
> >
> > then I think you don't need the memset call (and it's all constant zeroed data).
> @hans reminded me elsewhere that this is only true if you also make the array static, unless you build with `-fmerge-all-constants`: https://godbolt.org/z/fMcKjvfjo
>
> So `static constexpr Zeros[ZerosSize] = {}` :)
> @hans reminded me elsewhere that this is only true if you also make the array static, unless you build with `-fmerge-all-constants`: https://godbolt.org/z/fMcKjvfjo
>
> So `static constexpr Zeros[ZerosSize] = {}` :)
Thank you - TIL today. Made the change as suggested.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124746/new/
https://reviews.llvm.org/D124746
More information about the llvm-commits
mailing list