[GHC] #16039: 'GHC.Magic.noinline <var>' should not float out

GHC ghc-devs at haskell.org
Wed Dec 12 12:22:37 UTC 2018


#16039: 'GHC.Magic.noinline <var>' should not float out
-------------------------------------+-------------------------------------
           Reporter:  heisenbug      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.8.1
          Component:  Compiler       |           Version:  8.2.1
           Keywords:  FloatOut       |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #15155
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 While working on #15155, I discovered that the magic function
 `GHC.Magic.noinline` tricked the float-out transformation into performing
 undesirable operations:

 Looking at the Core produced:
 {{{#!hs
                   { ghc-prim-0.5.3:GHC.Types.I# x_azMX [Dmd=<S,U>] ->
                   case x_azMX of {
                     __DEFAULT -> jump $j_sMly;
                     3674937295934324920# ->
                       src<compiler/typecheck/TcTyClsDecls.hs:3561:9-35>
                       check_ty_roles_sLb3
 (src<compiler/typecheck/TcTyClsDecls.hs:3561:24-26> env_aqfK)
 (src<compiler/typecheck/TcTyClsDecls.hs:3561:28-31> role_aqfL)
                         (ghc-prim-0.5.3:GHC.Magic.noinline @ Kind
 liftedTypeKind)
                   }
                   }
 }}}
 After simplification we end up with a toplevel variable basically
 redirecting to an imported variable.
 {{{#!hs
 -- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0}
 lvl330_r12qn :: Kind
 [GblId]
 lvl330_r12qn
   = ghc-prim-0.5.3:GHC.Magic.noinline @ Kind liftedTypeKind
 }}}
 This would cause `IND_STATIC`s when eventually emitted as assembly.

 IIRC `GHC.Magic.noinline` was introduced with GHC v8.2. This probably
 regressed the float-out optimisation.

 I have a patch to reclassify `noinline <some-var>` as cheap, so that it
 won't be floated out.

 N.B.: for more details, see: https://github.com/ghc/ghc/pull/224

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


More information about the ghc-tickets mailing list