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.
- Secrets of the GHC inliner -- quite an old paper but a great description of the main ideas
GHC User Guide -- Provides a description of
- 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.
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.
|`--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|
See the inlining label.