[PATCH] D123872: Force GHashCell to be 8-byte-aligned.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 15 13:09:56 PDT 2022
efriedma created this revision.
efriedma added reviewers: rnk, MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: LLVM.
Otherwise, with recent versions of libstdc++, clang can't tell that the atomic operations are properly aligned, and generates calls to libatomic.
Fixes https://github.com/llvm/llvm-project/issues/54790 , at least for that specific case.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123872
Files:
lld/COFF/DebugTypes.cpp
Index: lld/COFF/DebugTypes.cpp
===================================================================
--- lld/COFF/DebugTypes.cpp
+++ lld/COFF/DebugTypes.cpp
@@ -902,7 +902,11 @@
/// A ghash table cell for deduplicating types from TpiSources.
class GHashCell {
- uint64_t data = 0;
+ // Force "data" to be 64-bit aligned; otherwise, some versions of clang
+ // will generate calls to libatomic when using some versions of libstdc++
+ // on 32-bit targets. (Also, in theory, there could be a target where
+ // new[] doesn't always return an 8-byte-aligned allocation.)
+ alignas(sizeof(uint64_t)) uint64_t data = 0;
public:
GHashCell() = default;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123872.423157.patch
Type: text/x-patch
Size: 660 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220415/c40a86cc/attachment.bin>
More information about the llvm-commits
mailing list