[GHC] #8275: Loopification breaks profiling

GHC ghc-devs at haskell.org
Fri Oct 18 14:06:22 UTC 2013


#8275: Loopification breaks profiling
----------------------------------------+----------------------------------
        Reporter:  jstolarek            |            Owner:  jstolarek
            Type:  bug                  |           Status:  new
        Priority:  high                 |        Milestone:  7.8.1
       Component:  Profiling            |          Version:  7.7
      Resolution:                       |         Keywords:
Operating System:  Unknown/Multiple     |     Architecture:
 Type of failure:  Building GHC failed  |  Unknown/Multiple
       Test Case:                       |       Difficulty:  Unknown
        Blocking:  8298                 |       Blocked By:  8456
                                        |  Related Tickets:
----------------------------------------+----------------------------------

Comment (by jstolarek):

 Replying to [comment:24 simonpj]:

 > But I don't understand the patch (in comment 19), to `CmmLayoutStack`.
 The change made there is simply to ''pass a different (larger) value to
 `manifestSp`''.  And that's the only change to that module.  So we'll
 generate different, wrong code.  I don't see how this can possibly work.
 And yet apparently it does.  What am I missing?

 I'll try to explain this with an example of function that uses no stack
 space. Previously we generated stack checks that looked like this:

 {{{
 if (Sp - <highSp> < SpLim) ...
 }}}

 If the function used no stack, then stack layout (`areaToSp` function,
 second guard) transformed this into:

 {{{
 if (Sp - 0 < SpLim) ...
 }}}

 This check is always false and it used to be eliminated by the third guard
 in `areaToSp`. The value of `<highSp>` is computed to be `0` by the line
 of code that I removed in !CmmLayoutStack.

 Now consider new version. Code generator gives us:

 {{{
 if ((old + 0) - <highSp> < SpLim) ...
 }}}

 As you pointed out, `<highSp>` will now be larger. But `(old + 0)` will
 not be `Sp`! This check will be turned into something this:

 {{{
 if ((Sp + 8) - 8 < SpLim) ...
 }}}

 That is the reason why the elimination of always false stack checks was
 killed by my change.

 BTW. Simon, you wrote the code for that patch when I was in Cambridge :-)
 Do you remember how we (well, mostly you) updated
 [http://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/StackAreas this
 wiki page] and how we were confused with addressing offsets into an `Old`
 area?

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


More information about the ghc-tickets mailing list