[GHC] #7411: Exceptions are optimized away in certain situations

GHC ghc-devs at haskell.org
Wed May 9 09:38:58 UTC 2018


#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Replying to [comment:30 simonpj]:
 > > I think we should at least give the other options a fair try.
 >
 > Do you have other options in mind?  This has bugged us for a decade --
 it's why it's called the "state hack".
 >
 > Getting perf numbers for compiling everything (incl libraries) with
 `-fno-state-hack` would give us a bit of data to go on.

 I'm thinking in two directions here.

 The first one would be to just throw out the state hack altogether, as you
 suggested, or at least make `-fno-state-hack` the default and pepper the
 `fstate-hack` flag with dire warnings. Timing things with and without the
 state hack shouldn't be a very difficult task, so I suggest I put a bit of
 time into this.

 For the second one, let me summarize what I think the core of the problem
 is: The equational reasoning strategies behind this eta expansion and
 `seq` are at odds. The eta expansion assumes that floating bottoms around
 will not make an effective difference (as per fast-and-loose reasoning),
 but this assumption doesn't hold when `seq` is involved, because `seq` is
 like this magical backdoor to bottoms. Eta expansion says that `case x of
 { _ -> f }` is equivalent to `\eta -> case x of { _ -> f eta }`, even if
 there are bottoms involved. But this breaks when `seq` is involved,
 because the eta expansion allows the argument to slip past `seq`.

 So what we would need to fix this "properly" would be a way to mark the
 relevant code sections as "here be dragons", and make the state hack skip
 over those. But I suspect this would be a rather invasive change
 (extending Core with such markers), and detecting such sections correctly
 could be tricky. Or maybe not, I really don't know.

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


More information about the ghc-tickets mailing list