summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix an outright bug in the unflattenerSimon Peyton Jones2017-12-141-21/+24
| | | | | | | | | Trac #14554 showed up an outright bug in the unflattening code in TcFlatten. I was filling in a coercion with the wrong coercion (a Syn in the wrong place). Result: "Bad coercion hole" assertion failures, and Core Lint Errors. Easily fixed, and the code is simpler too.
* Typofix in commentGabor Greif2017-12-131-1/+1
|
* Further improvements to well-kinded typesSimon Peyton Jones2017-12-133-102/+134
| | | | | | | | | | | | | | | | | | | | | | | The typechecker has the invariant that every type should be well-kinded as it stands, without zonking. See Note [The well-kinded type invariant] in TcType. That invariant was not being upheld, which led to Trac #14174. I fixed part of it, but T14174a showed that there was more. This patch finishes the job. * See Note [The tcType invariant] in TcHsType, which articulates an invariant that was very nearly, but not quite, true. One place that falisified it was the HsWildCardTy case of tc_hs_type, so I fixed that. * mkNakedCastTy now makes no attempt to eliminate casts; indeed it cannot lest it break Note [The well-kinded type invariant]. The prior comment suggested that it was crucial for performance but happily it seems not to be. The extra Refls are eliminated by the zonker. * I found I could tidy up TcHsType.instantiateTyN and instantiateTyUntilN by eliminating one of its parameters. That led to a cascade of minor improvements in TcTyClsDecls. Hooray.
* Tidy up of wired-in namesSimon Peyton Jones2017-12-132-76/+67
| | | | | | | | | | | | Two things here: * While debugging Trac #14561 I found it hard to understand ghcPrimIds and magicIds in MkId. This patch adds more structure and comments. * I also discovered that ($) no longer needs to be a wiredInId because we now have levity polymorphism. So I took dollarId out of MkId; and gave it a levity-polymorphic type in GHC.Base
* Detect levity-polymorphic uses of unsafeCoerce#Simon Peyton Jones2017-12-132-4/+25
| | | | | | | | This bug was shown up by Trac #14561. The deguarer carefully detects unsaturated and levity-polymorphic uses of primops, but not of things like unsafeCoerce#. The fix is simple: see Note [Levity-polymorphic Ids] in Id.
* Minor refactor of TcExpr.tcAppSimon Peyton Jones2017-12-131-54/+70
| | | | | This refactoring has no change in behaviour but makes the structure clearer
* Allow users to ignore optimization changesDavid Feuer2017-12-115-19/+183
| | | | | | | | | | | | | | | | | | | | * Add a new flag, `-fignore-optim-changes`, allowing them to avoid recompilation if the only changes are to the `-O` level or to flags controlling optimizations. * When `-fignore-optim-changes` is *off*, recompile when optimization flags (e.g., `-fno-full-laziness`) change. Previously, we ignored these unconditionally when deciding whether to recompile a module. Reviewers: austin, bgamari, simonmar Reviewed By: simonmar Subscribers: duog, carter, simonmar, rwbarton, thomie GHC Trac Issues: #13604 Differential Revision: https://phabricator.haskell.org/D4123
* Fix SigTvs at the kind levelSimon Peyton Jones2017-12-117-103/+179
| | | | | | | | | | | | | | This patch fixes two bugs in the treatment of SigTvs at the kind level: - We should always generalise them, never default them (Trac #14555, #14563) - We should check if they get unified with each other (Trac #11203) Both are described in TcHsType Note [Kind generalisation and SigTvs]
* Build only well-kinded types in type checkerSimon Peyton Jones2017-12-111-6/+34
| | | | | | | | | | | | | | | During type inference, we maintain the invariant that every type is well-kinded /without/ zonking; and in particular that typeKind does not fail (as it can for ill-kinded types). But TcHsType.tcInferApps was not guaranteeing this invariant, resulting in Trac #14174 and #14520. This patch fixes it, making things better -- but it does /not/ fix the program in Trac #14174 comment:5, which still crashes. So more work to be done. See Note [Ensure well-kinded types] in TcHsType
* Improved panic message for zonkTcTyVarToTyVarSimon Peyton Jones2017-12-111-2/+6
|
* Occurrrence analysis improvements for NOINLINE functionsSimon Peyton Jones2017-12-085-36/+47
| | | | | | | | | This patch fixes #14567. The idea is simple: if a function is marked NOINLINE then it makes a great candidate for a loop breaker. Implementation is easy too, but it needs a little extra plubming, notably the occ_unf_act field in OccEnv
* Improve LiberateCaseSimon Peyton Jones2017-12-081-36/+54
| | | | | | | | | | | | | | | This patch, which fixes Trac #14566, makes LiberateCase a little more conservative. In particular: * In libCaseBind, treat a recursive group as a whole, rather than binding-by-binding, allowing the group to be duplicated only if - the bindings /considered together/ are smaller than the liberate-case threshold (which is large by default) - none of them are thunks - none of them are guaranteed-diverging The latter condidtion is new, and happens to apply in the case of Data/Typeable/Internal.mkTrApp
* Refactor kcHsTyVarBndrsSimon Peyton Jones2017-12-082-71/+83
| | | | | | | | | | | | | | | This refactoring * Renames kcHsTyVarBndrs to kcLHsQTyVars, which is more truthful. It is only used in getInitialKind. * Pulls out bind_telescope from that function, and calls it kcLHsTyVarBndrs, again to reflect its argument * Uses the new kcLHsTyVarBndrs in kcConDecl, where the old function was wild overkill. There should not be any change in behaviour
* Refactor ConDecl: Trac #14529Simon Peyton Jones2017-12-0713-440/+478
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch refactors HsDecls.ConDecl. Specifically * ConDeclGADT was horrible, with all the information hidden inside con_res_ty. Now it's kept separate, as it should be. * ConDeclH98: use [LHsTyVarBndr] instead of LHsQTyVars for the existentials. There is no implicit binding here. * Add a field con_forall to both ConDeclGADT and ConDeclH98 which says if there is an explicit user-written forall. * Field renamings in ConDecl con_cxt to con_mb_cxt con_details to con_args There is an accompanying submodule update to Haddock. Also the following change turned out to remove a lot of clutter: * add a smart constructor for HsAppsTy, namely mkHsAppsTy, and use it consistently. This avoids a lot of painful pattern matching for the common singleton case. Two api-annotation tests (T10278, and T10399) are broken, hence marking them as expect_broken(14529). Alan is going to fix them, probably by changing the con_forall field to con_forall :: Maybe SrcSpan instead of Bool
* template-haskell: Rip out FamFlavourBen Gamari2017-12-041-12/+0
| | | | | This was scheduled to happen for 8.2, it looks like it will actually happen in 8.4.
* Cache TypeRep kinds aggressivelyDavid Feuer2017-12-013-22/+36
| | | | | | | | | | | | | | | | | | | Cache `TypeRep k` in each `TrApp` or `TrTyCon` constructor of `TypeRep (a :: k)`. This makes `typeRepKind` cheap. With this change, we won't need any special effort to deserialize typereps efficiently. The downside, of course, is that we make `TypeRep`s slightly larger. Reviewers: austin, hvr, bgamari, simonpj Reviewed By: bgamari, simonpj Subscribers: carter, simonpj, rwbarton, thomie GHC Trac Issues: #14254 Differential Revision: https://phabricator.haskell.org/D4085
* Add trace injectionDavid Feuer2017-12-012-3/+43
| | | | | | | | | | | | | | Add support for injecting runtime calls to `trace` in `DsM`. This allows the desugarer to add compile-time information to a runtime trace. Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: carter, thomie, rwbarton Differential Revision: https://phabricator.haskell.org/D4162
* Handle CPP properly in BackpackEdward Z. Yang2017-11-301-2/+8
| | | | | | | | | | | | | | | | | | Summary: Previously, we attempted to lookup 'hole' packages for include directories; this obviously is not going to work. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: validate Reviewers: ekmett, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #14525 Differential Revision: https://phabricator.haskell.org/D4234
* Make use of boot TyThings during typechecking.Edward Z. Yang2017-11-307-216/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Suppose that you are typechecking A.hs, which transitively imports, via B.hs, A.hs-boot. When we poke on B.hs and discover that it has a reference to a type from A, what TyThing should we wire it up with? Clearly, if we have already typechecked A, we should use the most up-to-date TyThing: the one we freshly generated when we typechecked A. But what if we haven't typechecked it yet? For the longest time, GHC adopted the policy that this was *an error condition*; that you MUST NEVER poke on B.hs's reference to a thing defined in A.hs until A.hs has gotten around to checking this. However, actually ensuring this is the case has proven to be a bug farm. The problem was especially poignant with type family consistency checks, which eagerly happen before any typechecking takes place. This patch takes a different strategy: if we ever try to access an entity from A which doesn't exist, we just fall back on the definition of A from the hs-boot file. This means that you may end up with a mix of A.hs and A.hs-boot TyThings during the course of typechecking. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: validate Reviewers: simonpj, bgamari, austin, goldfire Subscribers: thomie, rwbarton GHC Trac Issues: #14396 Differential Revision: https://phabricator.haskell.org/D4154
* Comments only: Trac #14511Simon Peyton Jones2017-11-291-0/+10
|
* CLabel: A bit of documentationBen Gamari2017-11-281-3/+25
|
* Cmm: Add missing cases for BlockInfoTableBen Gamari2017-11-281-0/+2
| | | | | Silly rabbit, BlockInfoTables are data. This fixes the unregisterised build, finally fixing #14454.
* CLabel: More specific debug output from CLabelBen Gamari2017-11-281-2/+3
|
* nativeGen: Use foldl' instead of foldlBen Gamari2017-11-281-1/+1
|
* nativeGen: Use plusUFMList instead of foldrBen Gamari2017-11-281-2/+2
|
* CLabel: Refactor pprDynamicLinkerAsmLabelBen Gamari2017-11-281-49/+59
|
* cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocksBen Gamari2017-11-288-25/+60
| | | | | | | | | | blockLbl was originally changed in 8b007abbeb3045900a11529d907a835080129176 to use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this breaks the C code generator, which doesn't support AsmTempLabels (#14454). Instead let's try going the other direction: use a new CLabel variety, LocalBlockLabel. Then we can teach the C code generator to deal with these as well.
* CLabel.labelType: Make catch-all case explicitBen Gamari2017-11-281-3/+14
|
* typecheck: Consistently use pretty quotes in error messagesBen Gamari2017-11-271-6/+9
| | | | | | Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4241
* Check quantification for partial type signatuesSimon Peyton Jones2017-11-272-49/+92
| | | | | | | | | | | Trac #14449 showed that we were failing to check that the quantified type variables of a partial type signature remained distinct. See Note [Quantified variables in partial type signatures] in TcBinds. A little refactoring along the way.
* Add obvious Outputable Integer instance.klebinger.andreas@gmx.at2017-11-271-0/+3
| | | | | | | | | | Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4232
* Don't complain about UNPACK in -fno-code.Edward Z. Yang2017-11-271-2/+10
| | | | | | | | | | | | Test Plan: validate Reviewers: ekmett, austin, bgamari Reviewed By: bgamari Subscribers: duog, goldfire, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4155
* DynFlags: Expand $topdir in --info outputBen Gamari2017-11-231-1/+2
| | | | | | | | | | Test Plan: Try running nofib on Windows Reviewers: Phyx Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4222
* SysTools: Split up TopDir logic into new moduleBen Gamari2017-11-233-184/+212
| | | | | | | | | | Test Plan: Validate on Linux and Windows Reviewers: erikd Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4225
* SysTools: Expand occurrences of $topdir anywhere in a Settings pathBen Gamari2017-11-231-18/+19
| | | | | | Subscribers: rwbarton, thomie, Phyx Differential Revision: https://phabricator.haskell.org/D4221
* Revert "Add new mbmi and mbmi2 compiler flags"Ben Gamari2017-11-2214-262/+1
| | | | | | This broke the 32-bit build. This reverts commit f5dc8ccc29429d0a1d011f62b6b430f6ae50290c.
* ErrUtils: Ensure timing dumps are always output on one lineBen Gamari2017-11-211-0/+1
| | | | | This output is supposed to be machine-readable; having random line-breaks defeats this.
* ErrUtils: Refactor dump file logicBen Gamari2017-11-211-37/+45
| | | | | This refactors the dump file setup path, separating concerns a bit. It also fixes an exception-unsafe usage of openFile.
* cmm: Optimise remainders by powers of twoBen Gamari2017-11-211-25/+41
| | | | | | | | | | | | | | Test Plan: validate Reviewers: bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #14437 Differential Revision: https://phabricator.haskell.org/D4180
* Update leftover reference to refer to [FunBind vs PatBind]klebinger.andreas@gmx.at2017-11-211-2/+2
| | | | | | | | | | Reviewers: bgamari, mpickering Reviewed By: mpickering Subscribers: rwbarton, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D4205
* Add warn-missing-export-listsEvan Rutledge Borden2017-11-212-4/+16
| | | | | | | | | | | | | | | | | | | | | | | Many industrial users have aligned around the idea that implicit exports are an anti-pattern. They lead to namespace pollution and byzantine naming schemes. They also prevent GHC's dead code analysis and create more obstacles to optimization. This warning allows teams/projects to warn on or enforce via -Werror explicit export lists. This warning also serves as a complement to warn-missing-import-lists. This was originally discussed here: https://github.com/ghc-proposals/ghc-proposals/pull/93 Test Plan: Three new minimal tests have been added to the type checker. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4197
* Revert "trees that grow" workBen Gamari2017-11-2158-4150/+2988
| | | | | | | | | | | | | | As documented in #14490, the Data instances currently blow up compilation time by too much to stomach. Alan will continue working on this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid having to perform painful cherry-picks in 8.2 minor releases. Reverts haddock submodule. This reverts commit 47ad6578ea460999b53eb4293c3a3b3017a56d65. This reverts commit e3ec2e7ae94524ebd111963faf34b84d942265b4. This reverts commit 438dd1cbba13d35f3452b4dcef3f94ce9a216905. This reverts commit 0ff152c9e633accca48815e26e59d1af1fe44ceb.
* base: Document GHC.Stack.CCS internalsBen Gamari2017-11-211-1/+1
| | | | | | | | Reviewers: hvr Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4204
* Rename ghc-version -> ghcversion-fileMoritz Angermann2017-11-192-7/+6
| | | | | | | | | | Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4210
* Fix #elfi -> #elif; unbreak -Werror.Moritz Angermann2017-11-191-0/+3
| | | | | | | | | | Reviewers: bgamari, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4209
* Relocatable GHCMoritz Angermann2017-11-181-0/+21
| | | | | | | | | | | | | | GHC and the binary distribution that's produced is not relocatable outside of Windows. This diff tries to address this for at least Linux and macOS. Reviewers: austin, hvr, bgamari, erikd, goldfire, Phyx Reviewed By: bgamari Subscribers: duog, rwbarton, thomie, erikd Differential Revision: https://phabricator.haskell.org/D4121
* Adds -ghc-version flag to ghc.Moritz Angermann2017-11-182-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When building the rts with ghc (e.g. using ghc as a c compiler), ghc's "Value Add"[1] is, it includes adding `-include /path/to/ghcversion.h`. For this it looksup the rts package in the package database, which--if empty--fails. Thus to allow compiling C files with GHC, we add the `-ghc-version` flag, which takes the path to the `ghcversion.h` file. A `-no-ghc-version` flag was omitted, as at that point it becomes questionable why one would use ghc to compile c if one doesn't any of the added value. -- [1] from `compiler/main/DriverPipeline.hs` > -- add package include paths even if we're just compiling .c > -- files; this is the Value Add(TM) that using ghc instead of > -- gcc gives you :) Reviewers: bgamari, geekosaur, austin Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4135
* Adjust AltCon Ord instance to match Core linter requirements.klebinger.andreas@gmx.at2017-11-151-4/+5
| | | | | | | | | | | | | | | | | | When sorting by the Ord instance put DEFAULT before other constructors. This is in line with what the core linter requests allowing the use of the instance for putting alternatives in the correct order. This implements #14464. Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #14464 Differential Revision: https://phabricator.haskell.org/D4198
* Allow the rts lib to be called rts-1.0Moritz Angermann2017-11-151-0/+12
| | | | | | | | | | Reviewers: bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4187
* Add dump flag for timing outputBen Gamari2017-11-152-9/+21
| | | | | | | | | | | This allows you to use `-ddump-to-file -ddump-timings` for more useful dump output. Test Plan: Try it Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4195