[GHC] #13080: Constant values are not floated out of the loop
GHC
ghc-devs at haskell.org
Sat Jan 7 14:42:24 UTC 2017
#13080: Constant values are not floated out of the loop
-------------------------------------+-------------------------------------
Reporter: Feuerbach | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
Floating out `return ()` won't help much. Even if you do that, the program
looks like
{{{
worker = let l = poll ()
in forever l
r = return ()
poll a = r >> poll a
}}}
so executing `l` will cause `l` to be evaluated as `r >> r >> r >> r >>
...` and we still have a live reference to `l` from within `forever`.
If you instead define
{{{
poll a = r >>= \_ -> poll a
}}}
and compile ''without optimization'' then `l` now looks like `r >>= (\_ ->
...)` and the space leak is gone. But turning on optimizations seems to
cause GHC to rewrite the above to
{{{
poll a = r >>= (let s = poll a in \_ -> s)
}}}
which now has the original problem again.
(BTW I am always compiling with `-fno-state-hack`, since that just adds
another layer of confusion to an already confusing situation.)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13080#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list