Skip to content

Commit 6b708cc

Browse files
authored
[DWARFLinkerParallel] fix build on 32-bit platform. (#73388)
This fixes usage of PointerIntPair on 32-bit platform - #73267.
1 parent 92b821f commit 6b708cc

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ enum ResolveInterCUReferencesMode : bool {
4747

4848
/// Stores all information related to a compile unit, be it in its original
4949
/// instance of the object file or its brand new cloned and generated DIE tree.
50-
class CompileUnit : public DwarfUnit {
50+
/// NOTE: we need alignment of at least 8 bytes as we use
51+
/// PointerIntPair<CompileUnit *, 3> in the DependencyTracker.h
52+
class alignas(8) CompileUnit : public DwarfUnit {
5153
public:
5254
/// The stages of new compile unit processing.
5355
enum class Stage : uint8_t {

llvm/lib/DWARFLinkerParallel/DependencyTracker.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class DependencyTracker {
135135
LiveRootWorklistItemTy(const LiveRootWorklistItemTy &) = default;
136136
LiveRootWorklistItemTy(LiveRootWorklistActionTy Action,
137137
UnitEntryPairTy RootEntry) {
138-
RootCU.setInt(static_cast<uint8_t>(Action));
138+
RootCU.setInt(Action);
139139
RootCU.setPointer(RootEntry.CU);
140140

141141
RootDieEntry = RootEntry.DieEntry;
@@ -144,7 +144,7 @@ class DependencyTracker {
144144
UnitEntryPairTy RootEntry,
145145
UnitEntryPairTy ReferencedBy) {
146146
RootCU.setPointer(RootEntry.CU);
147-
RootCU.setInt(static_cast<uint8_t>(Action));
147+
RootCU.setInt(Action);
148148
RootDieEntry = RootEntry.DieEntry;
149149

150150
ReferencedByCU = ReferencedBy.CU;
@@ -175,7 +175,22 @@ class DependencyTracker {
175175
/// Root entry.
176176
/// ASSUMPTION: 3 bits are used to store LiveRootWorklistActionTy value.
177177
/// Thus LiveRootWorklistActionTy should have no more eight elements.
178-
PointerIntPair<CompileUnit *, 3> RootCU;
178+
179+
/// Pointer traits for CompileUnit.
180+
struct CompileUnitPointerTraits {
181+
static inline void *getAsVoidPointer(CompileUnit *P) { return P; }
182+
static inline CompileUnit *getFromVoidPointer(void *P) {
183+
return (CompileUnit *)P;
184+
}
185+
static constexpr int NumLowBitsAvailable = 3;
186+
static_assert(
187+
alignof(CompileUnit) >= (1 << NumLowBitsAvailable),
188+
"CompileUnit insufficiently aligned to have enough low bits.");
189+
};
190+
191+
PointerIntPair<CompileUnit *, 3, LiveRootWorklistActionTy,
192+
CompileUnitPointerTraits>
193+
RootCU;
179194
const DWARFDebugInfoEntry *RootDieEntry = nullptr;
180195

181196
/// Another root entry which references this RootDieEntry.

0 commit comments

Comments
 (0)