[GHC] #4012: Compilation results are not deterministic

GHC ghc-devs at haskell.org
Fri Oct 30 23:06:21 UTC 2015


#4012: Compilation results are not deterministic
-------------------------------------+-------------------------------------
        Reporter:  kili              |                Owner:  niteria
            Type:  bug               |               Status:  patch
        Priority:  high              |            Milestone:  8.0.1
       Component:  Compiler          |              Version:  6.12.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10424            |  Differential Rev(s):  Phab:D910,
                                     |  Phab:D1073, Phab:D1133, Phab:D1192,
       Wiki Page:                    |  Phab:D1268
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"a5cb27f323a0c78f61db1a3c5338045b0981850b/ghc"
 a5cb27f3/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="a5cb27f323a0c78f61db1a3c5338045b0981850b"
 Make type-class dictionary let binds deterministic

 When generating dictionary let binds in dsTcEvBinds we may
 end up generating them in arbitrary order according to Unique order.

 Consider:

 ```
 let $dEq = GHC.Classes.$fEqInt in
 let $$dNum = GHC.Num.$fNumInt in ...
 ```

 vs

 ```
 let $dNum = GHC.Num.$fNumInt in
 let $dEq = GHC.Classes.$fEqInt in ...
 ```

 The way this change fixes it is by using `UniqDFM` - a type of
 deterministic finite maps of things keyed on `Unique`s. This way when
 you pull out evidence variables corresponding to type-class dictionaries
 they are in deterministic order.

 Currently it's the order of insertion and the way it's implemented is by
 tagging the values with the time of insertion.

 Test Plan:
 I've added a new test case to reproduce the issue.
 ./validate

 Reviewers: ezyang, simonmar, austin, simonpj, bgamari

 Reviewed By: simonmar, simonpj, bgamari

 Subscribers: thomie

 Differential Revision: https://phabricator.haskell.org/D1396

 GHC Trac Issues: #4012
 }}}

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


More information about the ghc-tickets mailing list