[GHC] #14001: Inlining does not work between modules

GHC ghc-devs at haskell.org
Thu Jul 20 15:41:06 UTC 2017


#14001: Inlining does not work between modules
-------------------------------------+-------------------------------------
           Reporter:  danilo2        |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  high           |         Milestone:
          Component:  Compiler       |           Version:  8.0.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Hi! I discovered today something that looks like a terrifying bug. I was
 discussing it on IRC and so far there is no explanation why it happens.
 Let's grab a test code from here: https://github.com/luna/dependent-
 state/tree/irc-testing (branch irc-testing).

 If you download it and execute `stack --stack-yaml stack-develop.yaml
 bench dependent-state:layered-state-benchmark` benchmarks from
 `test/bench/Main.hs` will be executed. Everything is compiled with `-O2`
 etc (see stack-develop.yaml for details).

 And now (everything regarding file `Control/Monad/State/Layered.hs`):

   1. If you change lines `94-111` to use pointfree instead of normal arg,
 you get 40x slowdown
   2. If you then uncomment lines `80-81`, everything is fast again.

 The problem is that lines `80-81` are:

 {{{
 (.) :: (b -> c) -> (a -> b) -> a -> c
 (.) f g = \x -> f (g x) ; {-# INLINE (.) #-}
 }}}

 It seems that this function is inlined ONLY if is defined in this module.
 If we use the one from base OR if we move this function to separate
 module, we can observe the slowdown.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14001>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list