summaryrefslogtreecommitdiff
path: root/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
* Be less verbose when printing Names when we don't know what's in scopeSimon Peyton Jones2014-04-241-13/+12
| | | | | | | | Previously we always printed qualified names, but that makes a lot of debug or warning output very verbose. So now we only print qualified names with -dppr-debug. Civilised output (from pukka error messages, with the environment available) is unaffected
* ghc: initial AArch64 patchesColin Watson2014-04-211-0/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Major Call Arity reworkJoachim Breitner2014-03-052-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the call arity analysis in various ways. Most importantly, it enriches the analysis result information so that when looking at a call, we do not have to make a random choice about what side we want to take the information from. Instead we can combine the results in a way that does not lose valuable information. To do so, besides the incoming arities, we store remember "what can be called with what", i.e. an undirected graph between the (interesting) free variables of an expression. Of course it makes combining the results a bit more tricky (especially mutual recursion), but still doable. The actually implemation of the graph structure is abstractly put away in a module of its own (UnVarGraph.hs) The implementation is geared towards efficiently representing the graphs that we need (which can contain large complete and large complete bipartite graphs, which would be huge in other representations). If someone feels like designing data structures: There is surely some speed-up to be obtained by improving that data structure. Additionally, the analysis now takes into account that if a RHS stays a thunk, then its calls happen only once, even if the variables the RHS is bound to is evaluated multiple times, or is part of a recursive group.
* Use U+2018 instead of U+201B quote mark in compiler messagesHerbert Valerio Riedel2014-02-251-1/+1
| | | | | | | This matches GCC's choice of Unicode quotation marks (i.e. U+2018 and U+2019) and therefore looks more familiar on the console. This addresses #2507. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Fix Haddock formattingMateusz Kowalczyk2014-02-241-11/+13
|
* Cleaned up Maybes.lhsBaldur Blöndal2014-02-131-34/+4
|
* Fix inplace dynamic linking on OS X (#8266)Christiaan Baaj2014-01-281-0/+6
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Implement pattern synonymsDr. ERDI Gergo2014-01-202-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements Pattern Synonyms (enabled by -XPatternSynonyms), allowing y ou to assign names to a pattern and abstract over it. The rundown is this: * Named patterns are introduced by the new 'pattern' keyword, and can be either *unidirectional* or *bidirectional*. A unidirectional pattern is, in the simplest sense, simply an 'alias' for a pattern, where the LHS may mention variables to occur in the RHS. A bidirectional pattern synonym occurs when a pattern may also be used in expression context. * Unidirectional patterns are declared like thus: pattern P x <- x:_ The synonym 'P' may only occur in a pattern context: foo :: [Int] -> Maybe Int foo (P x) = Just x foo _ = Nothing * Bidirectional patterns are declared like thus: pattern P x y = [x, y] Here, P may not only occur as a pattern, but also as an expression when given values for 'x' and 'y', i.e. bar :: Int -> [Int] bar x = P x 10 * Patterns can't yet have their own type signatures; signatures are inferred. * Pattern synonyms may not be recursive, c.f. type synonyms. * Pattern synonyms are also exported/imported using the 'pattern' keyword in an import/export decl, i.e. module Foo (pattern Bar) where ... Note that pattern synonyms share the namespace of constructors, so this disambiguation is required as a there may also be a 'Bar' type in scope as well as the 'Bar' pattern. * The semantics of a pattern synonym differ slightly from a typical pattern: when using a synonym, the pattern itself is matched, followed by all the arguments. This means that the strictness differs slightly: pattern P x y <- [x, y] f (P True True) = True f _ = False g [True, True] = True g _ = False In the example, while `g (False:undefined)` evaluates to False, `f (False:undefined)` results in undefined as both `x` and `y` arguments are matched to `True`. For more information, see the wiki: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/Implementation Reviewed-by: Simon Peyton Jones <simonpj@microsoft.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Tidy up Outputable.printDoc, and add printDoc_Simon Peyton Jones2014-01-171-4/+11
| | | | | | The former adds a newline at the end (restoring the previous behaviour) while the latter does not (which previously happened by turning the thuing into a string and only then printing it).
* Another AMP fix for StreamAustin Seipp2014-01-141-0/+9
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix AMP warnings for MaybeT/MaybeErrAustin Seipp2014-01-141-1/+13
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix new Haddock doc parse failures.Austin Seipp2014-01-121-7/+11
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Make showSDoc and friends respect -dppr-colsSimon Peyton Jones2014-01-102-49/+28
| | | | | | | | Previously they just used a fixed width of 100, ignoring -dppr-cols. I think this dates back to a time when the flag didn't exist, or wasn't conveniently available. Thanks to Andrew Gibiansky for pointing this out.
* Re-work the naming story for the GHCi prompt (Trac #8649)Simon Peyton Jones2014-01-091-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic idea here is simple, and described in Note [The interactive package] in HscTypes, which starts thus: Note [The interactive package] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Type and class declarations at the command prompt are treated as if they were defined in modules interactive:Ghci1 interactive:Ghci2 ...etc... with each bunch of declarations using a new module, all sharing a common package 'interactive' (see Module.interactivePackageId, and PrelNames.mkInteractiveModule). This scheme deals well with shadowing. For example: ghci> data T = A ghci> data T = B ghci> :i A data Ghci1.T = A -- Defined at <interactive>:2:10 Here we must display info about constructor A, but its type T has been shadowed by the second declaration. But it has a respectable qualified name (Ghci1.T), and its source location says where it was defined. So the main invariant continues to hold, that in any session an original name M.T only refers to oe unique thing. (In a previous iteration both the T's above were called :Interactive.T, albeit with different uniques, which gave rise to all sorts of trouble.) This scheme deals nicely with the original problem. It allows us to eliminate a couple of grotseque hacks - Note [Outputable Orig RdrName] in HscTypes - Note [interactive name cache] in IfaceEnv (both these comments have gone, because the hacks they describe are no longer necessary). I was also able to simplify Outputable.QueryQualifyName, so that it takes a Module/OccName as args rather than a Name. However, matters are never simple, and this change took me an unreasonably long time to get right. There are some details in Note [The interactive package] in HscTypes.
* Clarify the default demand on demand environmentsJoachim Breitner2013-12-161-0/+28
| | | | by adding Notes and using easier to understand combinators.
* Mask async exceptions in forkM_Edsko de Vries2013-12-031-1/+3
| | | | See #8006 for the reason why. This is not a fix as such; more of a workaround.
* Remove unnecessary and deprecated inclusions of Typeable.hPatrick Palka2013-11-121-2/+0
| | | | | The build system would've complained loudly about these inclusions if it weren't for #8527.
* Remove old workaround for containers <= 0.3Patrick Palka2013-11-121-4/+0
|
* Placate clang (#8444, #8445)Austin Seipp2013-10-251-2/+2
| | | | | | | | Once again the whitespace rules (and the rules concerning expansion of tokens) have bitten us. Authored-by: Authored-by: Luke Iannini <lukexi@me.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Added comments to BooleanFormula to explain the expression simplifier. (#7633)Twan van Laarhoven2013-10-151-3/+47
|
* TyposKrzysztof Gogolewski2013-10-121-1/+1
|
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-015-5/+5
|
* Discard unreachable code in the register allocator (#7574)Simon Marlow2013-09-231-5/+25
| | | | | | | | | | | | | | | | | | | The problem with unreachable code is that it might refer to undefined registers. This happens accidentally: a block can be orphaned by an optimisation, for example when the result of a comparsion becomes known. The register allocator panics when it finds an undefined register, because they shouldn't occur in generated code. So we need to also discard unreachable code to prevent this panic being triggered by optimisations. The register alloator already does a strongly-connected component analysis, so it ought to be easy to make it discard unreachable code as part of that traversal. It turns out that we need a different variant of the scc algorithm to do that (see Digraph), however the new variant also generates slightly better code by putting the blocks within a loop in a better order for register allocation.
* Comments onlyJan Stolarek2013-09-191-0/+1
|
* Restore old names of comparison primopsJan Stolarek2013-09-185-8/+299
| | | | | | | | | | | | In 6579a6c we removed existing comparison primops and introduced new ones returning Int# instead of Bool. This commit (and associated commits in array, base, dph, ghc-prim, integer-gmp, integer-simple, primitive, testsuite and template-haskell) restores old names of primops. This allows us to keep our API cleaner at the price of not having backwards compatibility. This patch also temporalily disables fix for #8317 (optimization of tagToEnum# at Core level). We need to fix #8326 first, otherwise our primops code will be very slow.
* Trailing whitespacesJan Stolarek2013-09-183-11/+11
|
* Implement checkable "minimal complete definitions" (#7633)Twan van Laarhoven2013-09-181-0/+167
| | | | | | | | | | | | | | This commit adds a `{-# MINIMAL #-}` pragma, which defines the possible minimal complete definitions for a class. The body of the pragma is a boolean formula of names. The old warning for missing methods is replaced with this new one. Note: The interface file format is changed to store the minimal complete definition. Authored-by: Twan van Laarhoven <twanvl@gmail.com> Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Outputable.isOrAre: "is" or "are" for correct grammarJoachim Breitner2013-09-131-1/+10
|
* Fix AMP warnings.Austin Seipp2013-09-111-1/+6
| | | | | Authored-by: David Luposchainsky <dluposchainsky@gmail.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Merge remote-tracking branch 'origin/master' into ghc-parmake-gsocghc-parmake-gsocPatrick Palka2013-09-081-0/+1
|\
| * Add basic support for GHCJSAustin Seipp2013-09-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch encompasses most of the basic infrastructure for GHCJS. It includes: * A new extension, -XJavaScriptFFI * A new architecture, ArchJavaScript * Parser and lexer support for 'foreign import javascript', only available under -XJavaScriptFFI, using ArchJavaScript. * As a knock-on, there is also a new 'WayCustom' constructor in DynFlags, so clients of the GHC API can add custom 'tags' to their built files. This should be useful for other users as well. The remaining changes are really just the resulting fallout, making sure all the cases are handled appropriately for DynFlags and Platform. Authored-by: Luite Stegeman <stegeman@gmail.com> Signed-off-by: Austin Seipp <aseipp@pobox.com>
| * Fix off-by-one error in FastString.getFastStringTable (#8110)Patrick Palka2013-08-301-1/+1
| | | | | | | | | | The function was reading past the end of the FastString table, causing the -dfaststring-stats option to behave unpredictably.
* | Binary: eradicate BinIO handlesPatrick Palka2013-08-261-44/+0
| | | | | | | | They are not used anywhere in the compiler.
* | Binary: Make lazyGet more thread-safePatrick Palka2013-08-261-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All values read lazily from the same BinHandle share the same mutable offset variable (_off_r). If two such lazy values are simultaneously evaluated, the two threads will step over each other when writing to _off_r. Fortunately, for BinMem handles, making lazyGet thread-safe is simple: just use a fresh off_r variable when deferring the call to getAt. For BinIO handles, a race condition still exists because IO handles contain their own mutable file pointer variable that gets clobbered in a similar way that _off_r would. But GHC doesn't use BinIO handles anywhere so this particular issue could be ignored for now.
* | FastString: make the string table thread-safePatrick Palka2013-08-261-86/+102
|/ | | | | While we're at it, consolidate duplicate code into a helper function and strictify a few arguments.
* Fix validation failure in Fingerprint.hscAustin Seipp2013-08-231-1/+1
| | | | Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Fingerprint.getFileHash: Fix not reading file at all.Niklas Hambüchen2013-08-231-1/+8
| | | | | | This lead to the stage1 compiler calculating random iface hashes. Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Fingerprint: Fix comment typoNiklas Hambüchen2013-08-231-1/+1
| | | | Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Remove trailing whitespace from Fingerprint.hscAustin Seipp2013-08-221-1/+1
| | | | Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Fix -Werror failure in Fingerprint.hscAustin Seipp2013-08-221-0/+3
| | | | Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Fix interface hashes including time stamp of dependent files.Niklas Hambüchen2013-08-221-2/+29
| | | | | | | | | | | | | | | | | | | | | | | Fixes #8144. Before, the modification time of e.g. #included files (and everything that ends up as a UsageFile, e.g. via addDependentFile) was taken as input for the interface hash of a module. This lead to different hashes for identical inputs on every compilation. We now use file content hashes instead. This changes the interface file format. You will get "Binary.get(Usage): 50" when you try to do an incremental using .hi files that were created with a GHC 7.7 (only) older than this commit. To calculate the md5 hash (`Fingerprint`) of a file in constant space, there now is GHC.Fingerprint.getFileHash, and a fallback version for older GHCs that needs to load the file into memory completely (only used when compiling stage1 with an older GHC). Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Add a better implementation of dropTail, and use itSimon Peyton Jones2013-08-191-1/+9
|
* Implement "roles" into GHC.Richard Eisenberg2013-08-023-2/+15
| | | | | | | | | | | | | | | | Roles are a solution to the GeneralizedNewtypeDeriving type-safety problem. Roles were first described in the "Generative type abstraction" paper, by Stephanie Weirich, Dimitrios Vytiniotis, Simon PJ, and Steve Zdancewic. The implementation is a little different than that paper. For a quick primer, check out Note [Roles] in Coercion. Also see http://ghc.haskell.org/trac/ghc/wiki/Roles and http://ghc.haskell.org/trac/ghc/wiki/RolesImplementation For a more formal treatment, check out docs/core-spec/core-spec.pdf. This fixes Trac #1496, #4846, #7148.
* Add NegativeLiterals extensionIan Lynagh2013-07-311-1/+1
| | | | | | | | | | | I'd been meaning to do this for some time, but finally got around to it due to the overflowing literals warning. With that enabled, we were getting a warning for -128 :: Int8 as that is parsed as negate (fromInteger 128) which just happens to do the right thing, as negate (fromInteger 128) = negate (-128) = -128
* De-orphan a load of Binary instancesIan Lynagh2013-07-271-0/+141
|
* adding FastString.string_table to the sharedCAF/Globals.c mechanismNicolas Frisby2013-07-161-7/+60
|
* This reverts commit 163de25813d12764aa5ded1666af7c06fee0d67e and commit ↵Nicolas Frisby2013-07-161-25/+2
| | | | 279ac9f66a83203448b279ea478b2cc1dafbd35d.
* copy the plugin's FastStringTable changes back into the host compilerNicolas Frisby2013-07-041-2/+12
|
* include FastString.string_table in CoreMonad.reinitializeGlobalsNicolas Frisby2013-07-031-1/+14
|
* Use SDoc for all LLVM pretty-printingPeter Wortmann2013-06-271-0/+7
| | | | | | | This patch reworks some parts of the LLVM pretty-printing code that were still using Show and String. Now we should be using SDoc and Outputable throughout. Note that many get*Name functions become pp*Name here as a side-effect.