summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Improve snocView implementation.klebinger.andreas@gmx.at2019-02-091-12/+17
| | | | | | | | | | | | The new implementation isn't tailrecursive and instead builds up the initial part of the list as it goes. This improves allocation numbers as we don't build up an intermediate list just to reverse it later. This is slightly slower for lists of size <= 3. But in benchmarks significantly faster for any list above 5 elements, assuming the majority of the resulting list will be evaluated.
* Replace a few uses of snocView with last/lastMaybe.klebinger.andreas@gmx.at2019-02-093-4/+13
| | | | | | These never used the first part of the result from snocView. Hence replacing them with last[Maybe] is both clearer and gives better performance.
* Stack: fix name mangling.Tamar Christina2019-02-091-1/+1
|
* Minor refactor of CUSK handlingSimon Peyton Jones2019-02-082-23/+34
| | | | | | | | | Previously, in getFamDeclInitialKind, we were figuring out whether the enclosing class decl had a CUSK very indirectly, via tcTyConIsPoly. This patch just makes the computation much more direct and easy to grok. No change in behaviour.
* Comments only about the binder-swap in OccurAnalSimon Peyton Jones2019-02-081-12/+41
|
* Comments onlySimon Peyton Jones2019-02-083-6/+11
|
* Remove a few undefined prel namesÖmer Sinan Ağacan2019-02-081-29/+3
| | | | | | | | | | - breakpointAuto - breakpointJump - breakpointCondJump - breakpointAutoJump These Ids are never defined, but there were definitions about those in PrelNames. Those are now removed.
* Fix optSemi type in Parser.yVladislav Zavialov2019-02-081-2/+1
| | | | | | | | | | | | | | | | | | | | | The definition of 'optSemi' claimed it had type ([Located a],Bool) Note that its production actually returns ([Located Token],Bool): : ';' { ([$1],True) } -- $1 :: Located Token Due to an infelicity in the implementation of 'happy -c', it effectively resulted in 'unsafeCoerce :: Token -> a'. See https://github.com/simonmar/happy/pull/134 If any consumer of 'optSemi' tried to instantiate 'a' to something not representationally equal to 'Token', they would experience a segfault. In addition to that, this definition made it impossible to compile Parser.y without the -c flag (as it's reliant on this bug to cast 'Token' to 'forall a. a').
* Cleanup in parser/Ctype.hsSylvain Henry2019-02-081-138/+135
| | | | | | | | | | | | | | | * GHC now performs constant folding on bit operations like (.|.) so we use them and we remove the misleading comment * we use Word8 instead of Int and we remove the useless conversion to Int32. Hopefully future releases of GHC could transform the big case in `charType` into a value table indexing instead of a jump table. Word8 would make the table smaller. * we use INLINABLE pragma instead of INLINE on `is_ctype`: in my test, the latter *prevents* `is_ctype` to be inlined because `charType` is inlined into `is_ctype` (to call charType`s worker on the unboxed Char directly).
* Lexer: Alternate Layout Rule injects actual not virtual bracesAlan Zimmerman2019-02-081-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | When the alternate layout rule is activated via a pragma, it injects tokens for { and } to make sure that the source is parsed properly. But it injects ITocurly and ITccurly, rather than their virtual counterparts ITvocurly and ITvccurly. This causes problems for ghc-exactprint, which tries to print these. Likewise, any injected ITsemi should have a zero-width SrcSpan. Test case (the existing T13087.hs) {-# LANGUAGE AlternativeLayoutRule #-} {-# LANGUAGE LambdaCase #-} isOne :: Int -> Bool isOne = \case 1 -> True _ -> False main = return () Closes #16279
* API Annotations: parens anns discarded for `(*)` operatorAlan Zimmerman2019-02-082-3/+4
| | | | | | | | | | | | | | | The patch from https://phabricator.haskell.org/D4865 introduces go _ (HsParTy _ (dL->L l (HsStarTy _ isUni))) acc ann fix = do { warnStarBndr l ; let name = mkOccName tcClsName (if isUni then "★" else "*") ; return (cL l (Unqual name), acc, fix, ann) } which discards the parens annotations belonging to the HsParTy. Updates haddock submodule Closes #16265
* API Annotations: AnnAt disconnected for TYPEAPPAlan Zimmerman2019-02-089-68/+84
| | | | | | | | | | | | For the code type family F1 (a :: k) (f :: k -> Type) :: Type where F1 @Peano a f = T @Peano f a the API annotation for the first @ is not attached to a SourceSpan in the ParsedSource Closes #16236
* API Annotations: more explicit foralls fixupAlan Zimmerman2019-02-082-24/+25
| | | | | | | The AnnForall annotations introduced via Phab:D4894 are not always attached to the correct SourceSpan. Closes #16230
* Allow resizing the stack for the graph allocator.klebinger.andreas@gmx.at2019-02-086-36/+105
| | | | | | | | | | The graph allocator now dynamically resizes the number of stack slots when running into the limit. This fixes #8657. Also loop membership of basic blocks is now available in the register allocator for cost heuristics.
* Fix #14729 by making the normaliser homogeneousRichard Eisenberg2019-02-085-371/+545
| | | | | | | | | | | | | | | | This ports the fix to #12919 to the normaliser. (#12919 was about the flattener.) Because the fix is involved, this is done by moving the critical piece of code to Coercion, and then calling this from both the flattener and the normaliser. The key bit is: simplifying type families in a type is always a *homogeneous* operation. See #12919 for a discussion of why this is the Right Way to simplify type families. Also fixes #15549. test case: dependent/should_compile/T14729{,kind} typecheck/should_compile/T15549[ab]
* Fix #16287 by checking for more unsaturated synonym argumentsRyan Scott2019-02-061-24/+23
| | | | | | | | | | | | | Trac #16287 shows that we were checking for unsaturated type synonym arguments (in `:kind`) when the argument was to a type synonym, but _not_ when the argument was to some other form of type constructor, such as a data type. The solution is to use the machinery that rejects unsaturated type synonym arguments (previously confined to `check_syn_tc_app`) to `check_arg_type`, which checks these other forms of arguments. While I was in town, I cleaned up `check_syn_tc_app` a bit to only invoke `check_arg_type` so as to minimize the number of different code paths that that function could go down.
* Fix #14579 by defining tyConAppNeedsKindSig, and using itRyan Scott2019-02-053-170/+342
|
* Refactor splice_exp in Parser.yVladislav Zavialov2019-02-053-22/+22
|
* Add `-fplugin-trustworthy` to avoid marking modules as unsafeZejun Wu2019-02-043-4/+10
| | | | | | | | By default, when a module is compiled with plugins, it will be marked as unsafe. With this flag passed, all plugins are treated as trustworthy and the safety inference will no longer be affected. This fixes Trac #16260.
* Report multiple errorsVladislav Zavialov2019-02-032-21/+28
|
* Fix missing space in ppr_cmd for HsCmdArrFormVladislav Zavialov2019-02-031-2/+2
|
* Remove unused importsSebastian Graf2019-02-021-3/+0
|
* Polished Note [Exceptions and strictness]Sebastian Graf2019-02-021-15/+27
| | | | [ci skip]
* Reject oversaturated VKAs in type family equationsRyan Scott2019-02-012-1/+70
|
* Remove ExnStr and ThrowsExn businessSebastian Graf2019-02-016-234/+126
|
* Fix #16219: TemplateHaskell causes indefinite package build errorEdward Z. Yang2019-01-312-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | It should work to write an indefinite package using TemplateHaskell, so long as all of the actual TH code lives outside of the package. However, cleverness we had to build TH code even when building with -fno-code meant that we attempted to build object code for modules in an indefinite package, even when the signatures were not instantiated. This patch disables said logic in the event that an indefinite package is being typechecked. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: validate Reviewers: simonpj, bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #16219 Differential Revision: https://phabricator.haskell.org/D5475
* PPC NCG: Promote integers to word size in C callsPeter Trommler2019-01-312-15/+29
| | | | Fixes #16222
* Small optimizations to BlockLayout.klebinger.andreas@gmx.at2019-01-311-39/+31
| | | | | | | | | | * Remove `takeL/R 1` occurences by lastOL/headOL. * Make BlockChain a OrdList newtype by removing the set of blocks. Initially BlockChain contained both, a set for membership test and a ordered list of blocks. The set is not used for any performance sensitive lookups so we get rid of it.
* Replace BlockSequence with OrdList in BlockLayout.hsklebinger.andreas@gmx.at2019-01-312-77/+45
| | | | | OrdList does the same thing and more so there is no reason to have both.
* Add -fdefer-diagnostics to defer and group diagnostic messages in make-modeZejun Wu2019-01-312-2/+39
| | | | | | | | | | | | | When loading many modules in parallel there can a lot of warnings and errors get mixed up with regular output. When the compilation fails, the relevant error message can be thousands of lines backward and is hard to find. When the compilation successes, warning message is likely to be ignored as it is not seen. We can address this by deferring the warning and error message after the compilation. We also put errors after warnings so it is more visible. This idea was originally proposed by Bartosz Nitka in https://phabricator.haskell.org/D4219.
* Optimize pprASCIISylvain Henry2019-01-311-12/+23
| | | | | | | | | * Use `ByteString.foldr` instead of `(List.foldr . BS.unpack)` * Avoid calling `chr` and its test that checks for invalid Unicode codepoints: we stay in the ASCII range so we know we're ok * Avoid calling `isPrint` (unsafe FFI call): we can check the ASCII printable range directly * Use bit operations (`unsafeShiftR`, `.&.`) instead of `div` and `mod`
* Use ByteString to represent Cmm string literals (#16198)Sylvain Henry2019-01-3129-91/+86
| | | | Also used ByteString in some other relevant places
* API Annotations: Parens not attached correctly for ClassDeclAlan Zimmerman2019-01-301-19/+22
| | | | | | | | | | | The parens around the kinded tyvars should be attached to the class declaration as a whole, they are attached to the tyvar instead, outside the span. An annotation must always be within or after the span it is contained in. Closes #16212
* Include type info for only some exprs in HIE filesAlec Theriault2019-01-301-8/+63
| | | | | | | | | | | | | | | | This commit relinquishes some some type information in `.hie` files in exchange for better performance. See #16233 for more on this. Using `.hie` files to generate hyperlinked sources is a crucial milestone towards Hi Haddock (the initiative to move Haddock to work over `.hi` files and embed docstrings in those). Unfortunately, even after much optimization on the Haddock side, the `.hie` based solution is still considerably slower and more memory hungry than the existing implementation - and the @.hie@ code is to blame. This changes `.hie` file generation to track type information for only a limited subset of expressions (specifically, those that might eventually turn into hyperlinks in the Haddock's hyperlinker backend).
* Use `NameEnv Id` instead of `Map Name Id`Alec Theriault2019-01-301-5/+8
| | | | This is more consistent with the rest of the GHC codebase.
* Compile count{Leading,Trailing}Zeros to corresponding x86_64 instructions ↵Dmitry Ivanov2019-01-303-28/+63
| | | | | | | under -mbmi2 This works similarly to existing implementation for popCount. Trac ticket: #16086.
* Revert "Batch merge"Ben Gamari2019-01-305-156/+60
| | | | This reverts commit 76c8fd674435a652c75a96c85abbf26f1f221876.
* Batch mergeBen Gamari2019-01-305-60/+156
|
* Use sigPrec in more places in Convert and HsUtilsRyan Scott2019-01-282-39/+36
| | | | | | | | | Trac #16183 was caused by TH conversion (in `Convert`) not properly inserting parentheses around occurrences of explicit signatures where appropriate, such as in applications, function types, and type family equations. Solution: use `parenthesizeHsType sigPrec` in these places. While I was in town, I also updated `nlHsFunTy` to do the same thing.
* Some refactoring in tcInferAppsRichard Eisenberg2019-01-272-92/+99
| | | | | Should be no change in behavior, but this makes the control flow a little more apparent.
* Fix regDotColor for amd64.klebinger.andreas@gmx.at2019-01-272-31/+48
| | | | | Add missing color mappings to regDotColor for amd64. Also set fakeRegs to red instead of xmm regs.
* GhcPlugins: Fix lookup of TH namesBen Gamari2019-01-271-3/+3
| | | | | | | | | | | Previously `thNameToGhcName` was calling `lookupOrigNameCache` directly, which failed to handle the case that the name wasn't already in the name cache. This happens, for instance, when the name was in scope in a plugin being used during compilation but not in scope in the module being compiled. In this case we the interface file containing the name won't be loaded and `lookupOrigNameCache` fails. This was the cause of #16104. The solution is simple: use the nicely packaged `lookupOrigIO` instead.
* Minor refactor [ci skip]Gabor Greif2019-01-233-6/+6
|
* A few typofixesGabor Greif2019-01-2312-14/+13
|
* Error out of invalid Int/Word bit shiftsAlec Theriault2019-01-231-3/+2
| | | | | | | | | | | | | Although the Haddock's for `shiftL` and `shiftR` do require the number of bits to be non-negative, we should still check this before calling out to primitives (which also have undefined behaviour for negative bit shifts). If a user _really_ wants to bypass checks that the number of bits is sensible, they already have the aptly-named `unsafeShiftL`/`unsafeShiftR` at their disposal. See #16111.
* Fix bogus worker for newtypesSimon Peyton Jones2019-01-221-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The "worker" for a newtype is actually a function with a small (compulsory) unfolding, namely a cast. But the construction of this function was plain wrong for newtype /instances/; it cast the arguemnt to the family type rather than the representation type. This never actually bit us because, in the case of a family instance, we immediately cast the result to the family type. So we get \x. (x |> co1) |> co2 where the compositio of co1 and co2 is ill-kinded. However the optimiser (even the simple optimiser) just collapsed those casts, ignoring the mis-match in the middle, so we never saw the problem. Trac #16191 is indeed a dup of #16141; but the resaon these tickets produce Lint errors is not the unnecessary forcing; it's because of the ill-typed casts. This patch fixes the ill-typed casts, properly. I can't see a way to trigger an actual failure prior to this patch, but it's still wrong wrong wrong to have ill-typed casts, so better to get rid of them.
* Fix typo in TcRnTypes.hs [skip ci]wip/tc-rn-types-typoMatthew Pickering2019-01-211-2/+2
|
* Add support for ASM foreign files (.s) in TH (#16180)Sylvain Henry2019-01-201-4/+5
|
* Remove TODO in HsExprMatthew Pickering2019-01-201-1/+0
| | | | It is correct to be `GhcTc` as the data type is for expressions which are inside splices so they can be delayed until desugaring.
* Mention DerivingStrategies in the warning when DAC and GND are both enabledChaitanya Koparkar2019-01-201-1/+4
| | | | | | | | | | | Summary: When DeriveAnyClass and GeneralizedNewtypeDeriving are both enabled, GHC prints out a warning that specifies the strategy it used to derive a class. This patch updates the warning to mention that users may pick a particular strategy by using DerivingStrategies. Test plan: make test TEST=T16179