summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* PmCheck: Handle ⊥ and strict fields correctly (#18341)wip/T18341Sebastian Graf2020-09-1013-498/+587
| | | | | | | | | | | | | | | | | | | | | In #18341, we discovered an incorrect digression from Lower Your Guards. This MR changes what's necessary to support properly fixing #18341. In particular, bottomness constraints are now properly tracked in the oracle/inhabitation testing, as an additional field `vi_bot :: Maybe Bool` in `VarInfo`. That in turn allows us to model newtypes as advertised in the Appendix of LYG and fix #17725. Proper handling of ⊥ also fixes #17977 (once again) and fixes #18670. For some reason I couldn't follow, this also fixes #18273. I also added a couple of regression tests that were missing. Most of them were already fixed before. In summary, this patch fixes #18341, #17725, #18273, #17977 and #18670. Metric Decrease: T12227
* PmCheck: Big refactor using guard tree variants more closely following ↵Sebastian Graf2020-09-109-871/+935
| | | | | | | | | | | | | | | | | | | | | | | | source syntax (#18565) Previously, we desugared and coverage checked plain guard trees as described in Lower Your Guards. That caused (in !3849) quite a bit of pain when we need to partially recover tree structure of the input syntax to return covered sets for long-distance information, for example. In this refactor, I introduced a guard tree variant for each relevant source syntax component of a pattern-match (mainly match groups, match, GRHS, empty case, pattern binding). I made sure to share as much coverage checking code as possible, so that the syntax-specific checking functions are just wrappers around the more substantial checking functions for the LYG primitives (`checkSequence`, `checkGrds`). The refactoring payed off in clearer code and elimination of all panics related to assumed guard tree structure and thus fixes #18565. I also took the liberty to rename and re-arrange the order of functions and comments in the module, deleted some dead and irrelevant Notes, wrote some new ones and gave an overview module haddock.
* Add long-distance info for pattern bindings (#18572)Sebastian Graf2020-09-108-70/+77
| | | | | | | | We didn't consider the RHS of a pattern-binding before, which led to surprising warnings listed in #18572. As can be seen from the regression test T18572, we get the expected output now.
* Remove GENERATED pragma, as it is not being usedAlan Zimmerman2020-09-098-50/+1
| | | | | | | | | | | | | | | | | | | | | @alanz pointed out on ghc-devs that the payload of this pragma does not appear to be used anywhere. I (@bgamari) did some digging and traced the pragma's addition back to d386e0d2 (way back in 2006!). It appears that it was intended to be used by code generators for use in informing the code coveraging checker about generated code provenance. When it was added it used the pragma's "payload" fields as source location information to build an "ExternalBox". However, it looks like this was dropped a year later in 55a5d8d9. At this point it seems like the pragma serves no useful purpose. Given that it also is not documented, I think we should remove it. Updates haddock submodule Closes #18639
* Add comments about sm_dflags and simpleOptExprSylvain Henry2020-09-092-2/+19
|
* DynFlags: add sm_pre_inline field into SimplMode (#17957)Sylvain Henry2020-09-0916-59/+61
| | | | It avoids passing and querying DynFlags down in the simplifier.
* DynFlags: add UnfoldingOpts and SimpleOptsSylvain Henry2020-09-0941-490/+673
| | | | | Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable.
* DynFlags: add OptCoercionOptsSylvain Henry2020-09-094-21/+47
| | | | | Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt
* Postpone associated tyfam default checks until after typecheckingRyan Scott2020-09-095-99/+164
| | | | | | | | | | | | Previously, associated type family defaults were validity-checked during typechecking. Unfortunately, the error messages that these checks produce run the risk of printing knot-tied type constructors, which will cause GHC to diverge. In order to preserve the current error message's descriptiveness, this patch postpones these validity checks until after typechecking, which are now located in the new function `GHC.Tc.Validity.checkValidAssocTyFamDeflt`. Fixes #18648.
* Use "to" instead of "2" in internal names of conversion opsJohn Ericson2020-09-094-70/+70
| | | | | | | | | | | Change the constructors for the primop union, and also names of the literal conversion functions. "2" runs into trouble when we need to do conversions from fixed-width types, and end up with thing like "Int642Word". Only the names internal to GHC are changed, as I don't want to worry about breaking changes ATM.
* Make the forall-or-nothing rule only apply to invisible foralls (#18660)Ryan Scott2020-09-082-17/+46
| | | | | | | | This fixes #18660 by changing `isLHsForAllTy` to `isLHsInvisForAllTy`, which is sufficient to make the `forall`-or-nothing rule only apply to invisible `forall`s. I also updated some related documentation and Notes while I was in the neighborhood.
* Move DynFlags test into updateModDetailsIdInfos's caller (#17957)Sylvain Henry2020-09-072-10/+7
|
* [macOS] improved runpath handlingMoritz Angermann2020-09-077-22/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In b592bd98ff25730bbe3c13d6f62a427df8c78e28 we started using -dead_strip_dylib on macOS when lining dynamic libraries and binaries. The underlying reason being the Load Command Size Limit in macOS Sierra (10.14) and later. GHC will produce @rpath/libHS... dependency entries together with a corresponding RPATH entry pointing to the location of the libHS... library. Thus for every library we produce two Load Commands. One to specify the dependent library, and one with the path where to find it. This makes relocating libraries and binaries easier, as we just need to update the RPATH entry with the install_name_tool. The dynamic linker will then subsitute each @rpath with the RPATH entries it finds in the libraries load commands or the environement, when looking up @rpath relative libraries. -dead_strip_dylibs intructs the linker to drop unused libraries. This in turn help us reduce the number of referenced libraries, and subsequently the size of the load commands. This however does not remove the RPATH entries. Subsequently we can end up (in extreme cases) with only a single @rpath/libHS... entry, but 100s or more RPATH entries in the Load Commands. This patch rectifies this (slighly unorthodox) by passing *no* -rpath arguments to the linker at link time, but -headerpad 8000. The headerpad argument is in hexadecimal and the maxium 32k of the load command size. This tells the linker to pad the load command section enough for us to inject the RPATHs later. We then proceed to link the library or binary with -dead_strip_dylibs, and *after* the linking inspect the library to find the left over (non-dead-stripped) dependencies (using otool). We find the corresponding RPATHs for each @rpath relative dependency, and inject them into the library or binary using the install_name_tool. Thus achieving a deadstripped dylib (and rpaths) build product. We can not do this in GHC, without starting to reimplement a dynamic linker as we do not know which symbols and subsequently libraries are necessary. Commissioned-by: Mercury Technologies, Inc. (mercury.com)
* configure: Avoid hard-coded ld path on WindowsGHC GitLab CI2020-09-041-1/+1
| | | | | | | The fix to #17962 ended up regressing on Windows as it failed to replicate the logic responsible for overriding the toolchain paths on Windows. This resulted in a hard-coded path to a directory that likely doesn't exist on the user's system (#18550).
* Introduce isBoxedTupleDataCon and use it to fix #18644Ryan Scott2020-09-0415-28/+32
| | | | | | | | | | | | | | | | | | | | The code that converts promoted tuple data constructors to `IfaceType`s in `GHC.CoreToIface` was using `isTupleDataCon`, which conflates boxed and unboxed tuple data constructors. To avoid this, this patch introduces `isBoxedTupleDataCon`, which is like `isTupleDataCon` but only works for _boxed_ tuple data constructors. While I was in town, I was horribly confused by the fact that there were separate functions named `isUnboxedTupleCon` and `isUnboxedTupleTyCon` (similarly, `isUnboxedSumCon` and `isUnboxedSumTyCon`). It turns out that the former only works for data constructors, despite its very general name! I opted to rename `isUnboxedTupleCon` to `isUnboxedTupleDataCon` (similarly, I renamed `isUnboxedSumCon` to `isUnboxedSumDataCon`) to avoid this potential confusion, as well as to be more consistent with the naming convention I used for `isBoxedTupleDataCon`. Fixes #18644.
* DynFlags: don't pass DynFlags to cmmImplementSwitchPlansSylvain Henry2020-09-042-6/+6
|
* DynFlags: use Platform in foldRegs*Sylvain Henry2020-09-049-152/+138
|
* Don't rely on CLabel's Outputable instance in CmmToCSylvain Henry2020-09-042-20/+21
| | | | | This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance.
* Remove outdated noteSylvain Henry2020-09-021-29/+0
|
* Turn on -XMonoLocalBinds by default (#18430)Sebastian Graf2020-09-027-11/+17
| | | | | | | | | And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski@gmail.com> Metric Decrease: parsing001
* Remove "Ord FastString" instanceSylvain Henry2020-09-0130-112/+236
| | | | | | | | | | | | | | | | | | | FastStrings can be compared in 2 ways: by Unique or lexically. We don't want to bless one particular way with an "Ord" instance because it leads to bugs (#18562) or to suboptimal code (e.g. using lexical comparison while a Unique comparison would suffice). UTF-8 encoding has the advantage that sorting strings by their encoded bytes also sorts them by their Unicode code points, without having to decode the actual code points. BUT GHC uses Modified UTF-8 which diverges from UTF-8 by encoding \0 as 0xC080 instead of 0x00 (to avoid null bytes in the middle of a String so that the string can still be null-terminated). This patch adds a new `utf8CompareShortByteString` function that performs sorting by bytes but that also takes Modified UTF-8 into account. It is much more performant than decoding the strings into [Char] to perform comparisons (which we did in the previous patch). Bump haddock submodule
* Fix FastString lexicographic ordering (fix #18562)Sylvain Henry2020-09-011-1/+3
|
* Set the dynamic-system-linker flag to ManualMoritz Angermann2020-08-311-1/+1
| | | | This flag should be user controllable, hence Manual: True.
* Don't store HomeUnit in UnitConfigSylvain Henry2020-08-311-17/+22
| | | | | Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335.
* Dominators.hs: Use unix line endingsAndreas Klebinger2020-08-311-563/+563
|
* Update dominator code with fixes from the dom-lt package.Andreas Klebinger2020-08-311-83/+49
| | | | | Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code.
* document how build system find toolchains on WindowsTamar Christina2020-08-281-12/+75
|
* Fix use distro toolchianTamar Christina2020-08-281-2/+3
|
* Add missing primop documentation (#18454)Krzysztof Gogolewski2020-08-285-37/+132
| | | | | | | | | | | | | | | - Add three pseudoops to primops.txt.pp, so that Haddock renders the documentation - Update comments - Remove special case for "->" - it's no longer exported from GHC.Prim - Remove reference to Note [Compiling GHC.Prim] - the ad-hoc fix is no longer there after updates to levity polymorphism. - Document GHC.Prim - Remove the comment that lazy is levity-polymorphic. As far as I can tell, it never was: in 80e399639, only the unfolding was given an open type variable. - Remove haddock hack in GHC.Magic - no longer neccessary after adding realWorld# to primops.txt.pp.
* Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuplesRyan Scott2020-08-273-1/+25
| | | | | | | | | | | | `hsExprNeedsParens`, `hsTypeNeedsParens`, and `patNeedsParens` previously assumed that all uses of explicit tuples in the source syntax never need to be parenthesized. This is true save for one exception: boxed one-tuples, which use the `Solo` data type from `GHC.Tuple` instead of special tuple syntax. This patch adds the necessary logic to the three `*NeedsParens` functions to handle `Solo` correctly. Fixes #18612.
* Consolidate imports in getMinimalImports (#18264)Aditya Gupta2020-08-271-3/+22
|
* primops: Remove Monadic and Dyadic categoriesKrzysztof Gogolewski2020-08-263-183/+150
| | | | | | | | | There were four categories of primops: Monadic, Dyadic, Compare, GenPrimOp. The compiler does not treat Monadic and Dyadic in any special way, we can just replace them with GenPrimOp. Compare is still used in isComparisonPrimOp.
* PPC and X86: Portable printing of IEEE floatsPeter Trommler2020-08-264-43/+34
| | | | | | | | | | | | GNU as and the AIX assembler support floating point literals. SPARC seems to have support too but I cannot test on SPARC. Curiously, `doubleToBytes` is also used in the LLVM backend. To avoid endianness issues when cross-compiling float and double literals are printed as C-style floating point values. The assembler then takes care of memory layout and endianness. This was brought up in #18431 by @hsyl20.
* Refactor UnitId pretty-printingSylvain Henry2020-08-2624-185/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we pretty-print a UnitId for the user, we try to map it back to its origin package name, version and component to print "package-version:component" instead of some hash. The UnitId type doesn't carry these information, so we have to look into a UnitState to find them. This is why the Outputable instance of UnitId used `sdocWithDynFlags` in order to access the `unitState` field of DynFlags. This is wrong for several reasons: 1. The DynFlags are accessed when the message is printed, not when it is generated. So we could imagine that the unitState may have changed in-between. Especially if we want to allow unit unloading. 2. We want GHC to support several independent sessions at once, hence several UnitState. The current approach supposes there is a unique UnitState as a UnitId doesn't indicate which UnitState to use. See the Note [Pretty-printing UnitId] in GHC.Unit for the new approach implemented by this patch. One step closer to remove `sdocDynFlags` field from `SDocContext` (#10143). Fix #18124. Also fix some Backpack code to use SDoc instead of String.
* Use LIdP rather than (XRec p (IdP p))Simon Peyton Jones2020-08-2513-83/+71
| | | | | | | | | | | | | | | This patch mainly just replaces use of XRec p (IdP p) with LIdP p One slightly more significant change is to parameterise HsPatSynDetails over the pass rather than the argument type, so that it's uniform with HsConDeclDetails and HsConPatDetails. I also got rid of the dead code GHC.Hs.type.conDetailsArgs But this is all just minor refactoring. No change in functionality.
* Use tcView, not coreView, in the pure unifier.Richard Eisenberg2020-08-252-3/+24
| | | | Addresses a lingering point within #11715.
* SysTools.Process: Handle exceptions in readCreateProcessWithExitCode'Ben Gamari2020-08-251-3/+18
| | | | | | In #18069 we are observing MVar deadlocks from somewhere in ghc.exe. This use of MVar stood out as being one of the more likely culprits. Here we make sure that it is exception-safe.
* Avoid roundtrip through SDocSylvain Henry2020-08-241-3/+1
| | | | As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126
* Perf: make SDoc monad one-shot (#18202)Sylvain Henry2020-08-241-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | With validate-x86_64-linux-deb9-hadrian: T1969 -3.4% (threshold: +/-1%) T3294 -3.3% (threshold: +/-1%) T12707 -1.4% (threshold: +/-1%) Additionally with validate-x86_64-linux-deb9-unreg-hadrian: T4801 -2.4% (threshold: +/-2%) T13035 -1.4% (threshold: +/-1%) T13379 -2.4% (threshold: +/-2%) ManyAlternatives -2.5% (threshold: +/-2%) ManyConstructors -3.0% (threshold: +/-2%) Metric Decrease: T12707 T1969 T3294 ManyAlternatives ManyConstructors T13035 T13379 T4801
* Fix types in silly shifts (#18589)Krzysztof Gogolewski2020-08-241-9/+13
| | | | Patch written by Simon. I have only added a testcase.
* Move pprTyTcApp' inside pprTyTcAppKrzysztof Gogolewski2020-08-231-44/+39
| | | | No semantic change
* Do not print synonyms in :i (->), :i Type (#18594)Krzysztof Gogolewski2020-08-234-4/+35
| | | | | This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'.
* Utils: clarify docs slightlyCraig Ferguson2020-08-221-1/+1
| | | | | The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`).
* mkUnique refactoring (#18362)Aditya Gupta2020-08-2236-171/+276
| | | | | Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques
* Import qualified Prelude in Cmm/Parser.yVladislav Zavialov2020-08-212-1/+2
| | | | | | | | In preparation for the next version of 'happy', c95920 added a qualified import to GHC/Parser.y but for some reason neglected GHC/Cmm/Parser.y This patch adds the missing qualified import to GHC/Cmm/Parser.y and also adds a clarifying comment to explain why this import is needed.
* Fix -ddump-stg flagSylvain Henry2020-08-213-6/+9
| | | | | | | -ddump-stg was dumping the initial STG (just after Core-to-STG pass) which was misleading because we want the final STG to know if a function allocates or not. Now we have a new flag -ddump-stg-from-core for this and -ddump-stg is deprecated.
* NCG: Dwarf configurationSylvain Henry2020-08-2112-70/+118
| | | | | | * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level
* Don't use DynFlags in CmmToAsm.BlockLayout (#17957)Sylvain Henry2020-08-213-22/+28
|
* Put CFG weights into their own module (#17957)Sylvain Henry2020-08-219-176/+184
| | | | It avoids having to query DynFlags to get them
* Add right-to-left rule for pattern bindingsSimon Peyton Jones2020-08-197-41/+115
| | | | | | | | | | | | | | | | | | | | | | | Fix #18323 by adding a few lines of code to handle non-recursive pattern bindings. see GHC.Tc.Gen.Bind Note [Special case for non-recursive pattern bindings] Alas, this confused the pattern-match overlap checker; see #18323. Note that this patch only affects pattern bindings like that for (x,y) in this program combine :: (forall a . [a] -> a) -> [forall a. a -> a] -> ((forall a . [a] -> a), [forall a. a -> a]) breaks = let (x,y) = combine head ids in x y True We need ImpredicativeTypes for those [forall a. a->a] types to be valid. And with ImpredicativeTypes the old, unprincipled "allow unification variables to unify with a polytype" story actually works quite well. So this test compiles fine (if delicatedly) with old GHCs; but not with QuickLook unless we add this patch