Skip to content

[DWARFLinkerParallel] fix build on 32-bit platform. #73388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompileUnit *, 3> in the DependencyTracker.h
class alignas(8) CompileUnit : public DwarfUnit {
public:
/// The stages of new compile unit processing.
enum class Stage : uint8_t {
Expand Down
21 changes: 18 additions & 3 deletions llvm/lib/DWARFLinkerParallel/DependencyTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class DependencyTracker {
LiveRootWorklistItemTy(const LiveRootWorklistItemTy &) = default;
LiveRootWorklistItemTy(LiveRootWorklistActionTy Action,
UnitEntryPairTy RootEntry) {
RootCU.setInt(static_cast<uint8_t>(Action));
RootCU.setInt(Action);
RootCU.setPointer(RootEntry.CU);

RootDieEntry = RootEntry.DieEntry;
Expand All @@ -144,7 +144,7 @@ class DependencyTracker {
UnitEntryPairTy RootEntry,
UnitEntryPairTy ReferencedBy) {
RootCU.setPointer(RootEntry.CU);
RootCU.setInt(static_cast<uint8_t>(Action));
RootCU.setInt(Action);
RootDieEntry = RootEntry.DieEntry;

ReferencedByCU = ReferencedBy.CU;
Expand Down Expand Up @@ -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<CompileUnit *, 3> 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<CompileUnit *, 3, LiveRootWorklistActionTy,
CompileUnitPointerTraits>
RootCU;
const DWARFDebugInfoEntry *RootDieEntry = nullptr;

/// Another root entry which references this RootDieEntry.
Expand Down