[GHC] #10346: Cross-module SpecConstr

GHC ghc-devs at haskell.org
Fri Apr 6 13:24:35 UTC 2018


#10346: Cross-module SpecConstr
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.1
      Resolution:                    |             Keywords:  SpecConstr,
                                     |  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13016            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by simonpj:

Old description:

> Type-class specialisation now happens flawlessly across modules.  That
> is, if I define
> {{{
> module DefineF where
>    f :: Num a => a -> a
>    {-# INLINEABLE f #-}
>    f x = ...f x'....
> }}}
> then modules that import `DefineF` and call `f` at some particular type
> (say `Int`) will generate a specialised copy of `f`'s code.
>
> But this does not happen for `SpecConstr`; we only specialise a function
> for calls made in the same module. All the infrastructure is in place to
> allow cross-module `SpecConstr`; it just hasn't been done yet.  This
> ticket is to record the idea.

New description:

 Type-class specialisation now happens flawlessly across modules.  That is,
 if I define
 {{{
 module DefineF where
    f :: Num a => a -> a
    {-# INLINEABLE f #-}
    f x = ...f x'....
 }}}
 then modules that import `DefineF` and call `f` at some particular type
 (say `Int`) will generate a specialised copy of `f`'s code.

 But this does not happen for `SpecConstr`; we only specialise a function
 for calls made in the same module.  For example:
 {{{
 module M where
   {-# INLINABLE foo #-}
   foo True  y     = y
   foo False (a,b) = foo True (a+b,b)

 module X where
   import M
   bar = ...(foo (x,y))...
 }}}
 Here `foo` is called with an explicit `(x,y)` argument in module `X`, and
 we'd like to !SpecConstr it, as it would be if the call was in module `M`.


 All the infrastructure is in place to allow cross-module `SpecConstr`; it
 just hasn't been done yet.  This ticket is to record the idea.

--

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


More information about the ghc-tickets mailing list