
#14399: NCG: dead code stripping prevention wastes space -------------------------------------+------------------------------------- Reporter: heisenbug | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: low-hanging | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- = Symptom Consider this NCG-generated code: {{{ .long _T5001a_zdp1Comorphism_info - _T5001a_zdp1Comorphism_info_dsp .data .align 3 .align 0 .globl _T5001a_mapzusentence_closure _T5001a_mapzusentence_closure: .quad _T5001a_mapzusentence_info .text .align 3 _T5001a_mapzusentence_info_dsp: .align 3 .quad 4294967301 .quad 0 .quad 14 .globl _T5001a_mapzusentence_info _T5001a_mapzusentence_info: }}} There is an inert `.long` at the end of each Cmm procedure. This fills up precious instruction cache and wastes space. = Potential solutions Some ideas to improve the situation follow: 1. Move all those longs to a "table" at the end of the compilation unit (idea by Henning Thielemann), 2. coalesce the relocation into the previous instruction by explicitly calculating the opcode (craziness by me), 3. coalesce the relocation into the following info table like this: {{{ .quad 4294967301 - 24 + _T5001a_zdp1Comorphism_info - _T5001a_zdp1Comorphism_info_dsp }}} 4. Instead of exporting `_T5001a_mapzusentence_info` export `_T5001a_mapzusentence_info_dsp` and jump/call `_T5001a_mapzusentence_info_dsp + 24` instead. (Idea by Henning Thielemann.) == Discussion 1. Improves instruction cache only 2. hard to implement, leads to ugly assembly 3. wastes a long per compilation unit (at the end), needs a new state in the assembly writer 4. leads to unintuitive (ugly?) assembly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14399 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler