Opened 4 years ago

Last modified 3 years ago

#10766 new task

user manual: INLINE's interaction with optimization levels is not clear

Reported by: osa1 Owned by:
Priority: normal Milestone:
Component: Documentation Version: 7.11
Keywords: Inlining Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Documentation bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by osa1)

From the user manual it's not possible to say how should INLINE and actual inlining behavior should interact with optimization levels.

What the user manuals says:

  • Without INLINE GHC tries to inline depending on size of definitions and current optimization level(user manual says -O is needed, but can we assume that for any inlining to be done we need at least -O? Because I have an example in which inlining is happening even with -O0).
  • With INLINE GHC tries hard to inline. But it doesn't say which optimization level is needed.

I think we should add word or two about this. Does anyone know the answer here?

My guess is: Even though INLINE makes sure GHC saves RHS of the definition in .hi files to be able to inline later, optimization levels still have an effect on deciding whether to inline or not. Because some INLINEd RHSs may be too big in which case it may decide not to inline with -O1 but inline with -O2 etc.

Furthermore, without -O, GHC doesn't mark definitions as INLINE. But if we have INLINEd definitions and compiling a code with -O0, it may still inline those definitions, because there are two different mechanisms to decide whether to mark as INLINE and whether to inline the RHS, and while without -O GHC doesn't mark anything as INLINE, it can still inline previously marked definitions.

Change History (3)

comment:1 Changed 4 years ago by osa1

Description: modified (diff)

comment:2 Changed 4 years ago by thomie

Type of failure: OtherDocumentation bug

comment:3 Changed 3 years ago by mpickering

Keywords: Inlining added
Note: See TracTickets for help on using tickets.