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

GHC ghc-devs at haskell.org
Tue Dec 18 23:33:33 UTC 2018


#16039: 'GHC.Magic.noinline <var>' should not float out
-------------------------------------+-------------------------------------
        Reporter:  heisenbug         |                Owner:  heisenbug
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:  FloatOut
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #15155            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by heisenbug):

 Augmenting
 {{{#!hs
 exprIsCheapX :: CheapAppFun -> CoreExpr -> Bool
 exprIsCheapX ok_app e
   = ok e
   where
     ok e = go 0 e

     -- n is the number of value arguments
     go n (Var v)                      = ok_app v n
     go _ (Lit {})                     = True
     go _ (Type {})                    = True
     go _ (Coercion {})                = True
     go n (Cast e _)                   = go n e
     go n (Case scrut _ _ alts)        = ok scrut &&
                                         and [ go n rhs | (_,_,rhs) <- alts
 ]
     go n (Tick t e) | tickishCounts t = False
                     | otherwise       = go n e
     go n (Lam x e)  | isRuntimeVar x  = n==0 || go (n-1) e
                     | otherwise       = go n e
     go n (App f e)  | App (Var v) Type {} <- f   -- added clause
                     , v `hasKey` noinlineIdKey
                     , isRuntimeArg e  = go n e
     go n (App f e)  | isRuntimeArg e  = go (n+1) f && ok e
                     | otherwise       = go n f
     go n (Let (NonRec _ r) e)         = go n e && ok r
     go n (Let (Rec prs) e)            = go n e && all (ok . snd) prs

 }}}
 helped a lot :-)

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


More information about the ghc-tickets mailing list