[GHC] #13182: Rethinking dataToTag#

GHC ghc-devs at haskell.org
Tue Jan 24 18:13:40 UTC 2017


#13182: Rethinking dataToTag#
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:
               Type:  task           |            Status:  new
           Priority:  normal         |         Milestone:  8.2.1
          Component:  Compiler       |           Version:  8.1
           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:
-------------------------------------+-------------------------------------
 We currently use a primop `dataToTag#` that requires some careful handling
 because it can only be applied to something that has already been
 evaluated. We (now) mark it `can_fail` to prevent it from floating out,
 and then add a fix-up pass in CorePrep just in case things went wrong.
 Could we do something simpler? Suppose we had

 {{{#!hs
 -- The real primop, preferably not exported from *anywhere*, but at least
 documented as never to be used outside GHC.
 secretDataToTag# :: a -> Int#

 -- A wired-in safe version
 dataToTag# :: a -> Int#
 dataToTag# !a = secretDataToTag# a
 {-# NOINLINE dataToTag# #-}
 }}}

 Then `dataToTag#` could be inlined in CorePrep, just like `runRW#`.

 === Questions ===

 How would this interact with float out? It should be perfectly safe to
 float out when its argument is known to be forced, but it seems likely
 we'll run into let/app invariant failures.

 What RULES do we (or should we) have for `dataToTag#`? How will this
 change affect them? My vague recollection is that we don't have any, but
 it would be pretty nice to apply something equivalent to case-of-known-
 constructor. Whenever `dataToTag#` is applied to a known constructor, we
 should be able to evaluate it. The earlier we do this the better it will
 inform simplification.

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


More information about the ghc-tickets mailing list