diff options
| author | Simon Brenner <olsner@gmail.com> | 2015-11-12 11:10:54 +0100 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-12 11:10:54 +0100 |
| commit | 4a32bf925b8aba7885d9c745769fe84a10979a53 (patch) | |
| tree | 73869f4df99cdb434e7fdd10f67cc9ea96022f4c /compiler/cmm/CmmBuildInfoTables.hs | |
| parent | 9bea234dbe3b36957acc42f74f0d54ddc05ad139 (diff) | |
| download | haskell-4a32bf925b8aba7885d9c745769fe84a10979a53.tar.gz | |
Implement function-sections for Haskell code, #8405
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: dterei, Phyx, austin, simonmar, thomie, bgamari
Reviewed By: simonmar, thomie, bgamari
Subscribers: hsyl20, erikd, kgardas, thomie
Differential Revision: https://phabricator.haskell.org/D1242
GHC Trac Issues: #8405
Diffstat (limited to 'compiler/cmm/CmmBuildInfoTables.hs')
| -rw-r--r-- | compiler/cmm/CmmBuildInfoTables.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/cmm/CmmBuildInfoTables.hs b/compiler/cmm/CmmBuildInfoTables.hs index 3bbd06f5c6..dafaea3156 100644 --- a/compiler/cmm/CmmBuildInfoTables.hs +++ b/compiler/cmm/CmmBuildInfoTables.hs @@ -148,8 +148,9 @@ addCAF caf srt = where last = next_elt srt srtToData :: TopSRT -> CmmGroup -srtToData srt = [CmmData RelocatableReadOnlyData (Statics (lbl srt) tbl)] +srtToData srt = [CmmData sec (Statics (lbl srt) tbl)] where tbl = map (CmmStaticLit . CmmLabel) (reverse (rev_elts srt)) + sec = Section RelocatableReadOnlyData (lbl srt) -- Once we have found the CAFs, we need to do two things: -- 1. Build a table of all the CAFs used in the procedure. @@ -223,7 +224,8 @@ to_SRT dflags top_srt off len bmp | len > maxBmpSize dflags || bmp == [toStgWord dflags (fromStgHalfWord (srtEscape dflags))] = do id <- getUniqueM let srt_desc_lbl = mkLargeSRTLabel id - tbl = CmmData RelocatableReadOnlyData $ + section = Section RelocatableReadOnlyData srt_desc_lbl + tbl = CmmData section $ Statics srt_desc_lbl $ map CmmStaticLit ( cmmLabelOffW dflags top_srt off : mkWordCLit dflags (fromIntegral len) |
