[GHC] #14626: No need to enter a scrutinised value
GHC
ghc-devs at haskell.org
Wed Jan 3 06:55:45 UTC 2018
#14626: No need to enter a scrutinised value
-------------------------------------+-------------------------------------
Reporter: heisenbug | Owner: heisenbug
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Resolution: | Keywords: performance
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #13861 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by heisenbug):
Replying to [comment:5 simonpj]:
> > So something is definitely fishy here.
>
> I think that there's something different about '''top-level''' binders.
Consider
> {{{#!hs
> data T = MkT !Bool
> top_x = True
>
> f True (MkT local_y) = local_y
> f False _ = top_x
> }}}
> Here I think that `local_y` gets bound to a correctly-tagged pointer,
fetched out of the `MkT` constructor.
>
> But, in contrast, I think that `top_x` is bound to the label for the
top-level closure for `top_x`, which is 8-byte aligned. So the label
isn't tagged; instead, the code generator has to tag it. Is that
happening in your "return it instead of eantering it" path?
No, I am not returning top-level bindings, I would be okay with entering
those. What I want is to avoid entering local bindings from the `StgCase`:
{{{#!hs
f = \inp -> case inp of wildBind { True -> ...; False -> wildBind }
}}}
`wildBind` is known to be evaled and properly tagged. I want to
`ReturnIt`.
>
> Other than that I have no idea why it crashes. Things you might try:
>
> * Switch off the new optimisation when building stage2 and the
libraries. Use it only for the test suite: these are small programs and
easier to debug.
>
> * Maybe add an assertion in the Cmm: the claim is that on the "return
it" path, the thing beign returned is a correctly-tagged pointer. So, the
assertion can follow the pointer and check that the thing pointed to is a
value, with the right tag, etc. There must be some code in the RTS (or
somewhere) that checks that.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14626#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list