From 4b3993a0faee15156f050472c46af3cd886cbbf3 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Sat, 25 Nov 2023 14:09:20 +0100 Subject: [PATCH] [DWARFLinkerParallel] fix build on 32-bit platform. This fixes usage of PointerIntPair on 32-bit platform. --- .../DWARFLinkerCompileUnit.h | 4 +++- .../DWARFLinkerParallel/DependencyTracker.h | 21 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h index 39e010fd63239..28fcc34d867db 100644 --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h @@ -47,7 +47,9 @@ enum ResolveInterCUReferencesMode : bool { /// Stores all information related to a compile unit, be it in its original /// instance of the object file or its brand new cloned and generated DIE tree. -class CompileUnit : public DwarfUnit { +/// NOTE: we need alignment of at least 8 bytes as we use +/// PointerIntPair in the DependencyTracker.h +class alignas(8) CompileUnit : public DwarfUnit { public: /// The stages of new compile unit processing. enum class Stage : uint8_t { diff --git a/llvm/lib/DWARFLinkerParallel/DependencyTracker.h b/llvm/lib/DWARFLinkerParallel/DependencyTracker.h index abd5371471eb9..b0b6ad3a1e8cf 100644 --- a/llvm/lib/DWARFLinkerParallel/DependencyTracker.h +++ b/llvm/lib/DWARFLinkerParallel/DependencyTracker.h @@ -135,7 +135,7 @@ class DependencyTracker { LiveRootWorklistItemTy(const LiveRootWorklistItemTy &) = default; LiveRootWorklistItemTy(LiveRootWorklistActionTy Action, UnitEntryPairTy RootEntry) { - RootCU.setInt(static_cast(Action)); + RootCU.setInt(Action); RootCU.setPointer(RootEntry.CU); RootDieEntry = RootEntry.DieEntry; @@ -144,7 +144,7 @@ class DependencyTracker { UnitEntryPairTy RootEntry, UnitEntryPairTy ReferencedBy) { RootCU.setPointer(RootEntry.CU); - RootCU.setInt(static_cast(Action)); + RootCU.setInt(Action); RootDieEntry = RootEntry.DieEntry; ReferencedByCU = ReferencedBy.CU; @@ -175,7 +175,22 @@ class DependencyTracker { /// Root entry. /// ASSUMPTION: 3 bits are used to store LiveRootWorklistActionTy value. /// Thus LiveRootWorklistActionTy should have no more eight elements. - PointerIntPair RootCU; + + /// Pointer traits for CompileUnit. + struct CompileUnitPointerTraits { + static inline void *getAsVoidPointer(CompileUnit *P) { return P; } + static inline CompileUnit *getFromVoidPointer(void *P) { + return (CompileUnit *)P; + } + static constexpr int NumLowBitsAvailable = 3; + static_assert( + alignof(CompileUnit) >= (1 << NumLowBitsAvailable), + "CompileUnit insufficiently aligned to have enough low bits."); + }; + + PointerIntPair + RootCU; const DWARFDebugInfoEntry *RootDieEntry = nullptr; /// Another root entry which references this RootDieEntry.