Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android: reachedcode: avoid a global std::atomic
In C++20 constructing an std::atomic is not 'trivial'. The various reasons for that are reachable from this discussion: [1]. The change will prevent the array from being put to BSS and be cheap when unused. Make the array a regular uint32_t array and refer to it as an array of std::atomic later (using reinterpret_cast). The std::atomic has the standard layout by the spec, making it hard to imagine an implementation of C++ that would construct the std::atomic<uint32_t> to anything different than (uint32_t)0. The Linux/Android memory page zero-fill is atomic and can only be done once. Therefore the new behavior should be equivalent to the current one. The code generated by Clang today is identical with/without this patch. This large chunk of zeroes in BSS still _may_ have a performance or code size impact because of increased immediates in relative references to .data and .bss. Resolving it may be even more controversial, hence suggesting to do it only if there is a confirmed regression. Disclaimer: I know this is .. bad. And I feel bad. [1] Discussion: <atomic>: In pre-C++20 mode, the constructor should be trivial microsoft/STL#661 Bug: None Change-Id: I06798f225bd557844072d154d47ace2d85606df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3282196 Reviewed-by: Alex Ilin <alexilin@chromium.org> Commit-Queue: Egor Pasko <pasko@chromium.org> Cr-Commit-Position: refs/heads/main@{#943056}
- Loading branch information