[GHC] #5889: -fno-prof-count-entries leads to linking errors

GHC ghc-devs at haskell.org
Thu Nov 2 19:16:01 UTC 2017


#5889: -fno-prof-count-entries leads to linking errors
-------------------------------------+-------------------------------------
        Reporter:  akio              |                Owner:  bgamari
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.3
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:  x86_64
 Type of failure:  GHC rejects       |  (amd64)
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by bgamari):

 Alright, the rest is pretty clear I think:

 Note that in the RHS of the simplified `newTyConInstRhs` the ticks should
 wrap the two arguments `ww1_suMl` and `ww2_suMm` but don't.

 `CoreUtils.mkTick` has the following case for ticks wrapping `Var`s,
 {{{#!hs
   mkTick' top rest expr = case expr of
     ...
     Var x
       | notFunction && tickishPlace t == PlaceCostCentre
       -> orig_expr
       | notFunction && canSplit
       -> top $ Tick (mkNoScope t) $ rest expr
       where
         -- SCCs can be eliminated on variables provided the variable
         -- is not a function.  In these cases the SCC makes no difference:
         -- the cost of evaluating the variable will be attributed to its
         -- definition site.  When the variable refers to a function,
 however,
         -- an SCC annotation on the variable affects the cost-centre stack
         -- when the function is called, so we must retain those.
         notFunction = not (isFunTy (idType x))
 }}}
 Moreover, `CoreSyn.tickishPlace` is defined thusly,
 {{{#!hs
 tickishPlace :: Tickish id -> TickishPlacement
 tickishPlace n at ProfNote{}
   | profNoteCount n        = PlaceRuntime
   | otherwise              = PlaceCostCentre
 ...
 }}}

 This is how the counting and non-counting cases are treated differently.

 So in short, in the non-counting case we try to wrap a `Var` expression in
 a tick. `mkTick` then notices that such a tick can be dropped and does so.
 However, the tick remains in the unfolding. Consequently, when we inline
 `newTyConInstRhs` in another module we end up with a reference to a cost
 center whose corresponding symbol doesn't exist in the module that is
 supposed to define it.

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


More information about the ghc-tickets mailing list