diff options
author | Simon Brenner <olsner@gmail.com> | 2015-09-19 15:23:51 +0200 |
---|---|---|
committer | Thomas Miedema <thomasmiedema@gmail.com> | 2015-09-19 15:23:51 +0200 |
commit | bb0897f60abcce697a1038baba86923eb8baa971 (patch) | |
tree | 23e2b7e9ce92e0d8c6a641833264858aa0923862 /compiler/cmm/CmmUtils.hs | |
parent | c8d438fb027cbefa31941d8397539c481a03a74f (diff) | |
download | haskell-wip/D1242.tar.gz |
Implement function-sections for Haskell code, #8405wip/D1242
Summary:
This adds a flag -split-sections that does similar things to -split-objs, but
using sections in single object files instead of relying on the Satanic
Splitter and other abominations. This is very similar to the GCC flags
-ffunction-sections and -fdata-sections.
The --gc-sections linker flag, which allows unused sections to actually
be removed, is added to all link commands (if the linker supports it) so that
space savings from having base compiled with sections can be realized.
Supported both in LLVM and the native code-gen, in theory for all
architectures, but really tested on x86 only.
In the GHC build, a new SplitSections variable enables -split-sections for
relevant parts of the build.
Test Plan: validate with both settings of SplitSections
Reviewers: simonmar, austin, dterei, bgamari
Subscribers: erikd, kgardas, thomie
Differential Revision: https://phabricator.haskell.org/D1242
GHC Trac Issues: #8405
Diffstat (limited to 'compiler/cmm/CmmUtils.hs')
-rw-r--r-- | compiler/cmm/CmmUtils.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/cmm/CmmUtils.hs b/compiler/cmm/CmmUtils.hs index 904e19ad99..dca57dca01 100644 --- a/compiler/cmm/CmmUtils.hs +++ b/compiler/cmm/CmmUtils.hs @@ -162,9 +162,10 @@ mkByteStringCLit :: Unique -> [Word8] -> (CmmLit, GenCmmDecl CmmStatics info stm -- We have to make a top-level decl for the string, -- and return a literal pointing to it mkByteStringCLit uniq bytes - = (CmmLabel lbl, CmmData ReadOnlyData $ Statics lbl [CmmString bytes]) + = (CmmLabel lbl, CmmData sec $ Statics lbl [CmmString bytes]) where lbl = mkStringLitLabel uniq + sec = Section ReadOnlyData lbl mkDataLits :: Section -> CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt -- Build a data-segment data block mkDataLits section lbl lits @@ -175,8 +176,8 @@ mkRODataLits :: CLabel -> [CmmLit] -> GenCmmDecl CmmStatics info stmt mkRODataLits lbl lits = mkDataLits section lbl lits where - section | any needsRelocation lits = RelocatableReadOnlyData - | otherwise = ReadOnlyData + section | any needsRelocation lits = Section RelocatableReadOnlyData lbl + | otherwise = Section ReadOnlyData lbl needsRelocation (CmmLabel _) = True needsRelocation (CmmLabelOff _ _) = True needsRelocation _ = False |