Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,320
    • Issues 4,320
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 359
    • Merge Requests 359
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14399

Closed
Open
Opened Oct 29, 2017 by Gabor Greif@ggreif💬Developer

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:

  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
  1. 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.
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
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14399