[PATCH] llvmGen: Align objects in the data section
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Mon, 27 Nov 2023 11:34:47 +0000 (12:34 +0100)
committerIlias Tsitsimpis <iliastsi@debian.org>
Wed, 10 Apr 2024 11:24:01 +0000 (14:24 +0300)
Objects in the data section may be referenced via tagged pointers.
Thus, align those objects to a 4- or 8-byte boundary for 32- or 64-bit
platforms, respectively.  Note, this may need to be reconsidered if
objects with a greater natural alignment requirement are emitted as e.g.
128-bit atomics.

Fixes #24163.

Gbp-Pq: Name dfe1c3540e4b519b62b862b5966dfec5cae9ece1.patch

compiler/GHC/CmmToLlvm/Data.hs

index edab12a6ef3994544759f57a55019e5df11a9fcc..267feb17ee41fc1f3976d5d966484540ec4f2f43 100644 (file)
@@ -89,6 +89,7 @@ genLlvmData (sec, CmmStaticsRaw lbl xs) = do
         align          = case sec of
                             Section CString _ -> if (platformArch platform == ArchS390X)
                                                     then Just 2 else Just 1
+                            Section Data _    -> Just $ platformWordSizeInBytes platform
                             _                 -> Nothing
         const          = if sectionProtection sec == ReadOnlySection
                             then Constant else Global