summaryrefslogtreecommitdiff
path: root/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
* Pretty: remove a harmful $! (#12227)Thomas Miedema2016-07-171-1/+44
| | | | | | | | | | | | | | | | | This is backport of [1] for GHC's copy of Pretty. See Note [Differences between libraries/pretty and compiler/utils/Pretty.hs]. [1] http://git.haskell.org/packages/pretty.git/commit/bbe9270c5f849a5bb74c9166a5f4202cfb0dba22 https://github.com/haskell/pretty/issues/32 https://github.com/haskell/pretty/pull/35 Reviewers: bgamari, austin Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D2397 GHC Trac Issues: #12227
* Binary: Use ByteString's copy in getBSBen Gamari2016-07-161-19/+12
| | | | | | | | | | | | | | It's unclear how much of an effect on runtime this will have, but if nothing else the code generation may be a tad better since the system's `memcpy` will be used. Test Plan: Validate Reviewers: simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2401
* Pretty: delete really old changelogThomas Miedema2016-07-111-154/+20
| | | | | | | This changelog is very incomplete, and basically useless. I'm removing it, because it made it harder to compare this copy of `Pretty.hs` with the copy in `libraries/pretty` (from which a similar changelog was deleted some time ago).
* FastString: Supply mconcat implementationBen Gamari2016-07-081-0/+1
| | | | | | | | | | Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2389
* FastString: Add IsString instanceBen Gamari2016-07-081-0/+3
|
* FastString: Reduce allocations of concatFSBen Gamari2016-07-081-1/+1
| | | | | Instead of unpacking and then repacking we simply concatenate all of the individual ByteStrings.
* Utils: Fix `lengthIs` and `lengthExceeds` for negative argsÖmer Sinan Ağacan2016-07-071-6/+15
| | | | Credits goes to SPJ for finding this.
* Document some codegen nondeterminismBartosz Nitka2016-07-072-11/+17
| | | | | | | | | Bit-for-bit reproducible binaries are not a goal for now, so this is just marking places that could be a problem. Doing this will allow eltsUFM to be removed and will leave only nonDetEltsUFM. GHC Trac: #4012
* Style changes for UniqFMBartosz Nitka2016-07-071-148/+145
| | | | | | | | | | | | | | | | | | | This file used the old style with type signatures separated from the code. As far as I understand the idea was to generate PostScript files from the source. I think the idea was abandoned and this more modern style is more common in the codebase. Test Plan: it still compiles Reviewers: austin, simonmar, bgamari Reviewed By: simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2383
* Kill varEnvElts in seqDmdEnvBartosz Nitka2016-07-011-1/+7
| | | | GHC Trac: #4012
* Remove uniqSetToListBartosz Nitka2016-07-014-15/+21
| | | | | | | This documents nondeterminism in code generation and removes the nondeterministic ufmToList function. In the future someone will have to use nonDetEltsUFM (with proper explanation) or pprUFM.
* Remove ufmToListBartosz Nitka2016-06-302-6/+16
| | | | | | | This documents nondeterminism in code generation and removes the nondeterministic ufmToList function. In the future someone will have to use nonDetUFMToList (with proper explanation) or pprUFMWithKeys.
* Remove some `undefined`sÖmer Sinan Ağacan2016-06-271-3/+2
| | | | | | These get annoying when `undefined` is actually used as placeholder in WIP code. Some of these were also completely redundant (just call `deAnnotate'` instead of `deAnnotate` etc.).
* Provide Uniquable version of SCCBartosz Nitka2016-06-231-22/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | We want to remove the `Ord Unique` instance because there's no way to implement it in deterministic way and it's too easy to use by accident. We sometimes compute SCC for datatypes whose Ord instance is implemented in terms of Unique. The Ord constraint on SCC is just an artifact of some internal data structures. We can have an alternative implementation with a data structure that uses Uniquable instead. This does exactly that and I'm pleased that I didn't have to introduce any duplication to do that. Test Plan: ./validate I looked at performance tests and it's a tiny bit better. Reviewers: bgamari, simonmar, ezyang, austin, goldfire Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2359 GHC Trac Issues: #4012
* Make UnitIdMap a deterministic mapBartosz Nitka2016-06-061-1/+6
| | | | | | | | | | | | | | | | | | | This impacts at least the order in which version macros are generated. It's pretty hard to track what kind of nondeterminism is benign and this should have no performance impact as the number of packages should be relatively small. Test Plan: ./validate Reviewers: simonmar, austin, bgamari, ezyang Reviewed By: ezyang Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2308 GHC Trac Issues: #4012
* Kill foldUniqSetBartosz Nitka2016-06-062-14/+20
| | | | | | | | | | | | | | | I planned to just say that we don't care about this part. Turns out I was able to document away the uses in the codegenerator. Test Plan: ./validate Reviewers: simonmar, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2307 GHC Trac Issues: #4012
* Document putDictionary determinismBartosz Nitka2016-06-061-1/+3
| | | | | | | | | | | | | | Summary: Like explained in the comment it's OK here. Test Plan: ./validate Reviewers: simonmar, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2306 GHC Trac Issues: #4012
* Use UniqDFM for HomePackageTableBartosz Nitka2016-06-061-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This isn't strictly necessary for deterministic ABIs. The results of eltsHpt are consumed in two ways: 1) they determine the order of linking 2) if you track the data flow all the family instances get put in FamInstEnvs, so the nondeterministic order is forgotten. 3) same for VectInfo stuff 4) same for Annotations The problem is that I haven't found a nice way to do 2. in a local way and 1. is nice to have if we went for deterministic object files. Besides these maps are keyed on ModuleNames so they should be small relative to other things and the overhead should be negligible. As a bonus we also get more specific names. Test Plan: ./validate Reviewers: bgamari, austin, hvr, ezyang, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2300 GHC Trac Issues: #4012
* Make FieldLabelEnv a deterministic setBartosz Nitka2016-06-032-3/+32
| | | | | | | | | | | | | | | | | | This lets us kill fsEnvElts function which is nondeterministic. We also get better guarantees than just comments. We don't do lookups, but I believe a set is needed for deduplication. Test Plan: ./validate Reviewers: bgamari, mpickering, austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2297 GHC Trac Issues: #4012
* Remove 'deriving Typeable' statementsRyan Scott2016-05-246-14/+7
| | | | | | | | | | | | | | | | | Summary: Deriving `Typeable` has been a no-op since GHC 7.10, and now that we require 7.10+ to build GHC, we can remove all the redundant `deriving Typeable` statements in GHC. Test Plan: ./validate Reviewers: goldfire, austin, hvr, bgamari Reviewed By: austin, hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2260
* Make Arrow desugaring deterministicBartosz Nitka2016-05-241-1/+6
| | | | | | | | | | | | | | | | | | | This kills two instances of varSetElems that turned out to be nondeterministic. I've tried to untangle this before, but it's a bit hard with the fixDs in the middle. Fortunately I now have a test case that proves that we need determinism here. Test Plan: ./validate, new testcase Reviewers: simonpj, simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2258 GHC Trac Issues: #4012
* Document some benign nondeterminismBartosz Nitka2016-05-242-29/+27
| | | | | | | | | | | | | | | | | | I've changed the functions to their nonDet equivalents and explained why they're OK there. This allowed me to remove foldNameSet, foldVarEnv, foldVarEnv_Directly, foldVarSet and foldUFM_Directly. Test Plan: ./validate, there should be no change in behavior Reviewers: simonpj, simonmar, austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2244 GHC Trac Issues: #4012
* Revert "compiler/iface: compress .hi files"Ben Gamari2016-05-232-144/+19
| | | | | | | | | | | | | | | | | | | | | This appears to cause validation issues on, TEST="T11108 T9071 T11076 T7600 T7672 T8329 T10420 T10322 T8308 T4114a T4114c T10602 T10110 T9204 T2435 T9838 T4114d T10233 T8696 T1735 T5281 T6056 T10134 T9580 T6018 T9762 T8103" With compiler panics of the form, Compile failed (status 256) errors were: ghc: panic! (the 'impossible' happened) (GHC version 8.1.20160523 for x86_64-unknown-linux): Binary.readBinMem: decompression failed CallStack (from HasCallStack): error, called at compiler/utils/Binary.hs:192:16 in ghc:Binary Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug This reverts commit d9cb7a8a94daa4d20aa042cd053e20b491315633.
* compiler/iface: compress .hi filesAustin Seipp2016-05-212-19/+144
| | | | | | | | | | | | | | | | | | | Compress all interface files generated by the compiler with LZ4. While being only a tiny amount of code, LZ4 is both fast at compression and decompression, and has good compression ratios. Non-scientific size test: size of stage2 compiler .hi files: `find ./compiler/stage2 -type f -iname '*.hi' -exec du -ch {} + | grep total$` Without this patch: 22MB of .hi files for stage2. With this patch: 9.2MB of .hi files for stage2. Signed-off-by: Austin Seipp <austin@well-typed.com> Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1159
* Make inert_model and inert_eqs deterministic setsBartosz Nitka2016-05-181-1/+21
| | | | | | | | | | | | | | | | | | | | The order inert_model and intert_eqs fold affects the order that the typechecker looks at things. I've been able to experimentally confirm that the order of equalities and the order of the model matter for determinism. This is just a straigthforward replacement of nondeterministic VarEnv for deterministic DVarEnv. Test Plan: ./validate Reviewers: simonpj, goldfire, austin, bgamari, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2232 GHC Trac Issues: #4012
* Refactor some ppr functions to use pprUFMBartosz Nitka2016-05-121-4/+4
| | | | | | | | | | | | | | | | | Nondeterminism doesn't matter in these places and pprUFM makes it obvious. I've flipped the order of arguments for convenience. Test Plan: ./validate Reviewers: simonmar, bgamari, austin, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2205 GHC Trac Issues: #4012
* Kill varEnvElts in specImportsBartosz Nitka2016-05-121-0/+32
| | | | | | | | | | | | | | | | | We need the order of specialized binds and rules to be deterministic, so we use a deterministic set here. Test Plan: ./validate Reviewers: simonmar, bgamari, austin, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2197 GHC Trac Issues: #4012
* Document SCC determinismBartosz Nitka2016-05-112-2/+25
| | | | | | | | | | | | | | | | | | | | | | I've documented the guarantees that stronglyConnCompFromEdgedVertices provides and commented on the call sites to explain why they are OK from determinism standpoint. I've changed the functions to nonDetUFM versions, so that it's explicit they could introduce nondeterminism. I haven't defined container (VarSet, NameSet) specific versions, so that we have less functions to worry about. Test Plan: this is mostly just documentation, it should have no runtime effect Reviewers: bgamari, simonmar, austin, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2194 GHC Trac Issues: #4012
* Get rid of Traversable UniqFM and Foldable UniqFMBartosz Nitka2016-05-101-11/+12
| | | | | | | | | | | | | | | | | | | Both Traversable and Foldable can introduce non-determinism and because of typeclass overloading it's implicit and not obvious at the call site. This removes the instances, so that they can't accidentally be used. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonmar, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2190 GHC Trac Issues: #4012
* Remove unused equivClassesByUniqBartosz Nitka2016-05-021-16/+1
| | | | | | | | | | | | | | | | | It uses `eltsUFM` so it can introduce nondeterminism, but it isn't used so we can delete it. Test Plan: it builds Reviewers: simonpj, goldfire, simonmar, austin, bgamari Reviewed By: austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2161 GHC Trac Issues: #4012
* Remove unused foldFsEnvBartosz Nitka2016-04-281-3/+1
| | | | | foldFsEnv is nondeterministic in the general case and since it's unused we can just remove it.
* Kill mapUniqSetBartosz Nitka2016-04-281-3/+9
| | | | | | | | | | | | | | Note [Unsound mapUniqSet] explains why it got removed. Test Plan: build ghc Reviewers: simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2152
* Add uniqSetAny and uniqSetAll and use themBartosz Nitka2016-04-282-2/+16
| | | | | | | | | | | | | | | | | | There are couple of places where we do `foldUniqSet` just to compute `any` or `all`. `foldUniqSet` is non-deterministic in the general case and `any` and `all` also read nicer. Test Plan: ./validate Reviewers: simonmar, goldfire, simonpj, bgamari, austin Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2156 GHC Trac Issues: #4012
* Kill varSetElemsWellScoped in quantifyTyVarsBartosz Nitka2016-04-263-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | varSetElemsWellScoped introduces unnecessary non-determinism in inferred type signatures. Removing this instance required changing the representation of TcDepVars to use deterministic sets. This is the last occurence of varSetElemsWellScoped, allowing me to finally remove it. Test Plan: ./validate I will update the expected outputs when commiting, some reordering of type variables in types is expected. Reviewers: goldfire, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie, simonmar Differential Revision: https://phabricator.haskell.org/D2135 GHC Trac Issues: #4012
* Make benign non-determinism in pretty-printing more obviousBartosz Nitka2016-04-221-1/+19
| | | | | | | | | | | | | | | | | | | This change takes us one step closer to being able to remove `varSetElemsWellScoped`. The end goal is to make every source of non-determinism obvious at the source level, so that when we achieve determinism it doesn't get broken accidentally. Test Plan: compile GHC Reviewers: simonmar, goldfire, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2123 GHC Trac Issues: #4012
* Rename FV related functionsBartosz Nitka2016-04-201-34/+35
| | | | | | | | | | | | | This is from Simon's suggestion: * `tyCoVarsOfTypesAcc` is a terrible name for a function with a perfectly decent type `[Type] -> FV`. Maybe `tyCoFVsOfTypes`? Similarly others * `runFVList` is also terrible, but also has a decent type. Maybe just `fvVarList` (and `fvVarSet` for `runFVSet`). * `someVars` could be `mkFVs :: [Var] -> FV`.
* utils: Provide CallStack to expectJustBen Gamari2016-04-151-1/+11
| | | | | | | | | | | | Test Plan: Validate Reviewers: gridaphobe, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2106
* Core pretty printer: Omit wild case bindersJoachim Breitner2016-04-061-1/+6
| | | | | | | as they (especially their id info with absence information) clutter the output too much. They come back with debug_on. Differential Revision: https://phabricator.haskell.org/D2072
* Scrap DEC OSF/1 supportHerbert Valerio Riedel2016-03-281-3/+0
| | | | | | | | | | | | | DEC OSF/1 (aka Tru64 UNIX) has been discontinued a few years ago already[1]. This removes the undoubtedly bitrotten support for `OSOsf3 :: OS` from GHC's code-base. Support for `ArchAlpha :: Arch` may be removed at some later point, as there may still be users out there running a more or less recent Linux/alpha distribution on their more-than-a-decade old Alpha hardware... [1]: https://en.wikipedia.org/wiki/Tru64_UNIX
* Panic: Try outputting SDocsBen Gamari2016-03-262-20/+34
| | | | | | | | | | | | | | | | | This works in conjunction with D2036 to allow useful debug output before DynFlags has been initializated. See #11755. Reviewers: austin Reviewed By: austin Subscribers: thomie, gridaphobe Differential Revision: https://phabricator.haskell.org/D2037 GHC Trac Issues: #11755
* ErrUtils: Add timings to compiler phasesBen Gamari2016-03-241-1/+7
| | | | | | | | | | | | | | | | | | | | | | | This adds timings and allocation figures to the compiler's output when run with `-v2` in an effort to ease performance analysis. Todo: * Documentation * Where else should we add these? * Perhaps we should remove some of the now-arguably-redundant `showPass` occurrences where they are * Must we force more? * Perhaps we should place this behind a `-ftimings` instead of `-v2` Test Plan: `ghc -v2 Test.hs`, look at the output Reviewers: hvr, goldfire, simonmar, austin Reviewed By: simonmar Subscribers: angerman, michalt, niteria, ezyang, thomie Differential Revision: https://phabricator.haskell.org/D1959
* Handle unset HOME environment variable more gracefullyBen Gamari2016-03-111-1/+9
| | | | | | | | | | | | | | | Test Plan: * Validate * try `env -i ghc` * try `env -i runghc HelloWorld.hs` Reviewers: austin Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D1971 GHC Trac Issues: #11678
* Add Monoid instance for FastStringBen Gamari2016-03-051-0/+4
|
* Address #11471 by putting RuntimeRep in kinds.wip/runtime-repRichard Eisenberg2016-02-241-0/+16
| | | | | | | | | | | | | | | | | | | | | See Note [TYPE] in TysPrim. There are still some outstanding pieces in #11471 though, so this doesn't actually nail the bug. This commit also contains a few performance improvements: * Short-cut equality checking of nullary type syns * Compare types before kinds in eqType * INLINE coreViewOneStarKind * Store tycon binders separately from kinds. This resulted in a ~10% performance improvement in compiling the Cabal package. No change in functionality other than performance. (This affects the interface file format, though.) This commit updates the haddock submodule.
* Remove superfluous code when deriving Foldable/TraversableRyanGlScott2016-02-171-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, `-XDeriveFoldable` and `-XDeriveTraversable` generate unnecessary `mempty` and `pure` expressions when it traverses of an argument of a constructor whose type does not mention the last type parameter. Not only is this inefficient, but it prevents `Traversable` from being derivable for datatypes with unlifted arguments (see Trac #11174). The solution to this problem is to adopt a slight change to the algorithms for `-XDeriveFoldable` and `-XDeriveTraversable`, which is described in [this wiki page](https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/DeriveFu nctor#Proposal:alternativestrategyforderivingFoldableandTraversable). The wiki page also describes why we don't apply the same changes to the algorithm for `-XDeriveFunctor`. This is techincally a breaking change for users of `-XDeriveFoldable` and `-XDeriveTraversable`, since if someone was using a law-breaking `Monoid` instance with a derived `Foldable` instance (i.e., one where `x <> mempty` does not equal `x`) or a law-breaking `Applicative` instance with a derived `Traversable` instance, then the new generated code could result in different behavior. I suspect the number of scenarios like this is very small, and the onus really should be on those users to fix up their `Monoid`/`Applicative` instances. Fixes #11174. Test Plan: ./validate Reviewers: hvr, simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1908 GHC Trac Issues: #11174
* Print * has Unicode star with -fprint-unicode-syntaxBen Gamari2016-02-091-0/+1
| | | | | | | | Reviewers: austin, thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1893
* Remote GHCi: parallelise BCO serializationSimon Marlow2016-02-021-0/+8
| | | | | | | | | | | | | | | | | | | Summary: Serialization of BCOs is slow, but we can parallelise it when using ghci -j<n>. It parallelises nicely, saving multiple seconds off the link time in a large example I have. Test Plan: * validate * `ghci -fexternal-interpreter` in `nofib/real/anna` Reviewers: niteria, bgamari, ezyang, austin, hvr, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1877 GHC Trac Issues: #11100
* Add some Outputable instancesOleg Grenrus2016-02-011-0/+4
| | | | | | | | | | Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1865
* Refactor the typechecker to use ExpTypes.Richard Eisenberg2016-01-271-1/+6
| | | | | | | | | | | | | | | | | | | | | The idea here is described in [wiki:Typechecker]. Briefly, this refactor keeps solid track of "synthesis" mode vs "checking" in GHC's bidirectional type-checking algorithm. When in synthesis mode, the expected type is just an IORef to write to. In addition, this patch does a significant reworking of RebindableSyntax, allowing much more freedom in the types of the rebindable operators. For example, we can now have `negate :: Int -> Bool` and `(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic is in tcSyntaxOp. This addresses tickets #11397, #11452, and #11458. Tests: typecheck/should_compile/{RebindHR,RebindNegate,T11397,T11458} th/T11452
* Check InScopeSet in substTy and provide substTyUncheckedBartosz Nitka2016-01-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds sanity checks to `substTy` that implement: > when calling substTy subst ty it should be the case that the in-scope > set in the substitution is a superset of > * The free vars of the range of the substitution > * The free vars of ty minus the domain of the substitution and replaces violators with unchecked version. The violators were found by running the GHC test suite. This ensures that I can work on this incrementally and that what I fix won't be undone by some other change. It also includes a couple of fixes that I've already done. Test Plan: ./validate Reviewers: simonmar, goldfire, simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1792 GHC Trac Issues: #11371