Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,844
    • Issues 4,844
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 453
    • Merge requests 453
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #11486

Closed
Open
Created Jan 24, 2016 by rwbarton@trac-rwbarton

info tables are no longer aligned

Take a simple program like

main = mapM_ print "Hello, world"

and build with -O.

Versions of ghc as late as 7.11.20150806 generate assembly that includes

...
_c3mn:
	movq $sat_s3m2_info,-16(%r12)
	movq %r14,(%r12)
	movq $block_c3mi_info,-16(%rbp)
	movl $GHC.Types.True_closure+2,%edi
	movq %rsi,%rax
	leaq -16(%r12),%rsi
	movl $GHC.IO.Handle.FD.stdout_closure,%r14d
	movq %rax,-8(%rbp)
	addq $-16,%rbp
	jmp GHC.IO.Handle.Text.hPutStr2_info
.text
	.align 8
	.quad	1
	.quad	32
block_c3mi_info:
_c3mi:
	movq 8(%rbp),%rbx
	addq $16,%rbp
	jmp stg_ap_v_fast
...

Note the .align 8 ensuring that the info table (and the code _c3mi itself) is 8-byte aligned.

In 8.1.20160107 we instead get

_c5gE:
	movq $sat_s5g9_info,-16(%r12)
	movq %r14,(%r12)
	movq $block_c5gz_info,-16(%rbp)
	movl $GHC.Types.True_closure+2,%edi
	movq %rsi,%rax
	leaq -16(%r12),%rsi
	movl $GHC.IO.Handle.FD.stdout_closure,%r14d
	movq %rax,-8(%rbp)
	addq $-16,%rbp
	jmp GHC.IO.Handle.Text.hPutStr2_info
_c5gF:
	movq $24,904(%r13)
_c5gC:
	movl $Main.main2_closure,%ebx
	jmp *-8(%r13)
	.quad	1
	.quad	32
block_c5gz_info:
_c5gz:
	movq 8(%rbp),%rbx
	addq $16,%rbp
	jmp stg_ap_v_fast
	.size Main.main2_info, .-Main.main2_info

There is some minor rearrangement, but more importantly there is no longer any .align 8 before .quad 1. That means the info table is not necessarily aligned, and indeed c5gz_info ended up at the address 40676f.

I'm guessing this is bad for performance, though I don't know how bad.

I'm pretty sure this is due to 4a32bf92 "Implement function-sections for Haskell code" though I haven't looked at that commit in detail.

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC olsner
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking