Skip to content
  • Simon Peyton Jones's avatar
    Preserve specialisations despite CSE · 3addf72a
    Simon Peyton Jones authored
    Trac #15445 showed that, as a result of CSE, a function with an
    automatically generated specialisation RULE could be inlined
    before the RULE had a chance to fire.
    
    This patch attaches a NOINLINE[2] activation to the Id, during
    CSE, to stop this happening.
    
    See Note [Delay inlining after CSE]
    
    ---- Historical note ---
    
    This patch is simpler and more direct than an earlier
    version:
    
      commit 2110738b
      Author: Simon Peyton Jones <simonpj@microsoft.com>
      Date:   Mon Jul 30 13:43:56 2018 +0100
    
      Don't inline functions with RULES too early
    
    We had to revert this patch because it made GHC itself slower.
    
    Why? It delayed inlining of /all/ functions with RULES, and that was
    very bad in TcFlatten.flatten_ty_con_app
    
    * It delayed inlining of liftM
    * That delayed the unravelling of the recursion in some dictionary
      bindings.
    * That delayed some eta expansion, leaving
         flatten_ty_con_app = \x y. let <stuff> in \z. blah
    * That allowed the float-out pass to put sguff between
      the \y and \z.
    * And that permanently stopped eta expasion of the function,
      even once <stuff> was simplified.
    
    -- End of historical note ---
    3addf72a