[llvm] [DWARFLinkerParallel] fix build on 32-bit platform. (PR #73388)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 25 05:58:43 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: None (avl-llvm)
<details>
<summary>Changes</summary>
This fixes usage of PointerIntPair on 32-bit platform - https://github.com/llvm/llvm-project/issues/73267.
---
Full diff: https://github.com/llvm/llvm-project/pull/73388.diff
2 Files Affected:
- (modified) llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h (+3-1)
- (modified) llvm/lib/DWARFLinkerParallel/DependencyTracker.h (+18-3)
``````````diff
diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h
index 39e010fd632393d..28fcc34d867dbdf 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<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 {
diff --git a/llvm/lib/DWARFLinkerParallel/DependencyTracker.h b/llvm/lib/DWARFLinkerParallel/DependencyTracker.h
index abd5371471eb95a..b0b6ad3a1e8cfaa 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<uint8_t>(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<uint8_t>(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<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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/73388
More information about the llvm-commits
mailing list