[PATCH] D124746: Make BinaryStreamWriter::padToAlignment write blocks vs bytes.
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 4 06:20:45 PDT 2022
thakis added a subscriber: hans.
thakis 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:
> 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] = {}` :)
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