Skip to content

INLINE should be NOINLINE

Look at this code in GHC.Core.Type.hs

-- | A helper for 'expandSynTyConApp_maybe' to avoid inlining this cold path
-- into call-sites.
expand_syn :: Int      -- ^ the arity of the synonym
           -> [TyVar]  -- ^ the variables bound by the synonym
           -> Type     -- ^ the RHS of the synonym
           -> [Type]   -- ^ the type arguments the synonym is instantiated at.
           -> Type
expand_syn arity tvs rhs tys
 =  ...blah...
-- We never want to inline this cold-path.
{-# INLINE expand_syn #-}

The words say "don't inline expand_syn" but the code says "always inline it".

I think the words are right.

@bgamari this has been the case since expand_syn was born in

commit dad87210efffce9cfc2d17dc088a71d9dea14535
Author: Ben Gamari <bgamari.foss@gmail.com>
Date:   Tue Mar 24 13:13:43 2020 -0400

    Optimise nullary type constructor usage
    
    During the compilation of programs GHC very frequently deals with
    the `Type` type, which is a synonym of `TYPE 'LiftedRep`. This patch
    teaches GHC to avoid expanding the `Type` synonym (and other nullary
    type synonyms) during type comparisons, saving a good amount of work.
    This optimisation is described in `Note [Comparing nullary type
    synonyms]`.

@bgamari, shall we just change it to NOINLINE?

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information