NCG: dead code stripping prevention wastes space
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:
- Move all those longs to a "table" at the end of the compilation unit (idea by Henning Thielemann),
- coalesce the relocation into the previous instruction by explicitly calculating the opcode (craziness by me),
- coalesce the relocation into the following info table like this:
.quad 4294967301 - 24 + _T5001a_zdp1Comorphism_info - _T5001a_zdp1Comorphism_info_dsp
- 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
- Improves instruction cache only
- hard to implement, leads to ugly assembly
- wastes a long per compilation unit (at the end), needs a new state in the assembly writer
- leads to unintuitive (ugly?) assembly.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |