[GHC] #13720: INLINE pragma semantics changed since 8.0.2

GHC ghc-devs at haskell.org
Thu May 18 16:51:27 UTC 2017


#13720: INLINE pragma semantics changed since 8.0.2
-------------------------------------+-------------------------------------
        Reporter:  mpickering        |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 BTW, there's a warning you get when compiling `A`:

 {{{
 A.hs:9:11: warning: [-Winline-rule-shadowing]
     Rule "h x" may never fire because ‘h’ might inline first
     Probable fix: add an INLINE[n] or NOINLINE[n] pragma for ‘h’
   |
 9 | {-# RULES "h x" forall x . h x = error "REWRITE" #-}
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 }}}

 If you follow GHC's advice:

 {{{#!hs
 module A where

 {-# INLINE f #-}
 f x = h x

 {-# INLINE[0] h #-}
 h x = x

 {-# RULES "h x" forall x . h x = error "REWRITE" #-
 }}}

 Then you get back the pre-8.2 behavior:

 {{{
 $ /opt/ghc/8.2.1/bin/ghc B.hs -O2 -fforce-recomp -ddump-simpl | grep qux
 -A5
 qux :: Integer
 [GblId, Str=x]
 qux
   = error ....
 }}}

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


More information about the ghc-tickets mailing list