[llvm] 6b708cc - [DWARFLinkerParallel] fix build on 32-bit platform. (#73388)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 25 15:21:57 PST 2023


Author: avl-llvm
Date: 2023-11-26T02:21:52+03:00
New Revision: 6b708cc96b4b78e943fc7af7beb3c9c1f52f979f

URL: https://github.com/llvm/llvm-project/commit/6b708cc96b4b78e943fc7af7beb3c9c1f52f979f
DIFF: https://github.com/llvm/llvm-project/commit/6b708cc96b4b78e943fc7af7beb3c9c1f52f979f.diff

LOG: [DWARFLinkerParallel] fix build on 32-bit platform. (#73388)

This fixes usage of PointerIntPair on 32-bit platform -
https://github.com/llvm/llvm-project/issues/73267.

Added: 
    

Modified: 
    llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h
    llvm/lib/DWARFLinkerParallel/DependencyTracker.h

Removed: 
    


################################################################################
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.


        


More information about the llvm-commits mailing list