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,257
    • Issues 4,257
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 394
    • Merge Requests 394
  • 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
  • Wiki
  • inlining

Last edited by Ben Gamari Apr 01, 2019
Page history New page

inlining

Inlining

Inlining is the most important compiler optimisation pass as it enables most other optimisation opportunities. The pass is simple, saturated names are replaced with their definitions, the details are complicated. The compiler must make judgements as to whether inlining a function will lead to further optimisations, if not then it is easy to increase the code size needlessly.

Getting Started

  • Secrets of the GHC inliner -- quite an old paper but a great description of the main ideas
  • GHC User Guide -- Provides a description of INLINE, INLINABLE and NOINLINE pragmas.
  • Inlining and Specialisation -- A blog post explaining the basic operation of the inliner and specialiser and the interaction of different pragmas and options.

Generics and Inlining

Inlining is essential to remove intermediate representations from generic programs. There are a number of papers about the topic.

  • Optimizing Generics Is Easy! (2010)
  • Optimizing SYB Is Easy! (2014)

Debugging the inliner

Firstly, remember that the inliner only fires with optimisations turns on (at least -O1). This will save you a lot of time wondering why nothing is happening!

There are several flags which are useful when working with the inliner.

Flag Usage
`--show-iface` Shows the contents of an interface file. Can be useful to check which unfoldings are being included.
`-dshow-passes` Shows the size of the program after each optimisation pass.
`-ddump-inlinings` Shows inlinings which take place
`-ddump-simpl` Dump the (core) output of the simplifer

Relevant Tickets

See the inlining label.

There are also lots of old relevant tickets related to inlining. Perfect for a keen newcomer! Look for tickets labelled with both inlining and newcomer.

Relevant Wiki Pages

  • Commentary/Compiler/DesugaringInstances -- About how default methods can lead to poor inliner performance due to recursion
  • Proposal/SelfExplinatoryInlinePragmas
Clone repository

GHC Home
GHC User's Guide

Joining In

Newcomers info
Mailing Lists & IRC
The GHC Team

Documentation

GHC Status Info
Working conventions
Building Guide
Debugging
Commentary

Wiki

Title Index
Recent Changes