From gitlab at gitlab.haskell.org Thu Oct 1 00:12:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 30 Sep 2020 20:12:10 -0400 Subject: [Git][ghc/ghc][wip/testing] testing Message-ID: <5f751eda88d48_80b3f849c79df501578479f@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: f798a708 by Ben Gamari at 2020-09-30T20:12:02-04:00 testing - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -282,6 +282,9 @@ hadrian-ghc-in-ghci: TEST_TYPE: test MAKE_ARGS: "-Werror" script: + - "echo $PATH" + - "echo $SHELL" + - which autoreconf - .gitlab/ci.sh setup - .gitlab/ci.sh configure - .gitlab/ci.sh build_make @@ -382,9 +385,10 @@ release-x86_64-freebsd: validate-x86_64-darwin: extends: .validate - stage: full-build + stage: lint tags: - x86_64-darwin + - testing variables: GHC_VERSION: 8.8.4 CABAL_INSTALL_VERSION: 3.0.0.0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f798a7080d1536d6864088b98e2da79a25901c4f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f798a7080d1536d6864088b98e2da79a25901c4f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 01:32:48 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 30 Sep 2020 21:32:48 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] Apply suggestion to compiler/GHC/CmmToAsm/AArch64/README.md Message-ID: <5f7531c03fe72_80bb31638815796787@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 4c5dfe06 by Moritz Angermann at 2020-09-30T21:32:47-04:00 Apply suggestion to compiler/GHC/CmmToAsm/AArch64/README.md - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/README.md Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/README.md ===================================== @@ -22,7 +22,7 @@ The HTML view has an instruction lookup, the xml file is also good. ### Cmm - at GHC.CmmToAsm@ contains the top-level netry point @nativeCodeGen@, + at GHC.CmmToAsm@ contains the top-level entry point @nativeCodeGen@, which will be called from @GHC.Driver.CodeOutput.outputAsm@, which is triggert via the @-fasm@ flag. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c5dfe0625da2568a18972abfe1110895e2d963a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4c5dfe0625da2568a18972abfe1110895e2d963a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 01:32:50 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Wed, 30 Sep 2020 21:32:50 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] Apply suggestion to compiler/GHC/CmmToAsm/AArch64/README.md Message-ID: <5f7531c241e7a_80b3f849a2d8e7c1579692@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 274aff7b by Moritz Angermann at 2020-09-30T21:32:49-04:00 Apply suggestion to compiler/GHC/CmmToAsm/AArch64/README.md - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/README.md Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/README.md ===================================== @@ -24,7 +24,7 @@ The HTML view has an instruction lookup, the xml file is also good. @GHC.CmmToAsm@ contains the top-level entry point @nativeCodeGen@, which will be called from @GHC.Driver.CodeOutput.outputAsm@, which -is triggert via the @-fasm@ flag. +is triggered via the @-fasm@ flag. Thus, we'll not concern ourselves with anything in the pipeline before that point. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/274aff7bfd76d0e9139ea4f06b560f5c95576d95 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/274aff7bfd76d0e9139ea4f06b560f5c95576d95 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 02:31:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 30 Sep 2020 22:31:59 -0400 Subject: [Git][ghc/ghc][master] hadrian/doc: Clarify documentation of key-value configuration Message-ID: <5f753f9fc7e9a_80b3f8468f6b33815806961@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 1 changed file: - hadrian/doc/user-settings.md Changes: ===================================== hadrian/doc/user-settings.md ===================================== @@ -382,7 +382,8 @@ the right names for them: - the stage slot, which comes first, can be filled with any of `stage0`, `stage1`, `stage2`, `stage3` or `*`; any value but `*` will restrict the setting update to targets built during the given stage, while `*` is taken - to mean "for any stage". + to mean "for any stage". For instance, the above example will affect + the linking of the `_build/stage1/bin/ghc` executable. - the package slot, which comes second, can be filled with any package name that Hadrian knows about (all packages that are part of a GHC checkout), or `*`, to respectively mean that the builder options are going to be updated View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c32655fffd0d8862f3ba693351f1e612daa0b6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c32655fffd0d8862f3ba693351f1e612daa0b6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 02:52:33 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 30 Sep 2020 22:52:33 -0400 Subject: [Git][ghc/ghc][wip/angerman/ghc-9.0-runpath-backport] 13 commits: Deprecate Data.Semigroup.Option Message-ID: <5f75447197f05_80b3f84941fdc24158073be@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/angerman/ghc-9.0-runpath-backport at Glasgow Haskell Compiler / GHC Commits: b1c4116d by Simon Jakobi at 2020-09-24T13:09:09-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. (cherry picked from commit a90d13091ff82e954432bedd0bb20845c666eddb) - - - - - 29fc00bc by Wander Hillen at 2020-09-24T13:11:02-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. (cherry picked from commit e195dae6d959e2a9b1a22a2ca78db5955e1d7dea) - - - - - 7f418acf by Ryan Scott at 2020-09-24T13:14:46-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. (cherry picked from commit 3ea8ac774efd9ee25156f444eacf49893d48a6c9) - - - - - 4c37274a by Ben Gamari at 2020-09-25T17:39:53-04:00 Bump Cabal, haskeline, directory, process submodules To accomodate Win32 2.10.0.0. - - - - - 12957a0b by Ben Gamari at 2020-09-25T17:39:53-04:00 Disable -Wdeprecations for deepseq Use to use of Data.Semigroup.Option for NFData instance. - - - - - 6c98a930 by Sylvain Henry at 2020-09-28T08:37:29+02:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 74f3f581 by Sylvain Henry at 2020-09-28T08:37:29+02:00 Bignum: implement extended GCD (#18427) - - - - - ebcc0968 by Sylvain Henry at 2020-09-28T09:56:49+02:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - edfa896e by Arnaud Spiwack at 2020-09-29T11:41:25-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. (cherry picked from commit 2707c4eae4cf99e6da2709e128f560d91e468357) - - - - - a64ea9d0 by Krzysztof Gogolewski at 2020-09-29T11:41:25-04:00 Disallow linear types in FFI (#18472) (cherry picked from commit 160fba4aa306c0649c72a6dcd7c98d9782a0e74b) - - - - - f8d8c343 by Krzysztof Gogolewski at 2020-09-29T11:41:25-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH (cherry picked from commit 83407ffc7acc00cc025b9f6ed063add9ab9f9bcc) - - - - - 90fe5cff by Krzysztof Gogolewski at 2020-09-29T11:41:25-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. (cherry picked from commit e124f2a7d9a5932a4c2383fd3f9dd772b2059885) - - - - - 7895dbef by Moritz Angermann at 2020-09-30T22:52:28-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 89a753308deb2c7ed012e875e220b1d39e1798d8) Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Misc.hs - compiler/ghc.cabal.in - configure.ac - docs/users_guide/conf.py The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5a622200257cfd758e619317ffeb0f50e982fcb...7895dbef7f903615d212ebcb733812b8e60cc37c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5a622200257cfd758e619317ffeb0f50e982fcb...7895dbef7f903615d212ebcb733812b8e60cc37c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 02:52:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 30 Sep 2020 22:52:59 -0400 Subject: [Git][ghc/ghc][wip/angerman/ghc-8.10-backport-rpath] 2 commits: rts linker: teach the linker about GLIBC's special handling of *stat, mknod... Message-ID: <5f75448b45208_80b89fd0f0158093a9@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/angerman/ghc-8.10-backport-rpath at Glasgow Haskell Compiler / GHC Commits: 721dc35d by Adam Sandberg Ericsson at 2020-09-12T10:19:57+01:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 (cherry picked from commit 0effc57d48ace6b719a9f4cbeac67c95ad55010b) - - - - - e2c9625a by Moritz Angermann at 2020-09-30T22:52:52-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 4ff93292243888545da452ea4d4c1987f2343591) Signed-off-by: Moritz Angermann <moritz.angermann at iohk.io> - - - - - 23 changed files: - aclocal.m4 - compiler/ghci/Linker.hs - compiler/main/DriverPipeline.hs - compiler/main/DynFlags.hs - compiler/main/Settings.hs - compiler/main/SysTools.hs - compiler/main/SysTools/Settings.hs - compiler/main/SysTools/Tasks.hs - compiler/main/ToolSettings.hs - configure.ac - docs/users_guide/phases.rst - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - includes/ghc.mk - mk/config.mk.in - rts/Linker.c - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/Makefile - + testsuite/tests/rts/linker/T7072-main.c - + testsuite/tests/rts/linker/T7072-obj.c - + testsuite/tests/rts/linker/T7072.stderr - testsuite/tests/rts/linker/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -578,6 +578,18 @@ AC_DEFUN([FP_SETTINGS], else SettingsOptCommand="$OptCmd" fi + if test -z "$OtoolCmd" + then + SettingsOtoolCommand="otool" + else + SettingsOtoolCommand="$OtoolCmd" + fi + if test -z "$InstallNameToolCmd" + then + SettingsInstallNameToolCommand="install_name_tool" + else + SettingsInstallNameToolCommand="$InstallNameToolCmd" + fi SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2" @@ -594,6 +606,8 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsLdFlags) AC_SUBST(SettingsArCommand) AC_SUBST(SettingsRanlibCommand) + AC_SUBST(SettingsOtoolCommand) + AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) AC_SUBST(SettingsLibtoolCommand) ===================================== compiler/ghci/Linker.hs ===================================== @@ -913,20 +913,22 @@ dynLoadObjs hsc_env pls at PersistentLinkerState{..} objs = do ldInputs = concatMap (\l -> [ Option ("-l" ++ l) ]) (nub $ snd <$> temp_sos) - ++ concatMap (\lp -> [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp ]) + ++ concatMap (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) (nub $ fst <$> temp_sos) ++ concatMap - (\lp -> - [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp - ]) + (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) minus_big_ls -- See Note [-Xlinker -rpath vs -Wl,-rpath] ++ map (\l -> Option ("-l" ++ l)) minus_ls, ===================================== compiler/main/DriverPipeline.hs ===================================== @@ -382,7 +382,56 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- --------------------------------------------------------------------------- -- Link - +-- +-- Note [Dynamic linking on macOS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Since macOS Sierra (10.14), the dynamic system linker enforces +-- a limit on the Load Commands. Specifically the Load Command Size +-- Limit is at 32K (32768). The Load Commands contain the install +-- name, dependencies, runpaths, and a few other commands. We however +-- only have control over the install name, dependencies and runpaths. +-- +-- The install name is the name by which this library will be +-- referenced. This is such that we do not need to bake in the full +-- absolute location of the library, and can move the library around. +-- +-- The dependency commands contain the install names from of referenced +-- libraries. Thus if a libraries install name is @rpath/libHS...dylib, +-- that will end up as the dependency. +-- +-- Finally we have the runpaths, which informs the linker about the +-- directories to search for the referenced dependencies. +-- +-- The system linker can do recursive linking, however using only the +-- direct dependencies conflicts with ghc's ability to inline across +-- packages, and as such would end up with unresolved symbols. +-- +-- Thus we will pass the full dependency closure to the linker, and then +-- ask the linker to remove any unused dynamic libraries (-dead_strip_dylibs). +-- +-- We still need to add the relevant runpaths, for the dynamic linker to +-- lookup the referenced libraries though. The linker (ld64) does not +-- have any option to dead strip runpaths; which makes sense as runpaths +-- can be used for dependencies of dependencies as well. +-- +-- The solution we then take in GHC is to not pass any runpaths to the +-- linker at link time, but inject them after the linking. For this to +-- work we'll need to ask the linker to create enough space in the header +-- to add more runpaths after the linking (-headerpad 8000). +-- +-- After the library has been linked by $LD (usually ld64), we will use +-- otool to inspect the libraries left over after dead stripping, compute +-- the relevant runpaths, and inject them into the linked product using +-- the install_name_tool command. +-- +-- This strategy should produce the smallest possible set of load commands +-- while still retaining some form of relocatability via runpaths. +-- +-- The only way I can see to reduce the load command size further would be +-- by shortening the library names, or start putting libraries into the same +-- folders, such that one runpath would be sufficient for multiple/all +-- libraries. link :: GhcLink -- interactive or batch -> DynFlags -- dynamic flags -> Bool -- attempt linking in batch mode? @@ -1769,9 +1818,12 @@ linkBinary' staticLink dflags o_files dep_packages = do rc_objs <- maybeCreateManifest dflags output_fn - let link = if staticLink - then SysTools.runLibtool - else SysTools.runLink + let link dflags args | staticLink = SysTools.runLibtool dflags args + | platformOS platform == OSDarwin + = SysTools.runLink dflags args >> SysTools.runInjectRPaths dflags pkg_lib_paths output_fn + | otherwise + = SysTools.runLink dflags args + link dflags ( map SysTools.Option verbFlags ++ [ SysTools.Option "-o" @@ -1838,7 +1890,13 @@ linkBinary' staticLink dflags o_files dep_packages = do ++ pkg_link_opts ++ pkg_framework_opts ++ (if platformOS platform == OSDarwin - then [ "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the left over + -- libraries during runInjectRpaths phase. + -- + -- See Note [Dynamic linking on macOS]. + then [ "-Wl,-dead_strip_dylibs", "-Wl,-headerpad,8000" ] else []) )) ===================================== compiler/main/DynFlags.hs ===================================== @@ -155,8 +155,8 @@ module DynFlags ( versionedAppDir, versionedFilePath, extraGccViaCFlags, systemPackageConfig, pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_libtool, pgm_ar, pgm_ranlib, pgm_lo, pgm_lc, - pgm_lcc, pgm_i, + pgm_windres, pgm_libtool, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, opt_P_signature, opt_windres, opt_lo, opt_lc, opt_lcc, @@ -1463,6 +1463,10 @@ pgm_lcc :: DynFlags -> (String,[Option]) pgm_lcc dflags = toolSettings_pgm_lcc $ toolSettings dflags pgm_ar :: DynFlags -> String pgm_ar dflags = toolSettings_pgm_ar $ toolSettings dflags +pgm_otool :: DynFlags -> String +pgm_otool dflags = toolSettings_pgm_otool $ toolSettings dflags +pgm_install_name_tool :: DynFlags -> String +pgm_install_name_tool dflags = toolSettings_pgm_install_name_tool $ toolSettings dflags pgm_ranlib :: DynFlags -> String pgm_ranlib dflags = toolSettings_pgm_ranlib $ toolSettings dflags pgm_lo :: DynFlags -> (String,[Option]) @@ -3089,6 +3093,10 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_libtool = f } , make_ord_flag defFlag "pgmar" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ar = f } + , make_ord_flag defFlag "pgmotool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_otool = f} + , make_ord_flag defFlag "pgminstall_name_tool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_install_name_tool = f} , make_ord_flag defFlag "pgmranlib" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ranlib = f } @@ -4589,7 +4597,6 @@ defaultFlags settings Opt_OmitYields, Opt_PrintBindContents, Opt_ProfCountEntries, - Opt_RPath, Opt_SharedImplib, Opt_SimplPreInlining, Opt_VersionMacros @@ -4600,6 +4607,8 @@ defaultFlags settings ++ default_PIC platform + ++ default_RPath platform + ++ concatMap (wayGeneralFlags platform) (defaultWays settings) ++ validHoleFitDefaults @@ -4640,6 +4649,29 @@ default_PIC platform = -- information. _ -> [] + +-- We usually want to use RPath, except on macOS (OSDarwin). On recent macOS +-- versions the number of load commands we can embed in a dynamic library is +-- restricted. Hence since b592bd98ff2 we rely on -dead_strip_dylib to only +-- link the needed dylibs instead of linking the full dependency closure. +-- +-- If we split the library linking into injecting -rpath and -l @rpath/... +-- components, we will reduce the number of libraries we link, however we will +-- still inject one -rpath entry for each library, independent of their use. +-- That is, we even inject -rpath values for libraries that we dead_strip in +-- the end. As such we can run afoul of the load command size limit simply +-- by polluting the load commands with RPATH entries. +-- +-- Thus, we disable Opt_RPath by default on OSDarwin. The savvy user can always +-- enable it with -use-rpath if they so wish. +-- +-- See Note [Dynamic linking on macOS] + +default_RPath :: Platform -> [GeneralFlag] +default_RPath platform | platformOS platform == OSDarwin = [] +default_RPath _ = [Opt_RPath] + + -- General flags that are switched on/off when other general flags are switched -- on impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] ===================================== compiler/main/Settings.hs ===================================== @@ -25,6 +25,8 @@ module Settings , sPgm_windres , sPgm_libtool , sPgm_ar + , sPgm_otool + , sPgm_install_name_tool , sPgm_ranlib , sPgm_lo , sPgm_lc @@ -139,6 +141,10 @@ sPgm_libtool :: Settings -> String sPgm_libtool = toolSettings_pgm_libtool . sToolSettings sPgm_ar :: Settings -> String sPgm_ar = toolSettings_pgm_ar . sToolSettings +sPgm_otool :: Settings -> String +sPgm_otool = toolSettings_pgm_otool . sToolSettings +sPgm_install_name_tool :: Settings -> String +sPgm_install_name_tool = toolSettings_pgm_install_name_tool . sToolSettings sPgm_ranlib :: Settings -> String sPgm_ranlib = toolSettings_pgm_ranlib . sToolSettings sPgm_lo :: Settings -> (String, [Option]) ===================================== compiler/main/SysTools.hs ===================================== @@ -254,7 +254,10 @@ linkDynLib dflags0 o_files dep_packages | ( osElfTarget (platformOS (targetPlatform dflags)) || osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && - WayDyn `elem` ways dflags + -- Only if we want dynamic libraries + WayDyn `elem` ways dflags && + -- Only use RPath if we explicitly asked for it + gopt Opt_RPath dflags = ["-L" ++ l, "-Xlinker", "-rpath", "-Xlinker", l] -- See Note [-Xlinker -rpath vs -Wl,-rpath] | otherwise = ["-L" ++ l] @@ -377,8 +380,15 @@ linkDynLib dflags0 o_files dep_packages ++ map Option pkg_lib_path_opts ++ map Option pkg_link_opts ++ map Option pkg_framework_opts - ++ [ Option "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the leftover + -- libraries in the runInjectRpaths phase below. + -- + -- See Note [Dynamic linking on macOS] + ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) + runInjectRPaths dflags pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/main/SysTools/Settings.hs ===================================== @@ -119,6 +119,8 @@ initSettings top_dir = do windres_path <- getToolSetting "windres command" libtool_path <- getToolSetting "libtool command" ar_path <- getToolSetting "ar command" + otool_path <- getToolSetting "otool command" + install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" -- TODO this side-effect doesn't belong here. Reading and parsing the settings @@ -210,6 +212,8 @@ initSettings top_dir = do , toolSettings_pgm_windres = windres_path , toolSettings_pgm_libtool = libtool_path , toolSettings_pgm_ar = ar_path + , toolSettings_pgm_otool = otool_path + , toolSettings_pgm_install_name_tool = install_name_tool_path , toolSettings_pgm_ranlib = ranlib_path , toolSettings_pgm_lo = (lo_prog,[]) , toolSettings_pgm_lc = (lc_prog,[]) ===================================== compiler/main/SysTools/Tasks.hs ===================================== @@ -28,6 +28,10 @@ import LlvmCodeGen.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, pars import SysTools.Process import SysTools.Info +import Control.Monad (join, forM, filterM) +import System.Directory (doesFileExist) +import System.FilePath (()) + {- ************************************************************************ * * @@ -237,6 +241,41 @@ figureLlvmVersion dflags = traceToolCommand dflags "llc" $ do return Nothing) +-- | On macOS we rely on the linkers @-dead_strip_dylibs@ flag to remove unused +-- libraries from the dynamic library. We do this to reduce the number of load +-- commands that end up in the dylib, and has been limited to 32K (32768) since +-- macOS Sierra (10.14). +-- +-- @-dead_strip_dylibs@ does not dead strip @-rpath@ entries, as such passing +-- @-l@ and @-rpath@ to the linker will result in the unnecesasry libraries not +-- being included in the load commands, however the @-rpath@ entries are all +-- forced to be included. This can lead to 100s of @-rpath@ entries being +-- included when only a handful of libraries end up being truely linked. +-- +-- Thus after building the library, we run a fixup phase where we inject the +-- @-rpath@ for each found library (in the given library search paths) into the +-- dynamic library through @-add_rpath at . +-- +-- See Note [Dynamic linking on macOS] +runInjectRPaths :: DynFlags -> [FilePath] -> FilePath -> IO () +runInjectRPaths dflags lib_paths dylib = do + info <- lines <$> askOtool dflags Nothing [Option "-L", Option dylib] + -- filter the output for only the libraries. And then drop the @rpath prefix. + let libs = fmap (drop 7) $ filter (isPrefixOf "@rpath") $ fmap (head.words) $ info + -- find any pre-existing LC_PATH items + info <- fmap words.lines <$> askOtool dflags Nothing [Option "-l", Option dylib] + let paths = concatMap f info + where f ("path":p:_) = [p] + f _ = [] + lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] + -- only find those rpaths, that aren't already in the library. + rpaths <- nub.sort.join <$> forM libs (\f -> filterM (\l -> doesFileExist (l f)) lib_paths') + -- inject the rpaths + case rpaths of + [] -> return () + _ -> runInstallNameTool dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + + runLink :: DynFlags -> [Option] -> IO () runLink dflags args = traceToolCommand dflags "linker" $ do -- See Note [Run-time linker info] @@ -335,6 +374,17 @@ askAr dflags mb_cwd args = traceToolCommand dflags "ar" $ do runSomethingWith dflags "Ar" ar args $ \real_args -> readCreateProcessWithExitCode' (proc ar real_args){ cwd = mb_cwd } +askOtool :: DynFlags -> Maybe FilePath -> [Option] -> IO String +askOtool dflags mb_cwd args = do + let otool = pgm_otool dflags + runSomethingWith dflags "otool" otool args $ \real_args -> + readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } + +runInstallNameTool :: DynFlags -> [Option] -> IO () +runInstallNameTool dflags args = do + let tool = pgm_install_name_tool dflags + runSomethingFiltered dflags id "Install Name Tool" tool args Nothing Nothing + runRanlib :: DynFlags -> [Option] -> IO () runRanlib dflags args = traceToolCommand dflags "ranlib" $ do let ranlib = pgm_ranlib dflags ===================================== compiler/main/ToolSettings.hs ===================================== @@ -31,6 +31,8 @@ data ToolSettings = ToolSettings , toolSettings_pgm_windres :: String , toolSettings_pgm_libtool :: String , toolSettings_pgm_ar :: String + , toolSettings_pgm_otool :: String + , toolSettings_pgm_install_name_tool :: String , toolSettings_pgm_ranlib :: String , -- | LLVM: opt llvm optimiser toolSettings_pgm_lo :: (String, [Option]) ===================================== configure.ac ===================================== @@ -669,6 +669,18 @@ else fi AC_SUBST([LibtoolCmd]) +dnl ** Which otool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +OtoolCmd="$OTOOL" +AC_SUBST(OtoolCmd) + +dnl ** Which install_name_tool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +InstallNameToolCmd="$INSTALL_NAME_TOOL" +AC_SUBST(InstallNameToolCmd) + # Here is where we re-target which specific version of the LLVM # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around @@ -1479,6 +1491,8 @@ echo "\ libtool : $LibtoolCmd objdump : $ObjdumpCmd ranlib : $RanlibCmd + otool : $OtoolCmd + install_name_tool : $InstallNameToolCmd windres : $WindresCmd dllwrap : $DllWrapCmd genlib : $GenlibCmd ===================================== docs/users_guide/phases.rst ===================================== @@ -95,6 +95,24 @@ given compilation phase: Use ⟨cmd⟩ as the pre-processor (with :ghc-flag:`-F` only). +.. ghc-flag:: -pgmotool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inspect mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inspect mach-o dynamic libraries and + executables to read the dynamic library dependencies. We will compute + the necessary ``runpath``s to embed for the dependencies based on the + result of the ``otool`` call. + +.. ghc-flag:: -pgminstall_name_tool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inject ``runpath`` into mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inject ``runpath``s into mach-o dynamic + libraries and executables. As detected by the ``otool`` call. + .. ghc-flag:: -pgmwindres ⟨cmd⟩ :shortdesc: Use ⟨cmd⟩ as the program for embedding manifests on Windows. :type: dynamic ===================================== hadrian/cfg/system.config.in ===================================== @@ -147,6 +147,8 @@ settings-merge-objects-command = @SettingsMergeObjectsCommand@ settings-merge-objects-flags = @SettingsMergeObjectsFlags@ settings-ar-command = @SettingsArCommand@ settings-ranlib-command = @SettingsRanlibCommand@ +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ settings-libtool-command = @SettingsLibtoolCommand@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -113,6 +113,8 @@ data SettingsFileSetting | SettingsFileSetting_MergeObjectsFlags | SettingsFileSetting_ArCommand | SettingsFileSetting_RanlibCommand + | SettingsFileSetting_OtoolCommand + | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand | SettingsFileSetting_LibtoolCommand @@ -198,6 +200,8 @@ settingsFileSetting key = lookupValueOrError configFile $ case key of SettingsFileSetting_MergeObjectsFlags -> "settings-merge-objects-flags" SettingsFileSetting_ArCommand -> "settings-ar-command" SettingsFileSetting_RanlibCommand -> "settings-ranlib-command" + SettingsFileSetting_OtoolCommand -> "settings-otool-command" + SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" SettingsFileSetting_LibtoolCommand -> "settings-libtool-command" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -294,6 +294,8 @@ generateSettings = do , ("ar flags", expr $ lookupValueOrError configFile "ar-args") , ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile) , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) + , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) + , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) ===================================== includes/ghc.mk ===================================== @@ -228,6 +228,8 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/. @echo ',("ar flags", "$(ArArgs)")' >> $@ @echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@ @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ + @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ + @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ ===================================== mk/config.mk.in ===================================== @@ -515,6 +515,8 @@ SettingsLdFlags = @SettingsLdFlags@ SettingsMergeObjectsCommand = @SettingsMergeObjectsCommand@ SettingsMergeObjectsFlags = @SettingsMergeObjectsFlags@ SettingsArCommand = @SettingsArCommand@ +SettingsOtoolCommand = @SettingsOtoolCommand@ +SettingsInstallNameToolCommand = @SettingsInstallNameToolCommand@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ ===================================== rts/Linker.c ===================================== @@ -655,23 +655,51 @@ internal_dlsym(const char *symbol) { // We acquire dl_mutex as concurrent dl* calls may alter dlerror ACQUIRE_LOCK(&dl_mutex); + + // clears dlerror dlerror(); + // look in program first v = dlsym(dl_prog_handle, symbol); if (dlerror() == NULL) { RELEASE_LOCK(&dl_mutex); + IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in program\n", symbol)); return v; } for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { v = dlsym(o_so->handle, symbol); if (dlerror() == NULL) { + IF_DEBUG(linker, debugBelch("internal_dlsym: found symbol '%s' in shared object\n", symbol)); RELEASE_LOCK(&dl_mutex); return v; } } RELEASE_LOCK(&dl_mutex); - return v; + +# if defined(HAVE_SYS_STAT_H) && defined(linux_HOST_OS) && defined(__GLIBC__) + // HACK: GLIBC implements these functions with a great deal of trickery where + // they are either inlined at compile time to their corresponding + // __xxxx(SYS_VER, ...) function or direct syscalls, or resolved at + // link time via libc_nonshared.a. + // + // We borrow the approach that the LLVM JIT uses to resolve these + // symbols. See http://llvm.org/PR274 and #7072 for more info. + + IF_DEBUG(linker, debugBelch("internal_dlsym: looking for symbol '%s' in GLIBC special cases\n", symbol)); + + if (strcmp(symbol, "stat") == 0) return (void*)&stat; + if (strcmp(symbol, "fstat") == 0) return (void*)&fstat; + if (strcmp(symbol, "lstat") == 0) return (void*)&lstat; + if (strcmp(symbol, "stat64") == 0) return (void*)&stat64; + if (strcmp(symbol, "fstat64") == 0) return (void*)&fstat64; + if (strcmp(symbol, "lstat64") == 0) return (void*)&lstat64; + if (strcmp(symbol, "atexit") == 0) return (void*)&atexit; + if (strcmp(symbol, "mknod") == 0) return (void*)&mknod; +# endif + + // we failed to find the symbol + return NULL; } # endif @@ -847,13 +875,13 @@ SymbolAddr* lookupSymbol_ (SymbolName* lbl) SymbolAddr* lookupSymbol_ (SymbolName* lbl) { - IF_DEBUG(linker, debugBelch("lookupSymbol: looking up %s\n", lbl)); + IF_DEBUG(linker, debugBelch("lookupSymbol: looking up '%s'\n", lbl)); ASSERT(symhash != NULL); RtsSymbolInfo *pinfo; if (!ghciLookupSymbolInfo(symhash, lbl, &pinfo)) { - IF_DEBUG(linker, debugBelch("lookupSymbol: symbol not found\n")); + IF_DEBUG(linker, debugBelch("lookupSymbol: symbol '%s' not found, trying dlsym\n", lbl)); # if defined(OBJFORMAT_ELF) return internal_dlsym(lbl); ===================================== testsuite/tests/rts/all.T ===================================== @@ -403,7 +403,7 @@ test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp - test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', - [when(opsys('darwin') or opsys('mingw32'), expect_broken(17447)), + [when(opsys('mingw32'), expect_broken(17447)), extra_files(['T13676.hs'])], ghci_script, ['T13676.script']) ===================================== testsuite/tests/rts/linker/Makefile ===================================== @@ -96,3 +96,10 @@ linker_error3: "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded ./linker_error3 linker_error3_o.o + +.PHONY: T7072 +T7072: + "$(TEST_HC)" -c T7072-obj.c -o T7072-obj.o + "$(TEST_HC)" -c T7072-main.c -o T7072-main.o + "$(TEST_HC)" T7072-main.c -o T7072-main -no-hs-main -debug + ./T7072-main T7072-obj.o ===================================== testsuite/tests/rts/linker/T7072-main.c ===================================== @@ -0,0 +1,39 @@ +#include "ghcconfig.h" +#include "Rts.h" +#include +#include + +int main (int argc, char *argv[]) +{ + int r; + char *obj; + + hs_init(&argc, &argv); + + initLinker_(0); + + // Load object file argv[1] repeatedly + + if (argc != 2) { + errorBelch("usage: T7072-main "); + exit(1); + } + + obj = argv[1]; + + r = loadObj(obj); + if (!r) { + debugBelch("loadObj(%s) failed\n", obj); + exit(1); + } + r = resolveObjs(); + if (!r) { + debugBelch("resolveObjs failed\n"); + unloadObj(obj); + exit(1); + } + debugBelch("loading succeeded"); + + hs_exit(); + return 0; +} ===================================== testsuite/tests/rts/linker/T7072-obj.c ===================================== @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +typedef int stat_func(const char*, struct stat*); + +stat_func *foo = &stat; + +void stat_test(void) +{ + struct stat buf; + + printf("About to stat-test.c\n"); + foo("stat-test.c", &buf); + printf("Done\n"); +} ===================================== testsuite/tests/rts/linker/T7072.stderr ===================================== @@ -0,0 +1 @@ +loading succeeded \ No newline at end of file ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -92,3 +92,10 @@ test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip) , omit_ways(['ghci']) ], compile_and_run, ['-rdynamic -package ghc']) + + +test('T7072', + [extra_files(['T7072-main.c', 'T7072-obj.c']), + unless(opsys('linux'), skip), + req_rts_linker], + makefile_test, ['T7072']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ffc00acc68776385e2736e613b2571ad89ae60b0...e2c9625a82516f4fcd516218f782d7007357aa77 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ffc00acc68776385e2736e613b2571ad89ae60b0...e2c9625a82516f4fcd516218f782d7007357aa77 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 11:58:38 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Thu, 01 Oct 2020 07:58:38 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f75c46ec5429_80b3f847c760cd815846719@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 6e89b7a7 by Daniel Rogozin at 2020-10-01T14:58:19+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 12 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,14 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1048,23 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was +out of scope. We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Type constructor 'Int' used where a value identifier was expected + +when the user writes the following term + + id Int + -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1079,19 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -215,6 +216,14 @@ demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion]. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion]. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -179,13 +179,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,5 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Type constructor ‘Foo’ used where a value identifier was expected + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,5 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Type constructor 'D' used where a value identifier was expected + In the expression: D 4 + In an equation for 'x': x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,6 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Type constructor ‘T’ used where a value identifier was expected +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740a.hs:3:5: error: + • Type constructor ‘Int’ used where a value identifier was expected + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e89b7a7e32aae249dd2ab419ed8b08ebac02c46 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e89b7a7e32aae249dd2ab419ed8b08ebac02c46 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 12:19:36 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 01 Oct 2020 08:19:36 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] 373 commits: DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) Message-ID: <5f75c9588588b_80b106cde68158509f2@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - e38c63ec by Andreas Klebinger at 2020-09-30T14:02:10+02:00 Enable strict dicts by default at -O2. In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. - - - - - 24 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/test-metrics.sh - CODEOWNERS - README.md - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Uniques.hs-boot - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/Cmm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8c212b98fe949feccbc4788cabedd3562fec842...e38c63ec52545d1f7336bf9e95200badcc661809 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8c212b98fe949feccbc4788cabedd3562fec842...e38c63ec52545d1f7336bf9e95200badcc661809 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 12:31:32 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Thu, 01 Oct 2020 08:31:32 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f75cc24c0f45_80b46f3520158549bd@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 7f363082 by Daniel Rogozin at 2020-10-01T15:31:10+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 12 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,14 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1048,23 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was +out of scope. We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Type constructor 'Int' used where a value identifier was expected + +when the user writes the following term + + id Int + -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1079,19 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -215,6 +216,14 @@ demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion]. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion]. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -179,13 +179,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f363082ecaa61cb3c1d5da70f73f5fd32d733bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f363082ecaa61cb3c1d5da70f73f5fd32d733bf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 13:24:43 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 09:24:43 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 23 commits: PmCheck: Long-distance information for LocalBinds (#18626) Message-ID: <5f75d89b2bd5_80b3f843859b9c815864583@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 6b226848 by Sylvain Henry at 2020-10-01T09:24:31-04:00 Add test for T18574 - - - - - 270f9d92 by Sylvain Henry at 2020-10-01T09:24:31-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - 40a023c9 by Fendor at 2020-10-01T09:24:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - 373b5f77 by Fendor at 2020-10-01T09:24:33-04:00 Use HomeUnit for main module without module declaration - - - - - a1ce41cb by Fendor at 2020-10-01T09:24:33-04:00 Remove mAIN completely - - - - - c4b2d61b by Sylvain Henry at 2020-10-01T09:24:34-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - aa72e3c8 by Sylvain Henry at 2020-10-01T09:24:34-04:00 Less DynFlags in Header parsing - - - - - d11c312a by Sylvain Henry at 2020-10-01T09:24:34-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 2235b268 by Sylvain Henry at 2020-10-01T09:24:34-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - 09c78bcd by Sebastian Graf at 2020-10-01T09:24:35-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - 6de6a62b by Richard Eisenberg at 2020-10-01T09:24:35-04:00 Add regression test for #18755. Close #18755 - - - - - 089c593e by Vladislav Zavialov at 2020-10-01T09:24:36-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - f7dcb965 by Sylvain Henry at 2020-10-01T09:24:37-04:00 Bignum: add integerNegate RULE - - - - - b07ba5ea by Vladislav Zavialov at 2020-10-01T09:24:37-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Backpack/Syntax.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Ppr.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Session.hs-boot - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/Iface/Recomp/Flags.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b39d9555b0b4df45baae05f72b4f7fd4141dcaaa...b07ba5ea2b680f3653b67552d16178f06cf84ddd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b39d9555b0b4df45baae05f72b4f7fd4141dcaaa...b07ba5ea2b680f3653b67552d16178f06cf84ddd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 14:08:41 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 01 Oct 2020 10:08:41 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] Fix some warnings causing failure with Werror in testsuite/timeout Message-ID: <5f75e2e9441ef_80b3f8468dc220c1588192a@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: e5e4f183 by Andreas Klebinger at 2020-10-01T16:08:15+02:00 Fix some warnings causing failure with Werror in testsuite/timeout - - - - - 2 changed files: - testsuite/timeout/WinCBindings.hsc - testsuite/timeout/timeout.hs Changes: ===================================== testsuite/timeout/WinCBindings.hsc ===================================== @@ -29,11 +29,11 @@ data PROCESS_INFORMATION = PROCESS_INFORMATION instance Storable PROCESS_INFORMATION where sizeOf = const #size PROCESS_INFORMATION alignment = sizeOf - poke buf pi = do - (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pi) - (#poke PROCESS_INFORMATION, hThread) buf (piThread pi) - (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pi) - (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pi) + poke buf pinfo = do + (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pinfo) + (#poke PROCESS_INFORMATION, hThread) buf (piThread pinfo) + (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pinfo) + (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pinfo) peek buf = do vhProcess <- (#peek PROCESS_INFORMATION, hProcess) buf @@ -361,7 +361,7 @@ createCompletionPort hJob = do return nullPtr waitForJobCompletion :: HANDLE -> HANDLE -> DWORD -> IO BOOL -waitForJobCompletion hJob ioPort timeout +waitForJobCompletion _hJob ioPort timeout = alloca $ \p_CompletionCode -> alloca $ \p_CompletionKey -> alloca $ \p_Overlapped -> do ===================================== testsuite/timeout/timeout.hs ===================================== @@ -2,22 +2,25 @@ {-# LANGUAGE LambdaCase #-} module Main where -import Control.Concurrent (forkIO, threadDelay) -import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) import Control.Monad import Control.Exception -import Data.Maybe (isNothing) import System.Environment (getArgs) import System.Exit -import System.IO (hPutStrLn, stderr) +import Prelude hiding (pi) #if !defined(mingw32_HOST_OS) +import Control.Concurrent (forkIO, threadDelay) +import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) + +import Data.Maybe (isNothing) + import System.Posix hiding (killProcess) import System.IO.Error hiding (try,catch) +import System.IO (hPutStrLn, stderr) #endif #if defined(mingw32_HOST_OS) -import System.Process +-- import System.Process import WinCBindings import Foreign import System.Win32.DebugApi @@ -114,8 +117,8 @@ run secs cmd = -- We're explicitly turning off handle inheritance to prevent misc handles -- from being inherited by the child. Notable we don't want the I/O Completion -- Ports and Job handles to be inherited. So we mark them as non-inheritable. - setHandleInformation job cHANDLE_FLAG_INHERIT 0 - setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation job cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 -- Now create the process suspended so we can add it to the job and then resume. -- This is so we don't miss any events on the receiving end of the I/O port. @@ -132,30 +135,30 @@ run secs cmd = let handleInterrupt action = action `onException` terminateJobObject job 99 handleCtrl _ = do - terminateJobObject job 99 - closeHandle ioPort - closeHandle job - exitWith (ExitFailure 99) + _ <- terminateJobObject job 99 + _ <- closeHandle ioPort + _ <- closeHandle job + _ <- exitWith (ExitFailure 99) return True withConsoleCtrlHandler handleCtrl $ handleInterrupt $ do - resumeThread (piThread pi) + _ <- resumeThread (piThread pi) -- The program is now running - let handle = piProcess pi + let p_handle = piProcess pi let millisecs = secs * 1000 rc <- waitForJobCompletion job ioPort (fromIntegral millisecs) - closeHandle ioPort + _ <- closeHandle ioPort if not rc - then do terminateJobObject job 99 - closeHandle job + then do _ <- terminateJobObject job 99 + _ <- closeHandle job exitWith (ExitFailure 99) else alloca $ \p_exitCode -> - do terminateJobObject job 0 + do _ <- terminateJobObject job 0 -- Ensured it's all really dead. - closeHandle job - r <- getExitCodeProcess handle p_exitCode + _ <- closeHandle job + r <- getExitCodeProcess p_handle p_exitCode if r then peek p_exitCode >>= \case 0 -> exitWith ExitSuccess View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5e4f1834df5f5bc5eacce7a70d63123b8477442 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5e4f1834df5f5bc5eacce7a70d63123b8477442 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 14:10:53 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 01 Oct 2020 10:10:53 -0400 Subject: [Git][ghc/ghc][wip/andreask/tune_perf_tests] Use proper RTS flags when collecting residency in perf tests. Message-ID: <5f75e36d5b29f_80bd359af015883155@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/tune_perf_tests at Glasgow Haskell Compiler / GHC Commits: acd3a25b by Andreas Klebinger at 2020-10-01T16:10:07+02:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 ------------------------- - - - - - 2 changed files: - testsuite/tests/perf/should_run/all.T - testsuite/tests/perf/space_leaks/all.T Changes: ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -88,15 +88,15 @@ test('T4321', test('T3736', [], makefile_test, ['T3736']) test('T3738', [extra_clean(['T3738a.hi', 'T3738a.o']), - collect_stats('peak_megabytes_allocated', 0), + collect_runtime_residency(1), collect_stats('bytes allocated',8), - only_ways(['normal']) + only_ways(['normal']), ], compile_and_run, ['-O']) test('MethSharing', - [collect_stats('peak_megabytes_allocated', 0), + [collect_runtime_residency(1), collect_stats('bytes allocated',5), only_ways(['normal']) ], @@ -177,7 +177,7 @@ test('T5536', test('T7257', [collect_stats('bytes allocated',10), - collect_stats('peak_megabytes_allocated',5), + collect_runtime_residency(5), only_ways(['normal']) ], compile_and_run, ['-O']) @@ -192,14 +192,14 @@ test('T7507', omit_ways(['ghci']), compile_and_run, ['-O']) # For 7507, stack overflow is the bad case test('T7436', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, ['-O']) test('T7436b', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, @@ -221,7 +221,7 @@ test('T7954', ['-O']) test('T7850', - [collect_stats('peak_megabytes_allocated',10), + [collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) @@ -308,7 +308,7 @@ test('T12990', test('T13218', [collect_stats('bytes allocated',5), - collect_stats('max_bytes_used',10), + collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) ===================================== testsuite/tests/perf/space_leaks/all.T ===================================== @@ -3,7 +3,7 @@ test('space_leak_001', # This could potentially be replaced with # collect_stats('all',5) to test all 3 with # 5% possible deviation. - [collect_stats(['peak_megabytes_allocated','bytes allocated'],5), + [ collect_stats(['bytes allocated'],5), collect_runtime_residency(15), omit_ways(['profasm','profthreaded','threaded1','threaded2','nonmoving_thr']) ], @@ -13,7 +13,7 @@ test('space_leak_001', test('T4334', # Test for a space leak in Data.List.lines (fixed with #4334) [extra_run_opts('1000000 2 t'), - collect_stats('peak_megabytes_allocated',2), + collect_runtime_residency(2), # prof ways don't work well with +RTS -V0, nonmoving way residency is # highly variable. omit_ways(['profasm','profthreaded','nonmoving_thr']) @@ -21,9 +21,8 @@ test('T4334', compile_and_run, ['']) test('T2762', - [collect_stats('peak_megabytes_allocated',2), + [collect_runtime_residency(2), only_ways(['normal']), - extra_run_opts('+RTS -G1 -RTS' ), extra_clean(['T2762A.hi', 'T2762A.o'])], compile_and_run, ['-O']) @@ -32,9 +31,7 @@ test('T4018', compile_and_run, ['-fno-state-hack']) test('T4029', - [collect_stats(['peak_megabytes_allocated'],10), - collect_runtime_residency(10), - extra_hc_opts('+RTS -G1 -RTS' ), + [collect_runtime_residency(10), ], ghci_script, ['T4029.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/acd3a25bf3d0bc590870d5ba493bd02a1c337489 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/acd3a25bf3d0bc590870d5ba493bd02a1c337489 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 14:19:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 01 Oct 2020 10:19:14 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/ci-fixes Message-ID: <5f75e562e00cf_80b3f8492575480158835d0@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/ci-fixes at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 14:19:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 01 Oct 2020 10:19:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ci-fixes Message-ID: <5f75e56631b5a_80badaf728158837ec@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/ci-fixes at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ci-fixes You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 15:02:09 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 01 Oct 2020 11:02:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18783 Message-ID: <5f75ef71b9c1e_80b3f84964785381589896a@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18783 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18783 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 15:18:25 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 01 Oct 2020 11:18:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/fix_timeout_warnings Message-ID: <5f75f3415c3b1_80b3f8411a332dc159017af@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/fix_timeout_warnings at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/fix_timeout_warnings You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 15:19:55 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 01 Oct 2020 11:19:55 -0400 Subject: [Git][ghc/ghc][wip/andreask/fix_timeout_warnings] testsuite/timeout: Fix windows specific errors. Message-ID: <5f75f39b98146_80b3f8411a332dc15901912@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/fix_timeout_warnings at Glasgow Haskell Compiler / GHC Commits: adb769b4 by Andreas Klebinger at 2020-10-01T17:18:37+02:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - 2 changed files: - testsuite/timeout/WinCBindings.hsc - testsuite/timeout/timeout.hs Changes: ===================================== testsuite/timeout/WinCBindings.hsc ===================================== @@ -29,11 +29,11 @@ data PROCESS_INFORMATION = PROCESS_INFORMATION instance Storable PROCESS_INFORMATION where sizeOf = const #size PROCESS_INFORMATION alignment = sizeOf - poke buf pi = do - (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pi) - (#poke PROCESS_INFORMATION, hThread) buf (piThread pi) - (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pi) - (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pi) + poke buf pinfo = do + (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pinfo) + (#poke PROCESS_INFORMATION, hThread) buf (piThread pinfo) + (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pinfo) + (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pinfo) peek buf = do vhProcess <- (#peek PROCESS_INFORMATION, hProcess) buf @@ -361,7 +361,7 @@ createCompletionPort hJob = do return nullPtr waitForJobCompletion :: HANDLE -> HANDLE -> DWORD -> IO BOOL -waitForJobCompletion hJob ioPort timeout +waitForJobCompletion _hJob ioPort timeout = alloca $ \p_CompletionCode -> alloca $ \p_CompletionKey -> alloca $ \p_Overlapped -> do ===================================== testsuite/timeout/timeout.hs ===================================== @@ -2,22 +2,25 @@ {-# LANGUAGE LambdaCase #-} module Main where -import Control.Concurrent (forkIO, threadDelay) -import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) import Control.Monad import Control.Exception -import Data.Maybe (isNothing) import System.Environment (getArgs) import System.Exit -import System.IO (hPutStrLn, stderr) +import Prelude hiding (pi) #if !defined(mingw32_HOST_OS) +import Control.Concurrent (forkIO, threadDelay) +import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) + +import Data.Maybe (isNothing) + import System.Posix hiding (killProcess) import System.IO.Error hiding (try,catch) +import System.IO (hPutStrLn, stderr) #endif #if defined(mingw32_HOST_OS) -import System.Process +-- import System.Process import WinCBindings import Foreign import System.Win32.DebugApi @@ -114,8 +117,8 @@ run secs cmd = -- We're explicitly turning off handle inheritance to prevent misc handles -- from being inherited by the child. Notable we don't want the I/O Completion -- Ports and Job handles to be inherited. So we mark them as non-inheritable. - setHandleInformation job cHANDLE_FLAG_INHERIT 0 - setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation job cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 -- Now create the process suspended so we can add it to the job and then resume. -- This is so we don't miss any events on the receiving end of the I/O port. @@ -132,30 +135,30 @@ run secs cmd = let handleInterrupt action = action `onException` terminateJobObject job 99 handleCtrl _ = do - terminateJobObject job 99 - closeHandle ioPort - closeHandle job - exitWith (ExitFailure 99) + _ <- terminateJobObject job 99 + _ <- closeHandle ioPort + _ <- closeHandle job + _ <- exitWith (ExitFailure 99) return True withConsoleCtrlHandler handleCtrl $ handleInterrupt $ do - resumeThread (piThread pi) + _ <- resumeThread (piThread pi) -- The program is now running - let handle = piProcess pi + let p_handle = piProcess pi let millisecs = secs * 1000 rc <- waitForJobCompletion job ioPort (fromIntegral millisecs) - closeHandle ioPort + _ <- closeHandle ioPort if not rc - then do terminateJobObject job 99 - closeHandle job + then do _ <- terminateJobObject job 99 + _ <- closeHandle job exitWith (ExitFailure 99) else alloca $ \p_exitCode -> - do terminateJobObject job 0 + do _ <- terminateJobObject job 0 -- Ensured it's all really dead. - closeHandle job - r <- getExitCodeProcess handle p_exitCode + _ <- closeHandle job + r <- getExitCodeProcess p_handle p_exitCode if r then peek p_exitCode >>= \case 0 -> exitWith ExitSuccess View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adb769b40ebbb9ce7bcc4a96b29b2542ac604053 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/adb769b40ebbb9ce7bcc4a96b29b2542ac604053 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 17:45:07 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 01 Oct 2020 13:45:07 -0400 Subject: [Git][ghc/ghc][wip/testing] Fix it Message-ID: <5f7615a3292e_80b3f8468cc152415950814@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: ab7c500f by Ben Gamari at 2020-10-01T13:45:05-04:00 Fix it - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -387,8 +387,7 @@ validate-x86_64-darwin: extends: .validate stage: lint tags: - - x86_64-darwin - - testing + - x86_64-darwin-testing variables: GHC_VERSION: 8.8.4 CABAL_INSTALL_VERSION: 3.0.0.0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab7c500fd06c67c7a056964f012c742232b6889e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab7c500fd06c67c7a056964f012c742232b6889e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:35:01 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:35:01 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Add test for T18574 Message-ID: <5f7659953332d_80b1071e8401600765f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - 5 changed files: - libraries/base/Data/Maybe.hs - libraries/base/changelog.md - + testsuite/tests/perf/should_run/T18574.hs - + testsuite/tests/perf/should_run/T18574.stdout - testsuite/tests/perf/should_run/all.T Changes: ===================================== libraries/base/Data/Maybe.hs ===================================== @@ -256,8 +256,8 @@ listToMaybe = foldr (const . Just) Nothing -- >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ] -- [1,3] -- -catMaybes :: [Maybe a] -> [a] -catMaybes ls = [x | Just x <- ls] +catMaybes :: [Maybe a] -> [a] +catMaybes = mapMaybe id -- use mapMaybe to allow fusion (#18574) -- | The 'mapMaybe' function is a version of 'map' which can throw -- out elements. In particular, the functional argument returns ===================================== libraries/base/changelog.md ===================================== @@ -32,6 +32,9 @@ * Add `MonadFix` and `MonadZip` instances for `Complex` * Add `Ix` instances for tuples of size 6 through 15 + + * `catMaybes` is now implemented using `mapMaybe`, so that it is both a "good + consumer" and "good producer" for list-fusion (#18574) ## 4.14.0.0 *TBA* * Bundled with GHC 8.10.1 ===================================== testsuite/tests/perf/should_run/T18574.hs ===================================== @@ -0,0 +1,7 @@ +import Data.Maybe + +main :: IO () +main = print $ even $ sum $ catMaybes $ map xx ([1..100000000] :: [Int]) + where + xx n | even n = Just n + | otherwise = Nothing ===================================== testsuite/tests/perf/should_run/T18574.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -379,3 +379,9 @@ test('UniqLoop', ], compile_and_run, ['-O -package ghc']) + +test('T18574', + [collect_stats('bytes allocated', 5), only_ways(['normal'])], + compile_and_run, + ['-O']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c32655fffd0d8862f3ba693351f1e612daa0b6b...e393f213f5ccff4fd6034d5294e51aa5a2720890 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c32655fffd0d8862f3ba693351f1e612daa0b6b...e393f213f5ccff4fd6034d5294e51aa5a2720890 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:35:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:35:40 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Add mainModuleNameIs and demote mainModIs Message-ID: <5f7659bc206b9_80bd5c0c301600834e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - 5 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Recomp/Flags.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Utils/Backpack.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -610,8 +610,7 @@ gHC_OVER_LABELS = mkBaseModule (fsLit "GHC.OverloadedLabels") gHC_RECORDS :: Module gHC_RECORDS = mkBaseModule (fsLit "GHC.Records") -mAIN, rOOT_MAIN :: Module -mAIN = mkMainModule_ mAIN_NAME +rOOT_MAIN :: Module rOOT_MAIN = mkMainModule (fsLit ":Main") -- Root module for initialisation mkInteractiveModule :: Int -> Module ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -41,7 +41,7 @@ module GHC.Driver.Session ( dynamicTooMkDynamicDynFlags, dynamicOutputFile, sccProfilingEnabled, - DynFlags(..), + DynFlags(..), mainModIs, FlagSpec(..), HasDynFlags(..), ContainsDynFlags(..), RtsOptsEnabled(..), @@ -240,7 +240,7 @@ import GHC.Unit.Parser import GHC.Unit.Module import {-# SOURCE #-} GHC.Driver.Plugins import {-# SOURCE #-} GHC.Driver.Hooks -import GHC.Builtin.Names ( mAIN ) +import GHC.Builtin.Names ( mAIN_NAME ) import {-# SOURCE #-} GHC.Unit.State (UnitState, emptyUnitState, UnitDatabase) import GHC.Driver.Phases ( Phase(..), phaseInputExt ) import GHC.Driver.Flags @@ -514,7 +514,7 @@ data DynFlags = DynFlags { historySize :: Int, -- ^ Simplification history size importPaths :: [FilePath], - mainModIs :: Module, + mainModuleNameIs :: ModuleName, mainFunIs :: Maybe String, reductionDepth :: IntWithInf, -- ^ Typechecker maximum stack depth solverIterations :: IntWithInf, -- ^ Number of iterations in the constraints solver @@ -1188,7 +1188,7 @@ defaultDynFlags mySettings llvmConfig = ghcHeapSize = Nothing, importPaths = ["."], - mainModIs = mAIN, + mainModuleNameIs = mAIN_NAME, mainFunIs = Nothing, reductionDepth = treatZeroAsInf mAX_REDUCTION_DEPTH, solverIterations = treatZeroAsInf mAX_SOLVER_ITERATIONS, @@ -1665,6 +1665,9 @@ lang_set dflags lang = extensionFlags = flattenExtensionFlags lang (extensions dflags) } +mainModIs :: DynFlags -> Module +mainModIs dflags = mkHomeModule (mkHomeUnitFromFlags dflags) (mainModuleNameIs dflags) + -- | Set the Haskell language standard to use setLanguage :: Language -> DynP () setLanguage l = upd (`lang_set` Just l) @@ -4505,10 +4508,10 @@ setMainIs arg | not (null main_fn) && isLower (head main_fn) -- The arg looked like "Foo.Bar.baz" = upd $ \d -> d { mainFunIs = Just main_fn, - mainModIs = mkModule mainUnit (mkModuleName main_mod) } + mainModuleNameIs = mkModuleName main_mod } | isUpper (head arg) -- The arg looked like "Foo" or "Foo.Bar" - = upd $ \d -> d { mainModIs = mkModule mainUnit (mkModuleName arg) } + = upd $ \d -> d { mainModuleNameIs = mkModuleName arg } | otherwise -- The arg looked like "baz" = upd $ \d -> d { mainFunIs = Just arg } ===================================== compiler/GHC/Iface/Recomp/Flags.hs ===================================== @@ -34,7 +34,7 @@ fingerprintDynFlags :: DynFlags -> Module -> IO Fingerprint fingerprintDynFlags dflags at DynFlags{..} this_mod nameio = - let mainis = if mainModIs == this_mod then Just mainFunIs else Nothing + let mainis = if mainModIs dflags == this_mod then Just mainFunIs else Nothing -- see #5878 -- pkgopts = (homeUnit home_unit, sort $ packageFlags dflags) safeHs = setSafeMode safeHaskell ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -194,7 +194,7 @@ tcRnModule hsc_env mod_sum save_rn_syntax = (mkHomeModule home_unit mod, mod_loc) | otherwise -- 'module M where' is omitted - = (mAIN, srcLocSpan (srcSpanStart loc)) + = (mkHomeModule home_unit mAIN_NAME, srcLocSpan (srcSpanStart loc)) ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -58,7 +58,6 @@ import GHC.Data.Maybe import GHC.Tc.Utils.Env import GHC.Types.Var import GHC.Iface.Syntax -import GHC.Builtin.Names import qualified Data.Map as Map import GHC.Driver.Finder @@ -346,7 +345,7 @@ tcRnCheckUnit hsc_env uid = initTc hsc_env HsigFile -- bogus False - mAIN -- bogus + (mainModIs dflags) (realSrcLocSpan (mkRealSrcLoc (fsLit loc_str) 0 0)) -- bogus $ checkUnit uid where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e393f213f5ccff4fd6034d5294e51aa5a2720890...dca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e393f213f5ccff4fd6034d5294e51aa5a2720890...dca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:36:17 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:36:17 -0400 Subject: [Git][ghc/ghc][master] 4 commits: Use ADTs for parser errors/warnings Message-ID: <5f7659e1c0370_80bd5c0c30160125f4@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Backpack/Syntax.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - + compiler/GHC/Parser/Errors.hs - + compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Header.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - + compiler/GHC/Parser/Types.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Error.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c...93d5de165a81dfb335bf1646c2e29956f5ab55ea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dca1cb22cab4fa7f5937e9ffdc0ee32313dbd01c...93d5de165a81dfb335bf1646c2e29956f5ab55ea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:36:54 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:36:54 -0400 Subject: [Git][ghc/ghc][master] Don't attach CPR signatures to NOINLINE data structures (#18154) Message-ID: <5f765a0684769_80bd5c0c301601618e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - 2 changed files: - compiler/GHC/Core/Opt/CprAnal.hs - testsuite/tests/simplCore/should_compile/T7360.stderr Changes: ===================================== compiler/GHC/Core/Opt/CprAnal.hs ===================================== @@ -118,9 +118,9 @@ cprAnalTopBind :: AnalEnv -> CoreBind -> (AnalEnv, CoreBind) cprAnalTopBind env (NonRec id rhs) - = (extendAnalEnv env id' (idCprInfo id'), NonRec id' rhs') + = (env', NonRec id' rhs') where - (id', rhs') = cprAnalBind TopLevel env id rhs + (id', rhs', env') = cprAnalBind TopLevel env id rhs cprAnalTopBind env (Rec pairs) = (env', Rec pairs') @@ -178,7 +178,7 @@ cprAnal' env (Lam var body) | otherwise = (lam_ty, Lam var body') where - env' = extendAnalEnvForDemand env var (idDemandInfo var) + env' = extendSigEnvForDemand env var (idDemandInfo var) (body_ty, body') = cprAnal env' body lam_ty = abstractCprTy body_ty @@ -194,9 +194,8 @@ cprAnal' env (Case scrut case_bndr ty alts) cprAnal' env (Let (NonRec id rhs) body) = (body_ty, Let (NonRec id' rhs') body') where - (id', rhs') = cprAnalBind NotTopLevel env id rhs - env' = extendAnalEnv env id' (idCprInfo id') - (body_ty, body') = cprAnal env' body + (id', rhs', env') = cprAnalBind NotTopLevel env id rhs + (body_ty, body') = cprAnal env' body cprAnal' env (Let (Rec pairs) body) = body_ty `seq` (body_ty, Let (Rec pairs') body') @@ -233,15 +232,15 @@ cprTransform env id sig where sig - -- See Note [CPR for expandable unfoldings] - | Just rhs <- cprExpandUnfolding_maybe id + -- Top-level binding, local let-binding or case binder + | Just sig <- lookupSigEnv env id + = getCprSig sig + -- See Note [CPR for data structures] + | Just rhs <- cprDataStructureUnfolding_maybe id = fst $ cprAnal env rhs -- Imported function or data con worker | isGlobalId id = getCprSig (idCprInfo id) - -- Local let-bound - | Just sig <- lookupSigEnv env id - = getCprSig sig | otherwise = topCprType @@ -251,46 +250,43 @@ cprTransform env id -- Recursive bindings cprFix :: TopLevelFlag - -> AnalEnv -- Does not include bindings for this binding + -> AnalEnv -- Does not include bindings for this binding -> [(Id,CoreExpr)] - -> (AnalEnv, [(Id,CoreExpr)]) -- Binders annotated with stricness info - -cprFix top_lvl env orig_pairs - = loop 1 initial_pairs + -> (AnalEnv, [(Id,CoreExpr)]) -- Binders annotated with CPR info +cprFix top_lvl orig_env orig_pairs + = loop 1 init_env init_pairs where - bot_sig = mkCprSig 0 botCpr + init_sig id rhs + -- See Note [CPR for data structures] + | isDataStructure id rhs = topCprSig + | otherwise = mkCprSig 0 botCpr -- See Note [Initialising strictness] in GHC.Core.Opt.DmdAnal - initial_pairs | ae_virgin env = [(setIdCprInfo id bot_sig, rhs) | (id, rhs) <- orig_pairs ] - | otherwise = orig_pairs - - -- The fixed-point varies the idCprInfo field of the binders, and terminates if that - -- annotation does not change any more. - loop :: Int -> [(Id,CoreExpr)] -> (AnalEnv, [(Id,CoreExpr)]) - loop n pairs - | found_fixpoint = (final_anal_env, pairs') - | otherwise = loop (n+1) pairs' - where - found_fixpoint = map (idCprInfo . fst) pairs' == map (idCprInfo . fst) pairs - first_round = n == 1 - pairs' = step first_round pairs - final_anal_env = extendAnalEnvs env (map fst pairs') - - step :: Bool -> [(Id, CoreExpr)] -> [(Id, CoreExpr)] - step first_round pairs = pairs' + orig_virgin = ae_virgin orig_env + init_pairs | orig_virgin = [(setIdCprInfo id (init_sig id rhs), rhs) | (id, rhs) <- orig_pairs ] + | otherwise = orig_pairs + init_env = extendSigEnvList orig_env (map fst init_pairs) + + -- The fixed-point varies the idCprInfo field of the binders and and their + -- entries in the AnalEnv, and terminates if that annotation does not change + -- any more. + loop :: Int -> AnalEnv -> [(Id,CoreExpr)] -> (AnalEnv, [(Id,CoreExpr)]) + loop n env pairs + | found_fixpoint = (reset_env', pairs') + | otherwise = loop (n+1) env' pairs' where -- In all but the first iteration, delete the virgin flag - start_env | first_round = env - | otherwise = nonVirgin env - - start = extendAnalEnvs start_env (map fst pairs) - - (_, pairs') = mapAccumL my_downRhs start pairs - - my_downRhs env (id,rhs) - = (env', (id', rhs')) + -- See Note [Initialising strictness] in GHC.Core.Opt.DmdAnal + (env', pairs') = step (applyWhen (n/=1) nonVirgin env) pairs + -- Make sure we reset the virgin flag to what it was when we are stable + reset_env' = env'{ ae_virgin = orig_virgin } + found_fixpoint = map (idCprInfo . fst) pairs' == map (idCprInfo . fst) pairs + + step :: AnalEnv -> [(Id, CoreExpr)] -> (AnalEnv, [(Id, CoreExpr)]) + step env pairs = mapAccumL go env pairs + where + go env (id, rhs) = (env', (id', rhs')) where - (id', rhs') = cprAnalBind top_lvl env id rhs - env' = extendAnalEnv env id (idCprInfo id') + (id', rhs', env') = cprAnalBind top_lvl env id rhs -- | Process the RHS of the binding for a sensible arity, add the CPR signature -- to the Id, and augment the environment with the signature as well. @@ -299,9 +295,13 @@ cprAnalBind -> AnalEnv -> Id -> CoreExpr - -> (Id, CoreExpr) + -> (Id, CoreExpr, AnalEnv) cprAnalBind top_lvl env id rhs - = (id', rhs') + -- See Note [CPR for data structures] + | isDataStructure id rhs + = (id, rhs, env) -- Data structure => no code => need to analyse rhs + | otherwise + = (id', rhs', env') where (rhs_ty, rhs') = cprAnal env rhs -- possibly trim thunk CPR info @@ -310,12 +310,11 @@ cprAnalBind top_lvl env id rhs | stays_thunk = trimCprTy rhs_ty -- See Note [CPR for sum types] | returns_sum = trimCprTy rhs_ty - -- See Note [CPR for expandable unfoldings] - | will_expand = topCprType | otherwise = rhs_ty -- See Note [Arity trimming for CPR signatures] - sig = mkCprSigForArity (idArity id) rhs_ty' - id' = setIdCprInfo id sig + sig = mkCprSigForArity (idArity id) rhs_ty' + id' = setIdCprInfo id sig + env' = extendSigEnv env id sig -- See Note [CPR for thunks] stays_thunk = is_thunk && not_strict @@ -325,15 +324,22 @@ cprAnalBind top_lvl env id rhs (_, ret_ty) = splitPiTys (idType id) not_a_prod = isNothing (deepSplitProductType_maybe (ae_fam_envs env) ret_ty) returns_sum = not (isTopLevel top_lvl) && not_a_prod - -- See Note [CPR for expandable unfoldings] - will_expand = isJust (cprExpandUnfolding_maybe id) -cprExpandUnfolding_maybe :: Id -> Maybe CoreExpr -cprExpandUnfolding_maybe id = do - guard (idArity id == 0) +isDataStructure :: Id -> CoreExpr -> Bool +-- See Note [CPR for data structures] +isDataStructure id rhs = + idArity id == 0 && exprIsHNF rhs + +-- | Returns an expandable unfolding +-- (See Note [exprIsExpandable] in "GHC.Core.Utils") that has +-- So effectively is a constructor application. +cprDataStructureUnfolding_maybe :: Id -> Maybe CoreExpr +cprDataStructureUnfolding_maybe id = do -- There are only FinalPhase Simplifier runs after CPR analysis guard (activeInFinalPhase (idInlineActivation id)) - expandUnfolding_maybe (idUnfolding id) + unf <- expandUnfolding_maybe (idUnfolding id) + guard (isDataStructure id unf) + return unf {- Note [Arity trimming for CPR signatures] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -394,15 +400,15 @@ emptyAnalEnv fam_envs , ae_fam_envs = fam_envs } --- | Extend an environment with the strictness IDs attached to the id -extendAnalEnvs :: AnalEnv -> [Id] -> AnalEnv -extendAnalEnvs env ids +-- | Extend an environment with the CPR sigs attached to the id +extendSigEnvList :: AnalEnv -> [Id] -> AnalEnv +extendSigEnvList env ids = env { ae_sigs = sigs' } where sigs' = extendVarEnvList (ae_sigs env) [ (id, idCprInfo id) | id <- ids ] -extendAnalEnv :: AnalEnv -> Id -> CprSig -> AnalEnv -extendAnalEnv env id sig +extendSigEnv :: AnalEnv -> Id -> CprSig -> AnalEnv +extendSigEnv env id sig = env { ae_sigs = extendVarEnv (ae_sigs env) id sig } lookupSigEnv :: AnalEnv -> Id -> Maybe CprSig @@ -411,17 +417,17 @@ lookupSigEnv env id = lookupVarEnv (ae_sigs env) id nonVirgin :: AnalEnv -> AnalEnv nonVirgin env = env { ae_virgin = False } --- | A version of 'extendAnalEnv' for a binder of which we don't see the RHS +-- | A version of 'extendSigEnv' for a binder of which we don't see the RHS -- needed to compute a 'CprSig' (e.g. lambdas and DataAlt field binders). -- In this case, we can still look at their demand to attach CPR signatures -- anticipating the unboxing done by worker/wrapper. -- See Note [CPR for binders that will be unboxed]. -extendAnalEnvForDemand :: AnalEnv -> Id -> Demand -> AnalEnv -extendAnalEnvForDemand env id dmd +extendSigEnvForDemand :: AnalEnv -> Id -> Demand -> AnalEnv +extendSigEnvForDemand env id dmd | isId id , Just (_, DataConAppContext { dcac_dc = dc }) <- wantToUnbox (ae_fam_envs env) has_inlineable_prag (idType id) dmd - = extendAnalEnv env id (CprSig (conCprType (dataConTag dc))) + = extendSigEnv env id (CprSig (conCprType (dataConTag dc))) | otherwise = env where @@ -436,7 +442,7 @@ extendEnvForDataAlt :: AnalEnv -> CoreExpr -> Id -> DataCon -> [Var] -> AnalEnv extendEnvForDataAlt env scrut case_bndr dc bndrs = foldl' do_con_arg env' ids_w_strs where - env' = extendAnalEnv env case_bndr (CprSig case_bndr_ty) + env' = extendSigEnv env case_bndr (CprSig case_bndr_ty) ids_w_strs = filter isId bndrs `zip` dataConRepStrictness dc @@ -460,7 +466,7 @@ extendEnvForDataAlt env scrut case_bndr dc bndrs | is_var scrut -- See Note [Add demands for strict constructors] in GHC.Core.Opt.WorkWrap.Utils , let dmd = applyWhen (isMarkedStrict str) strictifyDmd (idDemandInfo id) - = extendAnalEnvForDemand env id dmd + = extendSigEnvForDemand env id dmd | otherwise = env @@ -645,46 +651,72 @@ assumption is that error cases are rarely entered and we are diverging anyway, so WW doesn't hurt. Should we also trim CPR on DataCon application bindings? -See Note [CPR for expandable unfoldings]! +See Note [CPR for data structures]! -Note [CPR for expandable unfoldings] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [CPR for data structures] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 -should not get CPR signatures, because they +should not get CPR signatures (#18154), because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! + Reason: the CPR info for xs1 contains the CPR info for xs; the CPR info + for xs2 contains that for xs1. And so on. + +Hence we don't analyse or annotate data structures in 'cprAnalBind'. To +implement this, the isDataStructure guard is triggered for bindings that satisfy -But we can't just stop giving DataCon application bindings the CPR property, + (1) idArity id == 0 (otherwise it's a function) + (2) exprIsHNF rhs (otherwise it's a thunk, Note [CPR for thunks] applies) + +But we can't just stop giving DataCon application bindings the CPR *property*, for example - fac 0 = 1 + fac 0 = I# 1# fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to - lvl = 1 + lvl = I# 1# fac 0 = lvl -If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a -CPR signature to extrapolate into a CPR transformer ('cprTransform'). So -instead we keep on cprAnal'ing through *expandable* unfoldings for these arity -0 bindings via 'cprExpandUnfolding_maybe'. +If lvl doesn't have the CPR property, fac won't either. But lvl is a data +structure, and hence (see above) will not have a CPR signature. So instead, when +'cprAnal' meets a variable lacking a CPR signature to extrapolate into a CPR +transformer, 'cprTransform' instead tries to get its unfolding (via +'cprDataStructureUnfolding_maybe'), and analyses that instead. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one -for each data declaration. It's wasteful to attach CPR signatures to each of -them (and intractable in case of Nested CPR). - -Tracked by #18154. +for each data declaration. They should not have CPR signatures (blow up!). + +There is a perhaps surprising special case: KindRep bindings satisfy +'isDataStructure' (so no CPR signature), but are marked NOINLINE at the same +time (see the noinline wrinkle in Note [Grand plan for Typeable]). So there is +no unfolding for 'cprDataStructureUnfolding_maybe' to look through and we'll +return topCprType. And that is fine! We should refrain to look through NOINLINE +data structures in general, as a constructed product could never be exposed +after WW. + +It's also worth pointing out how ad-hoc this is: If we instead had + + f1 x = x:[] + f2 x = x : f1 x + f3 x = x : f2 x + ... + +we still give every function an every deepening CPR signature. But it's very +uncommon to find code like this, whereas the long static data structures from +the beginning of this Note are very common because of GHC's strategy of ANF'ing +data structure RHSs. Note [CPR examples] ~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -92,7 +92,7 @@ T7360.$trModule -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} $krep :: GHC.Types.KindRep -[GblId, Cpr=m1, Unf=OtherCon []] +[GblId, Unf=OtherCon []] $krep = GHC.Types.KindRepTyConApp GHC.Types.$tcInt (GHC.Types.[] @GHC.Types.KindRep) @@ -127,7 +127,7 @@ T7360.$tcFoo -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} T7360.$tc'Foo4 [InlPrag=NOUSERINLINE[~]] :: GHC.Types.KindRep -[GblId, Cpr=m1, Unf=OtherCon []] +[GblId, Unf=OtherCon []] T7360.$tc'Foo4 = GHC.Types.KindRepTyConApp T7360.$tcFoo (GHC.Types.[] @GHC.Types.KindRep) @@ -190,7 +190,7 @@ T7360.$tc'Foo2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo9 [InlPrag=NOUSERINLINE[~]] :: GHC.Types.KindRep -[GblId, Cpr=m4, Unf=OtherCon []] +[GblId, Unf=OtherCon []] T7360.$tc'Foo9 = GHC.Types.KindRepFun $krep T7360.$tc'Foo4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3655f810b4eba1fb7d81a3227a08dae8b85dfc4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3655f810b4eba1fb7d81a3227a08dae8b85dfc4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:37:29 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:37:29 -0400 Subject: [Git][ghc/ghc][master] Add regression test for #18755. Message-ID: <5f765a29f2893_80b7871cb416019231@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - 3 changed files: - + testsuite/tests/ghci/scripts/T18755.script - + testsuite/tests/ghci/scripts/T18755.stdout - testsuite/tests/ghci/scripts/all.T Changes: ===================================== testsuite/tests/ghci/scripts/T18755.script ===================================== @@ -0,0 +1,2 @@ +:set -fprint-explicit-runtime-reps +:t ($) ===================================== testsuite/tests/ghci/scripts/T18755.stdout ===================================== @@ -0,0 +1,3 @@ +($) + :: forall (r :: GHC.Types.RuntimeRep) a (b :: TYPE r). + (a -> b) -> a -> b ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -320,3 +320,4 @@ test('T17549', normal, ghci_script, ['T17549.script']) test('T17669', [extra_run_opts('-fexternal-interpreter -fobject-code'), expect_broken(17669)], ghci_script, ['T17669.script']) test('T18501', normal, ghci_script, ['T18501.script']) test('T18644', normal, ghci_script, ['T18644.script']) +test('T18755', normal, ghci_script, ['T18755.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba5965eb10967d21b992aac925fb772db2ddde12 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ba5965eb10967d21b992aac925fb772db2ddde12 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:38:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:38:04 -0400 Subject: [Git][ghc/ghc][master] Fix pretty-printing of the mult-polymorphic arrow Message-ID: <5f765a4cd801e_80b783e9f416021975@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - 6 changed files: - compiler/GHC/Utils/Outputable.hs - testsuite/tests/linear/should_fail/LinearErrOrigin.stderr - testsuite/tests/linear/should_fail/LinearPartialSig.stderr - testsuite/tests/linear/should_fail/LinearVar.stderr - testsuite/tests/roles/should_compile/Roles13.stderr - testsuite/tests/simplCore/should_compile/T4201.stdout Changes: ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -677,7 +677,7 @@ lbrace = docToSDoc $ Pretty.lbrace rbrace = docToSDoc $ Pretty.rbrace mulArrow :: SDoc -> SDoc -mulArrow d = text "#" <+> d <+> arrow +mulArrow d = text "%" <> d <+> arrow forAllLit :: SDoc ===================================== testsuite/tests/linear/should_fail/LinearErrOrigin.stderr ===================================== @@ -5,15 +5,15 @@ LinearErrOrigin.hs:7:7: error: the type signature for: foo :: forall a b (p :: GHC.Types.Multiplicity) (q :: GHC.Types.Multiplicity). - (a # p -> b) -> a # q -> b + (a %p -> b) -> a %q -> b at LinearErrOrigin.hs:6:1-31 ‘q’ is a rigid type variable bound by the type signature for: foo :: forall a b (p :: GHC.Types.Multiplicity) (q :: GHC.Types.Multiplicity). - (a # p -> b) -> a # q -> b + (a %p -> b) -> a %q -> b at LinearErrOrigin.hs:6:1-31 • In an equation for ‘foo’: foo f x = f x • Relevant bindings include - f :: a # p -> b (bound at LinearErrOrigin.hs:7:5) - foo :: (a # p -> b) -> a # q -> b (bound at LinearErrOrigin.hs:7:1) + f :: a %p -> b (bound at LinearErrOrigin.hs:7:5) + foo :: (a %p -> b) -> a %q -> b (bound at LinearErrOrigin.hs:7:1) ===================================== testsuite/tests/linear/should_fail/LinearPartialSig.stderr ===================================== @@ -3,5 +3,5 @@ LinearPartialSig.hs:5:9: error: • Found type wildcard ‘_’ standing for ‘'Many :: GHC.Types.Multiplicity’ To use the inferred type, enable PartialTypeSignatures - • In the type ‘a # _ -> a’ - In the type signature: f :: a # _ -> a + • In the type ‘a %_ -> a’ + In the type signature: f :: a %_ -> a ===================================== testsuite/tests/linear/should_fail/LinearVar.stderr ===================================== @@ -1,13 +1,13 @@ LinearVar.hs:5:5: error: • Couldn't match type ‘m’ with ‘'Many’ - Expected: a # m -> b + Expected: a %m -> b Actual: a -> b ‘m’ is a rigid type variable bound by the type signature for: - f :: forall a b (m :: GHC.Types.Multiplicity). a # m -> b + f :: forall a b (m :: GHC.Types.Multiplicity). a %m -> b at LinearVar.hs:4:1-14 • In the expression: undefined :: a -> b In an equation for ‘f’: f = undefined :: a -> b • Relevant bindings include - f :: a # m -> b (bound at LinearVar.hs:5:1) + f :: a %m -> b (bound at LinearVar.hs:5:1) ===================================== testsuite/tests/roles/should_compile/Roles13.stderr ===================================== @@ -14,7 +14,7 @@ convert :: Wrap Age -> Int convert = convert1 `cast` (_R - # <'Many>_N ->_R Roles13.N:Wrap[0] (Roles13.N:Age[0]) + %<'Many>_N ->_R Roles13.N:Wrap[0] (Roles13.N:Age[0]) :: (Wrap Age -> Wrap Age) ~R# (Wrap Age -> Int)) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T4201.stdout ===================================== @@ -1,4 +1,4 @@ [HasNoCafRefs, LambdaFormInfo: LFReEntrant 1, Arity: 1, Strictness: , Unfolding: InlineRule (0, True, True) - bof `cast` (Sym (N:Foo[0]) # <'Many>_N ->_R _R)] + bof `cast` (Sym (N:Foo[0]) %<'Many>_N ->_R _R)] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8018c17747342444c67eeec21a506c89c1110e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a8018c17747342444c67eeec21a506c89c1110e8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:38:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:38:42 -0400 Subject: [Git][ghc/ghc][master] Bignum: add integerNegate RULE Message-ID: <5f765a72999b8_80b783e9f416024046@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 4 changed files: - libraries/ghc-bignum/src/GHC/Num/Integer.hs - testsuite/tests/lib/integer/all.T - + testsuite/tests/lib/integer/integerNegate.hs - + testsuite/tests/lib/integer/integerNegate.stderr Changes: ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -486,6 +486,9 @@ integerNegate (IP b) | isTrue# (bigNatEqWord# b ABS_INT_MINBOUND##) = IS INT_MINBOUND# | True = IN b +{-# RULES +"integerNegate/integerNegate" forall x. integerNegate (integerNegate x) = x +#-} -- | Compute absolute value of an 'Integer' integerAbs :: Integer -> Integer ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -1,3 +1,4 @@ +test('integerNegate', normal, compile, ['-ddump-simpl -dno-typeable-binds -dsuppress-all -dsuppress-uniques']) test('integerBits', normal, compile_and_run, ['']) test('integerConversions', normal, compile_and_run, ['']) test('plusMinusInteger', [omit_ways(['ghci'])], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/integerNegate.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS_GHC -O2 #-} + +module Test where + +import GHC.Num.Integer + +neg_neg :: Integer -> Integer +neg_neg x = integerNegate (integerNegate x) ===================================== testsuite/tests/lib/integer/integerNegate.stderr ===================================== @@ -0,0 +1,10 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 3, types: 3, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 1, coercions: 0, joins: 0/0} +neg_neg = \ x -> x + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5523324d2c55e0091857e21bf5613b5f6b442a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5523324d2c55e0091857e21bf5613b5f6b442a7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:39:16 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 18:39:16 -0400 Subject: [Git][ghc/ghc][master] Refactor: remove rnHsDoc Message-ID: <5f765a94bca0e_80b6b17fc816026351@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - 5 changed files: - − compiler/GHC/Rename/Doc.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Rename/Doc.hs deleted ===================================== @@ -1,25 +0,0 @@ -{-# LANGUAGE ViewPatterns #-} - -module GHC.Rename.Doc ( rnHsDoc, rnLHsDoc, rnMbLHsDoc ) where - -import GHC.Prelude - -import GHC.Tc.Types -import GHC.Hs -import GHC.Types.SrcLoc - - -rnMbLHsDoc :: Maybe LHsDocString -> RnM (Maybe LHsDocString) -rnMbLHsDoc mb_doc = case mb_doc of - Just doc -> do - doc' <- rnLHsDoc doc - return (Just doc') - Nothing -> return Nothing - -rnLHsDoc :: LHsDocString -> RnM LHsDocString -rnLHsDoc (L pos doc) = do - doc' <- rnHsDoc doc - return (L pos doc') - -rnHsDoc :: HsDocString -> RnM HsDocString -rnHsDoc = pure ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -41,7 +41,6 @@ import {-# SOURCE #-} GHC.Rename.Splice( rnSpliceType ) import GHC.Driver.Session import GHC.Hs -import GHC.Rename.Doc ( rnLHsDoc, rnMbLHsDoc ) import GHC.Rename.Env import GHC.Rename.Utils ( HsDocContext(..), inHsDocContext, withHsDocContext , mapFvRn, pprHsDocContext, bindLocalNamesFV @@ -698,8 +697,7 @@ rnHsTyKi _ (HsSpliceTy _ sp) rnHsTyKi env (HsDocTy _ ty haddock_doc) = do { (ty', fvs) <- rnLHsTyKi env ty - ; haddock_doc' <- rnLHsDoc haddock_doc - ; return (HsDocTy noExtField ty' haddock_doc', fvs) } + ; return (HsDocTy noExtField ty' haddock_doc, fvs) } rnHsTyKi _ (XHsType (NHsCoreTy ty)) = return (XHsType (NHsCoreTy ty), emptyFVs) @@ -1168,8 +1166,7 @@ rnField :: FastStringEnv FieldLabel -> RnTyKiEnv -> LConDeclField GhcPs rnField fl_env env (L l (ConDeclField _ names ty haddock_doc)) = do { let new_names = map (fmap lookupField) names ; (new_ty, fvs) <- rnLHsTyKi env ty - ; new_haddock_doc <- rnMbLHsDoc haddock_doc - ; return (L l (ConDeclField noExtField new_names new_ty new_haddock_doc) + ; return (L l (ConDeclField noExtField new_names new_ty haddock_doc) , fvs) } where lookupField :: FieldOcc GhcPs -> FieldOcc GhcRn ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -38,7 +38,6 @@ import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) import GHC.Rename.Names -import GHC.Rename.Doc ( rnHsDoc, rnMbLHsDoc ) import GHC.Tc.Gen.Annotation ( annCtxt ) import GHC.Tc.Utils.Monad @@ -199,8 +198,6 @@ rnSrcDecls group@(HsGroup { hs_valds = val_decls, (rn_default_decls, src_fvs5) <- rnList rnDefaultDecl default_decls ; (rn_deriv_decls, src_fvs6) <- rnList rnSrcDerivDecl deriv_decls ; (rn_splice_decls, src_fvs7) <- rnList rnSpliceDecl splice_decls ; - -- Haddock docs; no free vars - rn_docs <- mapM (wrapLocM rnDocDecl) docs ; last_tcg_env <- getGblEnv ; -- (I) Compute the results and return @@ -216,7 +213,7 @@ rnSrcDecls group@(HsGroup { hs_valds = val_decls, hs_annds = rn_ann_decls, hs_defds = rn_default_decls, hs_ruleds = rn_rule_decls, - hs_docs = rn_docs } ; + hs_docs = docs } ; tcf_bndrs = hsTyClForeignBinders rn_tycl_decls rn_foreign_decls ; other_def = (Just (mkNameSet tcf_bndrs), emptyNameSet) ; @@ -245,28 +242,6 @@ addTcgDUs tcg_env dus = tcg_env { tcg_dus = tcg_dus tcg_env `plusDU` dus } rnList :: (a -> RnM (b, FreeVars)) -> [Located a] -> RnM ([Located b], FreeVars) rnList f xs = mapFvRn (wrapLocFstM f) xs -{- -********************************************************* -* * - HsDoc stuff -* * -********************************************************* --} - -rnDocDecl :: DocDecl -> RnM DocDecl -rnDocDecl (DocCommentNext doc) = do - rn_doc <- rnHsDoc doc - return (DocCommentNext rn_doc) -rnDocDecl (DocCommentPrev doc) = do - rn_doc <- rnHsDoc doc - return (DocCommentPrev rn_doc) -rnDocDecl (DocCommentNamed str doc) = do - rn_doc <- rnHsDoc doc - return (DocCommentNamed str rn_doc) -rnDocDecl (DocGroup lev doc) = do - rn_doc <- rnHsDoc doc - return (DocGroup lev rn_doc) - {- ********************************************************* * * @@ -1770,15 +1745,12 @@ rnTyClDecl (ClassDecl { tcdCtxt = context, tcdLName = lcls, -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn -- and the methods are already in scope - -- Haddock docs - ; docs' <- mapM (wrapLocM rnDocDecl) docs - ; let all_fvs = meth_fvs `plusFV` stuff_fvs `plusFV` fv_at_defs ; return (ClassDecl { tcdCtxt = context', tcdLName = lcls', tcdTyVars = tyvars', tcdFixity = fixity, tcdFDs = fds', tcdSigs = sigs', tcdMeths = mbinds', tcdATs = ats', tcdATDefs = at_defs', - tcdDocs = docs', tcdCExt = all_fvs }, + tcdDocs = docs, tcdCExt = all_fvs }, all_fvs ) } where cls_doc = ClassDeclCtx lcls @@ -2196,7 +2168,6 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs , con_doc = mb_doc, con_forall = forall }) = do { _ <- addLocM checkConName name ; new_name <- lookupLocatedTopBndrRn name - ; mb_doc' <- rnMbLHsDoc mb_doc -- We bind no implicit binders here; this is just like -- a nested HsForAllTy. E.g. consider @@ -2220,7 +2191,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; return (decl { con_ext = noExtField , con_name = new_name, con_ex_tvs = new_ex_tvs , con_mb_cxt = new_context, con_args = new_args - , con_doc = mb_doc' + , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) }} @@ -2233,7 +2204,6 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; mb_doc' <- rnMbLHsDoc mb_doc ; let theta = hsConDeclTheta mcxt arg_tys = hsConDeclArgTys args @@ -2269,7 +2239,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt , con_args = new_args, con_res_ty = new_res_ty - , con_doc = mb_doc' + , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -41,7 +41,6 @@ import GHC.Data.FastString (fsLit) import Control.Monad import GHC.Driver.Session -import GHC.Rename.Doc ( rnHsDoc ) import GHC.Parser.PostProcess ( setRdrNameSpace ) import Data.Either ( partitionEithers ) @@ -323,9 +322,8 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod , new_exports))) } exports_from_item acc@(ExportAccum occs mods) (L loc ie) - | isDoc ie - = do new_ie <- lookup_doc_ie ie - return (Just (acc, (L loc new_ie, []))) + | Just new_ie <- lookup_doc_ie ie + = return (Just (acc, (L loc new_ie, []))) | otherwise = do (new_ie, avail) <- lookup_ie ie @@ -406,13 +404,11 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod return (L l name, non_flds, flds) ------------- - lookup_doc_ie :: IE GhcPs -> RnM (IE GhcRn) - lookup_doc_ie (IEGroup _ lev doc) = do rn_doc <- rnHsDoc doc - return (IEGroup noExtField lev rn_doc) - lookup_doc_ie (IEDoc _ doc) = do rn_doc <- rnHsDoc doc - return (IEDoc noExtField rn_doc) - lookup_doc_ie (IEDocNamed _ str) = return (IEDocNamed noExtField str) - lookup_doc_ie _ = panic "lookup_doc_ie" -- Other cases covered earlier + lookup_doc_ie :: IE GhcPs -> Maybe (IE GhcRn) + lookup_doc_ie (IEGroup _ lev doc) = Just (IEGroup noExtField lev doc) + lookup_doc_ie (IEDoc _ doc) = Just (IEDoc noExtField doc) + lookup_doc_ie (IEDocNamed _ str) = Just (IEDocNamed noExtField str) + lookup_doc_ie _ = Nothing -- In an export item M.T(A,B,C), we want to treat the uses of -- A,B,C as if they were M.A, M.B, M.C @@ -431,12 +427,6 @@ classifyGRE gre = case gre_par gre of where n = gre_name gre -isDoc :: IE GhcPs -> Bool -isDoc (IEDoc {}) = True -isDoc (IEDocNamed {}) = True -isDoc (IEGroup {}) = True -isDoc _ = False - -- Renaming and typechecking of exports happens after everything else has -- been typechecked. ===================================== compiler/ghc.cabal.in ===================================== @@ -423,7 +423,6 @@ Library GHC.Rename.Bind GHC.Rename.Env GHC.Rename.Expr - GHC.Rename.Doc GHC.Rename.Names GHC.Rename.Pat GHC.Rename.Module View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1edd6d21c0abea34b498a627234a97df21648024 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1edd6d21c0abea34b498a627234a97df21648024 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 22:40:08 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 01 Oct 2020 18:40:08 -0400 Subject: [Git][ghc/ghc][wip/backport-9.0-linear-types-syntax] Fix pretty-printing of the mult-polymorphic arrow Message-ID: <5f765ac852c2c_80b7871cb416027733@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/backport-9.0-linear-types-syntax at Glasgow Haskell Compiler / GHC Commits: d5e13ceb by Vladislav Zavialov at 2020-10-02T01:39:25+03:00 Fix pretty-printing of the mult-polymorphic arrow (cherry-picked from a8018c17747342444c67eeec21a506c89c1110e8) - - - - - 6 changed files: - compiler/GHC/Utils/Outputable.hs - testsuite/tests/linear/should_fail/LinearErrOrigin.stderr - testsuite/tests/linear/should_fail/LinearPartialSig.stderr - testsuite/tests/linear/should_fail/LinearVar.stderr - testsuite/tests/roles/should_compile/Roles13.stderr - testsuite/tests/simplCore/should_compile/T4201.stdout Changes: ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -677,7 +677,7 @@ lbrace = docToSDoc $ Pretty.lbrace rbrace = docToSDoc $ Pretty.rbrace mulArrow :: SDoc -> SDoc -mulArrow d = text "#" <+> d <+> arrow +mulArrow d = text "%" <> d <+> arrow forAllLit :: SDoc ===================================== testsuite/tests/linear/should_fail/LinearErrOrigin.stderr ===================================== @@ -5,15 +5,15 @@ LinearErrOrigin.hs:7:7: error: the type signature for: foo :: forall a b (p :: GHC.Types.Multiplicity) (q :: GHC.Types.Multiplicity). - (a # p -> b) -> a # q -> b + (a %p -> b) -> a %q -> b at LinearErrOrigin.hs:6:1-31 ‘q’ is a rigid type variable bound by the type signature for: foo :: forall a b (p :: GHC.Types.Multiplicity) (q :: GHC.Types.Multiplicity). - (a # p -> b) -> a # q -> b + (a %p -> b) -> a %q -> b at LinearErrOrigin.hs:6:1-31 • In an equation for ‘foo’: foo f x = f x • Relevant bindings include - f :: a # p -> b (bound at LinearErrOrigin.hs:7:5) - foo :: (a # p -> b) -> a # q -> b (bound at LinearErrOrigin.hs:7:1) + f :: a %p -> b (bound at LinearErrOrigin.hs:7:5) + foo :: (a %p -> b) -> a %q -> b (bound at LinearErrOrigin.hs:7:1) ===================================== testsuite/tests/linear/should_fail/LinearPartialSig.stderr ===================================== @@ -3,5 +3,5 @@ LinearPartialSig.hs:5:9: error: • Found type wildcard ‘_’ standing for ‘'Many :: GHC.Types.Multiplicity’ To use the inferred type, enable PartialTypeSignatures - • In the type ‘a # _ -> a’ - In the type signature: f :: a # _ -> a + • In the type ‘a %_ -> a’ + In the type signature: f :: a %_ -> a ===================================== testsuite/tests/linear/should_fail/LinearVar.stderr ===================================== @@ -1,13 +1,13 @@ LinearVar.hs:5:5: error: • Couldn't match type ‘m’ with ‘'Many’ - Expected: a # m -> b + Expected: a %m -> b Actual: a -> b ‘m’ is a rigid type variable bound by the type signature for: - f :: forall a b (m :: GHC.Types.Multiplicity). a # m -> b + f :: forall a b (m :: GHC.Types.Multiplicity). a %m -> b at LinearVar.hs:4:1-14 • In the expression: undefined :: a -> b In an equation for ‘f’: f = undefined :: a -> b • Relevant bindings include - f :: a # m -> b (bound at LinearVar.hs:5:1) + f :: a %m -> b (bound at LinearVar.hs:5:1) ===================================== testsuite/tests/roles/should_compile/Roles13.stderr ===================================== @@ -14,7 +14,7 @@ convert :: Wrap Age -> Int convert = convert1 `cast` (_R - # <'Many>_N ->_R Roles13.N:Wrap[0] (Roles13.N:Age[0]) + %<'Many>_N ->_R Roles13.N:Wrap[0] (Roles13.N:Age[0]) :: (Wrap Age -> Wrap Age) ~R# (Wrap Age -> Int)) -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T4201.stdout ===================================== @@ -1,4 +1,4 @@ [HasNoCafRefs, LambdaFormInfo: LFReEntrant 1, Arity: 1, Strictness: , Unfolding: InlineRule (0, True, True) - bof `cast` (Sym (N:Foo[0]) # <'Many>_N ->_R _R)] + bof `cast` (Sym (N:Foo[0]) %<'Many>_N ->_R _R)] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5e13cebc969f9820b6b9437afe0699e15bbc2ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5e13cebc969f9820b6b9437afe0699e15bbc2ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 1 23:10:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 01 Oct 2020 19:10:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 16 commits: Add test for T18574 Message-ID: <5f7661ce97baf_80b3f8455b26d1c1603791f@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - 9895abc9 by Krzysztof Gogolewski at 2020-10-01T19:09:57-04:00 Fix typos in comments [skip ci] - - - - - 556bd11e by Icelandjack at 2020-10-01T19:09:59-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Backpack/Syntax.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b07ba5ea2b680f3653b67552d16178f06cf84ddd...556bd11e3a607ca5ddd2006e46cd9e7b5683f068 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b07ba5ea2b680f3653b67552d16178f06cf84ddd...556bd11e3a607ca5ddd2006e46cd9e7b5683f068 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 03:12:40 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Thu, 01 Oct 2020 23:12:40 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/angerman/arm64 Message-ID: <5f769aa824bfa_80b3f8439969bf8160658c7@gitlab.haskell.org.mail> Moritz Angermann pushed new branch wip/angerman/arm64 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/angerman/arm64 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 07:43:52 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 03:43:52 -0400 Subject: [Git][ghc/ghc][wip/T18765] s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) Message-ID: <5f76da38541ba_80b3f847c00ed2c160708e@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18765 at Glasgow Haskell Compiler / GHC Commits: 5eee7d6e by Sebastian Graf at 2020-10-02T09:43:38+02:00 s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) This defeats constant-folding in the final phases of the Simplifier, but enables us to get rid of allocations by inlining calls that can't be constant-folded. `NOINLINE[0]` is a better choice than `NOINLINE`, because 1. We still delay inlining long enough for the constant-folding RULEs to fire 2. The compiler has the option to inlining them late, possibly cancelling away boxes in the process. `NOINLINE[0]` is a better choice than `INLINE[0]`, because 3. We don't unconditionally inline huge definitions such as `integerDiv`, which would lead to code bloat at pretty much no gain. 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. `integerDiv`, there is no gain in inlining the unoptimised unfoldings. We also have to mark all callers that want to participate in constant folding as `INLINE`. See the new `Note [Integer constant folding]` for details. I had to change the `Num.fromInteger` and `Integral.toInteger` implementations of `Int*` and `Word*` variants to call the constant folded `integerToInt*#` and `integerToWord*#` variants directly to ensure constant folding. Fixes #18765. Metric Decrease: T10359 - - - - - 8 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Opt/ConstantFold.hs - libraries/base/GHC/Float.hs - libraries/base/GHC/Int.hs - libraries/base/GHC/Num.hs - libraries/base/GHC/Real.hs - libraries/base/GHC/Word.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -354,6 +354,7 @@ basicKnownKeyNames integerToWord64Name, integerToInt64Name, integerFromWordName, + integerFromIntName, integerFromWord64Name, integerFromInt64Name, integerAddName, @@ -1130,6 +1131,7 @@ integerFromNaturalName , integerToWord64Name , integerToInt64Name , integerFromWordName + , integerFromIntName , integerFromWord64Name , integerFromInt64Name , integerAddName @@ -1198,6 +1200,7 @@ integerToIntName = bniVarQual "integerToInt#" integerToIntI integerToWord64Name = bniVarQual "integerToWord64#" integerToWord64IdKey integerToInt64Name = bniVarQual "integerToInt64#" integerToInt64IdKey integerFromWordName = bniVarQual "integerFromWord#" integerFromWordIdKey +integerFromIntName = bniVarQual "integerFromInt#" integerFromIntIdKey integerFromWord64Name = bniVarQual "integerFromWord64#" integerFromWord64IdKey integerFromInt64Name = bniVarQual "integerFromInt64#" integerFromInt64IdKey integerAddName = bniVarQual "integerAdd" integerAddIdKey @@ -2464,6 +2467,7 @@ integerFromNaturalIdKey , integerShiftLIdKey , integerShiftRIdKey , integerFromWordIdKey + , integerFromIntIdKey , integerFromWord64IdKey , integerFromInt64IdKey , integerDecodeDoubleIdKey @@ -2519,6 +2523,7 @@ integerFromWordIdKey = mkPreludeMiscIdUnique 638 integerFromWord64IdKey = mkPreludeMiscIdUnique 639 integerFromInt64IdKey = mkPreludeMiscIdUnique 640 integerDecodeDoubleIdKey = mkPreludeMiscIdUnique 641 +integerFromIntIdKey = mkPreludeMiscIdUnique 642 naturalToWordIdKey = mkPreludeMiscIdUnique 650 naturalAddIdKey = mkPreludeMiscIdUnique 651 ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1312,7 +1312,8 @@ builtinRules enableBignumRules builtinBignumRules :: EnableBignumRules -> [CoreRule] builtinBignumRules (EnableBignumRules False) = [] builtinBignumRules _ = - [ rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName + [ rule_IntegerFromLitNum "Int# -> Integer" integerFromIntName + , rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName , rule_IntegerFromLitNum "Int64# -> Integer" integerFromInt64Name , rule_IntegerFromLitNum "Word64# -> Integer" integerFromWord64Name , rule_IntegerFromLitNum "Natural -> Integer" integerFromNaturalName @@ -1347,7 +1348,7 @@ builtinBignumRules _ = , rule_shift_op "integerShiftL" integerShiftLName shiftL , rule_shift_op "integerShiftR" integerShiftRName shiftR , rule_integerBit "integerBit" integerBitName - -- See Note [Integer division constant folding] in libraries/base/GHC/Real.hs + -- See Note [Integer constant folding] in "GHC.Num.Integer" , rule_divop_one "integerQuot" integerQuotName quot , rule_divop_one "integerRem" integerRemName rem , rule_divop_one "integerDiv" integerDivName div ===================================== libraries/base/GHC/Float.hs ===================================== @@ -494,6 +494,7 @@ instance Num Double where -- | @since 2.01 instance Real Double where + {-# INLINE toRational #-} -- See Note [Integer constant folding] toRational (D# x#) = case integerDecodeDouble# x# of (# m, e# #) @@ -580,11 +581,7 @@ instance Floating Double where -- | @since 2.01 instance RealFrac Double where - -- ceiling, floor, and truncate are all small - {-# INLINE [1] ceiling #-} - {-# INLINE [1] floor #-} - {-# INLINE [1] truncate #-} - + {-# INLINE properFraction #-} -- See Note [Integer constant folding] properFraction x = case (decodeFloat x) of { (m,n) -> if n >= 0 then @@ -595,9 +592,11 @@ instance RealFrac Double where } } + {-# INLINE truncate #-} -- See Note [Integer constant folding] truncate x = case properFraction x of (n,_) -> n + {-# INLINE round #-} -- See Note [Integer constant folding] round x = case properFraction x of (n,r) -> let m = if r < 0.0 then n - 1 else n + 1 @@ -608,9 +607,11 @@ instance RealFrac Double where EQ -> if even n then n else m GT -> m + {-# INLINE ceiling #-} -- See Note [Integer constant folding] ceiling x = case properFraction x of (n,r) -> if r > 0.0 then n + 1 else n + {-# INLINE floor #-} -- See Note [Integer constant folding] floor x = case properFraction x of (n,r) -> if r < 0.0 then n - 1 else n @@ -620,18 +621,23 @@ instance RealFloat Double where floatDigits _ = DBL_MANT_DIG -- ditto floatRange _ = (DBL_MIN_EXP, DBL_MAX_EXP) -- ditto + {-# INLINE decodeFloat #-} -- See Note [Integer constant folding] decodeFloat (D# x#) = case integerDecodeDouble# x# of (# i, j #) -> (i, I# j) + {-# INLINE encodeFloat #-} -- See Note [Integer constant folding] encodeFloat i (I# j) = D# (integerEncodeDouble# i j) + {-# INLINE exponent #-} -- See Note [Integer constant folding] exponent x = case decodeFloat x of (m,n) -> if m == 0 then 0 else n + floatDigits x + {-# INLINE significand #-} -- See Note [Integer constant folding] significand x = case decodeFloat x of (m,_) -> encodeFloat m (negate (floatDigits x)) + {-# INLINE scaleFloat #-} -- See Note [Integer constant folding] scaleFloat 0 x = x scaleFloat k x | isFix = x ===================================== libraries/base/GHC/Int.hs ===================================== @@ -106,6 +106,7 @@ instance Num Int8 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I8# (narrow8Int# (integerToInt# i)) -- | @since 2.01 @@ -160,7 +161,8 @@ instance Integral Int8 where (# d, m #) -> (I8# (narrow8Int# d), I8# (narrow8Int# m)) - toInteger (I8# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I8# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int8 where @@ -313,6 +315,7 @@ instance Num Int16 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I16# (narrow16Int# (integerToInt# i)) -- | @since 2.01 @@ -367,7 +370,8 @@ instance Integral Int16 where (# d, m #) -> (I16# (narrow16Int# d), I16# (narrow16Int# m)) - toInteger (I16# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I16# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int16 where @@ -525,6 +529,7 @@ instance Num Int32 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I32# (narrow32Int# (integerToInt# i)) -- | @since 2.01 @@ -587,7 +592,8 @@ instance Integral Int32 where (# d, m #) -> (I32# (narrow32Int# d), I32# (narrow32Int# m)) - toInteger (I32# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I32# x) = integerFromInt# x -- | @since 2.01 instance Read Int32 where @@ -748,6 +754,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt64# i) -- | @since 2.01 @@ -804,6 +811,7 @@ instance Integral Int64 where | y == (-1) && x == minBound = (overflowError, 0) | otherwise = (I64# (x# `divInt64#` y#), I64# (x# `modInt64#` y#)) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (I64# x) = integerFromInt64# x @@ -953,6 +961,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt# i) -- | @since 2.01 @@ -1006,7 +1015,8 @@ instance Integral Int64 where | otherwise = case x# `divModInt#` y# of (# d, m #) -> (I64# d, I64# m) - toInteger (I64# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I64# x) = integerFromInt64# x -- | @since 2.01 instance Read Int64 where ===================================== libraries/base/GHC/Num.hs ===================================== @@ -109,7 +109,7 @@ instance Num Int where | n `eqInt` 0 = 0 | otherwise = 1 - {-# INLINE fromInteger #-} -- Just to be sure! + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToInt i -- | @since 2.01 @@ -121,6 +121,7 @@ instance Num Word where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToWord i -- | @since 2.01 @@ -150,6 +151,7 @@ instance Num Natural where | naturalIsZero x = x | otherwise = raise# underflowException + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger x | x < 0 = raise# underflowException | otherwise = integerToNaturalClamp x @@ -160,4 +162,3 @@ instance Num Natural where {-# DEPRECATED quotRemInteger "Use integerQuotRem# instead" #-} quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger = integerQuotRem# - ===================================== libraries/base/GHC/Real.hs ===================================== @@ -324,7 +324,8 @@ instance Real Int where -- | @since 2.0.1 instance Integral Int where - toInteger (I# i) = IS i + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I# x) = integerFromInt# x a `quot` b | b == 0 = divZeroError @@ -399,6 +400,7 @@ instance Integral Word where divMod (W# x#) y@(W# y#) | y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W# x#) = integerFromWord# x# -------------------------------------------------------------- @@ -413,71 +415,60 @@ instance Real Integer where instance Real Natural where toRational n = integerFromNatural n :% 1 --- Note [Integer division constant folding] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- Constant folding of quot, rem, div, mod, divMod and quotRem for Integer --- arguments depends crucially on inlining. Constant folding rules defined in --- GHC.Core.Opt.ConstantFold trigger for integerQuot, integerRem and so on. --- So if calls to quot, rem and so on were not inlined the rules would not fire. --- --- The rules would also not fire if calls to integerQuot and so on were inlined, --- but this does not happen because they are all marked with NOINLINE pragma. - - -- | @since 2.0.1 instance Integral Integer where toInteger n = n - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `integerQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `integerRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `integerDiv` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `integerMod` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `integerDivMod` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `integerQuotRem` d -- | @since 4.8.0.0 instance Integral Natural where + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger = integerFromNatural - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `naturalQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `naturalRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `naturalQuot` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `naturalRem` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `naturalQuotRem` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `naturalQuotRem` d ===================================== libraries/base/GHC/Word.hs ===================================== @@ -112,6 +112,7 @@ instance Num Word8 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W8# (narrow8Word# (integerToWord# i)) -- | @since 2.01 @@ -156,7 +157,8 @@ instance Integral Word8 where divMod (W8# x#) y@(W8# y#) | y /= 0 = (W8# (x# `quotWord#` y#), W8# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W8# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W8# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word8 where @@ -303,6 +305,7 @@ instance Num Word16 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W16# (narrow16Word# (integerToWord# i)) -- | @since 2.01 @@ -347,7 +350,8 @@ instance Integral Word16 where divMod (W16# x#) y@(W16# y#) | y /= 0 = (W16# (x# `quotWord#` y#), W16# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W16# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W16# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word16 where @@ -533,6 +537,7 @@ instance Num Word32 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W32# (narrow32Word# (integerToWord# i)) -- | @since 2.01 @@ -587,15 +592,8 @@ instance Integral Word32 where divMod (W32# x#) y@(W32# y#) | y /= 0 = (W32# (x# `quotWord#` y#), W32# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W32# x#) -#if WORD_SIZE_IN_BITS == 32 - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# -#else - = IS (word2Int# x#) -#endif + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W32# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word32 where @@ -728,6 +726,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord64# i) -- | @since 2.01 @@ -770,6 +769,7 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord64#` y#), W64# (x# `remWord64#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W64# x#) = integerFromWord64# x# -- | @since 2.01 @@ -875,6 +875,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord# i) -- | @since 2.01 @@ -953,11 +954,8 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord#` y#), W64# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W64# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word64 where ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-spec-constr #-} -- See Note [Integer constant folding], + -- the bit about `integerAdd` {-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE BangPatterns #-} @@ -66,6 +68,7 @@ integerCheck# (IN bn) = bigNatCheck# bn &&# (bn `bigNatGtWord#` ABS_INT_MINBOUND -- | Check Integer invariants integerCheck :: Integer -> Bool +{-# INLINE integerCheck #-} integerCheck i = isTrue# (integerCheck# i) -- | Integer Zero @@ -137,6 +140,7 @@ integerToBigNatClamp# _ = bigNatZero# (# #) -- | Create an Integer from an Int# integerFromInt# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt# #-} -- See Note [Integer constant folding] integerFromInt# i = IS i -- | Create an Integer from an Int @@ -145,18 +149,19 @@ integerFromInt (I# i) = IS i -- | Truncates 'Integer' to least-significant 'Int#' integerToInt# :: Integer -> Int# -{-# NOINLINE integerToInt# #-} +{-# NOINLINE[0] integerToInt# #-} -- See Note [Integer constant folding] integerToInt# (IS i) = i integerToInt# (IP b) = word2Int# (bigNatToWord# b) integerToInt# (IN b) = negateInt# (word2Int# (bigNatToWord# b)) -- | Truncates 'Integer' to least-significant 'Int#' integerToInt :: Integer -> Int +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] integerToInt i = I# (integerToInt# i) -- | Convert a Word# into an Integer integerFromWord# :: Word# -> Integer -{-# NOINLINE integerFromWord# #-} +{-# NOINLINE[0] integerFromWord# #-} -- See Note [Integer constant folding] integerFromWord# w | i <- word2Int# w , isTrue# (i >=# 0#) @@ -167,6 +172,7 @@ integerFromWord# w -- | Convert a Word into an Integer integerFromWord :: Word -> Integer +{-# INLINE integerFromWord #-} -- See Note [Integer constant folding] integerFromWord (W# w) = integerFromWord# w -- | Create a negative Integer with the given Word magnitude @@ -185,23 +191,25 @@ integerFromWordSign# _ w = integerFromWordNeg# w -- | Truncate an Integer into a Word integerToWord# :: Integer -> Word# -{-# NOINLINE integerToWord# #-} +{-# NOINLINE[0] integerToWord# #-} -- See Note [Integer constant folding] integerToWord# (IS i) = int2Word# i integerToWord# (IP bn) = bigNatToWord# bn integerToWord# (IN bn) = int2Word# (negateInt# (word2Int# (bigNatToWord# bn))) -- | Truncate an Integer into a Word integerToWord :: Integer -> Word +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] integerToWord !i = W# (integerToWord# i) -- | Convert a Natural into an Integer integerFromNatural :: Natural -> Integer -{-# NOINLINE integerFromNatural #-} +{-# NOINLINE[0] integerFromNatural #-} -- See Note [Integer constant folding] integerFromNatural (NS x) = integerFromWord# x integerFromNatural (NB x) = integerFromBigNat# x -- | Convert a list of Word into an Integer integerFromWordList :: Bool -> [Word] -> Integer +{-# INLINE integerFromWordList #-} -- See Note [Integer constant folding] integerFromWordList True ws = integerFromBigNatNeg# (bigNatFromWordList ws) integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) @@ -209,7 +217,7 @@ integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) -- -- Return 0 for negative Integers. integerToNaturalClamp :: Integer -> Natural -{-# NOINLINE integerToNaturalClamp #-} +{-# NOINLINE[0] integerToNaturalClamp #-} -- See Note [Integer constant folding] integerToNaturalClamp (IS x) | isTrue# (x <# 0#) = naturalZero | True = naturalFromWord# (int2Word# x) @@ -220,7 +228,7 @@ integerToNaturalClamp (IN _) = naturalZero -- -- Return absolute value integerToNatural :: Integer -> Natural -{-# NOINLINE integerToNatural #-} +{-# NOINLINE[0] integerToNatural #-} -- See Note [Integer constant folding] integerToNatural (IS x) = naturalFromWord# (wordFromAbsInt# x) integerToNatural (IP x) = naturalFromBigNat# x integerToNatural (IN x) = naturalFromBigNat# x @@ -237,40 +245,50 @@ integerIsNegative# (IN _) = 1# -- | Negative predicate integerIsNegative :: Integer -> Bool +{-# INLINE integerIsNegative #-} -- See Note [Integer constant folding] integerIsNegative !i = isTrue# (integerIsNegative# i) -- | Zero predicate integerIsZero :: Integer -> Bool +{-# INLINE integerIsZero #-} -- See Note [Integer constant folding] integerIsZero (IS 0#) = True integerIsZero _ = False -- | Not-equal predicate. integerNe :: Integer -> Integer -> Bool +{-# INLINE integerNe #-} -- See Note [Integer constant folding] integerNe !x !y = isTrue# (integerNe# x y) -- | Equal predicate. integerEq :: Integer -> Integer -> Bool +{-# INLINE integerEq #-} -- See Note [Integer constant folding] integerEq !x !y = isTrue# (integerEq# x y) -- | Lower-or-equal predicate. integerLe :: Integer -> Integer -> Bool +{-# INLINE integerLe #-} -- See Note [Integer constant folding] integerLe !x !y = isTrue# (integerLe# x y) -- | Lower predicate. integerLt :: Integer -> Integer -> Bool +{-# INLINE integerLt #-} -- See Note [Integer constant folding] integerLt !x !y = isTrue# (integerLt# x y) -- | Greater predicate. integerGt :: Integer -> Integer -> Bool +{-# INLINE integerGt #-} -- See Note [Integer constant folding] integerGt !x !y = isTrue# (integerGt# x y) -- | Greater-or-equal predicate. integerGe :: Integer -> Integer -> Bool +{-# INLINE integerGe #-} -- See Note [Integer constant folding] integerGe !x !y = isTrue# (integerGe# x y) -- | Equal predicate. integerEq# :: Integer -> Integer -> Bool# -{-# NOINLINE integerEq# #-} +{-# NOINLINE integerEq# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerEq# (IS x) (IS y) = x ==# y integerEq# (IN x) (IN y) = bigNatEq# x y integerEq# (IP x) (IP y) = bigNatEq# x y @@ -278,7 +296,9 @@ integerEq# _ _ = 0# -- | Not-equal predicate. integerNe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerNe# #-} +{-# NOINLINE integerNe# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerNe# (IS x) (IS y) = x /=# y integerNe# (IN x) (IN y) = bigNatNe# x y integerNe# (IP x) (IP y) = bigNatNe# x y @@ -286,39 +306,43 @@ integerNe# _ _ = 1# -- | Greater predicate. integerGt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGt# #-} +{-# NOINLINE[0] integerGt# #-} -- See Note [Integer constant folding] integerGt# (IS x) (IS y) = x ># y integerGt# x y | GT <- integerCompare x y = 1# integerGt# _ _ = 0# -- | Lower-or-equal predicate. integerLe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLe# #-} +{-# NOINLINE[0] integerLe# #-} -- See Note [Integer constant folding] integerLe# (IS x) (IS y) = x <=# y integerLe# x y | GT <- integerCompare x y = 0# integerLe# _ _ = 1# -- | Lower predicate. integerLt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLt# #-} +{-# NOINLINE[0] integerLt# #-} -- See Note [Integer constant folding] integerLt# (IS x) (IS y) = x <# y integerLt# x y | LT <- integerCompare x y = 1# integerLt# _ _ = 0# -- | Greater-or-equal predicate. integerGe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGe# #-} +{-# NOINLINE[0] integerGe# #-} -- See Note [Integer constant folding] integerGe# (IS x) (IS y) = x >=# y integerGe# x y | LT <- integerCompare x y = 0# integerGe# _ _ = 1# instance Eq Integer where + {-# INLINE (==) #-} -- See Note [Integer constant folding] (==) = integerEq + {-# INLINE (/=) #-} -- See Note [Integer constant folding] (/=) = integerNe -- | Compare two Integer integerCompare :: Integer -> Integer -> Ordering -{-# NOINLINE integerCompare #-} +{-# NOINLINE integerCompare #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerCompare (IS x) (IS y) = compareInt# x y integerCompare (IP x) (IP y) = bigNatCompare x y integerCompare (IN x) (IN y) = bigNatCompare y x @@ -330,6 +354,7 @@ integerCompare (IP _) (IN _) = GT integerCompare (IN _) (IP _) = LT instance Ord Integer where + {-# INLINE compare #-} -- See Note [Integer constant folding] compare = integerCompare --------------------------------------------------------------------- @@ -338,7 +363,7 @@ instance Ord Integer where -- | Subtract one 'Integer' from another. integerSub :: Integer -> Integer -> Integer -{-# NOINLINE integerSub #-} +{-# NOINLINE[0] integerSub #-} -- See Note [Integer constant folding] integerSub !x (IS 0#) = x integerSub (IS x#) (IS y#) = case subIntC# x# y# of @@ -384,7 +409,7 @@ integerSub (IN x) (IS y#) -- | Add two 'Integer's integerAdd :: Integer -> Integer -> Integer -{-# NOINLINE integerAdd #-} +{-# NOINLINE[0] integerAdd #-} -- See Note [Integer constant folding] integerAdd !x (IS 0#) = x integerAdd (IS 0#) y = y integerAdd (IS x#) (IS y#) @@ -413,7 +438,7 @@ integerAdd (IP x) (IN y) -- | Multiply two 'Integer's integerMul :: Integer -> Integer -> Integer -{-# NOINLINE integerMul #-} +{-# NOINLINE[0] integerMul #-} -- See Note [Integer constant folding] integerMul !_ (IS 0#) = IS 0# integerMul (IS 0#) _ = IS 0# integerMul x (IS 1#) = x @@ -478,7 +503,7 @@ integerMul (IN x) (IS y) -- IP is used iff n > maxBound::Int -- IN is used iff n < minBound::Int integerNegate :: Integer -> Integer -{-# NOINLINE integerNegate #-} +{-# NOINLINE[0] integerNegate #-} -- See Note [Integer constant folding] integerNegate (IN b) = IP b integerNegate (IS INT_MINBOUND#) = IP (bigNatFromWord# ABS_INT_MINBOUND##) integerNegate (IS i) = IS (negateInt# i) @@ -489,7 +514,7 @@ integerNegate (IP b) -- | Compute absolute value of an 'Integer' integerAbs :: Integer -> Integer -{-# NOINLINE integerAbs #-} +{-# NOINLINE[0] integerAbs #-} -- See Note [Integer constant folding] integerAbs (IN i) = IP i integerAbs n@(IP _) = n integerAbs n@(IS i) @@ -501,13 +526,13 @@ integerAbs n@(IS i) -- | Return @-1@, @0@, and @1@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum :: Integer -> Integer -{-# NOINLINE integerSignum #-} +{-# NOINLINE[0] integerSignum #-} -- See Note [Integer constant folding] integerSignum !j = IS (integerSignum# j) -- | Return @-1#@, @0#@, and @1#@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum# :: Integer -> Int# -{-# NOINLINE integerSignum# #-} +{-# NOINLINE[0] integerSignum# #-} -- See Note [Integer constant folding] integerSignum# (IN _) = -1# integerSignum# (IS i#) = sgnI# i# integerSignum# (IP _ ) = 1# @@ -515,7 +540,7 @@ integerSignum# (IP _ ) = 1# -- | Count number of set bits. For negative arguments returns -- the negated population count of the absolute value. integerPopCount# :: Integer -> Int# -{-# NOINLINE integerPopCount# #-} +{-# NOINLINE[0] integerPopCount# #-} -- See Note [Integer constant folding] integerPopCount# (IS i) | isTrue# (i >=# 0#) = word2Int# (popCntI# i) | True = negateInt# (word2Int# (popCntI# (negateInt# i))) @@ -524,7 +549,7 @@ integerPopCount# (IN bn) = negateInt# (word2Int# (bigNatPopCount# bn)) -- | Positive 'Integer' for which only /n/-th bit is set integerBit# :: Word# -> Integer -{-# NOINLINE integerBit# #-} +{-# NOINLINE[0] integerBit# #-} -- See Note [Integer constant folding] integerBit# i | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##)) = IS (uncheckedIShiftL# 1# (word2Int# i)) @@ -533,13 +558,14 @@ integerBit# i -- | 'Integer' for which only /n/-th bit is set integerBit :: Word -> Integer +{-# INLINE integerBit #-} -- See Note [Integer constant folding] integerBit (W# i) = integerBit# i -- | Test if /n/-th bit is set. -- -- Fake 2's complement for negative values (might be slow) integerTestBit# :: Integer -> Word# -> Bool# -{-# NOINLINE integerTestBit# #-} +{-# NOINLINE[0] integerTestBit# #-} -- See Note [Integer constant folding] integerTestBit# (IS x) i | isTrue# (i `ltWord#` WORD_SIZE_IN_BITS##) = testBitI# x i @@ -569,13 +595,14 @@ integerTestBit# (IN x) i -- -- Fake 2's complement for negative values (might be slow) integerTestBit :: Integer -> Word -> Bool +{-# INLINE integerTestBit #-} -- See Note [Integer constant folding] integerTestBit !i (W# n) = isTrue# (integerTestBit# i n) -- | Shift-right operation -- -- Fake 2's complement for negative values (might be slow) integerShiftR# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftR# #-} +{-# NOINLINE[0] integerShiftR# #-} -- See Note [Integer constant folding] integerShiftR# !x 0## = x integerShiftR# (IS i) n = IS (iShiftRA# i (word2Int# n)) where @@ -592,11 +619,12 @@ integerShiftR# (IN bn) n = -- -- Fake 2's complement for negative values (might be slow) integerShiftR :: Integer -> Word -> Integer +{-# INLINE integerShiftR #-} -- See Note [Integer constant folding] integerShiftR !x (W# w) = integerShiftR# x w -- | Shift-left operation integerShiftL# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftL# #-} +{-# NOINLINE[0] integerShiftL# #-} -- See Note [Integer constant folding] integerShiftL# !x 0## = x integerShiftL# (IS 0#) _ = IS 0# integerShiftL# (IS 1#) n = integerBit# n @@ -611,13 +639,14 @@ integerShiftL# (IN bn) n = IN (bigNatShiftL# bn n) -- Remember that bits are stored in sign-magnitude form, hence the behavior of -- negative Integers is different from negative Int's behavior. integerShiftL :: Integer -> Word -> Integer +{-# INLINE integerShiftL #-} -- See Note [Integer constant folding] integerShiftL !x (W# w) = integerShiftL# x w -- | Bitwise OR operation -- -- Fake 2's complement for negative values (might be slow) integerOr :: Integer -> Integer -> Integer -{-# NOINLINE integerOr #-} +{-# NOINLINE[0] integerOr #-} -- See Note [Integer constant folding] integerOr a b = case a of IS 0# -> b IS -1# -> IS -1# @@ -676,7 +705,7 @@ integerOr a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerXor :: Integer -> Integer -> Integer -{-# NOINLINE integerXor #-} +{-# NOINLINE[0] integerXor #-} -- See Note [Integer constant folding] integerXor a b = case a of IS 0# -> b IS -1# -> integerComplement b @@ -731,7 +760,7 @@ integerXor a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerAnd :: Integer -> Integer -> Integer -{-# NOINLINE integerAnd #-} +{-# NOINLINE[0] integerAnd #-} -- See Note [Integer constant folding] integerAnd a b = case a of IS 0# -> IS 0# IS -1# -> b @@ -766,7 +795,7 @@ integerAnd a b = case a of -- | Binary complement of the integerComplement :: Integer -> Integer -{-# NOINLINE integerComplement #-} +{-# NOINLINE[0] integerComplement #-} -- See Note [Integer constant folding] integerComplement (IS x) = IS (notI# x) integerComplement (IP x) = IN (bigNatAddWord# x 1##) integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) @@ -777,7 +806,7 @@ integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerQuotRem# #-} +{-# NOINLINE[0] integerQuotRem# #-} -- See Note [Integer constant folding] integerQuotRem# !n (IS 1#) = (# n, IS 0# #) integerQuotRem# !n (IS -1#) = let !q = integerNegate n in (# q, (IS 0#) #) integerQuotRem# !_ (IS 0#) = case raiseDivZero of @@ -815,12 +844,13 @@ integerQuotRem# n@(IS n#) (IP d) -- need to account for (IS minBound) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerQuotRem #-} -- See Note [Integer constant folding] integerQuotRem !x !y = case integerQuotRem# x y of (# q, r #) -> (q, r) integerQuot :: Integer -> Integer -> Integer -{-# NOINLINE integerQuot #-} +{-# NOINLINE[0] integerQuot #-} -- See Note [Integer constant folding] integerQuot !n (IS 1#) = n integerQuot !n (IS -1#) = integerNegate n integerQuot !_ (IS 0#) = raiseDivZero @@ -841,7 +871,7 @@ integerQuot (IN n) (IN d) = integerFromBigNat# (bigNatQuot n d) integerQuot n d = case integerQuotRem# n d of (# q, _ #) -> q integerRem :: Integer -> Integer -> Integer -{-# NOINLINE integerRem #-} +{-# NOINLINE[0] integerRem #-} -- See Note [Integer constant folding] integerRem !_ (IS 1#) = IS 0# integerRem _ (IS -1#) = IS 0# integerRem _ (IS 0#) = IS (remInt# 0# 0#) @@ -863,7 +893,7 @@ integerRem n d = case integerQuotRem# n d of (# _, r #) -> r -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerDivMod# #-} +{-# NOINLINE[0] integerDivMod# #-} -- See Note [Integer constant folding] integerDivMod# !n !d | isTrue# (integerSignum# r ==# negateInt# (integerSignum# d)) = let !q' = integerSub q (IS 1#) @@ -878,12 +908,13 @@ integerDivMod# !n !d -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerDivMod #-} -- See Note [Integer constant folding] integerDivMod !n !d = case integerDivMod# n d of (# q,r #) -> (q,r) integerDiv :: Integer -> Integer -> Integer -{-# NOINLINE integerDiv #-} +{-# NOINLINE[0] integerDiv #-} -- See Note [Integer constant folding] integerDiv !n !d -- same-sign ops can be handled by more efficient 'integerQuot' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerQuot n d @@ -891,7 +922,7 @@ integerDiv !n !d integerMod :: Integer -> Integer -> Integer -{-# NOINLINE integerMod #-} +{-# NOINLINE[0] integerMod #-} -- See Note [Integer constant folding] integerMod !n !d -- same-sign ops can be handled by more efficient 'integerRem' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerRem n d @@ -899,7 +930,7 @@ integerMod !n !d -- | Compute greatest common divisor. integerGcd :: Integer -> Integer -> Integer -{-# NOINLINE integerGcd #-} +{-# NOINLINE[0] integerGcd #-} -- See Note [Integer constant folding] integerGcd (IS 0#) !b = integerAbs b integerGcd a (IS 0#) = integerAbs a integerGcd (IS 1#) _ = IS 1# @@ -917,7 +948,7 @@ integerGcd (IP a) (IS b) = integerFromWord# (bigNatGcdWord# a (int2Word# (ab -- | Compute least common multiple. integerLcm :: Integer -> Integer -> Integer -{-# NOINLINE integerLcm #-} +{-# NOINLINE[0] integerLcm #-} -- See Note [Integer constant folding] integerLcm (IS 0#) !_ = IS 0# integerLcm (IS 1#) b = integerAbs b integerLcm (IS -1#) b = integerAbs b @@ -931,6 +962,7 @@ integerLcm a b = (aa `integerQuot` (aa `integerGcd` ab)) `integerMul` ab -- | Square a Integer integerSqr :: Integer -> Integer +{-# INLINE integerSqr #-} -- See Note [Integer constant folding] integerSqr !a = integerMul a a @@ -948,6 +980,7 @@ integerLog2# (IP b) = bigNatLog2# b -- -- For numbers <= 0, return 0 integerLog2 :: Integer -> Word +{-# INLINE integerLog2 #-} -- See Note [Integer constant folding] integerLog2 !i = W# (integerLog2# i) -- | Logarithm (floor) for an arbitrary base @@ -962,6 +995,7 @@ integerLogBaseWord# base !i -- -- For numbers <= 0, return 0 integerLogBaseWord :: Word -> Integer -> Word +{-# INLINE integerLogBaseWord #-} -- See Note [Integer constant folding] integerLogBaseWord (W# base) !i = W# (integerLogBaseWord# base i) -- | Logarithm (floor) for an arbitrary base @@ -977,6 +1011,7 @@ integerLogBase# !base !i -- -- For numbers <= 0, return 0 integerLogBase :: Integer -> Integer -> Word +{-# INLINE integerLogBase #-} -- See Note [Integer constant folding] integerLogBase !base !i = W# (integerLogBase# base i) -- | Indicate if the value is a power of two and which one @@ -991,7 +1026,7 @@ integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w -- | Convert an Int64# into an Integer on 32-bit architectures integerFromInt64# :: Int64# -> Integer -{-# NOINLINE integerFromInt64# #-} +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !i | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#) &&# (i `geInt64#` intToInt64# -0x80000000#)) @@ -1005,7 +1040,7 @@ integerFromInt64# !i -- | Convert a Word64# into an Integer on 32-bit architectures integerFromWord64# :: Word64# -> Integer -{-# NOINLINE integerFromWord64# #-} +{-# NOINLINE[0] integerFromWord64# #-} -- See Note [Integer constant folding] integerFromWord64# !w | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##) = IS (int64ToInt# (word64ToInt64# w)) @@ -1014,14 +1049,14 @@ integerFromWord64# !w -- | Convert an Integer into an Int64# on 32-bit architectures integerToInt64# :: Integer -> Int64# -{-# NOINLINE integerToInt64# #-} +{-# NOINLINE[0] integerToInt64# #-} -- See Note [Integer constant folding] integerToInt64# (IS i) = intToInt64# i integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b) integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b)) -- | Convert an Integer into a Word64# on 32-bit architectures integerToWord64# :: Integer -> Word64# -{-# NOINLINE integerToWord64# #-} +{-# NOINLINE[0] integerToWord64# #-} -- See Note [Integer constant folding] integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) integerToWord64# (IP b) = bigNatToWord64# b integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b))) @@ -1030,6 +1065,7 @@ integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatTo -- | Convert an Int64# into an Integer on 64-bit architectures integerFromInt64# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !x = IS x #endif @@ -1040,18 +1076,19 @@ integerFromInt64# !x = IS x -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble# :: Double# -> (# Integer, Int# #) -{-# NOINLINE integerDecodeDouble# #-} +{-# NOINLINE[0] integerDecodeDouble# #-} -- See Note [Integer constant folding] integerDecodeDouble# !x = case decodeDouble_Int64# x of (# m, e #) -> (# integerFromInt64# m, e #) -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble :: Double -> (Integer, Int) +{-# INLINE integerDecodeDouble #-} -- See Note [Integer constant folding] integerDecodeDouble (D# x) = case integerDecodeDouble# x of (# m, e #) -> (m, I# e) -- | Encode (# Integer mantissa, Int# exponent #) into a Double# integerEncodeDouble# :: Integer -> Int# -> Double# -{-# NOINLINE integerEncodeDouble# #-} +{-# NOINLINE[0] integerEncodeDouble# #-} -- See Note [Integer constant folding] integerEncodeDouble# (IS i) 0# = int2Double# i integerEncodeDouble# (IS i) e = intEncodeDouble# i e integerEncodeDouble# (IP b) e = bigNatEncodeDouble# b e @@ -1059,23 +1096,24 @@ integerEncodeDouble# (IN b) e = negateDouble# (bigNatEncodeDouble# b e) -- | Encode (Integer mantissa, Int exponent) into a Double integerEncodeDouble :: Integer -> Int -> Double +{-# INLINE integerEncodeDouble #-} -- See Note [Integer constant folding] integerEncodeDouble !m (I# e) = D# (integerEncodeDouble# m e) -- | Encode an Integer (mantissa) into a Double# integerToDouble# :: Integer -> Double# -{-# NOINLINE integerToDouble# #-} +{-# NOINLINE[0] integerToDouble# #-} -- See Note [Integer constant folding] integerToDouble# !i = integerEncodeDouble# i 0# -- | Encode an Integer (mantissa) into a Float# integerToFloat# :: Integer -> Float# -{-# NOINLINE integerToFloat# #-} +{-# NOINLINE[0] integerToFloat# #-} -- See Note [Integer constant folding] integerToFloat# !i = integerEncodeFloat# i 0# -- | Encode (# Integer mantissa, Int# exponent #) into a Float# -- -- TODO: Not sure if it's worth to write 'Float' optimized versions here integerEncodeFloat# :: Integer -> Int# -> Float# -{-# NOINLINE integerEncodeFloat# #-} +{-# NOINLINE[0] integerEncodeFloat# #-} -- See Note [Integer constant folding] integerEncodeFloat# !m 0# = double2Float# (integerToDouble# m) integerEncodeFloat# !m e = double2Float# (integerEncodeDouble# m e) @@ -1105,6 +1143,7 @@ integerToAddr# (IN n) = bigNatToAddr# n -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToAddr :: Integer -> Addr# -> Bool# -> IO Word +{-# INLINE integerToAddr #-} -- See Note [Integer constant folding] integerToAddr a addr e = IO \s -> case integerToAddr# a addr e s of (# s', w #) -> (# s', W# w #) @@ -1132,6 +1171,7 @@ integerFromAddr# sz addr e s = -- -- Null higher limbs are automatically trimed. integerFromAddr :: Word# -> Addr# -> Bool# -> IO Integer +{-# INLINE integerFromAddr #-} -- See Note [Integer constant folding] integerFromAddr sz addr e = IO (integerFromAddr# sz addr e) @@ -1154,6 +1194,7 @@ integerToMutableByteArray# (IN a) = bigNatToMutableByteArray# a -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word +{-# INLINE integerToMutableByteArray #-} -- See Note [Integer constant folding] integerToMutableByteArray i mba w e = IO \s -> case integerToMutableByteArray# i mba w e s of (# s', r #) -> (# s', W# r #) @@ -1180,6 +1221,7 @@ integerFromByteArray# sz ba off e s = case bigNatFromByteArray# sz ba off e s of -- -- Null higher limbs are automatically trimed. integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer +{-# INLINE integerFromByteArray #-} -- See Note [Integer constant folding] integerFromByteArray sz ba off e = case runRW# (integerFromByteArray# sz ba off e) of (# _, i #) -> i @@ -1212,5 +1254,45 @@ integerGcde :: Integer -> Integer -> ( Integer, Integer, Integer) +{-# INLINE integerGcde #-} -- See Note [Integer constant folding] integerGcde a b = case integerGcde# a b of (# g,x,y #) -> (g,x,y) + +{- Note [Integer constant folding] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We define constant folding rules in "GHC.Core.Opt.ConstantFold" for most of the + at integer*#@ operations in this module, hence they are marked NOINLINE[0]. + +Why NOINLINE[0] rather than NOINLINE? Because + + 1. We still delay inlining long enough for the constant-folding RULEs + to fire + 2. The compiler has the option to inlining the operations late, possibly + cancelling away boxes in the process. + +Why NOINLINE[0] rather than INLINE? Because + + 3. We don't unconditionally inline huge definitions such as + `integerDiv`, which would lead to code bloat at pretty much no + gain. + 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. + `integerDiv`, there is no gain in inlining the unoptimised + unfoldings. + +But since we potentially inline the constant folded operations in phase 0, we +have to make sure that *all* callers that want to take part in constant folding +are marked INLINE. Otherwise, we'd store optimised unfoldings for them, in which +the constant folded functions are inlined. +That concerns for most of the @integer*@ without trailing hash in this module, +as well as the type class instances for 'Eq', 'Ord', 'Num', 'Integral', +'RealFloat' (which is for 'Double'!), etc. + +There are a couple of constant-folded functions that require special treatment, +though: + + * `integerEq`, `integerNe`, `integerCompare`: They are huge and lead to + regressions when inlined. Solution: mark these NOINLINE. + * Under -O2, `integerAdd` will be specialised by SpecConstr. These + specialisations defeat constant folding. + Solution: -fno-spec-constr for this module. +-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5eee7d6e908b736fdb1a98a287f642b8e6c68d12 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5eee7d6e908b736fdb1a98a287f642b8e6c68d12 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 08:07:29 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 04:07:29 -0400 Subject: [Git][ghc/ghc][wip/T18765] s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) Message-ID: <5f76dfc1f25c8_80b3f8454d21640160775a6@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18765 at Glasgow Haskell Compiler / GHC Commits: 8320f630 by Sebastian Graf at 2020-10-02T10:07:17+02:00 s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) This defeats constant-folding in the final phases of the Simplifier, but enables us to get rid of allocations by inlining calls that can't be constant-folded. `NOINLINE[0]` is a better choice than `NOINLINE`, because 1. We still delay inlining long enough for the constant-folding RULEs to fire 2. The compiler has the option to inlining them late, possibly cancelling away boxes in the process. `NOINLINE[0]` is a better choice than `INLINE[0]`, because 3. We don't unconditionally inline huge definitions such as `integerDiv`, which would lead to code bloat at pretty much no gain. 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. `integerDiv`, there is no gain in inlining the unoptimised unfoldings. We also have to mark all callers that want to participate in constant folding as `INLINE`. See the new `Note [Integer constant folding]` for details. I had to change the `Num.fromInteger` and `Integral.toInteger` implementations of `Int*` and `Word*` variants to call the constant folded `integerToInt*#` and `integerToWord*#` variants directly to ensure constant folding. Fixes #18765. Metric Decrease: T10359 - - - - - 9 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Opt/ConstantFold.hs - libraries/base/GHC/Float.hs - libraries/base/GHC/Int.hs - libraries/base/GHC/Integer.hs - libraries/base/GHC/Num.hs - libraries/base/GHC/Real.hs - libraries/base/GHC/Word.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -354,6 +354,7 @@ basicKnownKeyNames integerToWord64Name, integerToInt64Name, integerFromWordName, + integerFromIntName, integerFromWord64Name, integerFromInt64Name, integerAddName, @@ -1130,6 +1131,7 @@ integerFromNaturalName , integerToWord64Name , integerToInt64Name , integerFromWordName + , integerFromIntName , integerFromWord64Name , integerFromInt64Name , integerAddName @@ -1198,6 +1200,7 @@ integerToIntName = bniVarQual "integerToInt#" integerToIntI integerToWord64Name = bniVarQual "integerToWord64#" integerToWord64IdKey integerToInt64Name = bniVarQual "integerToInt64#" integerToInt64IdKey integerFromWordName = bniVarQual "integerFromWord#" integerFromWordIdKey +integerFromIntName = bniVarQual "integerFromInt#" integerFromIntIdKey integerFromWord64Name = bniVarQual "integerFromWord64#" integerFromWord64IdKey integerFromInt64Name = bniVarQual "integerFromInt64#" integerFromInt64IdKey integerAddName = bniVarQual "integerAdd" integerAddIdKey @@ -2464,6 +2467,7 @@ integerFromNaturalIdKey , integerShiftLIdKey , integerShiftRIdKey , integerFromWordIdKey + , integerFromIntIdKey , integerFromWord64IdKey , integerFromInt64IdKey , integerDecodeDoubleIdKey @@ -2519,6 +2523,7 @@ integerFromWordIdKey = mkPreludeMiscIdUnique 638 integerFromWord64IdKey = mkPreludeMiscIdUnique 639 integerFromInt64IdKey = mkPreludeMiscIdUnique 640 integerDecodeDoubleIdKey = mkPreludeMiscIdUnique 641 +integerFromIntIdKey = mkPreludeMiscIdUnique 642 naturalToWordIdKey = mkPreludeMiscIdUnique 650 naturalAddIdKey = mkPreludeMiscIdUnique 651 ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1312,7 +1312,8 @@ builtinRules enableBignumRules builtinBignumRules :: EnableBignumRules -> [CoreRule] builtinBignumRules (EnableBignumRules False) = [] builtinBignumRules _ = - [ rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName + [ rule_IntegerFromLitNum "Int# -> Integer" integerFromIntName + , rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName , rule_IntegerFromLitNum "Int64# -> Integer" integerFromInt64Name , rule_IntegerFromLitNum "Word64# -> Integer" integerFromWord64Name , rule_IntegerFromLitNum "Natural -> Integer" integerFromNaturalName @@ -1347,7 +1348,7 @@ builtinBignumRules _ = , rule_shift_op "integerShiftL" integerShiftLName shiftL , rule_shift_op "integerShiftR" integerShiftRName shiftR , rule_integerBit "integerBit" integerBitName - -- See Note [Integer division constant folding] in libraries/base/GHC/Real.hs + -- See Note [Integer constant folding] in "GHC.Num.Integer" , rule_divop_one "integerQuot" integerQuotName quot , rule_divop_one "integerRem" integerRemName rem , rule_divop_one "integerDiv" integerDivName div ===================================== libraries/base/GHC/Float.hs ===================================== @@ -494,6 +494,7 @@ instance Num Double where -- | @since 2.01 instance Real Double where + {-# INLINE toRational #-} -- See Note [Integer constant folding] toRational (D# x#) = case integerDecodeDouble# x# of (# m, e# #) @@ -580,11 +581,7 @@ instance Floating Double where -- | @since 2.01 instance RealFrac Double where - -- ceiling, floor, and truncate are all small - {-# INLINE [1] ceiling #-} - {-# INLINE [1] floor #-} - {-# INLINE [1] truncate #-} - + {-# INLINE properFraction #-} -- See Note [Integer constant folding] properFraction x = case (decodeFloat x) of { (m,n) -> if n >= 0 then @@ -595,9 +592,11 @@ instance RealFrac Double where } } + {-# INLINE truncate #-} -- See Note [Integer constant folding] truncate x = case properFraction x of (n,_) -> n + {-# INLINE round #-} -- See Note [Integer constant folding] round x = case properFraction x of (n,r) -> let m = if r < 0.0 then n - 1 else n + 1 @@ -608,9 +607,11 @@ instance RealFrac Double where EQ -> if even n then n else m GT -> m + {-# INLINE ceiling #-} -- See Note [Integer constant folding] ceiling x = case properFraction x of (n,r) -> if r > 0.0 then n + 1 else n + {-# INLINE floor #-} -- See Note [Integer constant folding] floor x = case properFraction x of (n,r) -> if r < 0.0 then n - 1 else n @@ -620,18 +621,23 @@ instance RealFloat Double where floatDigits _ = DBL_MANT_DIG -- ditto floatRange _ = (DBL_MIN_EXP, DBL_MAX_EXP) -- ditto + {-# INLINE decodeFloat #-} -- See Note [Integer constant folding] decodeFloat (D# x#) = case integerDecodeDouble# x# of (# i, j #) -> (i, I# j) + {-# INLINE encodeFloat #-} -- See Note [Integer constant folding] encodeFloat i (I# j) = D# (integerEncodeDouble# i j) + {-# INLINE exponent #-} -- See Note [Integer constant folding] exponent x = case decodeFloat x of (m,n) -> if m == 0 then 0 else n + floatDigits x + {-# INLINE significand #-} -- See Note [Integer constant folding] significand x = case decodeFloat x of (m,_) -> encodeFloat m (negate (floatDigits x)) + {-# INLINE scaleFloat #-} -- See Note [Integer constant folding] scaleFloat 0 x = x scaleFloat k x | isFix = x ===================================== libraries/base/GHC/Int.hs ===================================== @@ -106,6 +106,7 @@ instance Num Int8 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I8# (narrow8Int# (integerToInt# i)) -- | @since 2.01 @@ -160,7 +161,8 @@ instance Integral Int8 where (# d, m #) -> (I8# (narrow8Int# d), I8# (narrow8Int# m)) - toInteger (I8# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I8# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int8 where @@ -313,6 +315,7 @@ instance Num Int16 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I16# (narrow16Int# (integerToInt# i)) -- | @since 2.01 @@ -367,7 +370,8 @@ instance Integral Int16 where (# d, m #) -> (I16# (narrow16Int# d), I16# (narrow16Int# m)) - toInteger (I16# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I16# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int16 where @@ -525,6 +529,7 @@ instance Num Int32 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I32# (narrow32Int# (integerToInt# i)) -- | @since 2.01 @@ -587,7 +592,8 @@ instance Integral Int32 where (# d, m #) -> (I32# (narrow32Int# d), I32# (narrow32Int# m)) - toInteger (I32# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I32# x) = integerFromInt# x -- | @since 2.01 instance Read Int32 where @@ -748,6 +754,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt64# i) -- | @since 2.01 @@ -804,6 +811,7 @@ instance Integral Int64 where | y == (-1) && x == minBound = (overflowError, 0) | otherwise = (I64# (x# `divInt64#` y#), I64# (x# `modInt64#` y#)) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (I64# x) = integerFromInt64# x @@ -953,6 +961,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt# i) -- | @since 2.01 @@ -1006,7 +1015,8 @@ instance Integral Int64 where | otherwise = case x# `divModInt#` y# of (# d, m #) -> (I64# d, I64# m) - toInteger (I64# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I64# x) = integerFromInt64# x -- | @since 2.01 instance Read Int64 where ===================================== libraries/base/GHC/Integer.hs ===================================== @@ -64,156 +64,203 @@ import GHC.Prim import GHC.Types smallInteger :: Int# -> Integer +{-# INLINE smallInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer smallInteger = I.integerFromInt# integerToInt :: Integer -> Int# +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt = I.integerToInt# wordToInteger :: Word# -> Integer +{-# INLINE wordToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer wordToInteger = I.integerFromWord# integerToWord :: Integer -> Word# +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord = I.integerToWord# #if WORD_SIZE_IN_BITS < 64 word64ToInteger :: Word64# -> Integer +{-# INLINE word64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer word64ToInteger = I.integerFromWord64# integerToWord64 :: Integer -> Word64# +{-# INLINE integerToWord64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord64 = I.integerToWord64# int64ToInteger :: Int64# -> Integer +{-# INLINE int64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer int64ToInteger = I.integerFromInt64# integerToInt64 :: Integer -> Int64# +{-# INLINE integerToInt64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt64 = I.integerToInt64# #endif encodeFloatInteger :: Integer -> Int# -> Float# +{-# INLINE encodeFloatInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeFloatInteger = I.integerEncodeFloat# floatFromInteger :: Integer -> Float# +{-# INLINE floatFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer floatFromInteger = I.integerToFloat# encodeDoubleInteger :: Integer -> Int# -> Double# +{-# INLINE encodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeDoubleInteger = I.integerEncodeDouble# doubleFromInteger :: Integer -> Double# +{-# INLINE doubleFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer doubleFromInteger = I.integerToDouble# decodeDoubleInteger :: Double# -> (# Integer, Int# #) +{-# INLINE decodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer decodeDoubleInteger = I.integerDecodeDouble# plusInteger :: Integer -> Integer -> Integer +{-# INLINE plusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer plusInteger = I.integerAdd minusInteger :: Integer -> Integer -> Integer +{-# INLINE minusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer minusInteger = I.integerSub timesInteger :: Integer -> Integer -> Integer +{-# INLINE timesInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer timesInteger = I.integerMul negateInteger :: Integer -> Integer +{-# INLINE negateInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer negateInteger = I.integerNegate absInteger :: Integer -> Integer +{-# INLINE absInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer absInteger = I.integerAbs signumInteger :: Integer -> Integer +{-# INLINE signumInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer signumInteger = I.integerSignum divModInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE divModInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divModInteger = I.integerDivMod# divInteger :: Integer -> Integer -> Integer +{-# INLINE divInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divInteger = I.integerDiv modInteger :: Integer -> Integer -> Integer +{-# INLINE modInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer modInteger = I.integerMod quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE quotRemInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotRemInteger = I.integerQuotRem# quotInteger :: Integer -> Integer -> Integer +{-# INLINE quotInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotInteger = I.integerQuot remInteger :: Integer -> Integer -> Integer +{-# INLINE remInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer remInteger = I.integerRem eqInteger :: Integer -> Integer -> Bool +{-# INLINE eqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger = I.integerEq neqInteger :: Integer -> Integer -> Bool +{-# INLINE neqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger = I.integerNe leInteger :: Integer -> Integer -> Bool +{-# INLINE leInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger = I.integerLe gtInteger :: Integer -> Integer -> Bool +{-# INLINE gtInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger = I.integerGt ltInteger :: Integer -> Integer -> Bool +{-# INLINE ltInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger = I.integerLt geInteger :: Integer -> Integer -> Bool +{-# INLINE geInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger = I.integerGe compareInteger :: Integer -> Integer -> Ordering +{-# INLINE compareInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer compareInteger = I.integerCompare eqInteger# :: Integer -> Integer -> Int# +{-# INLINE eqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger# = I.integerEq# neqInteger# :: Integer -> Integer -> Int# +{-# INLINE neqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger# = I.integerNe# leInteger# :: Integer -> Integer -> Int# +{-# INLINE leInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger# = I.integerLe# gtInteger# :: Integer -> Integer -> Int# +{-# INLINE gtInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger# = I.integerGt# ltInteger# :: Integer -> Integer -> Int# +{-# INLINE ltInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger# = I.integerLt# geInteger# :: Integer -> Integer -> Int# +{-# INLINE geInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger# = I.integerGe# andInteger :: Integer -> Integer -> Integer +{-# INLINE andInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer andInteger = I.integerAnd orInteger :: Integer -> Integer -> Integer +{-# INLINE orInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer orInteger = I.integerOr xorInteger :: Integer -> Integer -> Integer +{-# INLINE xorInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer xorInteger = I.integerXor complementInteger :: Integer -> Integer +{-# INLINE complementInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer complementInteger = I.integerComplement shiftLInteger :: Integer -> Int# -> Integer +{-# INLINE shiftLInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftLInteger n i = I.integerShiftL# n (int2Word# i) shiftRInteger :: Integer -> Int# -> Integer +{-# INLINE shiftRInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftRInteger n i = I.integerShiftR# n (int2Word# i) testBitInteger :: Integer -> Int# -> Bool +{-# INLINE testBitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer testBitInteger n i = isTrue# (I.integerTestBit# n (int2Word# i)) hashInteger :: Integer -> Int# +{-# INLINE hashInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer hashInteger = I.integerToInt# bitInteger :: Int# -> Integer +{-# INLINE bitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer bitInteger i = I.integerBit# (int2Word# i) popCountInteger :: Integer -> Int# +{-# INLINE popCountInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer popCountInteger = I.integerPopCount# - ===================================== libraries/base/GHC/Num.hs ===================================== @@ -109,7 +109,7 @@ instance Num Int where | n `eqInt` 0 = 0 | otherwise = 1 - {-# INLINE fromInteger #-} -- Just to be sure! + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToInt i -- | @since 2.01 @@ -121,6 +121,7 @@ instance Num Word where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToWord i -- | @since 2.01 @@ -150,6 +151,7 @@ instance Num Natural where | naturalIsZero x = x | otherwise = raise# underflowException + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger x | x < 0 = raise# underflowException | otherwise = integerToNaturalClamp x @@ -160,4 +162,3 @@ instance Num Natural where {-# DEPRECATED quotRemInteger "Use integerQuotRem# instead" #-} quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger = integerQuotRem# - ===================================== libraries/base/GHC/Real.hs ===================================== @@ -324,7 +324,8 @@ instance Real Int where -- | @since 2.0.1 instance Integral Int where - toInteger (I# i) = IS i + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I# x) = integerFromInt# x a `quot` b | b == 0 = divZeroError @@ -399,6 +400,7 @@ instance Integral Word where divMod (W# x#) y@(W# y#) | y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W# x#) = integerFromWord# x# -------------------------------------------------------------- @@ -413,71 +415,60 @@ instance Real Integer where instance Real Natural where toRational n = integerFromNatural n :% 1 --- Note [Integer division constant folding] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- Constant folding of quot, rem, div, mod, divMod and quotRem for Integer --- arguments depends crucially on inlining. Constant folding rules defined in --- GHC.Core.Opt.ConstantFold trigger for integerQuot, integerRem and so on. --- So if calls to quot, rem and so on were not inlined the rules would not fire. --- --- The rules would also not fire if calls to integerQuot and so on were inlined, --- but this does not happen because they are all marked with NOINLINE pragma. - - -- | @since 2.0.1 instance Integral Integer where toInteger n = n - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `integerQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `integerRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `integerDiv` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `integerMod` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `integerDivMod` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `integerQuotRem` d -- | @since 4.8.0.0 instance Integral Natural where + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger = integerFromNatural - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `naturalQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `naturalRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `naturalQuot` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `naturalRem` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `naturalQuotRem` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `naturalQuotRem` d ===================================== libraries/base/GHC/Word.hs ===================================== @@ -112,6 +112,7 @@ instance Num Word8 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W8# (narrow8Word# (integerToWord# i)) -- | @since 2.01 @@ -156,7 +157,8 @@ instance Integral Word8 where divMod (W8# x#) y@(W8# y#) | y /= 0 = (W8# (x# `quotWord#` y#), W8# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W8# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W8# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word8 where @@ -303,6 +305,7 @@ instance Num Word16 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W16# (narrow16Word# (integerToWord# i)) -- | @since 2.01 @@ -347,7 +350,8 @@ instance Integral Word16 where divMod (W16# x#) y@(W16# y#) | y /= 0 = (W16# (x# `quotWord#` y#), W16# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W16# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W16# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word16 where @@ -533,6 +537,7 @@ instance Num Word32 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W32# (narrow32Word# (integerToWord# i)) -- | @since 2.01 @@ -587,15 +592,8 @@ instance Integral Word32 where divMod (W32# x#) y@(W32# y#) | y /= 0 = (W32# (x# `quotWord#` y#), W32# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W32# x#) -#if WORD_SIZE_IN_BITS == 32 - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# -#else - = IS (word2Int# x#) -#endif + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W32# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word32 where @@ -728,6 +726,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord64# i) -- | @since 2.01 @@ -770,6 +769,7 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord64#` y#), W64# (x# `remWord64#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W64# x#) = integerFromWord64# x# -- | @since 2.01 @@ -875,6 +875,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord# i) -- | @since 2.01 @@ -953,11 +954,8 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord#` y#), W64# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W64# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word64 where ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-spec-constr #-} -- See Note [Integer constant folding], + -- the bit about `integerAdd` {-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE BangPatterns #-} @@ -66,6 +68,7 @@ integerCheck# (IN bn) = bigNatCheck# bn &&# (bn `bigNatGtWord#` ABS_INT_MINBOUND -- | Check Integer invariants integerCheck :: Integer -> Bool +{-# INLINE integerCheck #-} integerCheck i = isTrue# (integerCheck# i) -- | Integer Zero @@ -137,26 +140,29 @@ integerToBigNatClamp# _ = bigNatZero# (# #) -- | Create an Integer from an Int# integerFromInt# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt# #-} -- See Note [Integer constant folding] integerFromInt# i = IS i -- | Create an Integer from an Int integerFromInt :: Int -> Integer -integerFromInt (I# i) = IS i +{-# INLINE integerFromInt #-} -- See Note [Integer constant folding] +integerFromInt (I# i) = integerFromInt# i -- | Truncates 'Integer' to least-significant 'Int#' integerToInt# :: Integer -> Int# -{-# NOINLINE integerToInt# #-} +{-# NOINLINE[0] integerToInt# #-} -- See Note [Integer constant folding] integerToInt# (IS i) = i integerToInt# (IP b) = word2Int# (bigNatToWord# b) integerToInt# (IN b) = negateInt# (word2Int# (bigNatToWord# b)) -- | Truncates 'Integer' to least-significant 'Int#' integerToInt :: Integer -> Int +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] integerToInt i = I# (integerToInt# i) -- | Convert a Word# into an Integer integerFromWord# :: Word# -> Integer -{-# NOINLINE integerFromWord# #-} +{-# NOINLINE[0] integerFromWord# #-} -- See Note [Integer constant folding] integerFromWord# w | i <- word2Int# w , isTrue# (i >=# 0#) @@ -167,6 +173,7 @@ integerFromWord# w -- | Convert a Word into an Integer integerFromWord :: Word -> Integer +{-# INLINE integerFromWord #-} -- See Note [Integer constant folding] integerFromWord (W# w) = integerFromWord# w -- | Create a negative Integer with the given Word magnitude @@ -185,23 +192,25 @@ integerFromWordSign# _ w = integerFromWordNeg# w -- | Truncate an Integer into a Word integerToWord# :: Integer -> Word# -{-# NOINLINE integerToWord# #-} +{-# NOINLINE[0] integerToWord# #-} -- See Note [Integer constant folding] integerToWord# (IS i) = int2Word# i integerToWord# (IP bn) = bigNatToWord# bn integerToWord# (IN bn) = int2Word# (negateInt# (word2Int# (bigNatToWord# bn))) -- | Truncate an Integer into a Word integerToWord :: Integer -> Word +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] integerToWord !i = W# (integerToWord# i) -- | Convert a Natural into an Integer integerFromNatural :: Natural -> Integer -{-# NOINLINE integerFromNatural #-} +{-# NOINLINE[0] integerFromNatural #-} -- See Note [Integer constant folding] integerFromNatural (NS x) = integerFromWord# x integerFromNatural (NB x) = integerFromBigNat# x -- | Convert a list of Word into an Integer integerFromWordList :: Bool -> [Word] -> Integer +{-# INLINE integerFromWordList #-} -- See Note [Integer constant folding] integerFromWordList True ws = integerFromBigNatNeg# (bigNatFromWordList ws) integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) @@ -209,7 +218,7 @@ integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) -- -- Return 0 for negative Integers. integerToNaturalClamp :: Integer -> Natural -{-# NOINLINE integerToNaturalClamp #-} +{-# NOINLINE[0] integerToNaturalClamp #-} -- See Note [Integer constant folding] integerToNaturalClamp (IS x) | isTrue# (x <# 0#) = naturalZero | True = naturalFromWord# (int2Word# x) @@ -220,7 +229,7 @@ integerToNaturalClamp (IN _) = naturalZero -- -- Return absolute value integerToNatural :: Integer -> Natural -{-# NOINLINE integerToNatural #-} +{-# NOINLINE[0] integerToNatural #-} -- See Note [Integer constant folding] integerToNatural (IS x) = naturalFromWord# (wordFromAbsInt# x) integerToNatural (IP x) = naturalFromBigNat# x integerToNatural (IN x) = naturalFromBigNat# x @@ -237,40 +246,50 @@ integerIsNegative# (IN _) = 1# -- | Negative predicate integerIsNegative :: Integer -> Bool +{-# INLINE integerIsNegative #-} -- See Note [Integer constant folding] integerIsNegative !i = isTrue# (integerIsNegative# i) -- | Zero predicate integerIsZero :: Integer -> Bool +{-# INLINE integerIsZero #-} -- See Note [Integer constant folding] integerIsZero (IS 0#) = True integerIsZero _ = False -- | Not-equal predicate. integerNe :: Integer -> Integer -> Bool +{-# INLINE integerNe #-} -- See Note [Integer constant folding] integerNe !x !y = isTrue# (integerNe# x y) -- | Equal predicate. integerEq :: Integer -> Integer -> Bool +{-# INLINE integerEq #-} -- See Note [Integer constant folding] integerEq !x !y = isTrue# (integerEq# x y) -- | Lower-or-equal predicate. integerLe :: Integer -> Integer -> Bool +{-# INLINE integerLe #-} -- See Note [Integer constant folding] integerLe !x !y = isTrue# (integerLe# x y) -- | Lower predicate. integerLt :: Integer -> Integer -> Bool +{-# INLINE integerLt #-} -- See Note [Integer constant folding] integerLt !x !y = isTrue# (integerLt# x y) -- | Greater predicate. integerGt :: Integer -> Integer -> Bool +{-# INLINE integerGt #-} -- See Note [Integer constant folding] integerGt !x !y = isTrue# (integerGt# x y) -- | Greater-or-equal predicate. integerGe :: Integer -> Integer -> Bool +{-# INLINE integerGe #-} -- See Note [Integer constant folding] integerGe !x !y = isTrue# (integerGe# x y) -- | Equal predicate. integerEq# :: Integer -> Integer -> Bool# -{-# NOINLINE integerEq# #-} +{-# NOINLINE integerEq# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerEq# (IS x) (IS y) = x ==# y integerEq# (IN x) (IN y) = bigNatEq# x y integerEq# (IP x) (IP y) = bigNatEq# x y @@ -278,7 +297,9 @@ integerEq# _ _ = 0# -- | Not-equal predicate. integerNe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerNe# #-} +{-# NOINLINE integerNe# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerNe# (IS x) (IS y) = x /=# y integerNe# (IN x) (IN y) = bigNatNe# x y integerNe# (IP x) (IP y) = bigNatNe# x y @@ -286,39 +307,43 @@ integerNe# _ _ = 1# -- | Greater predicate. integerGt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGt# #-} +{-# NOINLINE[0] integerGt# #-} -- See Note [Integer constant folding] integerGt# (IS x) (IS y) = x ># y integerGt# x y | GT <- integerCompare x y = 1# integerGt# _ _ = 0# -- | Lower-or-equal predicate. integerLe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLe# #-} +{-# NOINLINE[0] integerLe# #-} -- See Note [Integer constant folding] integerLe# (IS x) (IS y) = x <=# y integerLe# x y | GT <- integerCompare x y = 0# integerLe# _ _ = 1# -- | Lower predicate. integerLt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLt# #-} +{-# NOINLINE[0] integerLt# #-} -- See Note [Integer constant folding] integerLt# (IS x) (IS y) = x <# y integerLt# x y | LT <- integerCompare x y = 1# integerLt# _ _ = 0# -- | Greater-or-equal predicate. integerGe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGe# #-} +{-# NOINLINE[0] integerGe# #-} -- See Note [Integer constant folding] integerGe# (IS x) (IS y) = x >=# y integerGe# x y | LT <- integerCompare x y = 0# integerGe# _ _ = 1# instance Eq Integer where + {-# INLINE (==) #-} -- See Note [Integer constant folding] (==) = integerEq + {-# INLINE (/=) #-} -- See Note [Integer constant folding] (/=) = integerNe -- | Compare two Integer integerCompare :: Integer -> Integer -> Ordering -{-# NOINLINE integerCompare #-} +{-# NOINLINE integerCompare #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerCompare (IS x) (IS y) = compareInt# x y integerCompare (IP x) (IP y) = bigNatCompare x y integerCompare (IN x) (IN y) = bigNatCompare y x @@ -330,6 +355,7 @@ integerCompare (IP _) (IN _) = GT integerCompare (IN _) (IP _) = LT instance Ord Integer where + {-# INLINE compare #-} -- See Note [Integer constant folding] compare = integerCompare --------------------------------------------------------------------- @@ -338,7 +364,7 @@ instance Ord Integer where -- | Subtract one 'Integer' from another. integerSub :: Integer -> Integer -> Integer -{-# NOINLINE integerSub #-} +{-# NOINLINE[0] integerSub #-} -- See Note [Integer constant folding] integerSub !x (IS 0#) = x integerSub (IS x#) (IS y#) = case subIntC# x# y# of @@ -384,7 +410,7 @@ integerSub (IN x) (IS y#) -- | Add two 'Integer's integerAdd :: Integer -> Integer -> Integer -{-# NOINLINE integerAdd #-} +{-# NOINLINE[0] integerAdd #-} -- See Note [Integer constant folding] integerAdd !x (IS 0#) = x integerAdd (IS 0#) y = y integerAdd (IS x#) (IS y#) @@ -413,7 +439,7 @@ integerAdd (IP x) (IN y) -- | Multiply two 'Integer's integerMul :: Integer -> Integer -> Integer -{-# NOINLINE integerMul #-} +{-# NOINLINE[0] integerMul #-} -- See Note [Integer constant folding] integerMul !_ (IS 0#) = IS 0# integerMul (IS 0#) _ = IS 0# integerMul x (IS 1#) = x @@ -478,7 +504,7 @@ integerMul (IN x) (IS y) -- IP is used iff n > maxBound::Int -- IN is used iff n < minBound::Int integerNegate :: Integer -> Integer -{-# NOINLINE integerNegate #-} +{-# NOINLINE[0] integerNegate #-} -- See Note [Integer constant folding] integerNegate (IN b) = IP b integerNegate (IS INT_MINBOUND#) = IP (bigNatFromWord# ABS_INT_MINBOUND##) integerNegate (IS i) = IS (negateInt# i) @@ -489,7 +515,7 @@ integerNegate (IP b) -- | Compute absolute value of an 'Integer' integerAbs :: Integer -> Integer -{-# NOINLINE integerAbs #-} +{-# NOINLINE[0] integerAbs #-} -- See Note [Integer constant folding] integerAbs (IN i) = IP i integerAbs n@(IP _) = n integerAbs n@(IS i) @@ -501,13 +527,13 @@ integerAbs n@(IS i) -- | Return @-1@, @0@, and @1@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum :: Integer -> Integer -{-# NOINLINE integerSignum #-} +{-# NOINLINE[0] integerSignum #-} -- See Note [Integer constant folding] integerSignum !j = IS (integerSignum# j) -- | Return @-1#@, @0#@, and @1#@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum# :: Integer -> Int# -{-# NOINLINE integerSignum# #-} +{-# NOINLINE[0] integerSignum# #-} -- See Note [Integer constant folding] integerSignum# (IN _) = -1# integerSignum# (IS i#) = sgnI# i# integerSignum# (IP _ ) = 1# @@ -515,7 +541,7 @@ integerSignum# (IP _ ) = 1# -- | Count number of set bits. For negative arguments returns -- the negated population count of the absolute value. integerPopCount# :: Integer -> Int# -{-# NOINLINE integerPopCount# #-} +{-# NOINLINE[0] integerPopCount# #-} -- See Note [Integer constant folding] integerPopCount# (IS i) | isTrue# (i >=# 0#) = word2Int# (popCntI# i) | True = negateInt# (word2Int# (popCntI# (negateInt# i))) @@ -524,7 +550,7 @@ integerPopCount# (IN bn) = negateInt# (word2Int# (bigNatPopCount# bn)) -- | Positive 'Integer' for which only /n/-th bit is set integerBit# :: Word# -> Integer -{-# NOINLINE integerBit# #-} +{-# NOINLINE[0] integerBit# #-} -- See Note [Integer constant folding] integerBit# i | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##)) = IS (uncheckedIShiftL# 1# (word2Int# i)) @@ -533,13 +559,14 @@ integerBit# i -- | 'Integer' for which only /n/-th bit is set integerBit :: Word -> Integer +{-# INLINE integerBit #-} -- See Note [Integer constant folding] integerBit (W# i) = integerBit# i -- | Test if /n/-th bit is set. -- -- Fake 2's complement for negative values (might be slow) integerTestBit# :: Integer -> Word# -> Bool# -{-# NOINLINE integerTestBit# #-} +{-# NOINLINE[0] integerTestBit# #-} -- See Note [Integer constant folding] integerTestBit# (IS x) i | isTrue# (i `ltWord#` WORD_SIZE_IN_BITS##) = testBitI# x i @@ -569,13 +596,14 @@ integerTestBit# (IN x) i -- -- Fake 2's complement for negative values (might be slow) integerTestBit :: Integer -> Word -> Bool +{-# INLINE integerTestBit #-} -- See Note [Integer constant folding] integerTestBit !i (W# n) = isTrue# (integerTestBit# i n) -- | Shift-right operation -- -- Fake 2's complement for negative values (might be slow) integerShiftR# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftR# #-} +{-# NOINLINE[0] integerShiftR# #-} -- See Note [Integer constant folding] integerShiftR# !x 0## = x integerShiftR# (IS i) n = IS (iShiftRA# i (word2Int# n)) where @@ -592,11 +620,12 @@ integerShiftR# (IN bn) n = -- -- Fake 2's complement for negative values (might be slow) integerShiftR :: Integer -> Word -> Integer +{-# INLINE integerShiftR #-} -- See Note [Integer constant folding] integerShiftR !x (W# w) = integerShiftR# x w -- | Shift-left operation integerShiftL# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftL# #-} +{-# NOINLINE[0] integerShiftL# #-} -- See Note [Integer constant folding] integerShiftL# !x 0## = x integerShiftL# (IS 0#) _ = IS 0# integerShiftL# (IS 1#) n = integerBit# n @@ -611,13 +640,14 @@ integerShiftL# (IN bn) n = IN (bigNatShiftL# bn n) -- Remember that bits are stored in sign-magnitude form, hence the behavior of -- negative Integers is different from negative Int's behavior. integerShiftL :: Integer -> Word -> Integer +{-# INLINE integerShiftL #-} -- See Note [Integer constant folding] integerShiftL !x (W# w) = integerShiftL# x w -- | Bitwise OR operation -- -- Fake 2's complement for negative values (might be slow) integerOr :: Integer -> Integer -> Integer -{-# NOINLINE integerOr #-} +{-# NOINLINE[0] integerOr #-} -- See Note [Integer constant folding] integerOr a b = case a of IS 0# -> b IS -1# -> IS -1# @@ -676,7 +706,7 @@ integerOr a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerXor :: Integer -> Integer -> Integer -{-# NOINLINE integerXor #-} +{-# NOINLINE[0] integerXor #-} -- See Note [Integer constant folding] integerXor a b = case a of IS 0# -> b IS -1# -> integerComplement b @@ -731,7 +761,7 @@ integerXor a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerAnd :: Integer -> Integer -> Integer -{-# NOINLINE integerAnd #-} +{-# NOINLINE[0] integerAnd #-} -- See Note [Integer constant folding] integerAnd a b = case a of IS 0# -> IS 0# IS -1# -> b @@ -766,7 +796,7 @@ integerAnd a b = case a of -- | Binary complement of the integerComplement :: Integer -> Integer -{-# NOINLINE integerComplement #-} +{-# NOINLINE[0] integerComplement #-} -- See Note [Integer constant folding] integerComplement (IS x) = IS (notI# x) integerComplement (IP x) = IN (bigNatAddWord# x 1##) integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) @@ -777,7 +807,7 @@ integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerQuotRem# #-} +{-# NOINLINE[0] integerQuotRem# #-} -- See Note [Integer constant folding] integerQuotRem# !n (IS 1#) = (# n, IS 0# #) integerQuotRem# !n (IS -1#) = let !q = integerNegate n in (# q, (IS 0#) #) integerQuotRem# !_ (IS 0#) = case raiseDivZero of @@ -815,12 +845,13 @@ integerQuotRem# n@(IS n#) (IP d) -- need to account for (IS minBound) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerQuotRem #-} -- See Note [Integer constant folding] integerQuotRem !x !y = case integerQuotRem# x y of (# q, r #) -> (q, r) integerQuot :: Integer -> Integer -> Integer -{-# NOINLINE integerQuot #-} +{-# NOINLINE[0] integerQuot #-} -- See Note [Integer constant folding] integerQuot !n (IS 1#) = n integerQuot !n (IS -1#) = integerNegate n integerQuot !_ (IS 0#) = raiseDivZero @@ -841,7 +872,7 @@ integerQuot (IN n) (IN d) = integerFromBigNat# (bigNatQuot n d) integerQuot n d = case integerQuotRem# n d of (# q, _ #) -> q integerRem :: Integer -> Integer -> Integer -{-# NOINLINE integerRem #-} +{-# NOINLINE[0] integerRem #-} -- See Note [Integer constant folding] integerRem !_ (IS 1#) = IS 0# integerRem _ (IS -1#) = IS 0# integerRem _ (IS 0#) = IS (remInt# 0# 0#) @@ -863,7 +894,7 @@ integerRem n d = case integerQuotRem# n d of (# _, r #) -> r -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerDivMod# #-} +{-# NOINLINE[0] integerDivMod# #-} -- See Note [Integer constant folding] integerDivMod# !n !d | isTrue# (integerSignum# r ==# negateInt# (integerSignum# d)) = let !q' = integerSub q (IS 1#) @@ -878,12 +909,13 @@ integerDivMod# !n !d -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerDivMod #-} -- See Note [Integer constant folding] integerDivMod !n !d = case integerDivMod# n d of (# q,r #) -> (q,r) integerDiv :: Integer -> Integer -> Integer -{-# NOINLINE integerDiv #-} +{-# NOINLINE[0] integerDiv #-} -- See Note [Integer constant folding] integerDiv !n !d -- same-sign ops can be handled by more efficient 'integerQuot' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerQuot n d @@ -891,7 +923,7 @@ integerDiv !n !d integerMod :: Integer -> Integer -> Integer -{-# NOINLINE integerMod #-} +{-# NOINLINE[0] integerMod #-} -- See Note [Integer constant folding] integerMod !n !d -- same-sign ops can be handled by more efficient 'integerRem' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerRem n d @@ -899,7 +931,7 @@ integerMod !n !d -- | Compute greatest common divisor. integerGcd :: Integer -> Integer -> Integer -{-# NOINLINE integerGcd #-} +{-# NOINLINE[0] integerGcd #-} -- See Note [Integer constant folding] integerGcd (IS 0#) !b = integerAbs b integerGcd a (IS 0#) = integerAbs a integerGcd (IS 1#) _ = IS 1# @@ -917,7 +949,7 @@ integerGcd (IP a) (IS b) = integerFromWord# (bigNatGcdWord# a (int2Word# (ab -- | Compute least common multiple. integerLcm :: Integer -> Integer -> Integer -{-# NOINLINE integerLcm #-} +{-# NOINLINE[0] integerLcm #-} -- See Note [Integer constant folding] integerLcm (IS 0#) !_ = IS 0# integerLcm (IS 1#) b = integerAbs b integerLcm (IS -1#) b = integerAbs b @@ -931,6 +963,7 @@ integerLcm a b = (aa `integerQuot` (aa `integerGcd` ab)) `integerMul` ab -- | Square a Integer integerSqr :: Integer -> Integer +{-# INLINE integerSqr #-} -- See Note [Integer constant folding] integerSqr !a = integerMul a a @@ -948,6 +981,7 @@ integerLog2# (IP b) = bigNatLog2# b -- -- For numbers <= 0, return 0 integerLog2 :: Integer -> Word +{-# INLINE integerLog2 #-} -- See Note [Integer constant folding] integerLog2 !i = W# (integerLog2# i) -- | Logarithm (floor) for an arbitrary base @@ -962,6 +996,7 @@ integerLogBaseWord# base !i -- -- For numbers <= 0, return 0 integerLogBaseWord :: Word -> Integer -> Word +{-# INLINE integerLogBaseWord #-} -- See Note [Integer constant folding] integerLogBaseWord (W# base) !i = W# (integerLogBaseWord# base i) -- | Logarithm (floor) for an arbitrary base @@ -977,6 +1012,7 @@ integerLogBase# !base !i -- -- For numbers <= 0, return 0 integerLogBase :: Integer -> Integer -> Word +{-# INLINE integerLogBase #-} -- See Note [Integer constant folding] integerLogBase !base !i = W# (integerLogBase# base i) -- | Indicate if the value is a power of two and which one @@ -991,7 +1027,7 @@ integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w -- | Convert an Int64# into an Integer on 32-bit architectures integerFromInt64# :: Int64# -> Integer -{-# NOINLINE integerFromInt64# #-} +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !i | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#) &&# (i `geInt64#` intToInt64# -0x80000000#)) @@ -1005,7 +1041,7 @@ integerFromInt64# !i -- | Convert a Word64# into an Integer on 32-bit architectures integerFromWord64# :: Word64# -> Integer -{-# NOINLINE integerFromWord64# #-} +{-# NOINLINE[0] integerFromWord64# #-} -- See Note [Integer constant folding] integerFromWord64# !w | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##) = IS (int64ToInt# (word64ToInt64# w)) @@ -1014,14 +1050,14 @@ integerFromWord64# !w -- | Convert an Integer into an Int64# on 32-bit architectures integerToInt64# :: Integer -> Int64# -{-# NOINLINE integerToInt64# #-} +{-# NOINLINE[0] integerToInt64# #-} -- See Note [Integer constant folding] integerToInt64# (IS i) = intToInt64# i integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b) integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b)) -- | Convert an Integer into a Word64# on 32-bit architectures integerToWord64# :: Integer -> Word64# -{-# NOINLINE integerToWord64# #-} +{-# NOINLINE[0] integerToWord64# #-} -- See Note [Integer constant folding] integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) integerToWord64# (IP b) = bigNatToWord64# b integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b))) @@ -1030,6 +1066,7 @@ integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatTo -- | Convert an Int64# into an Integer on 64-bit architectures integerFromInt64# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !x = IS x #endif @@ -1040,18 +1077,19 @@ integerFromInt64# !x = IS x -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble# :: Double# -> (# Integer, Int# #) -{-# NOINLINE integerDecodeDouble# #-} +{-# NOINLINE[0] integerDecodeDouble# #-} -- See Note [Integer constant folding] integerDecodeDouble# !x = case decodeDouble_Int64# x of (# m, e #) -> (# integerFromInt64# m, e #) -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble :: Double -> (Integer, Int) +{-# INLINE integerDecodeDouble #-} -- See Note [Integer constant folding] integerDecodeDouble (D# x) = case integerDecodeDouble# x of (# m, e #) -> (m, I# e) -- | Encode (# Integer mantissa, Int# exponent #) into a Double# integerEncodeDouble# :: Integer -> Int# -> Double# -{-# NOINLINE integerEncodeDouble# #-} +{-# NOINLINE[0] integerEncodeDouble# #-} -- See Note [Integer constant folding] integerEncodeDouble# (IS i) 0# = int2Double# i integerEncodeDouble# (IS i) e = intEncodeDouble# i e integerEncodeDouble# (IP b) e = bigNatEncodeDouble# b e @@ -1059,23 +1097,24 @@ integerEncodeDouble# (IN b) e = negateDouble# (bigNatEncodeDouble# b e) -- | Encode (Integer mantissa, Int exponent) into a Double integerEncodeDouble :: Integer -> Int -> Double +{-# INLINE integerEncodeDouble #-} -- See Note [Integer constant folding] integerEncodeDouble !m (I# e) = D# (integerEncodeDouble# m e) -- | Encode an Integer (mantissa) into a Double# integerToDouble# :: Integer -> Double# -{-# NOINLINE integerToDouble# #-} +{-# NOINLINE[0] integerToDouble# #-} -- See Note [Integer constant folding] integerToDouble# !i = integerEncodeDouble# i 0# -- | Encode an Integer (mantissa) into a Float# integerToFloat# :: Integer -> Float# -{-# NOINLINE integerToFloat# #-} +{-# NOINLINE[0] integerToFloat# #-} -- See Note [Integer constant folding] integerToFloat# !i = integerEncodeFloat# i 0# -- | Encode (# Integer mantissa, Int# exponent #) into a Float# -- -- TODO: Not sure if it's worth to write 'Float' optimized versions here integerEncodeFloat# :: Integer -> Int# -> Float# -{-# NOINLINE integerEncodeFloat# #-} +{-# NOINLINE[0] integerEncodeFloat# #-} -- See Note [Integer constant folding] integerEncodeFloat# !m 0# = double2Float# (integerToDouble# m) integerEncodeFloat# !m e = double2Float# (integerEncodeDouble# m e) @@ -1105,6 +1144,7 @@ integerToAddr# (IN n) = bigNatToAddr# n -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToAddr :: Integer -> Addr# -> Bool# -> IO Word +{-# INLINE integerToAddr #-} -- See Note [Integer constant folding] integerToAddr a addr e = IO \s -> case integerToAddr# a addr e s of (# s', w #) -> (# s', W# w #) @@ -1132,6 +1172,7 @@ integerFromAddr# sz addr e s = -- -- Null higher limbs are automatically trimed. integerFromAddr :: Word# -> Addr# -> Bool# -> IO Integer +{-# INLINE integerFromAddr #-} -- See Note [Integer constant folding] integerFromAddr sz addr e = IO (integerFromAddr# sz addr e) @@ -1154,6 +1195,7 @@ integerToMutableByteArray# (IN a) = bigNatToMutableByteArray# a -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word +{-# INLINE integerToMutableByteArray #-} -- See Note [Integer constant folding] integerToMutableByteArray i mba w e = IO \s -> case integerToMutableByteArray# i mba w e s of (# s', r #) -> (# s', W# r #) @@ -1180,6 +1222,7 @@ integerFromByteArray# sz ba off e s = case bigNatFromByteArray# sz ba off e s of -- -- Null higher limbs are automatically trimed. integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer +{-# INLINE integerFromByteArray #-} -- See Note [Integer constant folding] integerFromByteArray sz ba off e = case runRW# (integerFromByteArray# sz ba off e) of (# _, i #) -> i @@ -1212,5 +1255,45 @@ integerGcde :: Integer -> Integer -> ( Integer, Integer, Integer) +{-# INLINE integerGcde #-} -- See Note [Integer constant folding] integerGcde a b = case integerGcde# a b of (# g,x,y #) -> (g,x,y) + +{- Note [Integer constant folding] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We define constant folding rules in "GHC.Core.Opt.ConstantFold" for most of the + at integer*#@ operations in this module, hence they are marked NOINLINE[0]. + +Why NOINLINE[0] rather than NOINLINE? Because + + 1. We still delay inlining long enough for the constant-folding RULEs + to fire + 2. The compiler has the option to inlining the operations late, possibly + cancelling away boxes in the process. + +Why NOINLINE[0] rather than INLINE? Because + + 3. We don't unconditionally inline huge definitions such as + `integerDiv`, which would lead to code bloat at pretty much no + gain. + 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. + `integerDiv`, there is no gain in inlining the unoptimised + unfoldings. + +But since we potentially inline the constant folded operations in phase 0, we +have to make sure that *all* callers that want to take part in constant folding +are marked INLINE. Otherwise, we'd store optimised unfoldings for them, in which +the constant folded functions are inlined. +That concerns for most of the @integer*@ without trailing hash in this module, +as well as the type class instances for 'Eq', 'Ord', 'Num', 'Integral', +'RealFloat' (which is for 'Double'!), etc. + +There are a couple of constant-folded functions that require special treatment, +though: + + * `integerEq`, `integerNe`, `integerCompare`: They are huge and lead to + regressions when inlined. Solution: mark these NOINLINE. + * Under -O2, `integerAdd` will be specialised by SpecConstr. These + specialisations defeat constant folding. + Solution: -fno-spec-constr for this module. +-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8320f630be066ec25245f18a67a38cdd05d211ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8320f630be066ec25245f18a67a38cdd05d211ee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 10:09:04 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 06:09:04 -0400 Subject: [Git][ghc/ghc][wip/T18765] 25 commits: Make the parser module less dependent on DynFlags Message-ID: <5f76fc404f101_80b3f849643b854160914c@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18765 at Glasgow Haskell Compiler / GHC Commits: 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - 7f8866bf by Sebastian Graf at 2020-10-02T12:08:53+02:00 s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) This defeats constant-folding in the final phases of the Simplifier, but enables us to get rid of allocations by inlining calls that can't be constant-folded. `NOINLINE[0]` is a better choice than `NOINLINE`, because 1. We still delay inlining long enough for the constant-folding RULEs to fire 2. The compiler has the option to inlining them late, possibly cancelling away boxes in the process. `NOINLINE[0]` is a better choice than `INLINE[0]`, because 3. We don't unconditionally inline huge definitions such as `integerDiv`, which would lead to code bloat at pretty much no gain. 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. `integerDiv`, there is no gain in inlining the unoptimised unfoldings. We also have to mark all callers that want to participate in constant folding as `INLINE`. See the new `Note [Integer constant folding]` for details. Fixes #18765. Metric Decrease: T10359 - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Backpack/Syntax.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Ppr.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Session.hs-boot - compiler/GHC/HsToCore/Pmc.hs - compiler/GHC/HsToCore/Pmc/Check.hs - compiler/GHC/HsToCore/Pmc/Desugar.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8320f630be066ec25245f18a67a38cdd05d211ee...7f8866bf419d9dce6666f93ea8ea551ac9b1a0f4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8320f630be066ec25245f18a67a38cdd05d211ee...7f8866bf419d9dce6666f93ea8ea551ac9b1a0f4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 10:32:02 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 06:32:02 -0400 Subject: [Git][ghc/ghc][wip/T18765] s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) Message-ID: <5f7701a239fcb_80b3f846919ac1c1609451f@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18765 at Glasgow Haskell Compiler / GHC Commits: caa84914 by Sebastian Graf at 2020-10-02T12:31:50+02:00 s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) This defeats constant-folding in the final phases of the Simplifier, but enables us to get rid of allocations by inlining calls that can't be constant-folded. `NOINLINE[0]` is a better choice than `NOINLINE`, because 1. We still delay inlining long enough for the constant-folding RULEs to fire 2. The compiler has the option to inlining them late, possibly cancelling away boxes in the process. `NOINLINE[0]` is a better choice than `INLINE[0]`, because 3. We don't unconditionally inline huge definitions such as `integerDiv`, which would lead to code bloat at pretty much no gain. 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. `integerDiv`, there is no gain in inlining the unoptimised unfoldings. We also have to mark all callers that want to participate in constant folding as `INLINE`. See the new `Note [Integer constant folding]` for details. Fixes #18765. Metric Decrease: T10359 - - - - - 9 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/SimpleOpt.hs - libraries/base/GHC/Float.hs - libraries/base/GHC/Int.hs - libraries/base/GHC/Integer.hs - libraries/base/GHC/Num.hs - libraries/base/GHC/Real.hs - libraries/base/GHC/Word.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1317,7 +1317,6 @@ builtinBignumRules _ = , rule_IntegerFromLitNum "Word64# -> Integer" integerFromWord64Name , rule_IntegerFromLitNum "Natural -> Integer" integerFromNaturalName , rule_convert "Integer -> Word#" integerToWordName mkWordLitWord - , rule_convert "Integer -> Int#" integerToIntName mkIntLitInt , rule_convert "Integer -> Word64#" integerToWord64Name (\_ -> mkWord64LitWord64) , rule_convert "Integer -> Int64#" integerToInt64Name (\_ -> mkInt64LitInt64) , rule_binopi "integerAdd" integerAddName (+) @@ -1347,7 +1346,7 @@ builtinBignumRules _ = , rule_shift_op "integerShiftL" integerShiftLName shiftL , rule_shift_op "integerShiftR" integerShiftRName shiftR , rule_integerBit "integerBit" integerBitName - -- See Note [Integer division constant folding] in libraries/base/GHC/Real.hs + -- See Note [Integer constant folding] in "GHC.Num.Integer" , rule_divop_one "integerQuot" integerQuotName quot , rule_divop_one "integerRem" integerRemName rem , rule_divop_one "integerDiv" integerDivName div ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1279,13 +1279,22 @@ exprIsLiteral_maybe env@(_, id_unf) e -> Just l Var v | Just rhs <- expandUnfolding_maybe (id_unf v) - , Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env rhs - , Just (LitNumber _ i) <- exprIsLiteral_maybe env arg - -> if - | dc == naturalNSDataCon -> Just (mkLitNatural i) - | dc == integerISDataCon -> Just (mkLitInteger i) - | otherwise -> Nothing - _ -> Nothing + , Just num <- match_bignum env rhs + -> Just num + _ + | Just num <- match_bignum env e + -> Just num + _ -> Nothing + where + match_bignum env e + | Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env e + , Just (LitNumber _ i) <- exprIsLiteral_maybe env arg + = if + | dc == naturalNSDataCon -> Just (mkLitNatural i) + | dc == integerISDataCon -> Just (mkLitInteger i) + | otherwise -> Nothing + | otherwise + = Nothing {- Note [exprIsLambda_maybe] ===================================== libraries/base/GHC/Float.hs ===================================== @@ -494,6 +494,7 @@ instance Num Double where -- | @since 2.01 instance Real Double where + {-# INLINE toRational #-} -- See Note [Integer constant folding] toRational (D# x#) = case integerDecodeDouble# x# of (# m, e# #) @@ -580,11 +581,7 @@ instance Floating Double where -- | @since 2.01 instance RealFrac Double where - -- ceiling, floor, and truncate are all small - {-# INLINE [1] ceiling #-} - {-# INLINE [1] floor #-} - {-# INLINE [1] truncate #-} - + {-# INLINE properFraction #-} -- See Note [Integer constant folding] properFraction x = case (decodeFloat x) of { (m,n) -> if n >= 0 then @@ -595,9 +592,11 @@ instance RealFrac Double where } } + {-# INLINE truncate #-} -- See Note [Integer constant folding] truncate x = case properFraction x of (n,_) -> n + {-# INLINE round #-} -- See Note [Integer constant folding] round x = case properFraction x of (n,r) -> let m = if r < 0.0 then n - 1 else n + 1 @@ -608,9 +607,11 @@ instance RealFrac Double where EQ -> if even n then n else m GT -> m + {-# INLINE ceiling #-} -- See Note [Integer constant folding] ceiling x = case properFraction x of (n,r) -> if r > 0.0 then n + 1 else n + {-# INLINE floor #-} -- See Note [Integer constant folding] floor x = case properFraction x of (n,r) -> if r < 0.0 then n - 1 else n @@ -620,18 +621,23 @@ instance RealFloat Double where floatDigits _ = DBL_MANT_DIG -- ditto floatRange _ = (DBL_MIN_EXP, DBL_MAX_EXP) -- ditto + {-# INLINE decodeFloat #-} -- See Note [Integer constant folding] decodeFloat (D# x#) = case integerDecodeDouble# x# of (# i, j #) -> (i, I# j) + {-# INLINE encodeFloat #-} -- See Note [Integer constant folding] encodeFloat i (I# j) = D# (integerEncodeDouble# i j) + {-# INLINE exponent #-} -- See Note [Integer constant folding] exponent x = case decodeFloat x of (m,n) -> if m == 0 then 0 else n + floatDigits x + {-# INLINE significand #-} -- See Note [Integer constant folding] significand x = case decodeFloat x of (m,_) -> encodeFloat m (negate (floatDigits x)) + {-# INLINE scaleFloat #-} -- See Note [Integer constant folding] scaleFloat 0 x = x scaleFloat k x | isFix = x ===================================== libraries/base/GHC/Int.hs ===================================== @@ -106,6 +106,7 @@ instance Num Int8 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I8# (narrow8Int# (integerToInt# i)) -- | @since 2.01 @@ -160,7 +161,8 @@ instance Integral Int8 where (# d, m #) -> (I8# (narrow8Int# d), I8# (narrow8Int# m)) - toInteger (I8# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I8# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int8 where @@ -313,6 +315,7 @@ instance Num Int16 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I16# (narrow16Int# (integerToInt# i)) -- | @since 2.01 @@ -367,7 +370,8 @@ instance Integral Int16 where (# d, m #) -> (I16# (narrow16Int# d), I16# (narrow16Int# m)) - toInteger (I16# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I16# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int16 where @@ -525,6 +529,7 @@ instance Num Int32 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I32# (narrow32Int# (integerToInt# i)) -- | @since 2.01 @@ -587,7 +592,8 @@ instance Integral Int32 where (# d, m #) -> (I32# (narrow32Int# d), I32# (narrow32Int# m)) - toInteger (I32# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I32# x) = integerFromInt# x -- | @since 2.01 instance Read Int32 where @@ -748,6 +754,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt64# i) -- | @since 2.01 @@ -804,6 +811,7 @@ instance Integral Int64 where | y == (-1) && x == minBound = (overflowError, 0) | otherwise = (I64# (x# `divInt64#` y#), I64# (x# `modInt64#` y#)) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (I64# x) = integerFromInt64# x @@ -953,6 +961,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt# i) -- | @since 2.01 @@ -1006,7 +1015,8 @@ instance Integral Int64 where | otherwise = case x# `divModInt#` y# of (# d, m #) -> (I64# d, I64# m) - toInteger (I64# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I64# x) = integerFromInt64# x -- | @since 2.01 instance Read Int64 where ===================================== libraries/base/GHC/Integer.hs ===================================== @@ -64,156 +64,203 @@ import GHC.Prim import GHC.Types smallInteger :: Int# -> Integer +{-# INLINE smallInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer smallInteger = I.integerFromInt# integerToInt :: Integer -> Int# +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt = I.integerToInt# wordToInteger :: Word# -> Integer +{-# INLINE wordToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer wordToInteger = I.integerFromWord# integerToWord :: Integer -> Word# +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord = I.integerToWord# #if WORD_SIZE_IN_BITS < 64 word64ToInteger :: Word64# -> Integer +{-# INLINE word64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer word64ToInteger = I.integerFromWord64# integerToWord64 :: Integer -> Word64# +{-# INLINE integerToWord64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord64 = I.integerToWord64# int64ToInteger :: Int64# -> Integer +{-# INLINE int64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer int64ToInteger = I.integerFromInt64# integerToInt64 :: Integer -> Int64# +{-# INLINE integerToInt64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt64 = I.integerToInt64# #endif encodeFloatInteger :: Integer -> Int# -> Float# +{-# INLINE encodeFloatInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeFloatInteger = I.integerEncodeFloat# floatFromInteger :: Integer -> Float# +{-# INLINE floatFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer floatFromInteger = I.integerToFloat# encodeDoubleInteger :: Integer -> Int# -> Double# +{-# INLINE encodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeDoubleInteger = I.integerEncodeDouble# doubleFromInteger :: Integer -> Double# +{-# INLINE doubleFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer doubleFromInteger = I.integerToDouble# decodeDoubleInteger :: Double# -> (# Integer, Int# #) +{-# INLINE decodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer decodeDoubleInteger = I.integerDecodeDouble# plusInteger :: Integer -> Integer -> Integer +{-# INLINE plusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer plusInteger = I.integerAdd minusInteger :: Integer -> Integer -> Integer +{-# INLINE minusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer minusInteger = I.integerSub timesInteger :: Integer -> Integer -> Integer +{-# INLINE timesInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer timesInteger = I.integerMul negateInteger :: Integer -> Integer +{-# INLINE negateInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer negateInteger = I.integerNegate absInteger :: Integer -> Integer +{-# INLINE absInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer absInteger = I.integerAbs signumInteger :: Integer -> Integer +{-# INLINE signumInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer signumInteger = I.integerSignum divModInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE divModInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divModInteger = I.integerDivMod# divInteger :: Integer -> Integer -> Integer +{-# INLINE divInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divInteger = I.integerDiv modInteger :: Integer -> Integer -> Integer +{-# INLINE modInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer modInteger = I.integerMod quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE quotRemInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotRemInteger = I.integerQuotRem# quotInteger :: Integer -> Integer -> Integer +{-# INLINE quotInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotInteger = I.integerQuot remInteger :: Integer -> Integer -> Integer +{-# INLINE remInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer remInteger = I.integerRem eqInteger :: Integer -> Integer -> Bool +{-# INLINE eqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger = I.integerEq neqInteger :: Integer -> Integer -> Bool +{-# INLINE neqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger = I.integerNe leInteger :: Integer -> Integer -> Bool +{-# INLINE leInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger = I.integerLe gtInteger :: Integer -> Integer -> Bool +{-# INLINE gtInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger = I.integerGt ltInteger :: Integer -> Integer -> Bool +{-# INLINE ltInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger = I.integerLt geInteger :: Integer -> Integer -> Bool +{-# INLINE geInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger = I.integerGe compareInteger :: Integer -> Integer -> Ordering +{-# INLINE compareInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer compareInteger = I.integerCompare eqInteger# :: Integer -> Integer -> Int# +{-# INLINE eqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger# = I.integerEq# neqInteger# :: Integer -> Integer -> Int# +{-# INLINE neqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger# = I.integerNe# leInteger# :: Integer -> Integer -> Int# +{-# INLINE leInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger# = I.integerLe# gtInteger# :: Integer -> Integer -> Int# +{-# INLINE gtInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger# = I.integerGt# ltInteger# :: Integer -> Integer -> Int# +{-# INLINE ltInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger# = I.integerLt# geInteger# :: Integer -> Integer -> Int# +{-# INLINE geInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger# = I.integerGe# andInteger :: Integer -> Integer -> Integer +{-# INLINE andInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer andInteger = I.integerAnd orInteger :: Integer -> Integer -> Integer +{-# INLINE orInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer orInteger = I.integerOr xorInteger :: Integer -> Integer -> Integer +{-# INLINE xorInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer xorInteger = I.integerXor complementInteger :: Integer -> Integer +{-# INLINE complementInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer complementInteger = I.integerComplement shiftLInteger :: Integer -> Int# -> Integer +{-# INLINE shiftLInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftLInteger n i = I.integerShiftL# n (int2Word# i) shiftRInteger :: Integer -> Int# -> Integer +{-# INLINE shiftRInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftRInteger n i = I.integerShiftR# n (int2Word# i) testBitInteger :: Integer -> Int# -> Bool +{-# INLINE testBitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer testBitInteger n i = isTrue# (I.integerTestBit# n (int2Word# i)) hashInteger :: Integer -> Int# +{-# INLINE hashInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer hashInteger = I.integerToInt# bitInteger :: Int# -> Integer +{-# INLINE bitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer bitInteger i = I.integerBit# (int2Word# i) popCountInteger :: Integer -> Int# +{-# INLINE popCountInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer popCountInteger = I.integerPopCount# - ===================================== libraries/base/GHC/Num.hs ===================================== @@ -109,7 +109,7 @@ instance Num Int where | n `eqInt` 0 = 0 | otherwise = 1 - {-# INLINE fromInteger #-} -- Just to be sure! + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToInt i -- | @since 2.01 @@ -121,6 +121,7 @@ instance Num Word where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToWord i -- | @since 2.01 @@ -150,6 +151,7 @@ instance Num Natural where | naturalIsZero x = x | otherwise = raise# underflowException + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger x | x < 0 = raise# underflowException | otherwise = integerToNaturalClamp x @@ -160,4 +162,3 @@ instance Num Natural where {-# DEPRECATED quotRemInteger "Use integerQuotRem# instead" #-} quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger = integerQuotRem# - ===================================== libraries/base/GHC/Real.hs ===================================== @@ -324,7 +324,8 @@ instance Real Int where -- | @since 2.0.1 instance Integral Int where - toInteger (I# i) = IS i + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I# x) = integerFromInt# x a `quot` b | b == 0 = divZeroError @@ -399,6 +400,7 @@ instance Integral Word where divMod (W# x#) y@(W# y#) | y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W# x#) = integerFromWord# x# -------------------------------------------------------------- @@ -413,71 +415,60 @@ instance Real Integer where instance Real Natural where toRational n = integerFromNatural n :% 1 --- Note [Integer division constant folding] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- Constant folding of quot, rem, div, mod, divMod and quotRem for Integer --- arguments depends crucially on inlining. Constant folding rules defined in --- GHC.Core.Opt.ConstantFold trigger for integerQuot, integerRem and so on. --- So if calls to quot, rem and so on were not inlined the rules would not fire. --- --- The rules would also not fire if calls to integerQuot and so on were inlined, --- but this does not happen because they are all marked with NOINLINE pragma. - - -- | @since 2.0.1 instance Integral Integer where toInteger n = n - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `integerQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `integerRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `integerDiv` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `integerMod` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `integerDivMod` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `integerQuotRem` d -- | @since 4.8.0.0 instance Integral Natural where + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger = integerFromNatural - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `naturalQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `naturalRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `naturalQuot` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `naturalRem` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `naturalQuotRem` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `naturalQuotRem` d ===================================== libraries/base/GHC/Word.hs ===================================== @@ -112,6 +112,7 @@ instance Num Word8 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W8# (narrow8Word# (integerToWord# i)) -- | @since 2.01 @@ -156,7 +157,8 @@ instance Integral Word8 where divMod (W8# x#) y@(W8# y#) | y /= 0 = (W8# (x# `quotWord#` y#), W8# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W8# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W8# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word8 where @@ -303,6 +305,7 @@ instance Num Word16 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W16# (narrow16Word# (integerToWord# i)) -- | @since 2.01 @@ -347,7 +350,8 @@ instance Integral Word16 where divMod (W16# x#) y@(W16# y#) | y /= 0 = (W16# (x# `quotWord#` y#), W16# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W16# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W16# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word16 where @@ -533,6 +537,7 @@ instance Num Word32 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W32# (narrow32Word# (integerToWord# i)) -- | @since 2.01 @@ -587,15 +592,8 @@ instance Integral Word32 where divMod (W32# x#) y@(W32# y#) | y /= 0 = (W32# (x# `quotWord#` y#), W32# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W32# x#) -#if WORD_SIZE_IN_BITS == 32 - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# -#else - = IS (word2Int# x#) -#endif + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W32# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word32 where @@ -728,6 +726,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord64# i) -- | @since 2.01 @@ -770,6 +769,7 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord64#` y#), W64# (x# `remWord64#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W64# x#) = integerFromWord64# x# -- | @since 2.01 @@ -875,6 +875,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord# i) -- | @since 2.01 @@ -953,11 +954,8 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord#` y#), W64# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W64# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word64 where ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-spec-constr #-} -- See Note [Integer constant folding], + -- the bit about `integerAdd` {-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE BangPatterns #-} @@ -66,6 +68,7 @@ integerCheck# (IN bn) = bigNatCheck# bn &&# (bn `bigNatGtWord#` ABS_INT_MINBOUND -- | Check Integer invariants integerCheck :: Integer -> Bool +{-# INLINE integerCheck #-} integerCheck i = isTrue# (integerCheck# i) -- | Integer Zero @@ -137,15 +140,16 @@ integerToBigNatClamp# _ = bigNatZero# (# #) -- | Create an Integer from an Int# integerFromInt# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt# #-} -- See Note [Integer constant folding] integerFromInt# i = IS i -- | Create an Integer from an Int integerFromInt :: Int -> Integer -integerFromInt (I# i) = IS i +{-# INLINE integerFromInt #-} -- See Note [Integer constant folding] +integerFromInt (I# i) = integerFromInt# i -- | Truncates 'Integer' to least-significant 'Int#' integerToInt# :: Integer -> Int# -{-# NOINLINE integerToInt# #-} integerToInt# (IS i) = i integerToInt# (IP b) = word2Int# (bigNatToWord# b) integerToInt# (IN b) = negateInt# (word2Int# (bigNatToWord# b)) @@ -156,7 +160,7 @@ integerToInt i = I# (integerToInt# i) -- | Convert a Word# into an Integer integerFromWord# :: Word# -> Integer -{-# NOINLINE integerFromWord# #-} +{-# NOINLINE[0] integerFromWord# #-} -- See Note [Integer constant folding] integerFromWord# w | i <- word2Int# w , isTrue# (i >=# 0#) @@ -167,6 +171,7 @@ integerFromWord# w -- | Convert a Word into an Integer integerFromWord :: Word -> Integer +{-# INLINE integerFromWord #-} -- See Note [Integer constant folding] integerFromWord (W# w) = integerFromWord# w -- | Create a negative Integer with the given Word magnitude @@ -185,23 +190,25 @@ integerFromWordSign# _ w = integerFromWordNeg# w -- | Truncate an Integer into a Word integerToWord# :: Integer -> Word# -{-# NOINLINE integerToWord# #-} +{-# NOINLINE[0] integerToWord# #-} -- See Note [Integer constant folding] integerToWord# (IS i) = int2Word# i integerToWord# (IP bn) = bigNatToWord# bn integerToWord# (IN bn) = int2Word# (negateInt# (word2Int# (bigNatToWord# bn))) -- | Truncate an Integer into a Word integerToWord :: Integer -> Word +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] integerToWord !i = W# (integerToWord# i) -- | Convert a Natural into an Integer integerFromNatural :: Natural -> Integer -{-# NOINLINE integerFromNatural #-} +{-# NOINLINE[0] integerFromNatural #-} -- See Note [Integer constant folding] integerFromNatural (NS x) = integerFromWord# x integerFromNatural (NB x) = integerFromBigNat# x -- | Convert a list of Word into an Integer integerFromWordList :: Bool -> [Word] -> Integer +{-# INLINE integerFromWordList #-} -- See Note [Integer constant folding] integerFromWordList True ws = integerFromBigNatNeg# (bigNatFromWordList ws) integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) @@ -209,7 +216,7 @@ integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) -- -- Return 0 for negative Integers. integerToNaturalClamp :: Integer -> Natural -{-# NOINLINE integerToNaturalClamp #-} +{-# NOINLINE[0] integerToNaturalClamp #-} -- See Note [Integer constant folding] integerToNaturalClamp (IS x) | isTrue# (x <# 0#) = naturalZero | True = naturalFromWord# (int2Word# x) @@ -220,7 +227,7 @@ integerToNaturalClamp (IN _) = naturalZero -- -- Return absolute value integerToNatural :: Integer -> Natural -{-# NOINLINE integerToNatural #-} +{-# NOINLINE[0] integerToNatural #-} -- See Note [Integer constant folding] integerToNatural (IS x) = naturalFromWord# (wordFromAbsInt# x) integerToNatural (IP x) = naturalFromBigNat# x integerToNatural (IN x) = naturalFromBigNat# x @@ -237,40 +244,50 @@ integerIsNegative# (IN _) = 1# -- | Negative predicate integerIsNegative :: Integer -> Bool +{-# INLINE integerIsNegative #-} -- See Note [Integer constant folding] integerIsNegative !i = isTrue# (integerIsNegative# i) -- | Zero predicate integerIsZero :: Integer -> Bool +{-# INLINE integerIsZero #-} -- See Note [Integer constant folding] integerIsZero (IS 0#) = True integerIsZero _ = False -- | Not-equal predicate. integerNe :: Integer -> Integer -> Bool +{-# INLINE integerNe #-} -- See Note [Integer constant folding] integerNe !x !y = isTrue# (integerNe# x y) -- | Equal predicate. integerEq :: Integer -> Integer -> Bool +{-# INLINE integerEq #-} -- See Note [Integer constant folding] integerEq !x !y = isTrue# (integerEq# x y) -- | Lower-or-equal predicate. integerLe :: Integer -> Integer -> Bool +{-# INLINE integerLe #-} -- See Note [Integer constant folding] integerLe !x !y = isTrue# (integerLe# x y) -- | Lower predicate. integerLt :: Integer -> Integer -> Bool +{-# INLINE integerLt #-} -- See Note [Integer constant folding] integerLt !x !y = isTrue# (integerLt# x y) -- | Greater predicate. integerGt :: Integer -> Integer -> Bool +{-# INLINE integerGt #-} -- See Note [Integer constant folding] integerGt !x !y = isTrue# (integerGt# x y) -- | Greater-or-equal predicate. integerGe :: Integer -> Integer -> Bool +{-# INLINE integerGe #-} -- See Note [Integer constant folding] integerGe !x !y = isTrue# (integerGe# x y) -- | Equal predicate. integerEq# :: Integer -> Integer -> Bool# -{-# NOINLINE integerEq# #-} +{-# NOINLINE integerEq# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerEq# (IS x) (IS y) = x ==# y integerEq# (IN x) (IN y) = bigNatEq# x y integerEq# (IP x) (IP y) = bigNatEq# x y @@ -278,7 +295,9 @@ integerEq# _ _ = 0# -- | Not-equal predicate. integerNe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerNe# #-} +{-# NOINLINE integerNe# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerNe# (IS x) (IS y) = x /=# y integerNe# (IN x) (IN y) = bigNatNe# x y integerNe# (IP x) (IP y) = bigNatNe# x y @@ -286,39 +305,43 @@ integerNe# _ _ = 1# -- | Greater predicate. integerGt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGt# #-} +{-# NOINLINE[0] integerGt# #-} -- See Note [Integer constant folding] integerGt# (IS x) (IS y) = x ># y integerGt# x y | GT <- integerCompare x y = 1# integerGt# _ _ = 0# -- | Lower-or-equal predicate. integerLe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLe# #-} +{-# NOINLINE[0] integerLe# #-} -- See Note [Integer constant folding] integerLe# (IS x) (IS y) = x <=# y integerLe# x y | GT <- integerCompare x y = 0# integerLe# _ _ = 1# -- | Lower predicate. integerLt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLt# #-} +{-# NOINLINE[0] integerLt# #-} -- See Note [Integer constant folding] integerLt# (IS x) (IS y) = x <# y integerLt# x y | LT <- integerCompare x y = 1# integerLt# _ _ = 0# -- | Greater-or-equal predicate. integerGe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGe# #-} +{-# NOINLINE[0] integerGe# #-} -- See Note [Integer constant folding] integerGe# (IS x) (IS y) = x >=# y integerGe# x y | LT <- integerCompare x y = 0# integerGe# _ _ = 1# instance Eq Integer where + {-# INLINE (==) #-} -- See Note [Integer constant folding] (==) = integerEq + {-# INLINE (/=) #-} -- See Note [Integer constant folding] (/=) = integerNe -- | Compare two Integer integerCompare :: Integer -> Integer -> Ordering -{-# NOINLINE integerCompare #-} +{-# NOINLINE integerCompare #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerCompare (IS x) (IS y) = compareInt# x y integerCompare (IP x) (IP y) = bigNatCompare x y integerCompare (IN x) (IN y) = bigNatCompare y x @@ -330,6 +353,7 @@ integerCompare (IP _) (IN _) = GT integerCompare (IN _) (IP _) = LT instance Ord Integer where + {-# INLINE compare #-} -- See Note [Integer constant folding] compare = integerCompare --------------------------------------------------------------------- @@ -338,7 +362,7 @@ instance Ord Integer where -- | Subtract one 'Integer' from another. integerSub :: Integer -> Integer -> Integer -{-# NOINLINE integerSub #-} +{-# NOINLINE[0] integerSub #-} -- See Note [Integer constant folding] integerSub !x (IS 0#) = x integerSub (IS x#) (IS y#) = case subIntC# x# y# of @@ -384,7 +408,7 @@ integerSub (IN x) (IS y#) -- | Add two 'Integer's integerAdd :: Integer -> Integer -> Integer -{-# NOINLINE integerAdd #-} +{-# NOINLINE[0] integerAdd #-} -- See Note [Integer constant folding] integerAdd !x (IS 0#) = x integerAdd (IS 0#) y = y integerAdd (IS x#) (IS y#) @@ -413,7 +437,7 @@ integerAdd (IP x) (IN y) -- | Multiply two 'Integer's integerMul :: Integer -> Integer -> Integer -{-# NOINLINE integerMul #-} +{-# NOINLINE[0] integerMul #-} -- See Note [Integer constant folding] integerMul !_ (IS 0#) = IS 0# integerMul (IS 0#) _ = IS 0# integerMul x (IS 1#) = x @@ -478,7 +502,7 @@ integerMul (IN x) (IS y) -- IP is used iff n > maxBound::Int -- IN is used iff n < minBound::Int integerNegate :: Integer -> Integer -{-# NOINLINE integerNegate #-} +{-# NOINLINE[0] integerNegate #-} -- See Note [Integer constant folding] integerNegate (IN b) = IP b integerNegate (IS INT_MINBOUND#) = IP (bigNatFromWord# ABS_INT_MINBOUND##) integerNegate (IS i) = IS (negateInt# i) @@ -492,7 +516,7 @@ integerNegate (IP b) -- | Compute absolute value of an 'Integer' integerAbs :: Integer -> Integer -{-# NOINLINE integerAbs #-} +{-# NOINLINE[0] integerAbs #-} -- See Note [Integer constant folding] integerAbs (IN i) = IP i integerAbs n@(IP _) = n integerAbs n@(IS i) @@ -504,13 +528,13 @@ integerAbs n@(IS i) -- | Return @-1@, @0@, and @1@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum :: Integer -> Integer -{-# NOINLINE integerSignum #-} +{-# NOINLINE[0] integerSignum #-} -- See Note [Integer constant folding] integerSignum !j = IS (integerSignum# j) -- | Return @-1#@, @0#@, and @1#@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum# :: Integer -> Int# -{-# NOINLINE integerSignum# #-} +{-# NOINLINE[0] integerSignum# #-} -- See Note [Integer constant folding] integerSignum# (IN _) = -1# integerSignum# (IS i#) = sgnI# i# integerSignum# (IP _ ) = 1# @@ -518,7 +542,7 @@ integerSignum# (IP _ ) = 1# -- | Count number of set bits. For negative arguments returns -- the negated population count of the absolute value. integerPopCount# :: Integer -> Int# -{-# NOINLINE integerPopCount# #-} +{-# NOINLINE[0] integerPopCount# #-} -- See Note [Integer constant folding] integerPopCount# (IS i) | isTrue# (i >=# 0#) = word2Int# (popCntI# i) | True = negateInt# (word2Int# (popCntI# (negateInt# i))) @@ -527,7 +551,7 @@ integerPopCount# (IN bn) = negateInt# (word2Int# (bigNatPopCount# bn)) -- | Positive 'Integer' for which only /n/-th bit is set integerBit# :: Word# -> Integer -{-# NOINLINE integerBit# #-} +{-# NOINLINE[0] integerBit# #-} -- See Note [Integer constant folding] integerBit# i | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##)) = IS (uncheckedIShiftL# 1# (word2Int# i)) @@ -536,13 +560,14 @@ integerBit# i -- | 'Integer' for which only /n/-th bit is set integerBit :: Word -> Integer +{-# INLINE integerBit #-} -- See Note [Integer constant folding] integerBit (W# i) = integerBit# i -- | Test if /n/-th bit is set. -- -- Fake 2's complement for negative values (might be slow) integerTestBit# :: Integer -> Word# -> Bool# -{-# NOINLINE integerTestBit# #-} +{-# NOINLINE[0] integerTestBit# #-} -- See Note [Integer constant folding] integerTestBit# (IS x) i | isTrue# (i `ltWord#` WORD_SIZE_IN_BITS##) = testBitI# x i @@ -572,13 +597,14 @@ integerTestBit# (IN x) i -- -- Fake 2's complement for negative values (might be slow) integerTestBit :: Integer -> Word -> Bool +{-# INLINE integerTestBit #-} -- See Note [Integer constant folding] integerTestBit !i (W# n) = isTrue# (integerTestBit# i n) -- | Shift-right operation -- -- Fake 2's complement for negative values (might be slow) integerShiftR# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftR# #-} +{-# NOINLINE[0] integerShiftR# #-} -- See Note [Integer constant folding] integerShiftR# !x 0## = x integerShiftR# (IS i) n = IS (iShiftRA# i (word2Int# n)) where @@ -595,11 +621,12 @@ integerShiftR# (IN bn) n = -- -- Fake 2's complement for negative values (might be slow) integerShiftR :: Integer -> Word -> Integer +{-# INLINE integerShiftR #-} -- See Note [Integer constant folding] integerShiftR !x (W# w) = integerShiftR# x w -- | Shift-left operation integerShiftL# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftL# #-} +{-# NOINLINE[0] integerShiftL# #-} -- See Note [Integer constant folding] integerShiftL# !x 0## = x integerShiftL# (IS 0#) _ = IS 0# integerShiftL# (IS 1#) n = integerBit# n @@ -614,13 +641,14 @@ integerShiftL# (IN bn) n = IN (bigNatShiftL# bn n) -- Remember that bits are stored in sign-magnitude form, hence the behavior of -- negative Integers is different from negative Int's behavior. integerShiftL :: Integer -> Word -> Integer +{-# INLINE integerShiftL #-} -- See Note [Integer constant folding] integerShiftL !x (W# w) = integerShiftL# x w -- | Bitwise OR operation -- -- Fake 2's complement for negative values (might be slow) integerOr :: Integer -> Integer -> Integer -{-# NOINLINE integerOr #-} +{-# NOINLINE[0] integerOr #-} -- See Note [Integer constant folding] integerOr a b = case a of IS 0# -> b IS -1# -> IS -1# @@ -679,7 +707,7 @@ integerOr a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerXor :: Integer -> Integer -> Integer -{-# NOINLINE integerXor #-} +{-# NOINLINE[0] integerXor #-} -- See Note [Integer constant folding] integerXor a b = case a of IS 0# -> b IS -1# -> integerComplement b @@ -734,7 +762,7 @@ integerXor a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerAnd :: Integer -> Integer -> Integer -{-# NOINLINE integerAnd #-} +{-# NOINLINE[0] integerAnd #-} -- See Note [Integer constant folding] integerAnd a b = case a of IS 0# -> IS 0# IS -1# -> b @@ -769,7 +797,7 @@ integerAnd a b = case a of -- | Binary complement of the integerComplement :: Integer -> Integer -{-# NOINLINE integerComplement #-} +{-# NOINLINE[0] integerComplement #-} -- See Note [Integer constant folding] integerComplement (IS x) = IS (notI# x) integerComplement (IP x) = IN (bigNatAddWord# x 1##) integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) @@ -780,7 +808,7 @@ integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerQuotRem# #-} +{-# NOINLINE[0] integerQuotRem# #-} -- See Note [Integer constant folding] integerQuotRem# !n (IS 1#) = (# n, IS 0# #) integerQuotRem# !n (IS -1#) = let !q = integerNegate n in (# q, (IS 0#) #) integerQuotRem# !_ (IS 0#) = case raiseDivZero of @@ -818,12 +846,13 @@ integerQuotRem# n@(IS n#) (IP d) -- need to account for (IS minBound) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerQuotRem #-} -- See Note [Integer constant folding] integerQuotRem !x !y = case integerQuotRem# x y of (# q, r #) -> (q, r) integerQuot :: Integer -> Integer -> Integer -{-# NOINLINE integerQuot #-} +{-# NOINLINE[0] integerQuot #-} -- See Note [Integer constant folding] integerQuot !n (IS 1#) = n integerQuot !n (IS -1#) = integerNegate n integerQuot !_ (IS 0#) = raiseDivZero @@ -844,7 +873,7 @@ integerQuot (IN n) (IN d) = integerFromBigNat# (bigNatQuot n d) integerQuot n d = case integerQuotRem# n d of (# q, _ #) -> q integerRem :: Integer -> Integer -> Integer -{-# NOINLINE integerRem #-} +{-# NOINLINE[0] integerRem #-} -- See Note [Integer constant folding] integerRem !_ (IS 1#) = IS 0# integerRem _ (IS -1#) = IS 0# integerRem _ (IS 0#) = IS (remInt# 0# 0#) @@ -866,7 +895,7 @@ integerRem n d = case integerQuotRem# n d of (# _, r #) -> r -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerDivMod# #-} +{-# NOINLINE[0] integerDivMod# #-} -- See Note [Integer constant folding] integerDivMod# !n !d | isTrue# (integerSignum# r ==# negateInt# (integerSignum# d)) = let !q' = integerSub q (IS 1#) @@ -881,12 +910,13 @@ integerDivMod# !n !d -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerDivMod #-} -- See Note [Integer constant folding] integerDivMod !n !d = case integerDivMod# n d of (# q,r #) -> (q,r) integerDiv :: Integer -> Integer -> Integer -{-# NOINLINE integerDiv #-} +{-# NOINLINE[0] integerDiv #-} -- See Note [Integer constant folding] integerDiv !n !d -- same-sign ops can be handled by more efficient 'integerQuot' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerQuot n d @@ -894,7 +924,7 @@ integerDiv !n !d integerMod :: Integer -> Integer -> Integer -{-# NOINLINE integerMod #-} +{-# NOINLINE[0] integerMod #-} -- See Note [Integer constant folding] integerMod !n !d -- same-sign ops can be handled by more efficient 'integerRem' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerRem n d @@ -902,7 +932,7 @@ integerMod !n !d -- | Compute greatest common divisor. integerGcd :: Integer -> Integer -> Integer -{-# NOINLINE integerGcd #-} +{-# NOINLINE[0] integerGcd #-} -- See Note [Integer constant folding] integerGcd (IS 0#) !b = integerAbs b integerGcd a (IS 0#) = integerAbs a integerGcd (IS 1#) _ = IS 1# @@ -920,7 +950,7 @@ integerGcd (IP a) (IS b) = integerFromWord# (bigNatGcdWord# a (int2Word# (ab -- | Compute least common multiple. integerLcm :: Integer -> Integer -> Integer -{-# NOINLINE integerLcm #-} +{-# NOINLINE[0] integerLcm #-} -- See Note [Integer constant folding] integerLcm (IS 0#) !_ = IS 0# integerLcm (IS 1#) b = integerAbs b integerLcm (IS -1#) b = integerAbs b @@ -934,6 +964,7 @@ integerLcm a b = (aa `integerQuot` (aa `integerGcd` ab)) `integerMul` ab -- | Square a Integer integerSqr :: Integer -> Integer +{-# INLINE integerSqr #-} -- See Note [Integer constant folding] integerSqr !a = integerMul a a @@ -951,6 +982,7 @@ integerLog2# (IP b) = bigNatLog2# b -- -- For numbers <= 0, return 0 integerLog2 :: Integer -> Word +{-# INLINE integerLog2 #-} -- See Note [Integer constant folding] integerLog2 !i = W# (integerLog2# i) -- | Logarithm (floor) for an arbitrary base @@ -965,6 +997,7 @@ integerLogBaseWord# base !i -- -- For numbers <= 0, return 0 integerLogBaseWord :: Word -> Integer -> Word +{-# INLINE integerLogBaseWord #-} -- See Note [Integer constant folding] integerLogBaseWord (W# base) !i = W# (integerLogBaseWord# base i) -- | Logarithm (floor) for an arbitrary base @@ -980,6 +1013,7 @@ integerLogBase# !base !i -- -- For numbers <= 0, return 0 integerLogBase :: Integer -> Integer -> Word +{-# INLINE integerLogBase #-} -- See Note [Integer constant folding] integerLogBase !base !i = W# (integerLogBase# base i) -- | Indicate if the value is a power of two and which one @@ -994,7 +1028,7 @@ integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w -- | Convert an Int64# into an Integer on 32-bit architectures integerFromInt64# :: Int64# -> Integer -{-# NOINLINE integerFromInt64# #-} +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !i | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#) &&# (i `geInt64#` intToInt64# -0x80000000#)) @@ -1008,7 +1042,7 @@ integerFromInt64# !i -- | Convert a Word64# into an Integer on 32-bit architectures integerFromWord64# :: Word64# -> Integer -{-# NOINLINE integerFromWord64# #-} +{-# NOINLINE[0] integerFromWord64# #-} -- See Note [Integer constant folding] integerFromWord64# !w | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##) = IS (int64ToInt# (word64ToInt64# w)) @@ -1017,14 +1051,14 @@ integerFromWord64# !w -- | Convert an Integer into an Int64# on 32-bit architectures integerToInt64# :: Integer -> Int64# -{-# NOINLINE integerToInt64# #-} +{-# NOINLINE[0] integerToInt64# #-} -- See Note [Integer constant folding] integerToInt64# (IS i) = intToInt64# i integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b) integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b)) -- | Convert an Integer into a Word64# on 32-bit architectures integerToWord64# :: Integer -> Word64# -{-# NOINLINE integerToWord64# #-} +{-# NOINLINE[0] integerToWord64# #-} -- See Note [Integer constant folding] integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) integerToWord64# (IP b) = bigNatToWord64# b integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b))) @@ -1033,6 +1067,7 @@ integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatTo -- | Convert an Int64# into an Integer on 64-bit architectures integerFromInt64# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !x = IS x #endif @@ -1043,18 +1078,19 @@ integerFromInt64# !x = IS x -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble# :: Double# -> (# Integer, Int# #) -{-# NOINLINE integerDecodeDouble# #-} +{-# NOINLINE[0] integerDecodeDouble# #-} -- See Note [Integer constant folding] integerDecodeDouble# !x = case decodeDouble_Int64# x of (# m, e #) -> (# integerFromInt64# m, e #) -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble :: Double -> (Integer, Int) +{-# INLINE integerDecodeDouble #-} -- See Note [Integer constant folding] integerDecodeDouble (D# x) = case integerDecodeDouble# x of (# m, e #) -> (m, I# e) -- | Encode (# Integer mantissa, Int# exponent #) into a Double# integerEncodeDouble# :: Integer -> Int# -> Double# -{-# NOINLINE integerEncodeDouble# #-} +{-# NOINLINE[0] integerEncodeDouble# #-} -- See Note [Integer constant folding] integerEncodeDouble# (IS i) 0# = int2Double# i integerEncodeDouble# (IS i) e = intEncodeDouble# i e integerEncodeDouble# (IP b) e = bigNatEncodeDouble# b e @@ -1062,23 +1098,24 @@ integerEncodeDouble# (IN b) e = negateDouble# (bigNatEncodeDouble# b e) -- | Encode (Integer mantissa, Int exponent) into a Double integerEncodeDouble :: Integer -> Int -> Double +{-# INLINE integerEncodeDouble #-} -- See Note [Integer constant folding] integerEncodeDouble !m (I# e) = D# (integerEncodeDouble# m e) -- | Encode an Integer (mantissa) into a Double# integerToDouble# :: Integer -> Double# -{-# NOINLINE integerToDouble# #-} +{-# NOINLINE[0] integerToDouble# #-} -- See Note [Integer constant folding] integerToDouble# !i = integerEncodeDouble# i 0# -- | Encode an Integer (mantissa) into a Float# integerToFloat# :: Integer -> Float# -{-# NOINLINE integerToFloat# #-} +{-# NOINLINE[0] integerToFloat# #-} -- See Note [Integer constant folding] integerToFloat# !i = integerEncodeFloat# i 0# -- | Encode (# Integer mantissa, Int# exponent #) into a Float# -- -- TODO: Not sure if it's worth to write 'Float' optimized versions here integerEncodeFloat# :: Integer -> Int# -> Float# -{-# NOINLINE integerEncodeFloat# #-} +{-# NOINLINE[0] integerEncodeFloat# #-} -- See Note [Integer constant folding] integerEncodeFloat# !m 0# = double2Float# (integerToDouble# m) integerEncodeFloat# !m e = double2Float# (integerEncodeDouble# m e) @@ -1108,6 +1145,7 @@ integerToAddr# (IN n) = bigNatToAddr# n -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToAddr :: Integer -> Addr# -> Bool# -> IO Word +{-# INLINE integerToAddr #-} -- See Note [Integer constant folding] integerToAddr a addr e = IO \s -> case integerToAddr# a addr e s of (# s', w #) -> (# s', W# w #) @@ -1135,6 +1173,7 @@ integerFromAddr# sz addr e s = -- -- Null higher limbs are automatically trimed. integerFromAddr :: Word# -> Addr# -> Bool# -> IO Integer +{-# INLINE integerFromAddr #-} -- See Note [Integer constant folding] integerFromAddr sz addr e = IO (integerFromAddr# sz addr e) @@ -1157,6 +1196,7 @@ integerToMutableByteArray# (IN a) = bigNatToMutableByteArray# a -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word +{-# INLINE integerToMutableByteArray #-} -- See Note [Integer constant folding] integerToMutableByteArray i mba w e = IO \s -> case integerToMutableByteArray# i mba w e s of (# s', r #) -> (# s', W# r #) @@ -1183,6 +1223,7 @@ integerFromByteArray# sz ba off e s = case bigNatFromByteArray# sz ba off e s of -- -- Null higher limbs are automatically trimed. integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer +{-# INLINE integerFromByteArray #-} -- See Note [Integer constant folding] integerFromByteArray sz ba off e = case runRW# (integerFromByteArray# sz ba off e) of (# _, i #) -> i @@ -1215,5 +1256,45 @@ integerGcde :: Integer -> Integer -> ( Integer, Integer, Integer) +{-# INLINE integerGcde #-} -- See Note [Integer constant folding] integerGcde a b = case integerGcde# a b of (# g,x,y #) -> (g,x,y) + +{- Note [Integer constant folding] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We define constant folding rules in "GHC.Core.Opt.ConstantFold" for most of the + at integer*#@ operations in this module, hence they are marked NOINLINE[0]. + +Why NOINLINE[0] rather than NOINLINE? Because + + 1. We still delay inlining long enough for the constant-folding RULEs + to fire + 2. The compiler has the option to inlining the operations late, possibly + cancelling away boxes in the process. + +Why NOINLINE[0] rather than INLINE? Because + + 3. We don't unconditionally inline huge definitions such as + `integerDiv`, which would lead to code bloat at pretty much no + gain. + 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. + `integerDiv`, there is no gain in inlining the unoptimised + unfoldings. + +But since we potentially inline the constant folded operations in phase 0, we +have to make sure that *all* callers that want to take part in constant folding +are marked INLINE. Otherwise, we'd store optimised unfoldings for them, in which +the constant folded functions are inlined. +That concerns for most of the @integer*@ without trailing hash in this module, +as well as the type class instances for 'Eq', 'Ord', 'Num', 'Integral', +'RealFloat' (which is for 'Double'!), etc. + +There are a couple of constant-folded functions that require special treatment, +though: + + * `integerEq`, `integerNe`, `integerCompare`: They are huge and lead to + regressions when inlined. Solution: mark these NOINLINE. + * Under -O2, `integerAdd` will be specialised by SpecConstr. These + specialisations defeat constant folding. + Solution: -fno-spec-constr for this module. +-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/caa84914094281af880d0c57592859307a9ed7ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/caa84914094281af880d0c57592859307a9ed7ba You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 11:54:25 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 07:54:25 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 60 commits: Optimize NthCo (FunCo ...) in coercion opt Message-ID: <5f7714f1290c1_80b3f847dc8140016096873@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - e683d1de by Sebastian Graf at 2020-10-02T12:18:25+02:00 Nested CPR - - - - - b2d21f7b by Sebastian Graf at 2020-10-02T12:18:27+02:00 Move tests from stranal to cpranal - - - - - 0ae3a61b by Sebastian Graf at 2020-10-02T12:18:27+02:00 Accept FacState - - - - - 0e89f542 by Sebastian Graf at 2020-10-02T12:22:52+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - 793f96f1 by Sebastian Graf at 2020-10-02T13:26:15+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - 3d133e95 by Sebastian Graf at 2020-10-02T13:26:17+02:00 stuff - - - - - 73016804 by Sebastian Graf at 2020-10-02T13:28:21+02:00 A slew of testsuite changes - - - - - 4cfd952b by Sebastian Graf at 2020-10-02T13:28:22+02:00 Fix T1600 - - - - - 51597247 by Sebastian Graf at 2020-10-02T13:28:22+02:00 Inline `decodeDoubleInteger` and constant-fold `decodeDouble_Int64#` instead Currently, `decodeDoubleInteger` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE`/`CONSTANT_FOLDED` things since #13143. Also it is a trade-off: The implementation of `decodeDoubleInteger` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `decodeDoubleInteger`. You may wonder how this affects performance of code using `integer-simple`; Apparently, according to @hsyl20 this is not a concern since we will hopefully land !2231 soon. Fixes #18092. - - - - - 44c4ee7f by Sebastian Graf at 2020-10-02T13:28:22+02:00 Fix primop termination - - - - - db1cef64 by Sebastian Graf at 2020-10-02T13:28:22+02:00 Test for DataCon wrapper CPR - - - - - 80eacba9 by Sebastian Graf at 2020-10-02T13:29:36+02:00 Fix CPR of bottoming functions/primops - - - - - 408cc9ef by Sebastian Graf at 2020-10-02T13:29:38+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - 13af2d36 by Sebastian Graf at 2020-10-02T13:29:38+02:00 Accept two more changed test outputs - - - - - 289a33d0 by Sebastian Graf at 2020-10-02T13:29:38+02:00 Update CaseBinderCPR with a new function - - - - - a16dd70e by Sebastian Graf at 2020-10-02T13:30:09+02:00 Don't give the case binder the CPR property - - - - - df0fa09e by Sebastian Graf at 2020-10-02T13:31:36+02:00 Prune CPR sigs to constant depth on all bindings - - - - - 1277ee1e by Sebastian Graf at 2020-10-02T13:31:37+02:00 Use variable length coding for ConTags - - - - - 157825a0 by Sebastian Graf at 2020-10-02T13:33:52+02:00 Accept testuite output - - - - - 3dc83f0e by Sebastian Graf at 2020-10-02T13:33:54+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - f9f60b4a by Sebastian Graf at 2020-10-02T13:34:34+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 39d8fef7 by Sebastian Graf at 2020-10-02T13:35:52+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - cd7312c2 by Sebastian Graf at 2020-10-02T13:35:53+02:00 Fix T9291 - - - - - 1b359995 by Sebastian Graf at 2020-10-02T13:35:53+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - 0e1dbf0e by Sebastian Graf at 2020-10-02T13:35:53+02:00 Testsuite changes - - - - - 94e39399 by Sebastian Graf at 2020-10-02T13:45:46+02:00 Refactoring around cprAnalBind - - - - - 933e699a by Sebastian Graf at 2020-10-02T13:52:11+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - a508a5f1 by Sebastian Graf at 2020-10-02T13:52:18+02:00 Regard all arity 0 bindings (incl. DataCon apps) as thunks - - - - - 6cb20f84 by Sebastian Graf at 2020-10-02T13:53:48+02:00 Don't store CPR info for data structures that are NOINLINE - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/Unfold.hs - compiler/GHC/CoreToIface.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dac38be5dbeea5a7a03c2c7cb2f893f97ac7f4bb...6cb20f84d98844f1d7970ded6be867d99590fc34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dac38be5dbeea5a7a03c2c7cb2f893f97ac7f4bb...6cb20f84d98844f1d7970ded6be867d99590fc34 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 12:00:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 08:00:32 -0400 Subject: [Git][ghc/ghc][master] Fix typos in comments Message-ID: <5f771660c3b09_80b898378c16097953@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - 29 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/flags.py - libraries/base/GHC/Conc/Sync.hs - libraries/base/GHC/TypeNats.hs - libraries/base/Unsafe/Coerce.hs - libraries/ghc-prim/GHC/Prim/Ext.hs - testsuite/tests/typecheck/should_fail/T18357b.hs - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1668,7 +1668,7 @@ datatypeClassKey = mkPreludeClassUnique 39 constructorClassKey = mkPreludeClassUnique 40 selectorClassKey = mkPreludeClassUnique 41 --- KnownNat: see Note [KnowNat & KnownSymbol and EvLit] in GHC.Tc.Types.Evidence +-- KnownNat: see Note [KnownNat & KnownSymbol and EvLit] in GHC.Tc.Types.Evidence knownNatClassNameKey :: Unique knownNatClassNameKey = mkPreludeClassUnique 42 ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -163,7 +163,7 @@ defaults -- -- Unfortunately, for the time being most of the primops which should be -- moved according to the previous paragraph can't yet. There are some --- superficial restrictions in `foreign import prim` which mus be fixed +-- superficial restrictions in `foreign import prim` which must be fixed -- first. Specifically, `foreign import prim` always requires: -- -- - No polymorphism in type ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -1174,7 +1174,7 @@ initNCGConfig dflags = NCGConfig ArchX86 -> bmiVersion dflags _ -> Nothing - -- We Assume SSE1 and SSE2 operations are available on both + -- We assume SSE1 and SSE2 operations are available on both -- x86 and x86_64. Historically we didn't default to SSE2 and -- SSE1 on x86, which results in defacto nondeterminism for how -- rounding behaves in the associated x87 floating point instructions ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -234,7 +234,7 @@ pprInstances :: [ClsInst] -> SDoc pprInstances ispecs = vcat (map pprInstance ispecs) instanceHead :: ClsInst -> ([TyVar], Class, [Type]) --- Returns the head, using the fresh tyavs from the ClsInst +-- Returns the head, using the fresh tyvars from the ClsInst instanceHead (ClsInst { is_tvs = tvs, is_tys = tys, is_dfun = dfun }) = (tvs, cls, tys) where ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -178,7 +178,7 @@ in GHC.Core.Opt.WorkWrap.Utils. (Maybe there are other "clients" of this featur might reject a correct program. So we carry a type substitution (in this example [a -> Bool]) and apply this substitution before comparing types. In effect, in Lint, type equality is always - equality-moduolo-le-subst. This is in the le_subst field of + equality-modulo-le-subst. This is in the le_subst field of LintEnv. But nota bene: (SI1) The le_subst substitution is applied to types and coercions only ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -940,7 +940,7 @@ We use aBSENT_ERROR_ID to build dummy values in workers. E.g. f x = (case x of (a,b) -> b) + 1::Int -The demand analyser figures ot that only the second component of x is +The demand analyser figures out that only the second component of x is used, and does a w/w split thus f x = case x of (a,b) -> $wf b ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -809,7 +809,7 @@ subst_id_bndr env@(SimplEnv { seInScope = in_scope, seIdSubst = id_subst }) = ASSERT2( not (isCoVar old_id), ppr old_id ) (env { seInScope = in_scope `extendInScopeSet` new_id, seIdSubst = new_subst }, new_id) - -- It's important that both seInScope and seIdSubt are updated with + -- It's important that both seInScope and seIdSubst are updated with -- the new_id, /after/ applying adjust_type. That's why adjust_type -- is done here. If we did adjust_type in simplJoinBndr (the only -- place that gives a non-identity adjust_type) we'd have to fiddle ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -946,7 +946,7 @@ and we get a loop! Note [specImport call stack] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When specialising an imports function 'f', we may get new calls -of an imported fuction 'g', which we want to specialise in turn, +of an imported function 'g', which we want to specialise in turn, and similarly specialising 'g' might expose a new call to 'h'. We track the stack of enclosing functions. So when specialising 'h' we ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -2032,7 +2032,7 @@ GHC.Core.Multiplicity above this module. -- | A shorthand for data with an attached 'Mult' element (the multiplicity). data Scaled a = Scaled Mult a deriving (Data.Data) - -- You might think that this would be a natural candiate for + -- You might think that this would be a natural candidate for -- Functor, Traversable but Krzysztof says (!3674) "it was too easy -- to accidentally lift functions (substitutions, zonking etc.) from -- Type -> Type to Scaled Type -> Scaled Type, ignoring ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -604,7 +604,7 @@ which allows only (Coercion co) on the RHS. ************************************************************************ * * - Operations oer case alternatives + Operations over case alternatives * * ************************************************************************ ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -625,7 +625,7 @@ schemeE d s p exp@(AnnTick (Breakpoint _id _fvs) _rhs) -- match = /\(r::RuntimeRep) /\(a::TYPE r). -- \(k :: Int -> a) \(v::T). -- case v of MkV n -> k n - -- Here (k n) :: a :: Type r, so we don't know if it's lifted + -- Here (k n) :: a :: TYPE r, so we don't know if it's lifted -- or not; but that should be fine provided we add that void arg. id <- newId (mkVisFunTyMany realWorldStatePrimTy ty) ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -4910,7 +4910,7 @@ isSseEnabled platform = case platformArch platform of isSse2Enabled :: Platform -> Bool isSse2Enabled platform = case platformArch platform of - -- We Assume SSE1 and SSE2 operations are available on both + -- We assume SSE1 and SSE2 operations are available on both -- x86 and x86_64. Historically we didn't default to SSE2 and -- SSE1 on x86, which results in defacto nondeterminism for how -- rounding behaves in the associated x87 floating point instructions ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -987,7 +987,7 @@ mismatch between two skolems We certainly don't want to say "Can't match LiftedRep ~ LiftedRep"! But if we are printing the type - (forall (a :: Type r). blah + (forall (a :: TYPE r). blah we do want to turn that (free) r into LiftedRep, so it prints as (forall a. blah) ===================================== compiler/GHC/Tc/Errors/Hole.hs ===================================== @@ -601,7 +601,7 @@ findValidHoleFits tidy_env implics simples h@(Hole { hole_sort = ExprHole _ ; traceTc "findingValidHoleFitsFor }" empty ; return (tidy_env, vMsg $$ refMsg) } where - -- We extract the type, the tcLevel and the types free variables + -- We extract the type, the TcLevel and the types free variables -- from the constraint. hole_fvs :: FV hole_fvs = tyCoFVsOfType hole_ty ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -196,7 +196,7 @@ tcApp works like this: The "list of arguments" is [HsExprArg], described in Note [HsExprArg]. in GHC.Tc.Gen.Head -2. Use tcInferAppHead to infer the type of the fuction, +2. Use tcInferAppHead to infer the type of the function, as an (uninstantiated) TcSigmaType There are special cases for HsVar, HsRecFld, and ExprWithTySig @@ -588,7 +588,7 @@ Consider (#15859) data A k :: k -> Type -- A :: forall k -> k -> Type type KindOf (a :: k) = k -- KindOf :: forall k. k -> Type - a = (undefind :: KindOf A) @Int + a = (undefined :: KindOf A) @Int With ImpredicativeTypes (thin ice, I know), we instantiate KindOf at type (forall k -> k -> Type), so ===================================== compiler/GHC/Tc/Gen/Export.hs ===================================== @@ -579,7 +579,7 @@ lookupChildrenExport spec_parent rdr_items = -- -- Note: [Types of TyCon] -- --- This check appears to be overlly complicated, Richard asked why it +-- This check appears to be overly complicated, Richard asked why it -- is not simply just `isAlgTyCon`. The answer for this is that -- a classTyCon is also an `AlgTyCon` which we explicitly want to disallow. -- (It is either a newtype or data depending on the number of methods) ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -326,7 +326,7 @@ tcInferAppHead :: HsExpr GhcRn -- See Note [Application chains and heads] in GHC.Tc.Gen.App -- We get back a /SigmaType/ because we have special cases for -- * A bare identifier (just look it up) --- This case also covers a record selectro HsRecFld +-- This case also covers a record selector HsRecFld -- * An expression with a type signature (e :: ty) -- See Note [Application chains and heads] in GHC.Tc.Gen.App -- ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -297,7 +297,7 @@ a more convenient function, defined in terms of `natSing`: The reason we don't use this directly in the class is that it is simpler and more efficient to pass around a Natural rather than an entire function, -especially when the `KnowNat` evidence is packaged up in an existential. +especially when the `KnownNat` evidence is packaged up in an existential. The story for kind `Symbol` is analogous: * class KnownSymbol ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -301,7 +301,7 @@ tcRnModuleTcRnM hsc_env mod_sum tcg_env <- return (tcg_env { tcg_doc_hdr = maybe_doc_hdr }) ; -- Report unused names - -- Do this /after/ typeinference, so that when reporting + -- Do this /after/ type inference, so that when reporting -- a function with no type signature we can give the -- inferred type reportUnusedNames tcg_env hsc_src ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -2606,7 +2606,7 @@ because many good things flow from [W] t1 ~# t2. The same reasoning applies to -* (~~) heqTyCOn +* (~~) heqTyCon * (~) eqTyCon * Coercible coercibleTyCon ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -1689,7 +1689,7 @@ points so that the code is readable with its original meaning. So scattered through "GHC.ThToHs" are various points where parens are added. -See (among other closed issued) https://gitlab.haskell.org/ghc/ghc/issues/14289 +See (among other closed issues) https://gitlab.haskell.org/ghc/ghc/issues/14289 -} -- --------------------------------------------------------------------- ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -1564,7 +1564,7 @@ Note [seqId magic] a) Its fixity is set in GHC.Iface.Load.ghcPrimIface b) It has quite a bit of desugaring magic. - See GHC.HsToCore.Utils Note [Desugaring seq (1)] and (2) and (3) + See GHC.HsToCore.Utils Note [Desugaring seq] (1) and (2) and (3) c) There is some special rule handing: Note [User-defined RULES for seq] @@ -1748,7 +1748,7 @@ definition in Core. The rewrite rule works as follows: f (x `cast` co a) y The `co` coercion is the newtype-coercion extracted from the type-class. -The type class is obtain by looking at the type of wrap. +The type class is obtained by looking at the type of wrap. ------------------------------------------------------------- ===================================== docs/users_guide/flags.py ===================================== @@ -257,7 +257,7 @@ class LanguageExtension(GenericFlag): @staticmethod def _noname(name): # We check isupper() so that NondecreasingIndentation - # is not counted as "No-decreasingIndentation" + # is not counted as "No-ndecreasingIndentation" if name[:2] == "No" and name[2].isupper(): return name[2:] else: ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -497,7 +497,7 @@ labelThread (ThreadId t) str = case labelThread# t p s of s1 -> (# s1, () #) -- Nota Bene: 'pseq' used to be 'seq' --- but 'seq' is now defined in PrelGHC +-- but 'seq' is now defined in GHC.Prim -- -- "pseq" is defined a bit weirdly (see below) -- ===================================== libraries/base/GHC/TypeNats.hs ===================================== @@ -82,7 +82,7 @@ someNatVal n = withSNat SomeNat (SNat n) Proxy {- Note [NOINLINE someNatVal] `someNatVal` converts a natural number to an existentially quantified -dictionary for `KnowNat` (aka `SomeNat`). The existential quantification +dictionary for `KnownNat` (aka `SomeNat`). The existential quantification is very important, as it captures the fact that we don't know the type statically, although we do know that it exists. Because this type is fully opaque, we should never be able to prove that it matches anything else. ===================================== libraries/base/Unsafe/Coerce.hs ===================================== @@ -277,7 +277,7 @@ unsafeEqualityProof = case unsafeEqualityProof @a @b of UnsafeRefl -> UnsafeRefl -- are the same -- but the proof of that relies on the complex, trusted -- implementation of @Typeable at . -- --- 4. The "reflection trick", which takes advantanage of the fact that in +-- 4. The "reflection trick", which takes advantage of the fact that in -- @class C a where { op :: ty }@, we can safely coerce between @C a@ and @ty@ -- (which have different kinds!) because it's really just a newtype. -- Note: there is /no guarantee, at all/ that this behavior will be supported ===================================== libraries/ghc-prim/GHC/Prim/Ext.hs ===================================== @@ -10,7 +10,7 @@ #include "MachDeps.h" -- See note [When do out-of-line primops go in primops.txt.pp]. More primops --- there are elgible according to the description below, but cannot yet be moved +-- there are eligible according to the description below, but cannot yet be moved -- here because of superficial restrictions to `foreign import prim`. Hopefully -- that is fixed soon. ===================================== testsuite/tests/typecheck/should_fail/T18357b.hs ===================================== @@ -10,4 +10,4 @@ newtype T :: Type where MkT :: Int -> (T :: Star) -- The error message is pretty terrible --- but it probably nevery happens in practice +-- but it probably never happens in practice ===================================== utils/genprimopcode/Main.hs ===================================== @@ -274,7 +274,7 @@ gen_hs_source (Info defaults entries) = -- with Declaration for $fEqMaybe: -- attempting to use module ‘GHC.Classes’ -- (libraries/ghc-prim/./GHC/Classes.hs) which is not loaded - -- coming from GHC.IFace.Load.homeModError + -- coming from GHC.Iface.Load.homeModError -- I'm not sure precisely why; but I *am* sure that we don't need -- any type-class defaulting; and it's clearly wrong to need -- the base package when haddocking ghc-prim View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9ae83af9e0cf48e860f2b7e1d50a057cb8a7890 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9ae83af9e0cf48e860f2b7e1d50a057cb8a7890 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 12:01:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 08:01:06 -0400 Subject: [Git][ghc/ghc][master] Replaced MkT1 with T1 in type signatures. Message-ID: <5f771682986b5_80ba8c359816101150@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 1 changed file: - docs/users_guide/exts/linear_types.rst Changes: ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -72,10 +72,10 @@ the value ``MkT1 x`` can be constructed and deconstructed in a linear context: :: - construct :: a %1 -> MkT1 a + construct :: a %1 -> T1 a construct x = MkT1 x - deconstruct :: MkT1 a %1 -> a + deconstruct :: T1 a %1 -> a deconstruct (MkT1 x) = x -- must consume `x` exactly once When used as a value, ``MkT1`` is given a multiplicity-polymorphic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b81350bb925f8cb309355ee46238dbc11b796faf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b81350bb925f8cb309355ee46238dbc11b796faf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 12:32:00 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 08:32:00 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Fix typos in comments Message-ID: <5f771dc0bbfc7_80b3f83d0dd89c816113616@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 5d961cf0 by Vladislav Zavialov at 2020-10-02T08:31:47-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 1264d837 by Sylvain Henry at 2020-10-02T08:31:51-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 7a1e6470 by Sylvain Henry at 2020-10-02T08:31:51-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 6224bb32 by Krzysztof Gogolewski at 2020-10-02T08:31:53-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/exts/linear_types.rst - docs/users_guide/flags.py - libraries/base/GHC/Conc/Sync.hs - libraries/base/GHC/TypeNats.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/556bd11e3a607ca5ddd2006e46cd9e7b5683f068...6224bb32a32f2e79061ad02d261763b93b8f60d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/556bd11e3a607ca5ddd2006e46cd9e7b5683f068...6224bb32a32f2e79061ad02d261763b93b8f60d0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 13:54:02 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 09:54:02 -0400 Subject: [Git][ghc/ghc][wip/T18765] s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) Message-ID: <5f7730fa1ebc1_80b3f848a2d815816121768@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18765 at Glasgow Haskell Compiler / GHC Commits: 5cfe4d6b by Sebastian Graf at 2020-10-02T11:53:51+02:00 s/NOINLINE/NOINLINE[0]/g in GHC.Num.Integer (#18765) This defeats constant-folding in the final phases of the Simplifier, but enables us to get rid of allocations by inlining calls that can't be constant-folded. `NOINLINE[0]` is a better choice than `NOINLINE`, because 1. We still delay inlining long enough for the constant-folding RULEs to fire 2. The compiler has the option to inlining them late, possibly cancelling away boxes in the process. `NOINLINE[0]` is a better choice than `INLINE[0]`, because 3. We don't unconditionally inline huge definitions such as `integerDiv`, which would lead to code bloat at pretty much no gain. 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. `integerDiv`, there is no gain in inlining the unoptimised unfoldings. We also have to mark all callers that want to participate in constant folding as `INLINE`. See the new `Note [Integer constant folding]` for details. I had to change the `Num.fromInteger` and `Integral.toInteger` implementations of `Int*` and `Word*` variants to call the constant folded `integerToInt*#` and `integerToWord*#` variants directly to ensure constant folding. Fixes #18765. Metric Decrease: T10359 - - - - - 9 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Opt/ConstantFold.hs - libraries/base/GHC/Float.hs - libraries/base/GHC/Int.hs - libraries/base/GHC/Integer.hs - libraries/base/GHC/Num.hs - libraries/base/GHC/Real.hs - libraries/base/GHC/Word.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -354,6 +354,7 @@ basicKnownKeyNames integerToWord64Name, integerToInt64Name, integerFromWordName, + integerFromIntName, integerFromWord64Name, integerFromInt64Name, integerAddName, @@ -1129,6 +1130,7 @@ integerFromNaturalName , integerToWord64Name , integerToInt64Name , integerFromWordName + , integerFromIntName , integerFromWord64Name , integerFromInt64Name , integerAddName @@ -1197,6 +1199,7 @@ integerToIntName = bniVarQual "integerToInt#" integerToIntI integerToWord64Name = bniVarQual "integerToWord64#" integerToWord64IdKey integerToInt64Name = bniVarQual "integerToInt64#" integerToInt64IdKey integerFromWordName = bniVarQual "integerFromWord#" integerFromWordIdKey +integerFromIntName = bniVarQual "integerFromInt#" integerFromIntIdKey integerFromWord64Name = bniVarQual "integerFromWord64#" integerFromWord64IdKey integerFromInt64Name = bniVarQual "integerFromInt64#" integerFromInt64IdKey integerAddName = bniVarQual "integerAdd" integerAddIdKey @@ -2463,6 +2466,7 @@ integerFromNaturalIdKey , integerShiftLIdKey , integerShiftRIdKey , integerFromWordIdKey + , integerFromIntIdKey , integerFromWord64IdKey , integerFromInt64IdKey , integerDecodeDoubleIdKey @@ -2518,6 +2522,7 @@ integerFromWordIdKey = mkPreludeMiscIdUnique 638 integerFromWord64IdKey = mkPreludeMiscIdUnique 639 integerFromInt64IdKey = mkPreludeMiscIdUnique 640 integerDecodeDoubleIdKey = mkPreludeMiscIdUnique 641 +integerFromIntIdKey = mkPreludeMiscIdUnique 642 naturalToWordIdKey = mkPreludeMiscIdUnique 650 naturalAddIdKey = mkPreludeMiscIdUnique 651 ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1312,7 +1312,8 @@ builtinRules enableBignumRules builtinBignumRules :: EnableBignumRules -> [CoreRule] builtinBignumRules (EnableBignumRules False) = [] builtinBignumRules _ = - [ rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName + [ rule_IntegerFromLitNum "Int# -> Integer" integerFromIntName + , rule_IntegerFromLitNum "Word# -> Integer" integerFromWordName , rule_IntegerFromLitNum "Int64# -> Integer" integerFromInt64Name , rule_IntegerFromLitNum "Word64# -> Integer" integerFromWord64Name , rule_IntegerFromLitNum "Natural -> Integer" integerFromNaturalName @@ -1347,7 +1348,7 @@ builtinBignumRules _ = , rule_shift_op "integerShiftL" integerShiftLName shiftL , rule_shift_op "integerShiftR" integerShiftRName shiftR , rule_integerBit "integerBit" integerBitName - -- See Note [Integer division constant folding] in libraries/base/GHC/Real.hs + -- See Note [Integer constant folding] in "GHC.Num.Integer" , rule_divop_one "integerQuot" integerQuotName quot , rule_divop_one "integerRem" integerRemName rem , rule_divop_one "integerDiv" integerDivName div ===================================== libraries/base/GHC/Float.hs ===================================== @@ -494,6 +494,7 @@ instance Num Double where -- | @since 2.01 instance Real Double where + {-# INLINE toRational #-} -- See Note [Integer constant folding] toRational (D# x#) = case integerDecodeDouble# x# of (# m, e# #) @@ -580,11 +581,7 @@ instance Floating Double where -- | @since 2.01 instance RealFrac Double where - -- ceiling, floor, and truncate are all small - {-# INLINE [1] ceiling #-} - {-# INLINE [1] floor #-} - {-# INLINE [1] truncate #-} - + {-# INLINE properFraction #-} -- See Note [Integer constant folding] properFraction x = case (decodeFloat x) of { (m,n) -> if n >= 0 then @@ -595,9 +592,11 @@ instance RealFrac Double where } } + {-# INLINE truncate #-} -- See Note [Integer constant folding] truncate x = case properFraction x of (n,_) -> n + {-# INLINE round #-} -- See Note [Integer constant folding] round x = case properFraction x of (n,r) -> let m = if r < 0.0 then n - 1 else n + 1 @@ -608,9 +607,11 @@ instance RealFrac Double where EQ -> if even n then n else m GT -> m + {-# INLINE ceiling #-} -- See Note [Integer constant folding] ceiling x = case properFraction x of (n,r) -> if r > 0.0 then n + 1 else n + {-# INLINE floor #-} -- See Note [Integer constant folding] floor x = case properFraction x of (n,r) -> if r < 0.0 then n - 1 else n @@ -620,18 +621,23 @@ instance RealFloat Double where floatDigits _ = DBL_MANT_DIG -- ditto floatRange _ = (DBL_MIN_EXP, DBL_MAX_EXP) -- ditto + {-# INLINE decodeFloat #-} -- See Note [Integer constant folding] decodeFloat (D# x#) = case integerDecodeDouble# x# of (# i, j #) -> (i, I# j) + {-# INLINE encodeFloat #-} -- See Note [Integer constant folding] encodeFloat i (I# j) = D# (integerEncodeDouble# i j) + {-# INLINE exponent #-} -- See Note [Integer constant folding] exponent x = case decodeFloat x of (m,n) -> if m == 0 then 0 else n + floatDigits x + {-# INLINE significand #-} -- See Note [Integer constant folding] significand x = case decodeFloat x of (m,_) -> encodeFloat m (negate (floatDigits x)) + {-# INLINE scaleFloat #-} -- See Note [Integer constant folding] scaleFloat 0 x = x scaleFloat k x | isFix = x ===================================== libraries/base/GHC/Int.hs ===================================== @@ -106,6 +106,7 @@ instance Num Int8 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I8# (narrow8Int# (integerToInt# i)) -- | @since 2.01 @@ -160,7 +161,8 @@ instance Integral Int8 where (# d, m #) -> (I8# (narrow8Int# d), I8# (narrow8Int# m)) - toInteger (I8# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I8# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int8 where @@ -313,6 +315,7 @@ instance Num Int16 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I16# (narrow16Int# (integerToInt# i)) -- | @since 2.01 @@ -367,7 +370,8 @@ instance Integral Int16 where (# d, m #) -> (I16# (narrow16Int# d), I16# (narrow16Int# m)) - toInteger (I16# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I16# x) = integerFromInt# x -- | @since 2.01 instance Bounded Int16 where @@ -525,6 +529,7 @@ instance Num Int32 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I32# (narrow32Int# (integerToInt# i)) -- | @since 2.01 @@ -587,7 +592,8 @@ instance Integral Int32 where (# d, m #) -> (I32# (narrow32Int# d), I32# (narrow32Int# m)) - toInteger (I32# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I32# x) = integerFromInt# x -- | @since 2.01 instance Read Int32 where @@ -748,6 +754,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt64# i) -- | @since 2.01 @@ -804,6 +811,7 @@ instance Integral Int64 where | y == (-1) && x == minBound = (overflowError, 0) | otherwise = (I64# (x# `divInt64#` y#), I64# (x# `modInt64#` y#)) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (I64# x) = integerFromInt64# x @@ -953,6 +961,7 @@ instance Num Int64 where signum x | x > 0 = 1 signum 0 = 0 signum _ = -1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = I64# (integerToInt# i) -- | @since 2.01 @@ -1006,7 +1015,8 @@ instance Integral Int64 where | otherwise = case x# `divModInt#` y# of (# d, m #) -> (I64# d, I64# m) - toInteger (I64# x#) = IS x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I64# x) = integerFromInt64# x -- | @since 2.01 instance Read Int64 where ===================================== libraries/base/GHC/Integer.hs ===================================== @@ -64,156 +64,203 @@ import GHC.Prim import GHC.Types smallInteger :: Int# -> Integer +{-# INLINE smallInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer smallInteger = I.integerFromInt# integerToInt :: Integer -> Int# +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt = I.integerToInt# wordToInteger :: Word# -> Integer +{-# INLINE wordToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer wordToInteger = I.integerFromWord# integerToWord :: Integer -> Word# +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord = I.integerToWord# #if WORD_SIZE_IN_BITS < 64 word64ToInteger :: Word64# -> Integer +{-# INLINE word64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer word64ToInteger = I.integerFromWord64# integerToWord64 :: Integer -> Word64# +{-# INLINE integerToWord64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToWord64 = I.integerToWord64# int64ToInteger :: Int64# -> Integer +{-# INLINE int64ToInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer int64ToInteger = I.integerFromInt64# integerToInt64 :: Integer -> Int64# +{-# INLINE integerToInt64 #-} -- See Note [Integer constant folding] in GHC.Num.Integer integerToInt64 = I.integerToInt64# #endif encodeFloatInteger :: Integer -> Int# -> Float# +{-# INLINE encodeFloatInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeFloatInteger = I.integerEncodeFloat# floatFromInteger :: Integer -> Float# +{-# INLINE floatFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer floatFromInteger = I.integerToFloat# encodeDoubleInteger :: Integer -> Int# -> Double# +{-# INLINE encodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer encodeDoubleInteger = I.integerEncodeDouble# doubleFromInteger :: Integer -> Double# +{-# INLINE doubleFromInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer doubleFromInteger = I.integerToDouble# decodeDoubleInteger :: Double# -> (# Integer, Int# #) +{-# INLINE decodeDoubleInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer decodeDoubleInteger = I.integerDecodeDouble# plusInteger :: Integer -> Integer -> Integer +{-# INLINE plusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer plusInteger = I.integerAdd minusInteger :: Integer -> Integer -> Integer +{-# INLINE minusInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer minusInteger = I.integerSub timesInteger :: Integer -> Integer -> Integer +{-# INLINE timesInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer timesInteger = I.integerMul negateInteger :: Integer -> Integer +{-# INLINE negateInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer negateInteger = I.integerNegate absInteger :: Integer -> Integer +{-# INLINE absInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer absInteger = I.integerAbs signumInteger :: Integer -> Integer +{-# INLINE signumInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer signumInteger = I.integerSignum divModInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE divModInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divModInteger = I.integerDivMod# divInteger :: Integer -> Integer -> Integer +{-# INLINE divInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer divInteger = I.integerDiv modInteger :: Integer -> Integer -> Integer +{-# INLINE modInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer modInteger = I.integerMod quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) +{-# INLINE quotRemInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotRemInteger = I.integerQuotRem# quotInteger :: Integer -> Integer -> Integer +{-# INLINE quotInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer quotInteger = I.integerQuot remInteger :: Integer -> Integer -> Integer +{-# INLINE remInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer remInteger = I.integerRem eqInteger :: Integer -> Integer -> Bool +{-# INLINE eqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger = I.integerEq neqInteger :: Integer -> Integer -> Bool +{-# INLINE neqInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger = I.integerNe leInteger :: Integer -> Integer -> Bool +{-# INLINE leInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger = I.integerLe gtInteger :: Integer -> Integer -> Bool +{-# INLINE gtInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger = I.integerGt ltInteger :: Integer -> Integer -> Bool +{-# INLINE ltInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger = I.integerLt geInteger :: Integer -> Integer -> Bool +{-# INLINE geInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger = I.integerGe compareInteger :: Integer -> Integer -> Ordering +{-# INLINE compareInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer compareInteger = I.integerCompare eqInteger# :: Integer -> Integer -> Int# +{-# INLINE eqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer eqInteger# = I.integerEq# neqInteger# :: Integer -> Integer -> Int# +{-# INLINE neqInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer neqInteger# = I.integerNe# leInteger# :: Integer -> Integer -> Int# +{-# INLINE leInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer leInteger# = I.integerLe# gtInteger# :: Integer -> Integer -> Int# +{-# INLINE gtInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer gtInteger# = I.integerGt# ltInteger# :: Integer -> Integer -> Int# +{-# INLINE ltInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer ltInteger# = I.integerLt# geInteger# :: Integer -> Integer -> Int# +{-# INLINE geInteger# #-} -- See Note [Integer constant folding] in GHC.Num.Integer geInteger# = I.integerGe# andInteger :: Integer -> Integer -> Integer +{-# INLINE andInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer andInteger = I.integerAnd orInteger :: Integer -> Integer -> Integer +{-# INLINE orInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer orInteger = I.integerOr xorInteger :: Integer -> Integer -> Integer +{-# INLINE xorInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer xorInteger = I.integerXor complementInteger :: Integer -> Integer +{-# INLINE complementInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer complementInteger = I.integerComplement shiftLInteger :: Integer -> Int# -> Integer +{-# INLINE shiftLInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftLInteger n i = I.integerShiftL# n (int2Word# i) shiftRInteger :: Integer -> Int# -> Integer +{-# INLINE shiftRInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer shiftRInteger n i = I.integerShiftR# n (int2Word# i) testBitInteger :: Integer -> Int# -> Bool +{-# INLINE testBitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer testBitInteger n i = isTrue# (I.integerTestBit# n (int2Word# i)) hashInteger :: Integer -> Int# +{-# INLINE hashInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer hashInteger = I.integerToInt# bitInteger :: Int# -> Integer +{-# INLINE bitInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer bitInteger i = I.integerBit# (int2Word# i) popCountInteger :: Integer -> Int# +{-# INLINE popCountInteger #-} -- See Note [Integer constant folding] in GHC.Num.Integer popCountInteger = I.integerPopCount# - ===================================== libraries/base/GHC/Num.hs ===================================== @@ -109,7 +109,7 @@ instance Num Int where | n `eqInt` 0 = 0 | otherwise = 1 - {-# INLINE fromInteger #-} -- Just to be sure! + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToInt i -- | @since 2.01 @@ -121,6 +121,7 @@ instance Num Word where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = integerToWord i -- | @since 2.01 @@ -150,6 +151,7 @@ instance Num Natural where | naturalIsZero x = x | otherwise = raise# underflowException + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger x | x < 0 = raise# underflowException | otherwise = integerToNaturalClamp x @@ -160,4 +162,3 @@ instance Num Natural where {-# DEPRECATED quotRemInteger "Use integerQuotRem# instead" #-} quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotRemInteger = integerQuotRem# - ===================================== libraries/base/GHC/Real.hs ===================================== @@ -324,7 +324,8 @@ instance Real Int where -- | @since 2.0.1 instance Integral Int where - toInteger (I# i) = IS i + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (I# x) = integerFromInt# x a `quot` b | b == 0 = divZeroError @@ -399,6 +400,7 @@ instance Integral Word where divMod (W# x#) y@(W# y#) | y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W# x#) = integerFromWord# x# -------------------------------------------------------------- @@ -413,71 +415,60 @@ instance Real Integer where instance Real Natural where toRational n = integerFromNatural n :% 1 --- Note [Integer division constant folding] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- Constant folding of quot, rem, div, mod, divMod and quotRem for Integer --- arguments depends crucially on inlining. Constant folding rules defined in --- GHC.Core.Opt.ConstantFold trigger for integerQuot, integerRem and so on. --- So if calls to quot, rem and so on were not inlined the rules would not fire. --- --- The rules would also not fire if calls to integerQuot and so on were inlined, --- but this does not happen because they are all marked with NOINLINE pragma. - - -- | @since 2.0.1 instance Integral Integer where toInteger n = n - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `integerQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `integerRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `integerDiv` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `integerMod` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `integerDivMod` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `integerQuotRem` d -- | @since 4.8.0.0 instance Integral Natural where + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger = integerFromNatural - {-# INLINE quot #-} + {-# INLINE quot #-} -- See Note [Integer constant folding] _ `quot` 0 = divZeroError n `quot` d = n `naturalQuot` d - {-# INLINE rem #-} + {-# INLINE rem #-} -- See Note [Integer constant folding] _ `rem` 0 = divZeroError n `rem` d = n `naturalRem` d - {-# INLINE div #-} + {-# INLINE div #-} -- See Note [Integer constant folding] _ `div` 0 = divZeroError n `div` d = n `naturalQuot` d - {-# INLINE mod #-} + {-# INLINE mod #-} -- See Note [Integer constant folding] _ `mod` 0 = divZeroError n `mod` d = n `naturalRem` d - {-# INLINE divMod #-} + {-# INLINE divMod #-} -- See Note [Integer constant folding] _ `divMod` 0 = divZeroError n `divMod` d = n `naturalQuotRem` d - {-# INLINE quotRem #-} + {-# INLINE quotRem #-} -- See Note [Integer constant folding] _ `quotRem` 0 = divZeroError n `quotRem` d = n `naturalQuotRem` d ===================================== libraries/base/GHC/Word.hs ===================================== @@ -112,6 +112,7 @@ instance Num Word8 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W8# (narrow8Word# (integerToWord# i)) -- | @since 2.01 @@ -156,7 +157,8 @@ instance Integral Word8 where divMod (W8# x#) y@(W8# y#) | y /= 0 = (W8# (x# `quotWord#` y#), W8# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W8# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W8# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word8 where @@ -303,6 +305,7 @@ instance Num Word16 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W16# (narrow16Word# (integerToWord# i)) -- | @since 2.01 @@ -347,7 +350,8 @@ instance Integral Word16 where divMod (W16# x#) y@(W16# y#) | y /= 0 = (W16# (x# `quotWord#` y#), W16# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W16# x#) = IS (word2Int# x#) + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W16# x#) = integerFromWord# x# -- | @since 2.01 instance Bounded Word16 where @@ -533,6 +537,7 @@ instance Num Word32 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W32# (narrow32Word# (integerToWord# i)) -- | @since 2.01 @@ -587,15 +592,8 @@ instance Integral Word32 where divMod (W32# x#) y@(W32# y#) | y /= 0 = (W32# (x# `quotWord#` y#), W32# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W32# x#) -#if WORD_SIZE_IN_BITS == 32 - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# -#else - = IS (word2Int# x#) -#endif + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W32# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word32 where @@ -728,6 +726,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord64# i) -- | @since 2.01 @@ -770,6 +769,7 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord64#` y#), W64# (x# `remWord64#` y#)) | otherwise = divZeroError + {-# INLINE toInteger #-} -- See Note [Integer constant folding] toInteger (W64# x#) = integerFromWord64# x# -- | @since 2.01 @@ -875,6 +875,7 @@ instance Num Word64 where abs x = x signum 0 = 0 signum _ = 1 + {-# INLINE fromInteger #-} -- See Note [Integer constant folding] fromInteger i = W64# (integerToWord# i) -- | @since 2.01 @@ -953,11 +954,8 @@ instance Integral Word64 where divMod (W64# x#) y@(W64# y#) | y /= 0 = (W64# (x# `quotWord#` y#), W64# (x# `remWord#` y#)) | otherwise = divZeroError - toInteger (W64# x#) - | isTrue# (i# >=# 0#) = IS i# - | otherwise = integerFromWord# x# - where - !i# = word2Int# x# + {-# INLINE toInteger #-} -- See Note [Integer constant folding] + toInteger (W64# x#) = integerFromWord# x# -- | @since 2.01 instance Bits Word64 where ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-spec-constr #-} -- See Note [Integer constant folding], + -- the bit about `integerAdd` {-# LANGUAGE CPP #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE BangPatterns #-} @@ -66,6 +68,7 @@ integerCheck# (IN bn) = bigNatCheck# bn &&# (bn `bigNatGtWord#` ABS_INT_MINBOUND -- | Check Integer invariants integerCheck :: Integer -> Bool +{-# INLINE integerCheck #-} integerCheck i = isTrue# (integerCheck# i) -- | Integer Zero @@ -137,26 +140,29 @@ integerToBigNatClamp# _ = bigNatZero# (# #) -- | Create an Integer from an Int# integerFromInt# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt# #-} -- See Note [Integer constant folding] integerFromInt# i = IS i -- | Create an Integer from an Int integerFromInt :: Int -> Integer -integerFromInt (I# i) = IS i +{-# INLINE integerFromInt #-} -- See Note [Integer constant folding] +integerFromInt (I# i) = integerFromInt# i -- | Truncates 'Integer' to least-significant 'Int#' integerToInt# :: Integer -> Int# -{-# NOINLINE integerToInt# #-} +{-# NOINLINE[0] integerToInt# #-} -- See Note [Integer constant folding] integerToInt# (IS i) = i integerToInt# (IP b) = word2Int# (bigNatToWord# b) integerToInt# (IN b) = negateInt# (word2Int# (bigNatToWord# b)) -- | Truncates 'Integer' to least-significant 'Int#' integerToInt :: Integer -> Int +{-# INLINE integerToInt #-} -- See Note [Integer constant folding] integerToInt i = I# (integerToInt# i) -- | Convert a Word# into an Integer integerFromWord# :: Word# -> Integer -{-# NOINLINE integerFromWord# #-} +{-# NOINLINE[0] integerFromWord# #-} -- See Note [Integer constant folding] integerFromWord# w | i <- word2Int# w , isTrue# (i >=# 0#) @@ -167,6 +173,7 @@ integerFromWord# w -- | Convert a Word into an Integer integerFromWord :: Word -> Integer +{-# INLINE integerFromWord #-} -- See Note [Integer constant folding] integerFromWord (W# w) = integerFromWord# w -- | Create a negative Integer with the given Word magnitude @@ -185,23 +192,25 @@ integerFromWordSign# _ w = integerFromWordNeg# w -- | Truncate an Integer into a Word integerToWord# :: Integer -> Word# -{-# NOINLINE integerToWord# #-} +{-# NOINLINE[0] integerToWord# #-} -- See Note [Integer constant folding] integerToWord# (IS i) = int2Word# i integerToWord# (IP bn) = bigNatToWord# bn integerToWord# (IN bn) = int2Word# (negateInt# (word2Int# (bigNatToWord# bn))) -- | Truncate an Integer into a Word integerToWord :: Integer -> Word +{-# INLINE integerToWord #-} -- See Note [Integer constant folding] integerToWord !i = W# (integerToWord# i) -- | Convert a Natural into an Integer integerFromNatural :: Natural -> Integer -{-# NOINLINE integerFromNatural #-} +{-# NOINLINE[0] integerFromNatural #-} -- See Note [Integer constant folding] integerFromNatural (NS x) = integerFromWord# x integerFromNatural (NB x) = integerFromBigNat# x -- | Convert a list of Word into an Integer integerFromWordList :: Bool -> [Word] -> Integer +{-# INLINE integerFromWordList #-} -- See Note [Integer constant folding] integerFromWordList True ws = integerFromBigNatNeg# (bigNatFromWordList ws) integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) @@ -209,7 +218,7 @@ integerFromWordList False ws = integerFromBigNat# (bigNatFromWordList ws) -- -- Return 0 for negative Integers. integerToNaturalClamp :: Integer -> Natural -{-# NOINLINE integerToNaturalClamp #-} +{-# NOINLINE[0] integerToNaturalClamp #-} -- See Note [Integer constant folding] integerToNaturalClamp (IS x) | isTrue# (x <# 0#) = naturalZero | True = naturalFromWord# (int2Word# x) @@ -220,7 +229,7 @@ integerToNaturalClamp (IN _) = naturalZero -- -- Return absolute value integerToNatural :: Integer -> Natural -{-# NOINLINE integerToNatural #-} +{-# NOINLINE[0] integerToNatural #-} -- See Note [Integer constant folding] integerToNatural (IS x) = naturalFromWord# (wordFromAbsInt# x) integerToNatural (IP x) = naturalFromBigNat# x integerToNatural (IN x) = naturalFromBigNat# x @@ -237,40 +246,50 @@ integerIsNegative# (IN _) = 1# -- | Negative predicate integerIsNegative :: Integer -> Bool +{-# INLINE integerIsNegative #-} -- See Note [Integer constant folding] integerIsNegative !i = isTrue# (integerIsNegative# i) -- | Zero predicate integerIsZero :: Integer -> Bool +{-# INLINE integerIsZero #-} -- See Note [Integer constant folding] integerIsZero (IS 0#) = True integerIsZero _ = False -- | Not-equal predicate. integerNe :: Integer -> Integer -> Bool +{-# INLINE integerNe #-} -- See Note [Integer constant folding] integerNe !x !y = isTrue# (integerNe# x y) -- | Equal predicate. integerEq :: Integer -> Integer -> Bool +{-# INLINE integerEq #-} -- See Note [Integer constant folding] integerEq !x !y = isTrue# (integerEq# x y) -- | Lower-or-equal predicate. integerLe :: Integer -> Integer -> Bool +{-# INLINE integerLe #-} -- See Note [Integer constant folding] integerLe !x !y = isTrue# (integerLe# x y) -- | Lower predicate. integerLt :: Integer -> Integer -> Bool +{-# INLINE integerLt #-} -- See Note [Integer constant folding] integerLt !x !y = isTrue# (integerLt# x y) -- | Greater predicate. integerGt :: Integer -> Integer -> Bool +{-# INLINE integerGt #-} -- See Note [Integer constant folding] integerGt !x !y = isTrue# (integerGt# x y) -- | Greater-or-equal predicate. integerGe :: Integer -> Integer -> Bool +{-# INLINE integerGe #-} -- See Note [Integer constant folding] integerGe !x !y = isTrue# (integerGe# x y) -- | Equal predicate. integerEq# :: Integer -> Integer -> Bool# -{-# NOINLINE integerEq# #-} +{-# NOINLINE integerEq# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerEq# (IS x) (IS y) = x ==# y integerEq# (IN x) (IN y) = bigNatEq# x y integerEq# (IP x) (IP y) = bigNatEq# x y @@ -278,7 +297,9 @@ integerEq# _ _ = 0# -- | Not-equal predicate. integerNe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerNe# #-} +{-# NOINLINE integerNe# #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerNe# (IS x) (IS y) = x /=# y integerNe# (IN x) (IN y) = bigNatNe# x y integerNe# (IP x) (IP y) = bigNatNe# x y @@ -286,39 +307,43 @@ integerNe# _ _ = 1# -- | Greater predicate. integerGt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGt# #-} +{-# NOINLINE[0] integerGt# #-} -- See Note [Integer constant folding] integerGt# (IS x) (IS y) = x ># y integerGt# x y | GT <- integerCompare x y = 1# integerGt# _ _ = 0# -- | Lower-or-equal predicate. integerLe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLe# #-} +{-# NOINLINE[0] integerLe# #-} -- See Note [Integer constant folding] integerLe# (IS x) (IS y) = x <=# y integerLe# x y | GT <- integerCompare x y = 0# integerLe# _ _ = 1# -- | Lower predicate. integerLt# :: Integer -> Integer -> Bool# -{-# NOINLINE integerLt# #-} +{-# NOINLINE[0] integerLt# #-} -- See Note [Integer constant folding] integerLt# (IS x) (IS y) = x <# y integerLt# x y | LT <- integerCompare x y = 1# integerLt# _ _ = 0# -- | Greater-or-equal predicate. integerGe# :: Integer -> Integer -> Bool# -{-# NOINLINE integerGe# #-} +{-# NOINLINE[0] integerGe# #-} -- See Note [Integer constant folding] integerGe# (IS x) (IS y) = x >=# y integerGe# x y | LT <- integerCompare x y = 0# integerGe# _ _ = 1# instance Eq Integer where + {-# INLINE (==) #-} -- See Note [Integer constant folding] (==) = integerEq + {-# INLINE (/=) #-} -- See Note [Integer constant folding] (/=) = integerNe -- | Compare two Integer integerCompare :: Integer -> Integer -> Ordering -{-# NOINLINE integerCompare #-} +{-# NOINLINE integerCompare #-} -- See Note [Integer constant folding] + -- But this function will be too huge if inlined + -- at all. Hence NOINLINE, without [0] integerCompare (IS x) (IS y) = compareInt# x y integerCompare (IP x) (IP y) = bigNatCompare x y integerCompare (IN x) (IN y) = bigNatCompare y x @@ -330,6 +355,7 @@ integerCompare (IP _) (IN _) = GT integerCompare (IN _) (IP _) = LT instance Ord Integer where + {-# INLINE compare #-} -- See Note [Integer constant folding] compare = integerCompare --------------------------------------------------------------------- @@ -338,7 +364,7 @@ instance Ord Integer where -- | Subtract one 'Integer' from another. integerSub :: Integer -> Integer -> Integer -{-# NOINLINE integerSub #-} +{-# NOINLINE[0] integerSub #-} -- See Note [Integer constant folding] integerSub !x (IS 0#) = x integerSub (IS x#) (IS y#) = case subIntC# x# y# of @@ -384,7 +410,7 @@ integerSub (IN x) (IS y#) -- | Add two 'Integer's integerAdd :: Integer -> Integer -> Integer -{-# NOINLINE integerAdd #-} +{-# NOINLINE[0] integerAdd #-} -- See Note [Integer constant folding] integerAdd !x (IS 0#) = x integerAdd (IS 0#) y = y integerAdd (IS x#) (IS y#) @@ -413,7 +439,7 @@ integerAdd (IP x) (IN y) -- | Multiply two 'Integer's integerMul :: Integer -> Integer -> Integer -{-# NOINLINE integerMul #-} +{-# NOINLINE[0] integerMul #-} -- See Note [Integer constant folding] integerMul !_ (IS 0#) = IS 0# integerMul (IS 0#) _ = IS 0# integerMul x (IS 1#) = x @@ -478,7 +504,7 @@ integerMul (IN x) (IS y) -- IP is used iff n > maxBound::Int -- IN is used iff n < minBound::Int integerNegate :: Integer -> Integer -{-# NOINLINE integerNegate #-} +{-# NOINLINE[0] integerNegate #-} -- See Note [Integer constant folding] integerNegate (IN b) = IP b integerNegate (IS INT_MINBOUND#) = IP (bigNatFromWord# ABS_INT_MINBOUND##) integerNegate (IS i) = IS (negateInt# i) @@ -492,7 +518,7 @@ integerNegate (IP b) -- | Compute absolute value of an 'Integer' integerAbs :: Integer -> Integer -{-# NOINLINE integerAbs #-} +{-# NOINLINE[0] integerAbs #-} -- See Note [Integer constant folding] integerAbs (IN i) = IP i integerAbs n@(IP _) = n integerAbs n@(IS i) @@ -504,13 +530,13 @@ integerAbs n@(IS i) -- | Return @-1@, @0@, and @1@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum :: Integer -> Integer -{-# NOINLINE integerSignum #-} +{-# NOINLINE[0] integerSignum #-} -- See Note [Integer constant folding] integerSignum !j = IS (integerSignum# j) -- | Return @-1#@, @0#@, and @1#@ depending on whether argument is -- negative, zero, or positive, respectively integerSignum# :: Integer -> Int# -{-# NOINLINE integerSignum# #-} +{-# NOINLINE[0] integerSignum# #-} -- See Note [Integer constant folding] integerSignum# (IN _) = -1# integerSignum# (IS i#) = sgnI# i# integerSignum# (IP _ ) = 1# @@ -518,7 +544,7 @@ integerSignum# (IP _ ) = 1# -- | Count number of set bits. For negative arguments returns -- the negated population count of the absolute value. integerPopCount# :: Integer -> Int# -{-# NOINLINE integerPopCount# #-} +{-# NOINLINE[0] integerPopCount# #-} -- See Note [Integer constant folding] integerPopCount# (IS i) | isTrue# (i >=# 0#) = word2Int# (popCntI# i) | True = negateInt# (word2Int# (popCntI# (negateInt# i))) @@ -527,7 +553,7 @@ integerPopCount# (IN bn) = negateInt# (word2Int# (bigNatPopCount# bn)) -- | Positive 'Integer' for which only /n/-th bit is set integerBit# :: Word# -> Integer -{-# NOINLINE integerBit# #-} +{-# NOINLINE[0] integerBit# #-} -- See Note [Integer constant folding] integerBit# i | isTrue# (i `ltWord#` (WORD_SIZE_IN_BITS## `minusWord#` 1##)) = IS (uncheckedIShiftL# 1# (word2Int# i)) @@ -536,13 +562,14 @@ integerBit# i -- | 'Integer' for which only /n/-th bit is set integerBit :: Word -> Integer +{-# INLINE integerBit #-} -- See Note [Integer constant folding] integerBit (W# i) = integerBit# i -- | Test if /n/-th bit is set. -- -- Fake 2's complement for negative values (might be slow) integerTestBit# :: Integer -> Word# -> Bool# -{-# NOINLINE integerTestBit# #-} +{-# NOINLINE[0] integerTestBit# #-} -- See Note [Integer constant folding] integerTestBit# (IS x) i | isTrue# (i `ltWord#` WORD_SIZE_IN_BITS##) = testBitI# x i @@ -572,13 +599,14 @@ integerTestBit# (IN x) i -- -- Fake 2's complement for negative values (might be slow) integerTestBit :: Integer -> Word -> Bool +{-# INLINE integerTestBit #-} -- See Note [Integer constant folding] integerTestBit !i (W# n) = isTrue# (integerTestBit# i n) -- | Shift-right operation -- -- Fake 2's complement for negative values (might be slow) integerShiftR# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftR# #-} +{-# NOINLINE[0] integerShiftR# #-} -- See Note [Integer constant folding] integerShiftR# !x 0## = x integerShiftR# (IS i) n = IS (iShiftRA# i (word2Int# n)) where @@ -595,11 +623,12 @@ integerShiftR# (IN bn) n = -- -- Fake 2's complement for negative values (might be slow) integerShiftR :: Integer -> Word -> Integer +{-# INLINE integerShiftR #-} -- See Note [Integer constant folding] integerShiftR !x (W# w) = integerShiftR# x w -- | Shift-left operation integerShiftL# :: Integer -> Word# -> Integer -{-# NOINLINE integerShiftL# #-} +{-# NOINLINE[0] integerShiftL# #-} -- See Note [Integer constant folding] integerShiftL# !x 0## = x integerShiftL# (IS 0#) _ = IS 0# integerShiftL# (IS 1#) n = integerBit# n @@ -614,13 +643,14 @@ integerShiftL# (IN bn) n = IN (bigNatShiftL# bn n) -- Remember that bits are stored in sign-magnitude form, hence the behavior of -- negative Integers is different from negative Int's behavior. integerShiftL :: Integer -> Word -> Integer +{-# INLINE integerShiftL #-} -- See Note [Integer constant folding] integerShiftL !x (W# w) = integerShiftL# x w -- | Bitwise OR operation -- -- Fake 2's complement for negative values (might be slow) integerOr :: Integer -> Integer -> Integer -{-# NOINLINE integerOr #-} +{-# NOINLINE[0] integerOr #-} -- See Note [Integer constant folding] integerOr a b = case a of IS 0# -> b IS -1# -> IS -1# @@ -679,7 +709,7 @@ integerOr a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerXor :: Integer -> Integer -> Integer -{-# NOINLINE integerXor #-} +{-# NOINLINE[0] integerXor #-} -- See Note [Integer constant folding] integerXor a b = case a of IS 0# -> b IS -1# -> integerComplement b @@ -734,7 +764,7 @@ integerXor a b = case a of -- -- Fake 2's complement for negative values (might be slow) integerAnd :: Integer -> Integer -> Integer -{-# NOINLINE integerAnd #-} +{-# NOINLINE[0] integerAnd #-} -- See Note [Integer constant folding] integerAnd a b = case a of IS 0# -> IS 0# IS -1# -> b @@ -769,7 +799,7 @@ integerAnd a b = case a of -- | Binary complement of the integerComplement :: Integer -> Integer -{-# NOINLINE integerComplement #-} +{-# NOINLINE[0] integerComplement #-} -- See Note [Integer constant folding] integerComplement (IS x) = IS (notI# x) integerComplement (IP x) = IN (bigNatAddWord# x 1##) integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) @@ -780,7 +810,7 @@ integerComplement (IN x) = IP (bigNatSubWordUnsafe# x 1##) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerQuotRem# #-} +{-# NOINLINE[0] integerQuotRem# #-} -- See Note [Integer constant folding] integerQuotRem# !n (IS 1#) = (# n, IS 0# #) integerQuotRem# !n (IS -1#) = let !q = integerNegate n in (# q, (IS 0#) #) integerQuotRem# !_ (IS 0#) = case raiseDivZero of @@ -818,12 +848,13 @@ integerQuotRem# n@(IS n#) (IP d) -- need to account for (IS minBound) -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerQuotRem :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerQuotRem #-} -- See Note [Integer constant folding] integerQuotRem !x !y = case integerQuotRem# x y of (# q, r #) -> (q, r) integerQuot :: Integer -> Integer -> Integer -{-# NOINLINE integerQuot #-} +{-# NOINLINE[0] integerQuot #-} -- See Note [Integer constant folding] integerQuot !n (IS 1#) = n integerQuot !n (IS -1#) = integerNegate n integerQuot !_ (IS 0#) = raiseDivZero @@ -844,7 +875,7 @@ integerQuot (IN n) (IN d) = integerFromBigNat# (bigNatQuot n d) integerQuot n d = case integerQuotRem# n d of (# q, _ #) -> q integerRem :: Integer -> Integer -> Integer -{-# NOINLINE integerRem #-} +{-# NOINLINE[0] integerRem #-} -- See Note [Integer constant folding] integerRem !_ (IS 1#) = IS 0# integerRem _ (IS -1#) = IS 0# integerRem _ (IS 0#) = IS (remInt# 0# 0#) @@ -866,7 +897,7 @@ integerRem n d = case integerQuotRem# n d of (# _, r #) -> r -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod# :: Integer -> Integer -> (# Integer, Integer #) -{-# NOINLINE integerDivMod# #-} +{-# NOINLINE[0] integerDivMod# #-} -- See Note [Integer constant folding] integerDivMod# !n !d | isTrue# (integerSignum# r ==# negateInt# (integerSignum# d)) = let !q' = integerSub q (IS 1#) @@ -881,12 +912,13 @@ integerDivMod# !n !d -- Divisor must be non-zero otherwise the GHC runtime will terminate -- with a division-by-zero fault. integerDivMod :: Integer -> Integer -> (Integer, Integer) +{-# INLINE integerDivMod #-} -- See Note [Integer constant folding] integerDivMod !n !d = case integerDivMod# n d of (# q,r #) -> (q,r) integerDiv :: Integer -> Integer -> Integer -{-# NOINLINE integerDiv #-} +{-# NOINLINE[0] integerDiv #-} -- See Note [Integer constant folding] integerDiv !n !d -- same-sign ops can be handled by more efficient 'integerQuot' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerQuot n d @@ -894,7 +926,7 @@ integerDiv !n !d integerMod :: Integer -> Integer -> Integer -{-# NOINLINE integerMod #-} +{-# NOINLINE[0] integerMod #-} -- See Note [Integer constant folding] integerMod !n !d -- same-sign ops can be handled by more efficient 'integerRem' | isTrue# (integerIsNegative# n ==# integerIsNegative# d) = integerRem n d @@ -902,7 +934,7 @@ integerMod !n !d -- | Compute greatest common divisor. integerGcd :: Integer -> Integer -> Integer -{-# NOINLINE integerGcd #-} +{-# NOINLINE[0] integerGcd #-} -- See Note [Integer constant folding] integerGcd (IS 0#) !b = integerAbs b integerGcd a (IS 0#) = integerAbs a integerGcd (IS 1#) _ = IS 1# @@ -920,7 +952,7 @@ integerGcd (IP a) (IS b) = integerFromWord# (bigNatGcdWord# a (int2Word# (ab -- | Compute least common multiple. integerLcm :: Integer -> Integer -> Integer -{-# NOINLINE integerLcm #-} +{-# NOINLINE[0] integerLcm #-} -- See Note [Integer constant folding] integerLcm (IS 0#) !_ = IS 0# integerLcm (IS 1#) b = integerAbs b integerLcm (IS -1#) b = integerAbs b @@ -934,6 +966,7 @@ integerLcm a b = (aa `integerQuot` (aa `integerGcd` ab)) `integerMul` ab -- | Square a Integer integerSqr :: Integer -> Integer +{-# INLINE integerSqr #-} -- See Note [Integer constant folding] integerSqr !a = integerMul a a @@ -951,6 +984,7 @@ integerLog2# (IP b) = bigNatLog2# b -- -- For numbers <= 0, return 0 integerLog2 :: Integer -> Word +{-# INLINE integerLog2 #-} -- See Note [Integer constant folding] integerLog2 !i = W# (integerLog2# i) -- | Logarithm (floor) for an arbitrary base @@ -965,6 +999,7 @@ integerLogBaseWord# base !i -- -- For numbers <= 0, return 0 integerLogBaseWord :: Word -> Integer -> Word +{-# INLINE integerLogBaseWord #-} -- See Note [Integer constant folding] integerLogBaseWord (W# base) !i = W# (integerLogBaseWord# base i) -- | Logarithm (floor) for an arbitrary base @@ -980,6 +1015,7 @@ integerLogBase# !base !i -- -- For numbers <= 0, return 0 integerLogBase :: Integer -> Integer -> Word +{-# INLINE integerLogBase #-} -- See Note [Integer constant folding] integerLogBase !base !i = W# (integerLogBase# base i) -- | Indicate if the value is a power of two and which one @@ -994,7 +1030,7 @@ integerIsPowerOf2# (IP w) = bigNatIsPowerOf2# w -- | Convert an Int64# into an Integer on 32-bit architectures integerFromInt64# :: Int64# -> Integer -{-# NOINLINE integerFromInt64# #-} +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !i | isTrue# ((i `leInt64#` intToInt64# 0x7FFFFFFF#) &&# (i `geInt64#` intToInt64# -0x80000000#)) @@ -1008,7 +1044,7 @@ integerFromInt64# !i -- | Convert a Word64# into an Integer on 32-bit architectures integerFromWord64# :: Word64# -> Integer -{-# NOINLINE integerFromWord64# #-} +{-# NOINLINE[0] integerFromWord64# #-} -- See Note [Integer constant folding] integerFromWord64# !w | isTrue# (w `leWord64#` wordToWord64# 0x7FFFFFFF##) = IS (int64ToInt# (word64ToInt64# w)) @@ -1017,14 +1053,14 @@ integerFromWord64# !w -- | Convert an Integer into an Int64# on 32-bit architectures integerToInt64# :: Integer -> Int64# -{-# NOINLINE integerToInt64# #-} +{-# NOINLINE[0] integerToInt64# #-} -- See Note [Integer constant folding] integerToInt64# (IS i) = intToInt64# i integerToInt64# (IP b) = word64ToInt64# (bigNatToWord64# b) integerToInt64# (IN b) = negateInt64# (word64ToInt64# (bigNatToWord64# b)) -- | Convert an Integer into a Word64# on 32-bit architectures integerToWord64# :: Integer -> Word64# -{-# NOINLINE integerToWord64# #-} +{-# NOINLINE[0] integerToWord64# #-} -- See Note [Integer constant folding] integerToWord64# (IS i) = int64ToWord64# (intToInt64# i) integerToWord64# (IP b) = bigNatToWord64# b integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatToWord64# b))) @@ -1033,6 +1069,7 @@ integerToWord64# (IN b) = int64ToWord64# (negateInt64# (word64ToInt64# (bigNatTo -- | Convert an Int64# into an Integer on 64-bit architectures integerFromInt64# :: Int# -> Integer +{-# NOINLINE[0] integerFromInt64# #-} -- See Note [Integer constant folding] integerFromInt64# !x = IS x #endif @@ -1043,18 +1080,19 @@ integerFromInt64# !x = IS x -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble# :: Double# -> (# Integer, Int# #) -{-# NOINLINE integerDecodeDouble# #-} +{-# NOINLINE[0] integerDecodeDouble# #-} -- See Note [Integer constant folding] integerDecodeDouble# !x = case decodeDouble_Int64# x of (# m, e #) -> (# integerFromInt64# m, e #) -- | Decode a Double# into (# Integer mantissa, Int# exponent #) integerDecodeDouble :: Double -> (Integer, Int) +{-# INLINE integerDecodeDouble #-} -- See Note [Integer constant folding] integerDecodeDouble (D# x) = case integerDecodeDouble# x of (# m, e #) -> (m, I# e) -- | Encode (# Integer mantissa, Int# exponent #) into a Double# integerEncodeDouble# :: Integer -> Int# -> Double# -{-# NOINLINE integerEncodeDouble# #-} +{-# NOINLINE[0] integerEncodeDouble# #-} -- See Note [Integer constant folding] integerEncodeDouble# (IS i) 0# = int2Double# i integerEncodeDouble# (IS i) e = intEncodeDouble# i e integerEncodeDouble# (IP b) e = bigNatEncodeDouble# b e @@ -1062,23 +1100,24 @@ integerEncodeDouble# (IN b) e = negateDouble# (bigNatEncodeDouble# b e) -- | Encode (Integer mantissa, Int exponent) into a Double integerEncodeDouble :: Integer -> Int -> Double +{-# INLINE integerEncodeDouble #-} -- See Note [Integer constant folding] integerEncodeDouble !m (I# e) = D# (integerEncodeDouble# m e) -- | Encode an Integer (mantissa) into a Double# integerToDouble# :: Integer -> Double# -{-# NOINLINE integerToDouble# #-} +{-# NOINLINE[0] integerToDouble# #-} -- See Note [Integer constant folding] integerToDouble# !i = integerEncodeDouble# i 0# -- | Encode an Integer (mantissa) into a Float# integerToFloat# :: Integer -> Float# -{-# NOINLINE integerToFloat# #-} +{-# NOINLINE[0] integerToFloat# #-} -- See Note [Integer constant folding] integerToFloat# !i = integerEncodeFloat# i 0# -- | Encode (# Integer mantissa, Int# exponent #) into a Float# -- -- TODO: Not sure if it's worth to write 'Float' optimized versions here integerEncodeFloat# :: Integer -> Int# -> Float# -{-# NOINLINE integerEncodeFloat# #-} +{-# NOINLINE[0] integerEncodeFloat# #-} -- See Note [Integer constant folding] integerEncodeFloat# !m 0# = double2Float# (integerToDouble# m) integerEncodeFloat# !m e = double2Float# (integerEncodeDouble# m e) @@ -1108,6 +1147,7 @@ integerToAddr# (IN n) = bigNatToAddr# n -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToAddr :: Integer -> Addr# -> Bool# -> IO Word +{-# INLINE integerToAddr #-} -- See Note [Integer constant folding] integerToAddr a addr e = IO \s -> case integerToAddr# a addr e s of (# s', w #) -> (# s', W# w #) @@ -1135,6 +1175,7 @@ integerFromAddr# sz addr e s = -- -- Null higher limbs are automatically trimed. integerFromAddr :: Word# -> Addr# -> Bool# -> IO Integer +{-# INLINE integerFromAddr #-} -- See Note [Integer constant folding] integerFromAddr sz addr e = IO (integerFromAddr# sz addr e) @@ -1157,6 +1198,7 @@ integerToMutableByteArray# (IN a) = bigNatToMutableByteArray# a -- byte first (big-endian) if @1#@ or least significant byte first -- (little-endian) if @0#@. integerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Bool# -> IO Word +{-# INLINE integerToMutableByteArray #-} -- See Note [Integer constant folding] integerToMutableByteArray i mba w e = IO \s -> case integerToMutableByteArray# i mba w e s of (# s', r #) -> (# s', W# r #) @@ -1183,6 +1225,7 @@ integerFromByteArray# sz ba off e s = case bigNatFromByteArray# sz ba off e s of -- -- Null higher limbs are automatically trimed. integerFromByteArray :: Word# -> ByteArray# -> Word# -> Bool# -> Integer +{-# INLINE integerFromByteArray #-} -- See Note [Integer constant folding] integerFromByteArray sz ba off e = case runRW# (integerFromByteArray# sz ba off e) of (# _, i #) -> i @@ -1215,5 +1258,45 @@ integerGcde :: Integer -> Integer -> ( Integer, Integer, Integer) +{-# INLINE integerGcde #-} -- See Note [Integer constant folding] integerGcde a b = case integerGcde# a b of (# g,x,y #) -> (g,x,y) + +{- Note [Integer constant folding] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We define constant folding rules in "GHC.Core.Opt.ConstantFold" for most of the + at integer*#@ operations in this module, hence they are marked NOINLINE[0]. + +Why NOINLINE[0] rather than NOINLINE? Because + + 1. We still delay inlining long enough for the constant-folding RULEs + to fire + 2. The compiler has the option to inlining the operations late, possibly + cancelling away boxes in the process. + +Why NOINLINE[0] rather than INLINE? Because + + 3. We don't unconditionally inline huge definitions such as + `integerDiv`, which would lead to code bloat at pretty much no + gain. + 4. Since RULEs are unlikely to fire on the inlined RHS of e.g. + `integerDiv`, there is no gain in inlining the unoptimised + unfoldings. + +But since we potentially inline the constant folded operations in phase 0, we +have to make sure that *all* callers that want to take part in constant folding +are marked INLINE. Otherwise, we'd store optimised unfoldings for them, in which +the constant folded functions are inlined. +That concerns for most of the @integer*@ without trailing hash in this module, +as well as the type class instances for 'Eq', 'Ord', 'Num', 'Integral', +'RealFloat' (which is for 'Double'!), etc. + +There are a couple of constant-folded functions that require special treatment, +though: + + * `integerEq`, `integerNe`, `integerCompare`: They are huge and lead to + regressions when inlined. Solution: mark these NOINLINE. + * Under -O2, `integerAdd` will be specialised by SpecConstr. These + specialisations defeat constant folding. + Solution: -fno-spec-constr for this module. +-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cfe4d6bbe12a4c7d560fc19e76d781907bf7bda -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5cfe4d6bbe12a4c7d560fc19e76d781907bf7bda You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 14:07:32 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 10:07:32 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] Accepting metric changes to advance CI Message-ID: <5f7734246fc17_80b3f84875363f816127146@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: c7e6705f by Sebastian Graf at 2020-10-02T16:06:27+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T9872a T9872b T9872c Metric Increase: T13253 T13701 - - - - - 0 changed files: Changes: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7e6705fb267ad71b16865ad01d0e8ac2694d90d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c7e6705fb267ad71b16865ad01d0e8ac2694d90d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 14:18:54 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 02 Oct 2020 10:18:54 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 30 commits: Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Message-ID: <5f7736ce82db8_80bd6431801612819b@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 255f7da3 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 09642b18 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Nested CPR - - - - - 21f4f6a8 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Move tests from stranal to cpranal - - - - - dfa71c42 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Accept FacState - - - - - dd43149b by Sebastian Graf at 2020-10-02T16:17:38+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - accc7b06 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - ffceb656 by Sebastian Graf at 2020-10-02T16:17:38+02:00 stuff - - - - - a0a58d44 by Sebastian Graf at 2020-10-02T16:17:38+02:00 A slew of testsuite changes - - - - - 301fbecc by Sebastian Graf at 2020-10-02T16:17:38+02:00 Fix T1600 - - - - - 5d686400 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Fix primop termination - - - - - cc60de43 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Test for DataCon wrapper CPR - - - - - 77a08dea by Sebastian Graf at 2020-10-02T16:17:38+02:00 Fix CPR of bottoming functions/primops - - - - - d0c371db by Sebastian Graf at 2020-10-02T16:17:38+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - abb7a677 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Accept two more changed test outputs - - - - - 57a1ddea by Sebastian Graf at 2020-10-02T16:17:38+02:00 Update CaseBinderCPR with a new function - - - - - 0882d7a1 by Sebastian Graf at 2020-10-02T16:17:38+02:00 Don't give the case binder the CPR property - - - - - adab24ea by Sebastian Graf at 2020-10-02T16:17:38+02:00 Prune CPR sigs to constant depth on all bindings - - - - - f21d25cf by Sebastian Graf at 2020-10-02T16:17:39+02:00 Use variable length coding for ConTags - - - - - fddeca22 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Accept testuite output - - - - - f36591b7 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - b65459f7 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 9272dc2b by Sebastian Graf at 2020-10-02T16:17:39+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - 295251f3 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Fix T9291 - - - - - 5a7d9758 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - f31e09ad by Sebastian Graf at 2020-10-02T16:17:39+02:00 Testsuite changes - - - - - fe784c0a by Sebastian Graf at 2020-10-02T16:17:39+02:00 Refactoring around cprAnalBind - - - - - f274b8fb by Sebastian Graf at 2020-10-02T16:17:39+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - b013bbed by Sebastian Graf at 2020-10-02T16:17:39+02:00 Regard all arity 0 bindings (incl. DataCon apps) as thunks - - - - - e8241350 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Don't store CPR info for data structures that are NOINLINE - - - - - e41b7ed8 by Sebastian Graf at 2020-10-02T16:17:39+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T9872a T9872b T9872c Metric Increase: T13253 T13701 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Cpr.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/using-optimisation.rst - − libraries/ghc-bignum/gmp/gmp-tarballs - libraries/ghc-bignum/src/GHC/Num/Integer.hs - testsuite/tests/stranal/sigs/CaseBinderCPR.hs → testsuite/tests/cpranal/sigs/CaseBinderCPR.hs - + testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr - testsuite/tests/stranal/sigs/FacState.hs → testsuite/tests/cpranal/sigs/FacState.hs - + testsuite/tests/cpranal/sigs/FacState.stderr - + testsuite/tests/cpranal/sigs/Makefile - testsuite/tests/stranal/should_compile/T10694.hs → testsuite/tests/cpranal/sigs/T10694.hs - + testsuite/tests/cpranal/sigs/T10694.stderr - + testsuite/tests/cpranal/sigs/T1600.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7e6705fb267ad71b16865ad01d0e8ac2694d90d...e41b7ed81ed0bf953b01ca7fff7e39d827238e33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c7e6705fb267ad71b16865ad01d0e8ac2694d90d...e41b7ed81ed0bf953b01ca7fff7e39d827238e33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 17:47:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 02 Oct 2020 13:47:36 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backport-9.0-linear-types-syntax Message-ID: <5f7767b8b02df_80b3f84903a0a9416183673@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backport-9.0-linear-types-syntax at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 17:47:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 02 Oct 2020 13:47:37 -0400 Subject: [Git][ghc/ghc][ghc-9.0] 3 commits: Linear types: fix kind inference when checking datacons Message-ID: <5f7767b94cdc5_80b3f8434fc847c161838ef@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: 93df442a by Krzysztof Gogolewski at 2020-09-30T01:05:27+03:00 Linear types: fix kind inference when checking datacons (cherry picked from b31a3360e2ef12f3ec7eaf66b3600247c1eb36c3) - - - - - 7c7bd94d by Vladislav Zavialov at 2020-09-30T01:06:07+03:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. (cherry-picked from 5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - d5e13ceb by Vladislav Zavialov at 2020-10-02T01:39:25+03:00 Fix pretty-printing of the mult-polymorphic arrow (cherry-picked from a8018c17747342444c67eeec21a506c89c1110e8) - - - - - 30 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/9.0.1-notes.rst - docs/users_guide/exts/linear_types.rst - libraries/base/Data/Typeable/Internal.hs - libraries/template-haskell/Language/Haskell/TH/Ppr.hs - testsuite/tests/linear/should_compile/Linear1Rule.hs - testsuite/tests/linear/should_compile/LinearConstructors.hs - testsuite/tests/linear/should_compile/LinearEmptyCase.hs - testsuite/tests/linear/should_compile/LinearGuards.hs - testsuite/tests/linear/should_compile/LinearTH2.hs - testsuite/tests/linear/should_compile/MultConstructor.hs - testsuite/tests/linear/should_compile/OldList.hs - testsuite/tests/linear/should_compile/Pr110.hs - testsuite/tests/linear/should_compile/all.T - testsuite/tests/linear/should_fail/Linear13.hs - testsuite/tests/linear/should_fail/LinearAsPat.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90fe5cffb0b0ba1ff86b8b9bf5299d0ed8437ad7...d5e13cebc969f9820b6b9437afe0699e15bbc2ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90fe5cffb0b0ba1ff86b8b9bf5299d0ed8437ad7...d5e13cebc969f9820b6b9437afe0699e15bbc2ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 17:52:05 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 13:52:05 -0400 Subject: [Git][ghc/ghc][master] Minor TTG clean-up: comments, unused families, bottom Message-ID: <5f7768c520e44_80b3f847d02888416186783@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 2 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -847,7 +847,6 @@ data HsPragE p | XHsPragE !(XXPragE p) type instance XSCC (GhcPass _) = NoExtField -type instance XCoreAnn (GhcPass _) = NoExtField type instance XXPragE (GhcPass _) = NoExtCon -- | Located Haskell Tuple Argument @@ -2403,7 +2402,7 @@ pprStmt (LastStmt _ expr m_dollar_stripped _) Just False -> text "return" Nothing -> empty) <+> ppr expr -pprStmt (BindStmt _ pat expr) = hsep [ppr pat, larrow, ppr expr] +pprStmt (BindStmt _ pat expr) = pprBindStmt pat expr pprStmt (LetStmt _ (L _ binds)) = hsep [text "let", pprBinds binds] pprStmt (BodyStmt _ expr _ _) = ppr expr pprStmt (ParStmt _ stmtss _ _) = sep (punctuate (text " | ") (map ppr stmtss)) @@ -2439,11 +2438,8 @@ pprStmt (ApplicativeStmt _ args mb_join) flattenArg :: forall a . (a, ApplicativeArg (GhcPass idL)) -> [SDoc] flattenArg (_, ApplicativeArgOne _ pat expr isBody) - | isBody = -- See Note [Applicative BodyStmt] - [ppr (BodyStmt (panic "pprStmt") expr noSyntaxExpr noSyntaxExpr - :: ExprStmt (GhcPass idL))] - | otherwise = - [ppr (BindStmt (panic "pprStmt") pat expr :: ExprStmt (GhcPass idL))] + | isBody = [ppr expr] -- See Note [Applicative BodyStmt] + | otherwise = [pprBindStmt pat expr] flattenArg (_, ApplicativeArgMany _ stmts _ _ _) = concatMap flattenStmt stmts @@ -2457,6 +2453,8 @@ pprStmt (ApplicativeStmt _ args mb_join) pp_arg :: (a, ApplicativeArg (GhcPass idL)) -> SDoc pp_arg (_, applicativeArg) = ppr applicativeArg +pprBindStmt :: (Outputable pat, Outputable expr) => pat -> expr -> SDoc +pprBindStmt pat expr = hsep [ppr pat, larrow, ppr expr] instance (OutputableBndrId idL) => Outputable (ApplicativeArg (GhcPass idL)) where @@ -2464,18 +2462,13 @@ instance (OutputableBndrId idL) pprArg :: forall idL . (OutputableBndrId idL) => ApplicativeArg (GhcPass idL) -> SDoc pprArg (ApplicativeArgOne _ pat expr isBody) - | isBody = -- See Note [Applicative BodyStmt] - ppr (BodyStmt (panic "pprStmt") expr noSyntaxExpr noSyntaxExpr - :: ExprStmt (GhcPass idL)) - | otherwise = - ppr (BindStmt (panic "pprStmt") pat expr :: ExprStmt (GhcPass idL)) + | isBody = ppr expr -- See Note [Applicative BodyStmt] + | otherwise = pprBindStmt pat expr pprArg (ApplicativeArgMany _ stmts return pat ctxt) = ppr pat <+> text "<-" <+> - ppr (HsDo (panic "pprStmt") ctxt (noLoc - (stmts ++ - [noLoc (LastStmt noExtField (noLoc return) Nothing noSyntaxExpr)])) - :: HsExpr (GhcPass idL)) + pprDo ctxt (stmts ++ + [noLoc (LastStmt noExtField (noLoc return) Nothing noSyntaxExpr)]) pprTransformStmt :: (OutputableBndrId p) => [IdP (GhcPass p)] -> LHsExpr (GhcPass p) ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -331,11 +331,11 @@ type family XHsIPBinds x x' type family XEmptyLocalBinds x x' type family XXHsLocalBindsLR x x' --- ValBindsLR type families +-- HsValBindsLR type families type family XValBinds x x' type family XXValBindsLR x x' --- HsBindsLR type families +-- HsBindLR type families type family XFunBind x x' type family XPatBind x x' type family XVarBind x x' @@ -469,7 +469,7 @@ type family XCClsInstDecl x type family XXClsInstDecl x -- ------------------------------------- --- ClsInstDecl type families +-- InstDecl type families type family XClsInstD x type family XDataFamInstD x type family XTyFamInstD x @@ -490,7 +490,7 @@ type family XCDefaultDecl x type family XXDefaultDecl x -- ------------------------------------- --- DefaultDecl type families +-- ForeignDecl type families type family XForeignImport x type family XForeignExport x type family XXForeignDecl x @@ -517,7 +517,7 @@ type family XWarnings x type family XXWarnDecls x -- ------------------------------------- --- AnnDecl type families +-- WarnDecl type families type family XWarning x type family XXWarnDecl x @@ -574,32 +574,34 @@ type family XBinTick x type family XPragE x type family XXExpr x +-- ------------------------------------- +-- HsPragE type families type family XSCC x -type family XCoreAnn x -type family XTickPragma x type family XXPragE x --- --------------------------------------------------------------------- + +-- ------------------------------------- +-- AmbiguousFieldOcc type families type family XUnambiguous x type family XAmbiguous x type family XXAmbiguousFieldOcc x --- ---------------------------------------------------------------------- - +-- ------------------------------------- +-- HsTupArg type families type family XPresent x type family XMissing x type family XXTupArg x --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- HsSplice type families type family XTypedSplice x type family XUntypedSplice x type family XQuasiQuote x type family XSpliced x type family XXSplice x --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- HsBracket type families type family XExpBr x type family XPatBr x type family XDecBrL x @@ -609,33 +611,33 @@ type family XVarBr x type family XTExpBr x type family XXBracket x --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- HsCmdTop type families type family XCmdTop x type family XXCmdTop x -- ------------------------------------- - +-- MatchGroup type families type family XMG x b type family XXMatchGroup x b -- ------------------------------------- - +-- Match type families type family XCMatch x b type family XXMatch x b -- ------------------------------------- - +-- GRHSs type families type family XCGRHSs x b type family XXGRHSs x b -- ------------------------------------- - +-- GRHS type families type family XCGRHS x b type family XXGRHS x b -- ------------------------------------- - +-- StmtLR type families type family XLastStmt x x' b type family XBindStmt x x' b type family XApplicativeStmt x x' b @@ -646,8 +648,8 @@ type family XTransStmt x x' b type family XRecStmt x x' b type family XXStmtLR x x' b --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- HsCmd type families type family XCmdArrApp x type family XCmdArrForm x type family XCmdApp x @@ -661,13 +663,13 @@ type family XCmdDo x type family XCmdWrap x type family XXCmd x --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- ParStmtBlock type families type family XParStmtBlock x x' type family XXParStmtBlock x x' --- --------------------------------------------------------------------- - +-- ------------------------------------- +-- ApplicativeArg type families type family XApplicativeArgOne x type family XApplicativeArgMany x type family XXApplicativeArg x @@ -697,6 +699,8 @@ type family XHsFloatPrim x type family XHsDoublePrim x type family XXLit x +-- ------------------------------------- +-- HsOverLit type families type family XOverLit x type family XXOverLit x @@ -725,26 +729,29 @@ type family XXPat x -- ===================================================================== -- Type families for the HsTypes type families + +-- ------------------------------------- +-- LHsQTyVars type families type family XHsQTvs x type family XXLHsQTyVars x -- ------------------------------------- - +-- HsImplicitBndrs type families type family XHsIB x b type family XXHsImplicitBndrs x b -- ------------------------------------- - +-- HsWildCardBndrs type families type family XHsWC x b type family XXHsWildCardBndrs x b -- ------------------------------------- - +-- HsPatSigType type families type family XHsPS x type family XXHsPatSigType x -- ------------------------------------- - +-- HsType type families type family XForAllTy x type family XQualTy x type family XTyVar x @@ -770,35 +777,37 @@ type family XWildCardTy x type family XXType x -- --------------------------------------------------------------------- - +-- HsForAllTelescope type families type family XHsForAllVis x type family XHsForAllInvis x type family XXHsForAllTelescope x -- --------------------------------------------------------------------- - +-- HsTyVarBndr type families type family XUserTyVar x type family XKindedTyVar x type family XXTyVarBndr x -- --------------------------------------------------------------------- - +-- ConDeclField type families type family XConDeclField x type family XXConDeclField x -- --------------------------------------------------------------------- - +-- FieldOcc type families type family XCFieldOcc x type family XXFieldOcc x -- ===================================================================== -- Type families for the HsImpExp type families +-- ------------------------------------- +-- ImportDecl type families type family XCImportDecl x type family XXImportDecl x -- ------------------------------------- - +-- IE type families type family XIEVar x type family XIEThingAbs x type family XIEThingAll x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c9beab75aaa5fbbb11132c99e2af114f322152f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c9beab75aaa5fbbb11132c99e2af114f322152f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 17:52:47 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 13:52:47 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Bignum: implement integerRecipMod (#18427) Message-ID: <5f7768ef18628_80b770b8e8161892d0@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 17 changed files: - libraries/ghc-bignum/cbits/gmp_wrappers.c - libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs - libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs - libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs-boot - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs-boot - libraries/ghc-bignum/src/GHC/Num/Natural.hs-boot - libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs - testsuite/tests/lib/integer/all.T - testsuite/tests/lib/integer/integerGmpInternals.hs - testsuite/tests/lib/integer/integerGmpInternals.stdout - testsuite/tests/lib/integer/integerPowMod.hs - testsuite/tests/lib/integer/integerPowMod.stdout - + testsuite/tests/lib/integer/integerRecipMod.hs - + testsuite/tests/lib/integer/integerRecipMod.stdout Changes: ===================================== libraries/ghc-bignum/cbits/gmp_wrappers.c ===================================== @@ -632,8 +632,7 @@ integer_gmp_powm(mp_limb_t rp[], // result assert(!mp_limb_zero_p(mp,mn)); if ((mn == 1 || mn == -1) && mp[0] == 1) { - rp[0] = 0; - return 1; + return 0; } if (mp_limb_zero_p(ep,en)) { @@ -659,11 +658,6 @@ integer_gmp_powm(mp_limb_t rp[], // result mpz_clear (r); - if (!rn) { - rp[0] = 0; - return 1; - } - return rn; } @@ -720,8 +714,7 @@ integer_gmp_powm_sec(mp_limb_t rp[], // result assert(mp[0] & 1); if ((mn == 1 || mn == -1) && mp[0] == 1) { - rp[0] = 0; - return 1; + return 0; } if (mp_limb_zero_p(ep,en)) { @@ -753,11 +746,6 @@ integer_gmp_powm_sec(mp_limb_t rp[], // result mpz_clear (r); - if (!rn) { - rp[0] = 0; - return 1; - } - return rn; } @@ -779,8 +767,7 @@ integer_gmp_invert(mp_limb_t rp[], // result if (mp_limb_zero_p(xp,xn) || mp_limb_zero_p(mp,mn) || ((mn == 1 || mn == -1) && mp[0] == 1)) { - rp[0] = 0; - return 1; + return 0; } const mpz_t x = CONST_MPZ_INIT(xp, xn); @@ -800,11 +787,6 @@ integer_gmp_invert(mp_limb_t rp[], // result mpz_clear (r); - if (!rn) { - rp[0] = 0; - return 1; - } - return rn; } ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs ===================================== @@ -17,6 +17,7 @@ import GHC.Types import GHC.Num.WordArray import GHC.Num.Primitives import {-# SOURCE #-} GHC.Num.Integer +import {-# SOURCE #-} GHC.Num.Natural import qualified GHC.Num.Backend.Native as Native import qualified GHC.Num.Backend.Selected as Other @@ -469,3 +470,32 @@ integer_gcde a b = then (# g0, x0, y0 #) else case unexpectedValue of !_ -> (# integerZero, integerZero, integerZero #) + +integer_recip_mod + :: Integer + -> Natural + -> (# Natural | () #) +integer_recip_mod x m = + let + !r0 = Other.integer_recip_mod x m + !r1 = Native.integer_recip_mod x m + in case (# r0, r1 #) of + (# (# | () #), (# | () #) #) -> r0 + (# (# y0 | #), (# y1 | #) #) + | isTrue# (naturalEq# y0 y1) -> r0 + _ -> case unexpectedValue of + !_ -> (# | () #) + +integer_powmod + :: Integer + -> Natural + -> Natural + -> Natural +integer_powmod b e m = + let + !r0 = Other.integer_powmod b e m + !r1 = Native.integer_powmod b e m + in if isTrue# (naturalEq# r0 r1) + then r0 + else case unexpectedValue of + !_ -> naturalZero ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs ===================================== @@ -20,6 +20,8 @@ import GHC.Types import GHC.Num.WordArray import GHC.Num.Primitives import qualified GHC.Num.Backend.Native as Native +import {-# SOURCE #-} GHC.Num.Natural +import {-# SOURCE #-} GHC.Num.Integer default () @@ -596,3 +598,35 @@ integer_gcde = Native.integer_gcde -- for now we use Native's implementation. If some FFI backend user needs a -- specific implementation, we'll need to determine a prototype to pass and -- return BigNat signs and sizes via FFI. + + +-- | Computes the modular inverse of two non-zero integers. +-- +-- I.e. y = integer_recip_mod x m +-- = x^(-1) `mod` m +-- +-- with 0 < y < abs m +integer_recip_mod + :: Integer + -> Natural + -> (# Natural | () #) +integer_recip_mod = Native.integer_recip_mod + -- for now we use Native's implementation. If some FFI backend user needs a + -- specific implementation, we'll need to determine a prototype to pass and + -- return BigNat signs and sizes via FFI. + +-- | Computes the modular exponentiation. +-- +-- I.e. y = integer_powmod b e m +-- = b^e `mod` m +-- +-- with 0 <= y < abs m +integer_powmod + :: Integer + -> Natural + -> Natural + -> Natural +integer_powmod = Native.integer_powmod + -- for now we use Native's implementation. If some FFI backend user needs a + -- specific implementation, we'll need to determine a prototype to pass and + -- return BigNat signs and sizes via FFI. ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs ===================================== @@ -28,6 +28,7 @@ import GHC.Types import GHC.Magic (runRW#) import {-# SOURCE #-} GHC.Num.Integer import {-# SOURCE #-} GHC.Num.BigNat +import {-# SOURCE #-} GHC.Num.Natural default () @@ -354,8 +355,37 @@ bignat_powmod -> WordArray# -> State# RealWorld -> State# RealWorld -bignat_powmod r b e m s = - case ioInt# (integer_gmp_powm# r b (wordArraySize# b) e (wordArraySize# e) m (wordArraySize# m)) s of +bignat_powmod r b e m s = sbignat_powmod r (wordArraySize# b) b e m s + +integer_powmod + :: Integer + -> Natural + -> Natural + -> Natural +integer_powmod b e m = naturalFromBigNat# (withNewWordArray# szm io) + where + !be = naturalToBigNat# e + !bm = naturalToBigNat# m + !(# sb, bb #) = integerToBigNatSign# b + !szb = bigNatSize# bb + !szm = bigNatSize# bm + !ssb = case sb of -- signed size of b + 0# -> szb + _ -> negateInt# szb + + io r s = sbignat_powmod r ssb bb be bm s + + +sbignat_powmod + :: MutableWordArray# RealWorld + -> Int# + -> WordArray# + -> WordArray# + -> WordArray# + -> State# RealWorld + -> State# RealWorld +sbignat_powmod r b_signed_size b e m s = + case ioInt# (integer_gmp_powm# r b b_signed_size e (wordArraySize# e) m (wordArraySize# m)) s of (# s', n #) -> mwaSetSize# r (narrowGmpSize# n) s' integer_gcde @@ -423,6 +453,32 @@ integer_gcde a b = case runRW# io of (# _, a #) -> a +integer_recip_mod + :: Integer + -> Natural + -> (# Natural | () #) +integer_recip_mod x m = + let + !(# sign_x, bx #) = integerToBigNatSign# x + !bm = naturalToBigNat# m + !br = sbignat_recip_mod sign_x bx bm + in if isTrue# (bigNatIsZero# br) + then (# | () #) + else (# naturalFromBigNat# br | #) + + +-- | Return 0 for invalid inputs +sbignat_recip_mod :: Int# -> BigNat# -> BigNat# -> BigNat# +sbignat_recip_mod sign_x x m = withNewWordArray# szm io + where + io r s = case ioInt# (integer_gmp_invert# r x ssx m szm) s of + (# s, rn #) -> mwaSetSize# r (narrowGmpSize# rn) s + !szx = bigNatSize# x + !szm = bigNatSize# m + !ssx = case sign_x of -- signed size of x + 0# -> szx + _ -> negateInt# szx + ---------------------------------------------------------------------- -- FFI ccall imports @@ -444,6 +500,11 @@ foreign import ccall unsafe "integer_gmp_gcdext" integer_gmp_gcdext# -> ByteArray# -> GmpSize# -> IO () +foreign import ccall unsafe "integer_gmp_invert" + integer_gmp_invert# :: MutableByteArray# RealWorld + -> ByteArray# -> GmpSize# + -> ByteArray# -> GmpSize# -> IO GmpSize + -- mp_limb_t mpn_add_1 (mp_limb_t *rp, const mp_limb_t *s1p, mp_size_t n, -- mp_limb_t s2limb) foreign import ccall unsafe "gmp.h __gmpn_add_1" ===================================== libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Num.Backend.Native where #include "MachDeps.h" #include "WordSize.h" -#if defined(BIGNUM_NATIVE) || defined(BIGNUM_CHECK) +#if defined(BIGNUM_NATIVE) || defined(BIGNUM_CHECK) || defined(BIGNUM_FFI) import {-# SOURCE #-} GHC.Num.BigNat import {-# SOURCE #-} GHC.Num.Natural import {-# SOURCE #-} GHC.Num.Integer @@ -737,3 +737,40 @@ integer_gcde a b = f (# a,integerOne,integerZero #) (# b,integerZero,integerOne | True = case integerQuotRem# old_g g of !(# q, r #) -> f new (# r , old_s `integerSub` (q `integerMul` s) , old_t `integerSub` (q `integerMul` t) #) + +integer_recip_mod + :: Integer + -> Natural + -> (# Natural | () #) +integer_recip_mod x m = + let m' = integerFromNatural m + in case integer_gcde x m' of + (# g, a, _b #) + -- gcd(x,m) = ax+mb = 1 + -- ==> ax - 1 = -mb + -- ==> ax = 1 [m] + | g `integerEq` integerOne -> (# integerToNatural (a `integerMod` m') | #) + -- a `mod` m > 0 because m > 0 + | True -> (# | () #) + +integer_powmod + :: Integer + -> Natural + -> Natural + -> Natural +integer_powmod b0 e0 m = go b0 e0 integerOne + where + !m' = integerFromNatural m + + go !b e !r + | isTrue# (e `naturalTestBit#` 0##) + = go b' e' ((r `integerMul` b) `integerMod` m') + + | naturalIsZero e + = integerToNatural r -- r >= 0 by integerMod above + + | True + = go b' e' r + where + b' = (b `integerMul` b) `integerRem` m' + e' = e `naturalShiftR#` 1## ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs-boot ===================================== @@ -5,11 +5,13 @@ module GHC.Num.BigNat where import GHC.Num.WordArray +import GHC.Num.Primitives import GHC.Prim type BigNat# = WordArray# data BigNat = BN# { unBigNat :: BigNat# } +bigNatIsZero# :: BigNat# -> Bool# bigNatSize# :: BigNat# -> Int# bigNatSubUnsafe :: BigNat# -> BigNat# -> BigNat# bigNatMulWord# :: BigNat# -> Word# -> BigNat# ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs ===================================== @@ -244,6 +244,11 @@ integerIsZero :: Integer -> Bool integerIsZero (IS 0#) = True integerIsZero _ = False +-- | One predicate +integerIsOne :: Integer -> Bool +integerIsOne (IS 1#) = True +integerIsOne _ = False + -- | Not-equal predicate. integerNe :: Integer -> Integer -> Bool integerNe !x !y = isTrue# (integerNe# x y) @@ -1217,3 +1222,50 @@ integerGcde -> ( Integer, Integer, Integer) integerGcde a b = case integerGcde# a b of (# g,x,y #) -> (g,x,y) + + +-- | Computes the modular inverse. +-- +-- I.e. y = integerRecipMod# x m +-- = x^(-1) `mod` m +-- +-- with 0 < y < |m| +-- +integerRecipMod# + :: Integer + -> Natural + -> (# Natural | () #) +integerRecipMod# x m + | integerIsZero x = (# | () #) + | naturalIsZero m = (# | () #) + | naturalIsOne m = (# | () #) + | True = Backend.integer_recip_mod x m + + +-- | Computes the modular exponentiation. +-- +-- I.e. y = integer_powmod b e m +-- = b^e `mod` m +-- +-- with 0 <= y < abs m +-- +-- If e is negative, we use `integerRecipMod#` to try to find a modular +-- multiplicative inverse (which may not exist). +integerPowMod# :: Integer -> Integer -> Natural -> (# Natural | () #) +integerPowMod# !b !e !m + | naturalIsZero m = (# | () #) + | naturalIsOne m = (# naturalZero | #) + | integerIsZero e = (# naturalOne | #) + | integerIsZero b = (# naturalZero | #) + | integerIsOne b = (# naturalOne | #) + -- when the exponent is negative, try to find the modular multiplicative + -- inverse and use it instead + | integerIsNegative e = case integerRecipMod# b m of + (# | () #) -> (# | () #) + (# b' | #) -> integerPowMod# + (integerFromNatural b') + (integerNegate e) + m + + -- e > 0 by cases above + | True = (# Backend.integer_powmod b (integerToNatural e) m | #) ===================================== libraries/ghc-bignum/src/GHC/Num/Integer.hs-boot ===================================== @@ -7,6 +7,7 @@ module GHC.Num.Integer where import GHC.Types import GHC.Prim import {-# SOURCE #-} GHC.Num.BigNat +import {-# SOURCE #-} GHC.Num.Natural data Integer @@ -17,14 +18,20 @@ integerEq# :: Integer -> Integer -> Int# integerEq :: Integer -> Integer -> Bool integerGt :: Integer -> Integer -> Bool integerIsZero :: Integer -> Bool +integerIsOne :: Integer -> Bool integerIsNegative :: Integer -> Bool integerSub :: Integer -> Integer -> Integer integerMul :: Integer -> Integer -> Integer +integerMod :: Integer -> Integer -> Integer +integerRem :: Integer -> Integer -> Integer integerNegate :: Integer -> Integer +integerAbs :: Integer -> Integer integerDivMod# :: Integer -> Integer -> (# Integer, Integer #) integerQuotRem# :: Integer -> Integer -> (# Integer, Integer #) integerToBigNatSign# :: Integer -> (# Int#, BigNat# #) integerFromBigNatSign# :: Int# -> BigNat# -> Integer integerFromBigNat# :: BigNat# -> Integer +integerToNatural :: Integer -> Natural +integerFromNatural :: Natural -> Integer ===================================== libraries/ghc-bignum/src/GHC/Num/Natural.hs-boot ===================================== @@ -16,8 +16,12 @@ naturalToWord# :: Natural -> Word# naturalFromWord# :: Word# -> Natural naturalFromBigNat# :: BigNat# -> Natural naturalToBigNat# :: Natural -> BigNat# + +naturalZero :: Natural naturalMul :: Natural -> Natural -> Natural naturalRem :: Natural -> Natural -> Natural -naturalIsZero :: Natural -> Bool naturalShiftR# :: Natural -> Word# -> Natural + +naturalIsZero :: Natural -> Bool naturalTestBit# :: Natural -> Word# -> Bool# +naturalEq# :: Natural -> Natural -> Bool# ===================================== libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs ===================================== @@ -32,6 +32,8 @@ module GHC.Integer.GMP.Internals , gcdExtInteger , lcmInteger , sqrInteger + , powModInteger + , recipModInteger -- ** Additional conversion operations to 'Integer' , wordToNegInteger @@ -186,6 +188,18 @@ lcmInteger = I.integerLcm sqrInteger :: Integer -> Integer sqrInteger = I.integerSqr +{-# DEPRECATED recipModInteger "Use integerRecipMod# instead" #-} +recipModInteger :: Integer -> Integer -> Integer +recipModInteger x m = case I.integerRecipMod# x (I.integerToNatural m) of + (# y | #) -> I.integerFromNatural y + (# | () #) -> 0 + +{-# DEPRECATED powModInteger "Use integerPowMod# instead" #-} +powModInteger :: Integer -> Integer -> Integer -> Integer +powModInteger b e m = case I.integerPowMod# b e (I.integerToNatural m) of + (# r | #) -> I.integerFromNatural r + (# | () #) -> 0 + {-# DEPRECATED wordToNegInteger "Use integerFromWordNeg# instead" #-} wordToNegInteger :: Word# -> Integer wordToNegInteger = I.integerFromWordNeg# ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -8,7 +8,8 @@ test('IntegerConversionRules', [], makefile_test, ['IntegerConversionRules']) test('gcdInteger', normal, compile_and_run, ['']) test('gcdeInteger', normal, compile_and_run, ['']) test('integerPowMod', [], compile_and_run, ['']) -test('integerGcdExt', [omit_ways(['ghci'])], compile_and_run, ['']) +test('integerGcdExt', [], compile_and_run, ['']) +test('integerRecipMod', [], compile_and_run, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/integerGmpInternals.hs ===================================== @@ -12,9 +12,6 @@ import GHC.Base import GHC.Num.Integer import qualified GHC.Num.Integer as I -recipModInteger :: Integer -> Integer -> Integer -recipModInteger = I.recipModInteger - -- FIXME: Lacks GMP2 version powInteger :: Integer -> Word -> Integer powInteger x e = x^e @@ -25,7 +22,6 @@ main = do print $ powInteger 12345 0 print $ powInteger 12345 1 print $ powInteger 12345 30 - print $ [ (x,i) | x <- [-7..71], let i = recipModInteger x (2*3*11*11*17*17), i /= 0 ] putStrLn "\n# nextPrimeInteger" print $ I.nextPrimeInteger b ===================================== testsuite/tests/lib/integer/integerGmpInternals.stdout ===================================== @@ -3,7 +3,6 @@ 1 12345 555562377826831043419246079513769804614412256811161773362797946971665712715296306339052301636736176350153982639312744140625 -[(-7,149867),(-5,167851),(-1,209813),(1,1),(5,41963),(7,59947),(13,177535),(19,143557),(23,182447),(25,134281),(29,7235),(31,33841),(35,95915),(37,113413),(41,61409),(43,24397),(47,174101),(49,158431),(53,193979),(59,188477),(61,185737),(65,35507),(67,118999),(71,186173)] # nextPrimeInteger 2988348162058574136915891421498819466320163312926952423791023078876343 ===================================== testsuite/tests/lib/integer/integerPowMod.hs ===================================== @@ -1,3 +1,6 @@ +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE MagicHash #-} + module Main (main) where import Data.List (group) @@ -7,22 +10,33 @@ import Control.Monad import GHC.Word import GHC.Base -import GHC.Natural +import GHC.Num.Natural +import GHC.Num.Integer + +integerPowMod :: Integer -> Integer -> Integer -> Maybe Integer +integerPowMod b e m = case integerPowMod# b e (fromIntegral m) of + (# | () #) -> Nothing + (# r | #) -> Just (fromIntegral r) main :: IO () main = do - print $ powModNatural b e m - print $ powModNatural b e (m-1) + print $ naturalPowMod b e m + print $ naturalPowMod b e (m-1) + + print $ integerPowMod b e m + print $ integerPowMod b e (m-1) + + print $ integerPowMod b (-e) m + print $ integerPowMod b (-e) (m-1) + + print $ integerPowMod (-b) e m + print $ integerPowMod (-b) e (m-1) + + print $ integerPowMod (-b) (-e) m + print $ integerPowMod (-b) (-e) (m-1) where + b,e,m :: Num a => a b = 2988348162058574136915891421498819466320163312926952423791023078876139 e = 2351399303373464486466122544523690094744975233415544072992656881240319 m = 10^(40::Int) - - x = 5328841272400314897981163497728751426 - y = 32052182750761975518649228050096851724 - - b1024 = roll (map fromIntegral (take 128 [0x80::Int .. ])) - - roll :: [Word8] -> Integer - roll = GHC.Base.foldr (\b a -> a `shiftL` 8 .|. fromIntegral b) 0 ===================================== testsuite/tests/lib/integer/integerPowMod.stdout ===================================== @@ -1,2 +1,10 @@ 1527229998585248450016808958343740453059 682382427572745901624116300491295556924 +Just 1527229998585248450016808958343740453059 +Just 682382427572745901624116300491295556924 +Just 9710805908340105786808462779613285007339 +Nothing +Just 8472770001414751549983191041656259546941 +Just 9317617572427254098375883699508704443075 +Just 289194091659894213191537220386714992661 +Nothing ===================================== testsuite/tests/lib/integer/integerRecipMod.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE BangPatterns, CPP, MagicHash, UnboxedTuples, TupleSections #-} + +module Main (main) where + +import Data.List (group) +import Data.Bits +import Data.Word +import Data.Maybe +import Control.Monad + +import GHC.Word +import GHC.Base +import GHC.Num.Integer +import GHC.Num.Natural +import qualified GHC.Num.Integer as I + +recipModInteger :: Integer -> Natural -> Maybe Natural +recipModInteger x m = case I.integerRecipMod# x m of + (# y | #) -> Just y + (# | () #) -> Nothing + +main :: IO () +main = do + let + f x = case recipModInteger x (2*3*11*11*17*17) of + y -> fmap (x,) y + + -- positive modulo + print $ mapMaybe f [-7..71] + + -- modulo == 1 or 0 + print (recipModInteger 77 1) + print (recipModInteger 77 0) ===================================== testsuite/tests/lib/integer/integerRecipMod.stdout ===================================== @@ -0,0 +1,3 @@ +[(-7,149867),(-5,167851),(-1,209813),(1,1),(5,41963),(7,59947),(13,177535),(19,143557),(23,182447),(25,134281),(29,7235),(31,33841),(35,95915),(37,113413),(41,61409),(43,24397),(47,174101),(49,158431),(53,193979),(59,188477),(61,185737),(65,35507),(67,118999),(71,186173)] +Nothing +Nothing View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c9beab75aaa5fbbb11132c99e2af114f322152f...8dd4f40512bb18e296280acde0507b4233a27b69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c9beab75aaa5fbbb11132c99e2af114f322152f...8dd4f40512bb18e296280acde0507b4233a27b69 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 17:53:30 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 02 Oct 2020 13:53:30 -0400 Subject: [Git][ghc/ghc][master] Reject linearity in kinds in checkValidType (#18780) Message-ID: <5f77691acd144_80b107bfb141619226e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - 8 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - testsuite/tests/linear/should_fail/LinearKind.stderr - + testsuite/tests/linear/should_fail/LinearKind2.hs - + testsuite/tests/linear/should_fail/LinearKind2.stderr - + testsuite/tests/linear/should_fail/LinearKind3.hs - + testsuite/tests/linear/should_fail/LinearKind3.stderr - testsuite/tests/linear/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1041,11 +1041,8 @@ tc_hs_type _ ty@(HsSpliceTy {}) _exp_kind = failWithTc (text "Unexpected type splice:" <+> ppr ty) ---------- Functions and applications -tc_hs_type mode ty@(HsFunTy _ mult ty1 ty2) exp_kind - | mode_tyki mode == KindLevel && not (isUnrestricted mult) - = failWithTc (text "Linear arrows disallowed in kinds:" <+> ppr ty) - | otherwise - = tc_fun_type mode mult ty1 ty2 exp_kind +tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind + = tc_fun_type mode mult ty1 ty2 exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -525,9 +525,7 @@ typeOrKindCtxt (GhciCtxt {}) = BothTypeAndKindCtxt -- GHCi's :kind command accepts both types and kinds -- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the --- context for a kind of a type, where the arbitrary use of constraints is --- currently disallowed. --- (See @Note [Constraints in kinds]@ in "GHC.Core.TyCo.Rep".) +-- context for a kind of a type. -- If the 'UserTypeCtxt' can refer to both types and kinds, this function -- conservatively returns 'True'. -- @@ -535,12 +533,25 @@ typeOrKindCtxt (GhciCtxt {}) = BothTypeAndKindCtxt -- @Show a => a -> a@ in @type Foo :: Show a => a -> a at . On the other hand, the -- same type in @foo :: Show a => a -> a@ is unambiguously the type of a term, -- not the kind of a type, so it is permitted. -allConstraintsAllowed :: UserTypeCtxt -> Bool -allConstraintsAllowed ctxt = case typeOrKindCtxt ctxt of +typeLevelUserTypeCtxt :: UserTypeCtxt -> Bool +typeLevelUserTypeCtxt ctxt = case typeOrKindCtxt ctxt of OnlyTypeCtxt -> True OnlyKindCtxt -> False BothTypeAndKindCtxt -> True +-- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the +-- context for a kind of a type, where the arbitrary use of constraints is +-- currently disallowed. +-- (See @Note [Constraints in kinds]@ in "GHC.Core.TyCo.Rep".) +allConstraintsAllowed :: UserTypeCtxt -> Bool +allConstraintsAllowed = typeLevelUserTypeCtxt + +-- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the +-- context for a kind of a type, where all function arrows currently +-- must be unrestricted. +linearityAllowed :: UserTypeCtxt -> Bool +linearityAllowed = typeLevelUserTypeCtxt + -- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the -- context for the type of a term, where visible, dependent quantification is -- currently disallowed. If the 'UserTypeCtxt' can refer to both types and @@ -744,8 +755,12 @@ check_type ve@(ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt (theta, tau) = tcSplitPhiTy phi (env', tvbs') = tidyTyCoVarBinders env tvbs -check_type (ve at ValidityEnv{ve_rank = rank}) (FunTy _ _ arg_ty res_ty) - = do { check_type (ve{ve_rank = arg_rank}) arg_ty +check_type (ve at ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt + , ve_rank = rank }) + ty@(FunTy _ mult arg_ty res_ty) + = do { failIfTcM (not (linearityAllowed ctxt) && not (isManyDataConTy mult)) + (linearFunKindErr env ty) + ; check_type (ve{ve_rank = arg_rank}) arg_ty ; check_type (ve{ve_rank = res_rank}) res_ty } where (arg_rank, res_rank) = funArgResRank rank @@ -993,6 +1008,11 @@ illegalVDQTyErr env ty = 2 (ppr_tidy env ty) , text "(GHC does not yet support this)" ] ) +-- | Reject uses of linear function arrows in kinds. +linearFunKindErr :: TidyEnv -> Type -> (TidyEnv, SDoc) +linearFunKindErr env ty = + (env, text "Illegal linear function in a kind:" <+> ppr_tidy env ty) + {- Note [Liberal type synonyms] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== testsuite/tests/linear/should_fail/LinearKind.stderr ===================================== @@ -1,5 +1,4 @@ -LinearKind.hs:4:11: error: - • Linear arrows disallowed in kinds: * %1 -> * - • In the kind ‘* %1 -> *’ - In the data type declaration for ‘A’ +LinearKind.hs:4:1: error: + • Illegal linear function in a kind: * %1 -> * + • In the data type declaration for ‘A’ ===================================== testsuite/tests/linear/should_fail/LinearKind2.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE LinearTypes, KindSignatures, DataKinds #-} +module LinearKind2 where -- T18780 + +import GHC.Exts +import GHC.Types + +data Two :: FUN One Type Type ===================================== testsuite/tests/linear/should_fail/LinearKind2.stderr ===================================== @@ -0,0 +1,4 @@ + +LinearKind2.hs:7:1: error: + • Illegal linear function in a kind: * %1 -> * + • In the data type declaration for ‘Two’ ===================================== testsuite/tests/linear/should_fail/LinearKind3.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE LinearTypes, KindSignatures, DataKinds #-} +module LinearKind3 where -- T18780 + +import GHC.Exts +import GHC.Types + +type K = Type %1 -> Type +data T :: K ===================================== testsuite/tests/linear/should_fail/LinearKind3.stderr ===================================== @@ -0,0 +1,5 @@ + +LinearKind3.hs:8:1: error: + • Illegal linear function in a kind: * %1 -> * + • In the expansion of type synonym ‘K’ + In the data type declaration for ‘T’ ===================================== testsuite/tests/linear/should_fail/all.T ===================================== @@ -20,6 +20,8 @@ test('LinearPatSyn', normal, compile_fail, ['']) test('LinearGADTNewtype', normal, compile_fail, ['']) test('LinearPartialSig', normal, compile_fail, ['']) test('LinearKind', normal, compile_fail, ['']) +test('LinearKind2', normal, compile_fail, ['']) +test('LinearKind3', normal, compile_fail, ['']) test('LinearVar', normal, compile_fail, ['-XLinearTypes']) test('LinearErrOrigin', normal, compile_fail, ['-XLinearTypes']) test('LinearPolyType', normal, compile_fail, ['']) # not supported yet (#390) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1033a720abf4a23a30c5cb0dfcb18b2bae3acc68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1033a720abf4a23a30c5cb0dfcb18b2bae3acc68 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 18:25:00 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 02 Oct 2020 14:25:00 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Refactor ghc-heap to allow decoding TSO/STACK closures Message-ID: <5f77707c62140_80b3f8459c04dc0161964c5@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 9e8e08bd by David Eichmann at 2020-10-02T19:19:29+01:00 Refactor ghc-heap to allow decoding TSO/STACK closures * Remove getClosureDataWith in favour of the old simpler getClosureData * Added getClosureDataFromHeapRep which is used by getClosureData and can be reused by ghc-debug - - - - - 6 changed files: - includes/rts/storage/TSO.h - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc - libraries/ghc-prim/changelog.md - rts/Heap.c Changes: ===================================== includes/rts/storage/TSO.h ===================================== @@ -255,7 +255,6 @@ typedef struct StgStack_ { /* Pointer to the "top" of the stack i.e. the most recently written address. * The stack is filled downwards, so the "top" of the stack starts with `sp * = stack + stack_size` and is decremented as the stack fills with data. - * The memory in `stack` strictly less than `sp` is free stack space. * See comment on "Invariants" below. */ StgPtr sp; ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -31,8 +31,8 @@ module GHC.Exts.Heap ( , WhatNext(..) , WhyBlocked(..) , TsoFlags(..) - , HasHeapRep(getClosureDataWith) - , getClosureData + , HasHeapRep(getClosureData) + , getClosureDataFromHeapRep -- * Info Table types , StgInfoTable(..) @@ -103,108 +103,136 @@ class HasHeapRep (a :: TYPE rep) where -- Inside a GHC context 'b' is usually a 'GHC.Exts.Heap.Closures.Box' -- containing a thunk or an evaluated heap object. Outside it can be e.g. -- a 'Word' for "raw" usage of pointers. - - getClosureDataWith :: - (forall c . c -> b) - -- ^ Convert any closure to some pointer type. - -> a + getClosureData + :: a -- ^ Closure to decode. - -> IO (GenClosure b) + -> IO Closure -- ^ Heap representation of the closure. instance HasHeapRep (a :: TYPE 'LiftedRep) where - getClosureDataWith = getClosureWith + getClosureData = getClosureDataFromHeapObject instance HasHeapRep (a :: TYPE 'UnliftedRep) where - getClosureDataWith k x = getClosureWith (k . unsafeCoerce#) (unsafeCoerce# x) + getClosureData x = getClosureDataFromHeapObject (unsafeCoerce# x) instance Int# ~ a => HasHeapRep (a :: TYPE 'IntRep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ IntClosure { ptipe = PInt, intVal = I# x } instance Word# ~ a => HasHeapRep (a :: TYPE 'WordRep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ WordClosure { ptipe = PWord, wordVal = W# x } instance Int64# ~ a => HasHeapRep (a :: TYPE 'Int64Rep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ Int64Closure { ptipe = PInt64, int64Val = I64# (unsafeCoerce# x) } instance Word64# ~ a => HasHeapRep (a :: TYPE 'Word64Rep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ Word64Closure { ptipe = PWord64, word64Val = W64# (unsafeCoerce# x) } instance Addr# ~ a => HasHeapRep (a :: TYPE 'AddrRep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ AddrClosure { ptipe = PAddr, addrVal = I# (unsafeCoerce# x) } instance Float# ~ a => HasHeapRep (a :: TYPE 'FloatRep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ FloatClosure { ptipe = PFloat, floatVal = F# x } instance Double# ~ a => HasHeapRep (a :: TYPE 'DoubleRep) where - getClosureDataWith _ x = return $ + getClosureData x = return $ DoubleClosure { ptipe = PDouble, doubleVal = D# x } --- | Deconstruct any closure's heap representation. -getClosureRaw - :: (forall c . c -> b) - -- ^ Convert any closure to some pointer type. - -> a - -- ^ Closure to deconstruct. - -> IO (Ptr StgInfoTable, [Word], [b]) - -- ^ Tuple of: - -- * A 'Ptr' to the info table - -- * Non-pointer data of the closure. - -- * Pointer data of the closure. These are the closures pointed to by the - -- input closure, boxed with the given function. The pointers are - -- collected in @Heap.c at . -getClosureRaw asBoxish x = do - case unpackClosure# x of --- This is a hack to cover the bootstrap compiler using the old version of --- 'unpackClosure'. The new 'unpackClosure' return values are not merely --- a reordering, so using the old version would not work. -#if MIN_VERSION_ghc_prim(0,5,3) - (# iptr, dat, pointers #) -> do -#else - (# iptr, pointers, dat #) -> do -#endif - let nelems = (I# (sizeofByteArray# dat)) `div` wORD_SIZE - end = fromIntegral nelems - 1 - rawWds = [W# (indexWordArray# dat i) | I# i <- [0.. end] ] - ptrList = [case indexArray# pointers i of (# ptr #) -> asBoxish ptr - | I# i <- [0..(I# (sizeofArray# pointers)) - 1] - ] - pure (Ptr iptr, rawWds, ptrList) - -getClosureData :: forall rep (a :: TYPE rep) . HasHeapRep a => a -> IO Closure -getClosureData = getClosureDataWith asBox - -- | Get the heap representation of a closure _at this moment_, even if it is -- unevaluated or an indirection or other exotic stuff. Beware when passing -- something to this function, the same caveats as for -- 'GHC.Exts.Heap.Closures.asBox' apply. -- -- For most use cases 'getClosureData' is an easier to use alternative. -getClosureWith :: forall a b. - (forall c . c -> b) - -- ^ Convert any closure to some pointer type. - -> a - -- ^ Closure to decode. +-- +-- Currently TSO and STACK objects will return `UnsupportedClosure`. This is +-- because it is not memory safe to extract TSO and STACK objects (done via +-- `unpackClosure#`). Other threads may be mutating those objects and interleave +-- with reads in `unpackClosure#`. This is particularly problematic with STACKs +-- where pointer values may be overwritten by non-pointer values as the haskell +-- thread runs. +getClosureDataFromHeapObject + :: a + -- ^ Heap object to decode. + -> IO Closure + -- ^ Heap representation of the closure. +getClosureDataFromHeapObject x = do + case unpackClosure# x of +#if MIN_VERSION_ghc_prim(0,5,3) + (# infoTableAddr, heapRep, pointersArray #) -> do +#else + -- This is a hack to cover the bootstrap compiler using the old version + -- of 'unpackClosure'. The new 'unpackClosure' return values are not + -- merely a reordering, so using the old version would not work. + (# infoTableAddr, pointersArray, heapRep #) -> do +#endif + let infoTablePtr = Ptr infoTableAddr + ptrList = [case indexArray# pointersArray i of + (# ptr #) -> Box ptr + | I# i <- [0..(I# (sizeofArray# pointersArray)) - 1] + ] + + infoTable <- peekItbl infoTablePtr + case tipe infoTable of + TSO -> pure $ UnsupportedClosure infoTable + STACK -> pure $ UnsupportedClosure infoTable + _ -> getClosureDataFromHeapRep Nothing heapRep infoTablePtr ptrList + +-- | Convert an unpacked heap object, to a `GenClosure b`. The inputs to this +-- function can be generated from a heap object using `unpackClosure#`. Care +-- must be take to ensure that the closure is not moved by the GC between +-- calling `unpackClosure#` and reading the closure's address (the first +-- argument to `getClosureDataFromHeapRep`). +getClosureDataFromHeapRep + :: Maybe (Ptr a) + -- ^ Pointer to the closure in the heap. This is only used for STACK + -- closures to properly calculate the `stack_spOffset`. If this argument is + -- Nothing and the closure is a STACK, then `UnsupportedClosure` is + -- returned. + -> ByteArray# + -- ^ Heap representation of the closure as returned by `unpackClosure#`. + -- This includes all of the object including the header, info table + -- pointer, pointer data, and non-pointer data. The ByteArray# may be + -- pinned or unpinned. + -> Ptr StgInfoTable + -- ^ Pointer to the `StgInfoTable` of the closure, extracted from the heap + -- representation. The info table must not be moved by GC i.e. must be an + -- info table from this process's runtime or in pinned or off-heap memory. + -> [b] + -- ^ Pointers in the payload of the closure, extracted from the heap + -- representation. In the case of STACK objects, this does NOT contain + -- pointers in the stack space (i.e. in StgStack::stack). Note `b` is some + -- representation of a pointer. If for example `b ~ Any` then the referenced + -- objects will be managed by the runtime system and kept alive by the + -- garbage collector. That is not true if for example `b ~ Ptr Any`. -> IO (GenClosure b) -- ^ Heap representation of the closure. -getClosureWith asBoxish x = do - (iptr, wds, pts) <- getClosureRaw asBoxish (unsafeCoerce# x) - itbl <- peekItbl iptr +getClosureDataFromHeapRep closureAddressMay heapRep infoTablePtr pts = do + itbl <- peekItbl infoTablePtr -- The remaining words after the header - let rawWds = drop (closureTypeHeaderSize (tipe itbl)) wds - -- For data args in a pointers then non-pointers closure - -- This is incorrect in non pointers-first setups - -- not sure if that happens - npts = drop (closureTypeHeaderSize (tipe itbl) + length pts) wds + let -- heapRep as a list of words. + rawHeapWords :: [Word] + rawHeapWords = [W# (indexWordArray# heapRep i) | I# i <- [0.. end] ] + where + nelems = (I# (sizeofByteArray# heapRep)) `div` wORD_SIZE + end = fromIntegral nelems - 1 + + -- Just the payload of rawHeapWords (no header). + payloadWords :: [Word] + payloadWords = drop (closureTypeHeaderSize (tipe itbl)) rawHeapWords + + -- The non-pointer words in the payload. Only valid for closures with a + -- "pointers first" layout. Not valid for bit field layout. + npts :: [Word] + npts = drop (closureTypeHeaderSize (tipe itbl) + length pts) rawHeapWords case tipe itbl of t | t >= CONSTR && t <= CONSTR_NOCAF -> do - (p, m, n) <- dataConNames iptr + (p, m, n) <- dataConNames infoTablePtr if m == "GHC.ByteCode.Instr" && n == "BreakInfo" then pure $ UnsupportedClosure itbl else pure $ ConstrClosure itbl pts npts p m n @@ -224,9 +252,9 @@ getClosureWith asBoxish x = do unless (length pts >= 1) $ fail "Expected at least 1 ptr argument to AP" -- We expect at least the arity, n_args, and fun fields - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail $ "Expected at least 2 raw words to AP" - let splitWord = rawWds !! 0 + let splitWord = payloadWords !! 0 pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -241,9 +269,9 @@ getClosureWith asBoxish x = do unless (length pts >= 1) $ fail "Expected at least 1 ptr argument to PAP" -- We expect at least the arity, n_args, and fun fields - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail "Expected at least 2 raw words to PAP" - let splitWord = rawWds !! 0 + let splitWord = payloadWords !! 0 pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -278,10 +306,10 @@ getClosureWith asBoxish x = do unless (length pts >= 3) $ fail $ "Expected at least 3 ptr argument to BCO, found " ++ show (length pts) - unless (length rawWds >= 4) $ + unless (length payloadWords >= 4) $ fail $ "Expected at least 4 words to BCO, found " - ++ show (length rawWds) - let splitWord = rawWds !! 3 + ++ show (length payloadWords) + let splitWord = payloadWords !! 3 pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -290,25 +318,25 @@ getClosureWith asBoxish x = do (fromIntegral splitWord) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 rawWds) + (drop 4 payloadWords) ARR_WORDS -> do - unless (length rawWds >= 1) $ + unless (length payloadWords >= 1) $ fail $ "Expected at least 1 words to ARR_WORDS, found " - ++ show (length rawWds) - pure $ ArrWordsClosure itbl (head rawWds) (tail rawWds) + ++ show (length payloadWords) + pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " - ++ "found " ++ show (length rawWds) - pure $ MutArrClosure itbl (rawWds !! 0) (rawWds !! 1) pts + ++ "found " ++ show (length payloadWords) + pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length rawWds >= 1) $ + unless (length payloadWords >= 1) $ fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " - ++ "found " ++ show (length rawWds) - pure $ SmallMutArrClosure itbl (rawWds !! 0) pts + ++ "found " ++ show (length payloadWords) + pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do unless (length pts >= 1) $ @@ -323,11 +351,11 @@ getClosureWith asBoxish x = do pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> - pure $ OtherClosure itbl pts wds + pure $ OtherClosure itbl pts rawHeapWords -- pure $ BlockingQueueClosure itbl -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts wds + -- pure $ OtherClosure itbl pts rawHeapWords -- WEAK -> pure $ WeakClosure @@ -339,16 +367,16 @@ getClosureWith asBoxish x = do , link = pts !! 4 } TSO | [ u_lnk, u_gbl_lnk, tso_stack, u_trec, u_blk_ex, u_bq] <- pts - -> withArray wds (\ptr -> do + -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekTSOFields peekStgTSOProfInfo ptr pure $ TSOClosure { info = itbl - , unsafe_link = u_lnk - , unsafe_global_link = u_gbl_lnk + , link = u_lnk + , global_link = u_gbl_lnk , tsoStack = tso_stack - , unsafe_trec = u_trec - , unsafe_blocked_exceptions = u_blk_ex - , unsafe_bq = u_bq + , trec = u_trec + , blocked_exceptions = u_blk_ex + , bq = u_bq , what_next = FFIClosures.tso_what_next fields , why_blocked = FFIClosures.tso_why_blocked fields , flags = FFIClosures.tso_flags fields @@ -362,27 +390,30 @@ getClosureWith asBoxish x = do | otherwise -> fail $ "Expected 6 ptr arguments to TSO, found " ++ show (length pts) - STACK | [u_sp] <- pts - -> withArray wds (\ptr -> do + STACK + | [] <- pts + -> case closureAddressMay of + Nothing -> pure $ UnsupportedClosure itbl + Just (Ptr closureAddress) -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekStackFields ptr - + let sp = FFIClosures.stack_sp fields + spOffset = I# (minusAddr# sp closureAddress) pure $ StackClosure { info = itbl , stack_size = FFIClosures.stack_size fields , stack_dirty = FFIClosures.stack_dirty fields - , unsafeStackPointer = u_sp - , unsafeStack = FFIClosures.stack fields #if __GLASGOW_HASKELL__ >= 811 , stack_marking = FFIClosures.stack_marking fields #endif + , stack_spOffset = spOffset }) - | otherwise - -> fail $ "Expected 1 ptr argument to STACK, found " - ++ show (length pts) + | otherwise + -> fail $ "Expected 0 ptr argument to STACK, found " + ++ show (length pts) _ -> pure $ UnsupportedClosure itbl --- | Like 'getClosureDataWith', but taking a 'Box', so it is easier to work with. +-- | Like 'getClosureData', but taking a 'Box', so it is easier to work with. getBoxedClosureData :: Box -> IO Closure getBoxedClosureData (Box a) = getClosureData a ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -105,11 +105,17 @@ type Closure = GenClosure Box -- | This is the representation of a Haskell value on the heap. It reflects -- -- --- The data type is parametrized by the type to store references in. Usually --- this is a 'Box' with the type synonym 'Closure'. +-- The data type is parametrized by `b`: the type to store references in. +-- Usually this is a 'Box' with the type synonym 'Closure'. -- --- All Heap objects have the same basic layout. A header containing a pointer --- to the info table and a payload with various fields. The @info@ field below +-- If you are observing closures from an external process, extra care must be +-- taken when dealing with `b` references. The external process's GC may move or +-- free the objects. If you plan on using the `b` references, you should pause +-- the external process's GC for example with `rts_lock` or `rts_pause` form +-- `RtsAPI.h`. +-- +-- All Heap objects have the same basic layout. A header containing a pointer to +-- the info table and a payload with various fields. The @info@ field below -- always refers to the info table pointed to by the header. The remaining -- fields are the payload. -- @@ -273,46 +279,50 @@ data GenClosure b , link :: !b -- ^ next weak pointer for the capability, can be NULL. } - -- | Representation of StgTSO: A Thread State Object. - -- The values for 'what_next', 'why_blocked' and 'flags' are defined in - -- @Constants.h at . - -- Fields marked as @unsafe@ are backed by dynamic pointers and should only - -- be accessed when the garbage collector is stopped. Otherwise segmentation - -- faults may happen when an invalidated pointer is accessed. + -- | Representation of StgTSO: A Thread State Object. The values for + -- 'what_next', 'why_blocked' and 'flags' are defined in @Constants.h at . | TSOClosure - { info :: !StgInfoTable + { info :: !StgInfoTable -- pointers - , unsafe_link :: !b - , unsafe_global_link :: !b - , tsoStack :: !b -- ^ stackobj from StgTSO - , unsafe_trec :: !b - , unsafe_blocked_exceptions :: !b - , unsafe_bq :: !b + , link :: !b + , global_link :: !b + , tsoStack :: !b -- ^ stackobj from StgTSO + , trec :: !b + , blocked_exceptions :: !b + , bq :: !b -- values - , what_next :: WhatNext - , why_blocked :: WhyBlocked - , flags :: [TsoFlags] - , threadId :: Word64 - , saved_errno :: Word32 - , tso_dirty:: Word32 -- ^ non-zero => dirty - , alloc_limit :: Int64 - , tot_stack_size :: Word32 - , prof :: Maybe StgTSOProfInfo + , what_next :: !WhatNext + , why_blocked :: !WhyBlocked + , flags :: ![TsoFlags] + , threadId :: !Word64 + , saved_errno :: !Word32 + , tso_dirty :: !Word32 -- ^ non-zero => dirty + , alloc_limit :: !Int64 + , tot_stack_size :: !Word32 + , prof :: !(Maybe StgTSOProfInfo) } - -- | Representation of StgStack: The 'tsoStack' of a 'TSOClosure'. - -- Fields marked as @unsafe@ are backed by dynamic pointers and should only - -- be accessed when the garbage collector is stopped. Otherwise segmentation - -- faults may happen when an invalidated pointer is accessed. + + -- | Representation of StgStack: The 'tsoStack ' of a 'TSOClosure'. + -- + -- Fields marked as @unsafe@ contain pointers to data that might be moved by + -- the RTS at any point (e.g. by the garbage collector or the scheduler). + -- These unsafe fields should only be accessed when all haskell threads are + -- paused, typically via GHC's `rts_pause` fucntion in `RtsAPI.h`. + -- Unfortunately, you need a running haskell thread to observe these fields in + -- the first place! Still, you can safely make use of these fields if the + -- closure is from an external Haskell process with a paused RTS. | StackClosure - { info :: !StgInfoTable - , stack_size :: !Word32 -- ^ stack size in *words* - , stack_dirty :: !Word8 -- ^ non-zero => dirty + { info :: !StgInfoTable + , stack_size :: !Word32 -- ^ stack size in *words* + , stack_dirty :: !Word8 -- ^ non-zero => dirty #if __GLASGOW_HASKELL__ >= 810 - , stack_marking :: Word8 + , stack_marking :: !Word8 #endif - , unsafeStackPointer :: !b -- ^ current stack pointer - , unsafeStack :: [Word] - } + -- | Offset of the `StgStack::sp` pointer in bytes + -- x->sp == ((byte*)x)+stack_spOffset + -- The type of `stack_spOffset` reflects the type of `stack_size`. + , stack_spOffset :: !Int + } ------------------------------------------------------------ -- Unboxed unlifted closures ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc ===================================== @@ -1,10 +1,13 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} + module GHC.Exts.Heap.FFIClosures where #include "Rts.h" import Prelude import Foreign +import GHC.Exts import GHC.Exts.Heap.ProfInfo.Types import GHC.Exts.Heap.Closures(WhatNext(..), WhyBlocked(..), TsoFlags(..)) @@ -100,7 +103,7 @@ data StackFields = StackFields { #if __GLASGOW_HASKELL__ >= 810 stack_marking :: Word8, #endif - stack :: [Word] + stack_sp :: Addr## } -- | Get non-closure fields from @StgStack_@ (@TSO.h@) @@ -111,9 +114,9 @@ peekStackFields ptr = do #if __GLASGOW_HASKELL__ >= 810 marking' <- (#peek struct StgStack_, marking) ptr #endif + Ptr sp' <- (#peek struct StgStack_, sp) ptr - let stackPtr = (#ptr struct StgStack_, stack) ptr - stack' <- peekArray (fromIntegral stack_size') stackPtr + -- TODO decode the stack. return StackFields { stack_size = stack_size', @@ -121,5 +124,5 @@ peekStackFields ptr = do #if __GLASGOW_HASKELL__ >= 810 stack_marking = marking', #endif - stack = stack' + stack_sp = sp' } ===================================== libraries/ghc-prim/changelog.md ===================================== @@ -5,7 +5,7 @@ - Add known-key `cstringLength#` to `GHC.CString`. This is just the C function `strlen`, but a built-in rewrite rule allows GHC to compute the result at compile time when the argument is known. - + - In order to support unicode better the following functions in `GHC.CString` gained UTF8 counterparts: ===================================== rts/Heap.c ===================================== @@ -224,10 +224,6 @@ StgWord collect_pointers(StgClosure *closure, StgWord size, StgClosure *ptrs[siz ASSERT((StgClosure *)((StgTSO *)closure)->bq != NULL); ptrs[nptrs++] = (StgClosure *)((StgTSO *)closure)->bq; - break; - case STACK: - ASSERT((StgClosure *)((StgStack *)closure)->sp != NULL); - ptrs[nptrs++] = (StgClosure *)((StgStack *)closure)->sp; break; case WEAK: ptrs[nptrs++] = (StgClosure *)((StgWeak *)closure)->cfinalizers; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e8e08bdc063d86fcd5c4f5ac11bd35407c103fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9e8e08bdc063d86fcd5c4f5ac11bd35407c103fd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 19:22:28 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 02 Oct 2020 15:22:28 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/alpine-static-flavour Message-ID: <5f777df446dc6_80b3f8438b8c2b016205418@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/alpine-static-flavour at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/alpine-static-flavour You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 20:57:28 2020 From: gitlab at gitlab.haskell.org (Adam Gundry) Date: Fri, 02 Oct 2020 16:57:28 -0400 Subject: [Git][ghc/ghc][wip/amg/hasfield-2020] 2 commits: Generate alternative form of updaters that are faster to typecheck Message-ID: <5f779438d51f0_80b3f848c2a457c1621865f@gitlab.haskell.org.mail> Adam Gundry pushed to branch wip/amg/hasfield-2020 at Glasgow Haskell Compiler / GHC Commits: f0c0b6ee by Adam Gundry at 2020-10-02T21:55:45+01:00 Generate alternative form of updaters that are faster to typecheck - - - - - 18968fd1 by Adam Gundry at 2020-10-02T21:56:07+01:00 Alternative (arguably better) error for partial setField - - - - - 2 changed files: - compiler/GHC/Tc/TyCl/Utils.hs - testsuite/tests/overloadedrecflds/should_run/hasfieldrun01.stderr Changes: ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -993,13 +993,44 @@ mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = field_var = mkInternalName (mkBuiltinUnique 1) (getOccName sel_name) loc mk_expr = L loc (HsVar noExtField (L loc field_var)) + -- Make a binding for the updater. We prefer to use upd_bind_fast, but + -- thanks to #2595 this does not work for some GADTs, so we fall back on + -- upd_bind_slow. + upd_bind + | null (conLikeExTyCoVars con1) = upd_bind_fast + | otherwise = upd_bind_slow + + -- Make the binding: + -- upd x = (\ y -> x { fld = y }, fld x) + -- + -- TODO: this implementation needs cleaning up + upd_bind_fast name = L loc (mkTopFunBind Generated lname [alt]) + where + lname = L loc name + alt = mkSimpleMatch (mkPrefixFunRhs lname) + [L loc (VarPat noExtField (L loc (x_var fl)))] + (mkLHsTupleExpr + [ mkHsLam [L loc (VarPat noExtField (L loc y_var))] + (L loc (RecordUpd noExtField + (L loc (HsVar noExtField (L loc (x_var fl)))) + [L loc (HsRecField (L loc afo) (L loc (HsVar noExtField (L loc y_var))) False)] + )) + , mkHsApp (L loc (HsRecFld noExtField afo)) + (L loc (HsVar noExtField (L loc (x_var fl)))) + ]) + + afo = Unambiguous sel_name (L loc (mkVarUnqual (flLabel fl))) + -- Make the binding: -- upd (C2 { fld1 = x1, .., fldN = xN }) -- = (\ y -> C2 { fld1 = y, fld2 = x2, .., fldN = xN }, x1) -- upd (C7 { fld1 = x1, .., fldM = xM }) -- = (\ y -> C7 { fld1 = y, fld3 = x3, .., fldM = xM }, x1) -- where cons_w_field = [C2,C7] and fld1 is being selected/updated - upd_bind = the_bind mk_rec_flds mk_expr + -- + -- TODO: we should probably be more consistent with upd_bind_fast and generate + -- upd x = ((\ y -> case x of { c at C2 { fld1 = x1 } -> c { fld1 = y } ; ... }), fld1 x) + upd_bind_slow = the_bind mk_rec_flds mk_expr where -- Pattern that matches { fld1 = x1, .., fldN = xN } mk_rec_flds con = rec_flds (rec_fields con pat_var) @@ -1041,10 +1072,10 @@ mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = field_occ fl' = FieldOcc (flSelector fl') (L loc (mkVarUnqual (flLabel fl'))) - -- The x_vars NameEnv contains a fresh name for every selector name in the - -- TyCon, i.e. maps fldN to xN. - x_var :: FieldLbl upd Name -> Name - x_var fl' = lookupNameEnv_NF x_vars (flSelector fl') + -- The x_vars NameEnv contains a fresh name for every selector name in the + -- TyCon, i.e. maps fldN to xN. + x_var :: FieldLbl upd Name -> Name + x_var fl' = lookupNameEnv_NF x_vars (flSelector fl') -- Add catch-all default case unless the case is exhaustive -- We do this explicitly so that we get a nice error message that ===================================== testsuite/tests/overloadedrecflds/should_run/hasfieldrun01.stderr ===================================== @@ -1 +1,2 @@ -hasfieldrun01: No match in record selector partial +hasfieldrun01: hasfieldrun01.hs:33:17-23: Non-exhaustive patterns in record update + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/573631554d1dbc6c648314a10695b6a553a8861a...18968fd1a25769ae82ba5ae7709f88885560a8a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/573631554d1dbc6c648314a10695b6a553a8861a...18968fd1a25769ae82ba5ae7709f88885560a8a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 2 22:33:49 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 02 Oct 2020 18:33:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T17656 Message-ID: <5f77aacde7fc0_80ba5bf068162336cb@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T17656 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T17656 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 3 12:29:02 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Sat, 03 Oct 2020 08:29:02 -0400 Subject: [Git][ghc/ghc][wip/andreask/tune_perf_tests] Use proper RTS flags when collecting residency in perf tests. Message-ID: <5f786e8e56c7f_80b3f849abb920816275191@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/tune_perf_tests at Glasgow Haskell Compiler / GHC Commits: 599ebea0 by Andreas Klebinger at 2020-10-03T14:25:43+02:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 ------------------------- - - - - - 2 changed files: - testsuite/tests/perf/should_run/all.T - testsuite/tests/perf/space_leaks/all.T Changes: ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -88,15 +88,15 @@ test('T4321', test('T3736', [], makefile_test, ['T3736']) test('T3738', [extra_clean(['T3738a.hi', 'T3738a.o']), - collect_stats('peak_megabytes_allocated', 0), + collect_runtime_residency(1), collect_stats('bytes allocated',8), - only_ways(['normal']) + only_ways(['normal']), ], compile_and_run, ['-O']) test('MethSharing', - [collect_stats('peak_megabytes_allocated', 0), + [collect_runtime_residency(1), collect_stats('bytes allocated',5), only_ways(['normal']) ], @@ -177,7 +177,7 @@ test('T5536', test('T7257', [collect_stats('bytes allocated',10), - collect_stats('peak_megabytes_allocated',5), + collect_runtime_residency(5), only_ways(['normal']) ], compile_and_run, ['-O']) @@ -192,14 +192,14 @@ test('T7507', omit_ways(['ghci']), compile_and_run, ['-O']) # For 7507, stack overflow is the bad case test('T7436', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, ['-O']) test('T7436b', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, @@ -221,7 +221,7 @@ test('T7954', ['-O']) test('T7850', - [collect_stats('peak_megabytes_allocated',10), + [collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) @@ -308,7 +308,7 @@ test('T12990', test('T13218', [collect_stats('bytes allocated',5), - collect_stats('max_bytes_used',10), + collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) ===================================== testsuite/tests/perf/space_leaks/all.T ===================================== @@ -3,7 +3,7 @@ test('space_leak_001', # This could potentially be replaced with # collect_stats('all',5) to test all 3 with # 5% possible deviation. - [collect_stats(['peak_megabytes_allocated','bytes allocated'],5), + [ collect_stats(['bytes allocated'],5), collect_runtime_residency(15), omit_ways(['profasm','profthreaded','threaded1','threaded2','nonmoving_thr']) ], @@ -13,7 +13,7 @@ test('space_leak_001', test('T4334', # Test for a space leak in Data.List.lines (fixed with #4334) [extra_run_opts('1000000 2 t'), - collect_stats('peak_megabytes_allocated',2), + collect_runtime_residency(2), # prof ways don't work well with +RTS -V0, nonmoving way residency is # highly variable. omit_ways(['profasm','profthreaded','nonmoving_thr']) @@ -21,9 +21,8 @@ test('T4334', compile_and_run, ['']) test('T2762', - [collect_stats('peak_megabytes_allocated',2), + [collect_runtime_residency(2), only_ways(['normal']), - extra_run_opts('+RTS -G1 -RTS' ), extra_clean(['T2762A.hi', 'T2762A.o'])], compile_and_run, ['-O']) @@ -32,9 +31,7 @@ test('T4018', compile_and_run, ['-fno-state-hack']) test('T4029', - [collect_stats(['peak_megabytes_allocated'],10), - collect_runtime_residency(10), - extra_hc_opts('+RTS -G1 -RTS' ), + [collect_runtime_residency(10), ], ghci_script, ['T4029.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/599ebea005d60b2c78c16811f3f3e86e2920b64b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/599ebea005d60b2c78c16811f3f3e86e2920b64b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 3 14:57:15 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sat, 03 Oct 2020 10:57:15 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 2 commits: Remove unneccesary primop cloneThreadStack# (#18741) Message-ID: <5f78914b8d744_80b10ea7d641628842b@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 4b5e678a by Sven Tennie at 2020-09-27T17:23:51+02:00 Remove unneccesary primop cloneThreadStack# (#18741) - - - - - ff9eb1a2 by Sven Tennie at 2020-10-03T16:56:57+02:00 Add cloneThreadStack and cloneMyStack - - - - - 20 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/StgMiscClosures.cmm - rts/Threads.c - rts/rts.cabal.in - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneMyStack.hs - + testsuite/tests/rts/cloneStackLib.c - + testsuite/tests/rts/cloneThreadStack.hs Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3586,13 +3586,6 @@ primop CloneMyStack "cloneMyStack#" GenPrimOp has_side_effects = True out_of_line = True -primop CloneThreadStack "cloneThreadStack#" GenPrimOp - ThreadId# -> State# RealWorld -> (# State# RealWorld, StackSnapshot# #) - { Clones the stack of a Haskell thread. } - with - has_side_effects = True - out_of_line = True - ------------------------------------------------------------------------ section "Safe coercions" ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1518,7 +1518,6 @@ emitPrimOp dflags primop = case primop of TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal CloneMyStack -> alwaysExternal - CloneThreadStack -> alwaysExternal where profile = targetProfile dflags ===================================== includes/rts/storage/Closures.h ===================================== @@ -431,6 +431,14 @@ typedef struct MessageBlackHole_ { StgClosure *bh; } MessageBlackHole; +typedef struct MessageCloneStack_ { + StgHeader header; + Message *link; + StgMVar *result; + StgTSO *tso; +} MessageCloneStack; + + /* ---------------------------------------------------------------------------- Compact Regions ------------------------------------------------------------------------- */ ===================================== includes/stg/MiscClosures.h ===================================== @@ -129,6 +129,7 @@ RTS_ENTRY(stg_STM_AWOKEN); RTS_ENTRY(stg_MSG_TRY_WAKEUP); RTS_ENTRY(stg_MSG_THROWTO); RTS_ENTRY(stg_MSG_BLACKHOLE); +RTS_ENTRY(stg_MSG_CLONE_STACK); RTS_ENTRY(stg_MSG_NULL); RTS_ENTRY(stg_MVAR_TSO_QUEUE); RTS_ENTRY(stg_catch); ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -624,7 +624,7 @@ data PrimMVar -- @hs_try_putmvar()@. The RTS wants a 'StablePtr' to the underlying -- 'MVar#', but a 'StablePtr#' can only refer to lifted types, so we -- have to cheat by coercing. -newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar) +newStablePtrPrimMVar :: MVar a -> IO (StablePtr PrimMVar) newStablePtrPrimMVar (MVar m) = IO $ \s0 -> case makeStablePtr# (unsafeCoerce# m :: PrimMVar) s0 of -- Coerce unlifted m :: MVar# RealWorld () ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -0,0 +1,40 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes#-} + + +module GHC.Stack.CloneStack ( + cloneThreadStack, + cloneMyStack, + StackSnapshot(..) + ) where + +import GHC.Prim (StackSnapshot#, cloneMyStack#, ThreadId#) +import Control.Concurrent.MVar +import GHC.Conc.Sync +import GHC.Stable +import GHC.IO (IO(..)) + +foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () + +data StackSnapshot = StackSnapshot StackSnapshot# + +-- | Clone the stack of a thread identified by it's 'ThreadId' +cloneThreadStack :: ThreadId -> IO StackSnapshot +cloneThreadStack (ThreadId tid#) = do + resultVar <- newEmptyMVar @StackSnapshot + ptr <- newStablePtrPrimMVar resultVar + -- Use the RTS's "message" mechanism to request that + -- the thread captures its stack, saving the result + -- into resultVar. + sendCloneStackMessage tid# ptr + freeStablePtr ptr + print "takeMVar" + takeMVar resultVar + +-- | Clone the stack of the executing thread +cloneMyStack :: IO StackSnapshot +cloneMyStack = IO $ \s -> + case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) ===================================== libraries/base/base.cabal ===================================== @@ -264,6 +264,7 @@ Library GHC.ResponseFile GHC.RTS.Flags GHC.ST + GHC.Stack.CloneStack GHC.StaticPtr GHC.STRef GHC.Show ===================================== rts/CloneStack.c ===================================== @@ -0,0 +1,67 @@ +#include + +#include "Rts.h" +#include "rts/Messages.h" +#include "rts/storage/TSO.h" +#include "stg/Types.h" +#include "CloneStack.h" + +#if defined(THREADED_RTS) + +// ThreadId# in Haskell is a StgTSO* in RTS. +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + Capability *srcCapability = rts_unsafeGetMyCapability(); + + MessageCloneStack *msg; + msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); + msg->tso = tso; + msg->result = (StgMVar*)deRefStablePtr(mvar); + // TODO: Free? See RtsAPI.c: hs_try_putmvar() + SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); + // Ensure that writes constructing Message are committed before sending. + write_barrier(); + + sendMessage(srcCapability, tso->cap, (Message *)msg); +} + +void handleCloneStackMessage(MessageCloneStack *msg){ + StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, newStackClosure); + + if(!putMVarWasSuccessful) { + barf("Can't put stack cloning result into MVar."); + } +} + +#else // !defined(THREADED_RTS) + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + barf("Sending CloneStackMessages is only available in threaded RTS!"); +} + +#endif // end !defined(THREADED_RTS) + +StgStack* cloneStack(Capability* capability, StgStack* stack){ +#if defined(DEBUG) + debugBelch("Stack to clone\n"); + printStack(stack); +#endif + + StgWord spOffset = stack->sp - stack->stack; + StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); + + StgStack* newStackClosure = (StgStack*) allocate(capability, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + + memcpy(newStackClosure, stack, closureSizeBytes); + + newStackClosure->sp = newStackClosure->stack + spOffset; + +#if defined(DEBUG) + debugBelch("Cloned stack\n"); + printStack(newStackClosure); + // TODO: Check sanity +#endif + + return newStackClosure; +} ===================================== rts/CloneStack.h ===================================== @@ -0,0 +1,9 @@ +#pragma once + +#if defined(THREADED_RTS) +void handleCloneStackMessage(MessageCloneStack *msg); +#endif + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); + +StgStack* cloneStack(Capability* capability, StgStack* stack); ===================================== rts/Messages.c ===================================== @@ -14,6 +14,7 @@ #include "Threads.h" #include "RaiseAsync.h" #include "sm/Storage.h" +#include "CloneStack.h" /* ---------------------------------------------------------------------------- Send a message to another Capability @@ -32,7 +33,8 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg) i != &stg_MSG_BLACKHOLE_info && i != &stg_MSG_TRY_WAKEUP_info && i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked - i != &stg_WHITEHOLE_info) { + i != &stg_WHITEHOLE_info && + i != &stg_MSG_CLONE_STACK_info) { barf("sendMessage: %p", i); } } @@ -131,6 +133,10 @@ loop: #endif goto loop; } + else if(i == &stg_MSG_CLONE_STACK_info){ + MessageCloneStack *cloneStackMessage = (MessageCloneStack*) m; + handleCloneStackMessage(cloneStackMessage); + } else { barf("executeMessage: %p", i); ===================================== rts/PrimOps.cmm ===================================== @@ -2841,26 +2841,13 @@ stg_setThreadAllocationCounterzh ( I64 counter ) return (); } -stg_cloneThreadStackzh () { - // TODO: Implement me! Consider locks, race-conditions, etc. - return (); -} - stg_cloneMyStackzh () { W_ stgStack; - gcptr p; - W_ neededMemorySize; + W_ clonedStack; stgStack = StgTSO_stackobj(CurrentTSO); - neededMemorySize = BYTES_TO_WDS(SIZEOF_StgStack) + StgStack_stack_size(stgStack); - - ("ptr" p) = ccall allocateMightFail(MyCapability() "ptr", neededMemorySize); - if (p == NULL) { - jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); - } + ("ptr" clonedStack) = ccall cloneStack(MyCapability() "ptr", stgStack "ptr"); - prim %memcpy(p, stgStack, WDS(neededMemorySize), SIZEOF_W); - - return (p); + return (clonedStack); } ===================================== rts/Printer.c ===================================== @@ -642,7 +642,8 @@ printStackChunk( StgPtr sp, StgPtr spBottom ) } } -static void printStack( StgStack *stack ) +// TODO: Do not merge. Only exported for debugging. +void printStack( StgStack *stack ) { printStackChunk( stack->sp, stack->stack + stack->stack_size ); } @@ -697,7 +698,7 @@ void printLargeAndPinnedObjects() for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { Capability *cap = capabilities[cap_idx]; - debugBelch("Capability %d: Current pinned object block: %p\n", + debugBelch("Capability %d: Current pinned object block: %p\n", cap_idx, (void*)cap->pinned_object_block); for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { debugBelch("%p\n", (void*)bd); ===================================== rts/Printer.h ===================================== @@ -21,6 +21,7 @@ const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); #if defined(DEBUG) +extern void printStack( StgStack *stack ); extern void printClosure ( const StgClosure *obj ); extern void printStackChunk ( StgPtr sp, StgPtr spLim ); extern void printTSO ( StgTSO *tso ); ===================================== rts/StgMiscClosures.cmm ===================================== @@ -573,6 +573,9 @@ INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") { foreign "C" barf("MSG_NULL object (%p) entered!", R1) never returns; } +INFO_TABLE_CONSTR(stg_MSG_CLONE_STACK,3,0,0,PRIM,"MSG_CLONE_STACK","MSG_CLONE_STACK") +{ foreign "C" barf("stg_MSG_CLONE_STACK object (%p) entered!", R1) never returns; } + /* ---------------------------------------------------------------------------- END_TSO_QUEUE ===================================== rts/Threads.c ===================================== @@ -23,6 +23,7 @@ #include "Printer.h" #include "sm/Sanity.h" #include "sm/Storage.h" +#include "Printer.h" #include ===================================== rts/rts.cabal.in ===================================== @@ -410,6 +410,7 @@ library Arena.c Capability.c CheckUnload.c + CloneStack.c ClosureFlags.c Disassembler.c FileLock.c ===================================== testsuite/tests/rts/all.T ===================================== @@ -418,3 +418,7 @@ test('T17088', compile_and_run, ['-rtsopts -O2']) test('T15427', normal, compile_and_run, ['']) + +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -debug']) + +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -debug -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack + +foreign import ccall "printy" printStack:: StackSnapshot# -> IO () + +main :: IO () +main = do + stackSnapshot <- cloneMyStack + let (StackSnapshot stack) = stackSnapshot + printStack stack ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -0,0 +1,9 @@ +#include "Rts.h" +#include "RtsAPI.h" + +// TODO: Do not merge. Only exported for debugging. +extern void printStack( StgStack *stack ); + +void printy(StgStack *stack) { + printStack(stack); +} ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack +import Control.Concurrent + +foreign import ccall "printy" printStack:: StackSnapshot# -> IO () + +main :: IO () +main = do + mVarToBeBlockedOn <- newEmptyMVar + threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + + stackSnapshot <- cloneThreadStack threadId + let (StackSnapshot stack) = stackSnapshot + printStack stack + +immediatelyBlocking :: MVar Int -> IO () +immediatelyBlocking mVarToBeBlockedOn = do + takeMVar mVarToBeBlockedOn + return () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4cd2c222e8f23d0ec73ca35694baa1cdc35e1c82...ff9eb1a2306a001236d606432e915ff5f27df39a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4cd2c222e8f23d0ec73ca35694baa1cdc35e1c82...ff9eb1a2306a001236d606432e915ff5f27df39a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 3 18:54:26 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sat, 03 Oct 2020 14:54:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18791 Message-ID: <5f78c8e29ccb4_80b3f837bb3f02c163127a0@gitlab.haskell.org.mail> Alan Zimmerman pushed new branch wip/T18791 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18791 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 3 22:14:15 2020 From: gitlab at gitlab.haskell.org (Adam Gundry) Date: Sat, 03 Oct 2020 18:14:15 -0400 Subject: [Git][ghc/ghc][wip/amg/hasfield-2020] 2 commits: Cleanup Message-ID: <5f78f7b7e07a2_80bd6ab438163196c@gitlab.haskell.org.mail> Adam Gundry pushed to branch wip/amg/hasfield-2020 at Glasgow Haskell Compiler / GHC Commits: 650b0156 by Adam Gundry at 2020-10-03T21:53:03+01:00 Cleanup - - - - - e82c38eb by Adam Gundry at 2020-10-03T23:13:23+01:00 More cleanup - - - - - 1 changed file: - compiler/GHC/Tc/TyCl/Utils.hs Changes: ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Hs import GHC.Core.Class import GHC.Core.FamInstEnv import GHC.Core.Type +import GHC.Driver.Session import GHC.Driver.Types import GHC.Core.TyCon import GHC.Core.ConLike @@ -854,6 +855,8 @@ tcRecSelBinds sel_bind_prs do { (rec_sel_binds, tcg_env) <- discardWarnings $ -- See Note [Impredicative record selectors] setXOptM LangExt.ImpredicativeTypes $ + -- See Note [Updaters use record update syntax] + unsetWOptM Opt_WarnIncompletePatternsRecUpd $ tcValBinds TopLevel binds sigs getGblEnv ; return (tcg_env `addTypecheckedBinds` map snd rec_sel_binds) } where @@ -879,8 +882,7 @@ mkRecSelAndUpd (tycon, fl) = do -- value of the field being updated. x_vars <- fmap mkNameEnv $ forM (tyConFieldLabels tycon) $ \fl' -> (,) (flSelector fl') <$> newSysName (mkVarOccFS (flLabel fl')) - y_var <- newSysName (mkVarOccFS (flLabel fl)) - let (sel, upd) = mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var + let (sel, upd) = mkRecordSelectorAndUpdater all_cons idDetails fl x_vars return [sel, upd] where all_cons = map RealDataCon (tyConDataCons tycon) @@ -891,14 +893,14 @@ mkRecSelAndUpd (tycon, fl) = do mkOneRecordSelector :: [ConLike] -> RecSelParent -> FieldLabelNoUpdater -> (Id, LHsBind GhcRn) mkOneRecordSelector all_cons idDetails fl - = fst $ mkRecordSelectorAndUpdater all_cons idDetails (fl { flUpdate = oops }) oops oops + = fst $ mkRecordSelectorAndUpdater all_cons idDetails (fl { flUpdate = oops }) oops where oops = error "mkOneRecordSelector: poked a field needed only for updaters" mkRecordSelectorAndUpdater :: [ConLike] -> RecSelParent -> FieldLabel - -> NameEnv Name -> Name + -> NameEnv Name -> ((Id, LHsBind GhcRn), (Id, LHsBind GhcRn)) -mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = +mkRecordSelectorAndUpdater all_cons idDetails fl x_vars = ( mk_binding rec_details sel_name sel_ty sel_bind is_naughty , mk_binding VanillaId upd_name upd_ty upd_bind no_updater ) @@ -909,12 +911,12 @@ mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = upd_name = flUpdate fl mk_binding :: IdDetails -> Name -> Type -- What is being bound - -> (Name -> LHsBind GhcRn) -- The body of the binding + -> LHsBind GhcRn -- The body of the binding -> Bool -- Should it be unit instead? -> (Id, Located (HsBindLR GhcRn GhcRn)) mk_binding details name ty bind is_unit | is_unit = (mkExportedLocalId details name unitTy, unit_bind name) - | otherwise = (mkExportedLocalId details name ty, bind name) + | otherwise = (mkExportedLocalId details name ty, bind) rec_details = RecSelId { sel_tycon = idDetails, sel_naughty = is_naughty } @@ -957,133 +959,115 @@ mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = -- fields in all the constructor have multiplicity Many. result_ty - -- Make a selector or updater binding: one alternative per constructor that - -- includes the field, plus a default case if necessary. - the_bind :: (ConLike -> [LHsRecField GhcRn (LPat GhcRn)]) - -- Fields to match on for this constructor - -> (ConLike -> LHsExpr GhcRn) -- RHS for this constructor - -> Name -- Name of the bound function - -> LHsBind GhcRn - the_bind mk_rec_flds mk_expr name - = L loc (mkTopFunBind Generated lname alts) - where - lname = L loc name - alts = map mk_match cons_w_field ++ deflt - - mk_match con = mkSimpleMatch (mkPrefixFunRhs lname) - [L loc pat] - (mk_expr con) - where - pat = ConPat NoExtField (L loc (getName con)) (RecCon rec_fields) - rec_fields = HsRecFields { rec_flds = mk_rec_flds con - , rec_dotdot = Nothing } - -- Make the binding: sel (C2 { fld = x }) = x -- sel (C7 { fld = x }) = x -- where cons_w_field = [C2,C7] - sel_bind = the_bind (const [rec_field]) (const mk_expr) + sel_bind = mkBind sel_name alts where - rec_field = noLoc (HsRecField - { hsRecFieldLbl - = L loc (FieldOcc sel_name - (L loc $ mkVarUnqual lbl)) - , hsRecFieldArg - = L loc (VarPat noExtField (L loc field_var)) - , hsRecPun = False }) - field_var = mkInternalName (mkBuiltinUnique 1) (getOccName sel_name) loc - mk_expr = L loc (HsVar noExtField (L loc field_var)) + alts = map mk_match cons_w_field ++ deflt - -- Make a binding for the updater. We prefer to use upd_bind_fast, but - -- thanks to #2595 this does not work for some GADTs, so we fall back on - -- upd_bind_slow. - upd_bind - | null (conLikeExTyCoVars con1) = upd_bind_fast - | otherwise = upd_bind_slow + mk_match con = ( [mkRecConPat con [rec_field]] + , mkHsVar field_var + ) + rec_field = mkHsRecField (mkFieldOcc fl) (mkVarPat field_var) + field_var = mkInternalName (mkBuiltinUnique 1) (getOccName sel_name) loc - -- Make the binding: - -- upd x = (\ y -> x { fld = y }, fld x) - -- - -- TODO: this implementation needs cleaning up - upd_bind_fast name = L loc (mkTopFunBind Generated lname [alt]) + -- Make the updater binding: + -- upd z = (\ y -> z { fld = y }, fld z) + upd_bind = mkBind upd_name [([mkVarPat z_var], expr)] where - lname = L loc name - alt = mkSimpleMatch (mkPrefixFunRhs lname) - [L loc (VarPat noExtField (L loc (x_var fl)))] - (mkLHsTupleExpr - [ mkHsLam [L loc (VarPat noExtField (L loc y_var))] - (L loc (RecordUpd noExtField - (L loc (HsVar noExtField (L loc (x_var fl)))) - [L loc (HsRecField (L loc afo) (L loc (HsVar noExtField (L loc y_var))) False)] - )) - , mkHsApp (L loc (HsRecFld noExtField afo)) - (L loc (HsVar noExtField (L loc (x_var fl)))) - ]) - - afo = Unambiguous sel_name (L loc (mkVarUnqual (flLabel fl))) - - -- Make the binding: - -- upd (C2 { fld1 = x1, .., fldN = xN }) - -- = (\ y -> C2 { fld1 = y, fld2 = x2, .., fldN = xN }, x1) - -- upd (C7 { fld1 = x1, .., fldM = xM }) - -- = (\ y -> C7 { fld1 = y, fld3 = x3, .., fldM = xM }, x1) - -- where cons_w_field = [C2,C7] and fld1 is being selected/updated - -- - -- TODO: we should probably be more consistent with upd_bind_fast and generate - -- upd x = ((\ y -> case x of { c at C2 { fld1 = x1 } -> c { fld1 = y } ; ... }), fld1 x) - upd_bind_slow = the_bind mk_rec_flds mk_expr - where - -- Pattern that matches { fld1 = x1, .., fldN = xN } - mk_rec_flds con = rec_flds (rec_fields con pat_var) - pat_var = VarPat noExtField . L loc . x_var - - -- RHS expression in updater binding: (\y -> C{...}, x1) - mk_expr con = mkLHsTupleExpr - [ mk_update_fun con - , L loc (HsVar noExtField (L loc (x_var fl))) - ] - - -- Make the first component of the pair: a function that takes a new value - -- for the field being updated and constructs a record with that field - -- updated and the others unchanged: e.g. if updating fld1 we make - -- \y -> C { fld1 = y, fld2 = x2, .., fldN = xN } - mk_update_fun con = mkHsLam - [L loc (VarPat noExtField (L loc y_var))] - (L loc (RecordCon noExtField - (L loc (getName con)) - (rec_fields con con_var))) - con_var fl' = HsVar noExtField (L loc (if flSelector fl' == sel_name - then y_var - else x_var fl')) - - -- Used for both pattern and record construction, to create - -- { fld1 = k fld1, .., fldN = k fldN } - -- where k gives the hsRecFieldArg for each field - rec_fields :: ConLike - -> (FieldLabelNoUpdater -> a) - -> HsRecFields GhcRn (Located a) - rec_fields con k = HsRecFields { rec_flds = map rec_field - (conLikeFieldLabels con) - , rec_dotdot = Nothing } + y_var = mkInternalName (mkBuiltinUnique 2) (mkVarOccFS lbl) loc + z_var = mkInternalName (mkBuiltinUnique 3) (mkVarOcc "z") loc + + expr = mkLHsTupleExpr + [ mkHsLam [mkVarPat y_var] update_expr + , mkHsApp (L loc (HsRecFld noExtField unambiguous_fld)) + (mkHsVar z_var) + ] + + unambiguous_fld = Unambiguous sel_name (L loc (mkVarUnqual (flLabel fl))) + + -- Either z { fld = y } or its desugaring as a case expression. + -- See Note [Updaters use record update syntax] for why we need the latter. + update_expr = L loc (if simple_update then rec_upd_expr else case_expr) + simple_update = null (conLikeExTyCoVars con1) + + -- z { fld = y } + rec_upd_expr = RecordUpd + { rupd_ext = noExtField + , rupd_expr = mkHsVar z_var + , rupd_flds = [mkHsRecField (L loc unambiguous_fld) (mkHsVar y_var)] } + + -- desugaring of z { fld1 = y }, i.e. + -- case z of + -- C2 { fld1 = x1, fld2 = x2, ..., fld = xN } + -- -> C2 { fld1 = y, fld2 = x2, ..., fldN = xN } + -- ... + case_expr = HsCase noExtField (mkHsVar z_var) (mkMatchGroup Generated alts) + alts = map mk_alt cons_w_field + ++ map (uncurry (mkSimpleMatch CaseAlt)) deflt + + -- C2 { fld1 = x1, ..., fld = xN } -> C2 { fld1 = y, fld2 = x2, ..., fldN = xN } + mk_alt con = mkHsCaseAlt pat expr where - rec_field fl' = L loc (HsRecField - { hsRecFieldLbl = L loc (field_occ fl') - , hsRecFieldArg = L loc (k fl') - , hsRecPun = False }) - field_occ fl' = FieldOcc (flSelector fl') - (L loc (mkVarUnqual (flLabel fl'))) - - -- The x_vars NameEnv contains a fresh name for every selector name in the - -- TyCon, i.e. maps fldN to xN. - x_var :: FieldLbl upd Name -> Name - x_var fl' = lookupNameEnv_NF x_vars (flSelector fl') + field_labels = conLikeFieldLabels con + pat = mkRecConPat con (map (rec_field (mkVarPat . x_var)) field_labels) + expr = mkRecordCon con (map (rec_field (mkHsVar . con_var)) field_labels) + con_var fl' = if flSelector fl' == sel_name then y_var else x_var fl' + + -- Used for both pattern and record construction, to create + -- fldN = k fldN + -- where k gives the hsRecFieldArg for each field + rec_field :: (FieldLabelNoUpdater -> a) + -> FieldLabelNoUpdater + -> LHsRecField' (FieldOcc GhcRn) a + rec_field k fl' = mkHsRecField (mkFieldOcc fl') (k fl') + + -- The x_vars NameEnv contains a fresh name for every selector name + -- in the TyCon, i.e. maps fldN to xN. + x_var :: FieldLabelNoUpdater -> Name + x_var fl' = lookupNameEnv_NF x_vars (flSelector fl') + + + -- These are just boring constructors for bits of syntax, using the SrcSpan + -- of the field (which is why they are not top-level). + mkBind :: Name -> [([LPat GhcRn], LHsExpr GhcRn)] -> LHsBind GhcRn + mkBind name alts = L loc (mkTopFunBind Generated lname alts') + where + lname = L loc name + alts' = map (uncurry (mkSimpleMatch (mkPrefixFunRhs lname))) alts + + mkVarPat :: Name -> LPat GhcRn + mkVarPat var = L loc (VarPat noExtField (L loc var)) + + mkRecConPat :: ConLike -> [LHsRecField GhcRn (XRec GhcRn (Pat GhcRn))] -> LPat GhcRn + mkRecConPat con rflds = L loc (ConPat noExtField (L loc (getName con)) + (RecCon (HsRecFields rflds Nothing))) + + mkHsVar :: Name -> LHsExpr GhcRn + mkHsVar var = L loc (HsVar noExtField (L loc var)) + + mkRecordCon :: ConLike -> [LHsRecField GhcRn (XRec GhcRn (HsExpr GhcRn))] -> LHsExpr GhcRn + mkRecordCon con rflds = L loc (RecordCon noExtField + (L loc (getName con)) + (HsRecFields rflds Nothing)) + + mkHsRecField :: Located lbl -> arg -> LHsRecField' lbl arg + mkHsRecField lbl arg = L loc (HsRecField { hsRecFieldLbl = lbl + , hsRecFieldArg = arg + , hsRecPun = False }) + + mkFieldOcc :: FieldLbl update_rep Name -> LFieldOcc GhcRn + mkFieldOcc fl' = L loc (FieldOcc (flSelector fl') + (L loc (mkVarUnqual (flLabel fl')))) + -- Add catch-all default case unless the case is exhaustive -- We do this explicitly so that we get a nice error message that -- mentions this particular record selector deflt | all dealt_with all_cons = [] - | otherwise = [mkSimpleMatch CaseAlt - [L loc (WildPat noExtField)] - (mkHsApp (L loc (HsVar noExtField + | otherwise = [( [L loc (WildPat noExtField)] + , mkHsApp (L loc (HsVar noExtField (L loc (getName rEC_SEL_ERROR_ID)))) (L loc (HsLit noExtField msg_lit)))] msg_lit = HsStringPrim NoSourceText (bytesFS lbl) @@ -1118,19 +1102,11 @@ mkRecordSelectorAndUpdater all_cons idDetails fl x_vars y_var = inst_tys = substTyVars eq_subst univ_tvs --- | Make a binding of unit: --- --- name :: () --- name = () --- --- used for naughty record selectors and missing updaters. -unit_bind :: Name -> LHsBind GhcRn -unit_bind name = L loc (mkTopFunBind Generated lname alts) - where - loc = getSrcSpan name - lname = L loc name - alts = [mkSimpleMatch (mkPrefixFunRhs lname) [] unit_rhs] - unit_rhs = mkLHsTupleExpr [] + -- Make a binding of unit, for naughty record selectors/updaters: + -- name :: () + -- name = () + unit_bind :: Name -> LHsBind GhcRn + unit_bind name = mkBind name [([], mkLHsTupleExpr [])] @@ -1301,12 +1277,10 @@ returns the existing value. For example, given the data declaration we generate the record updaters: $upd:foo:MkT :: T y -> ([y] -> T y, [y]) - $upd:foo:MkT (MkT { foo = x1, bar = x2}) - = (\y -> MkT { foo = y, bar = x2}, x1) + $upd:foo:MkT x = (\ y -> t { foo = y }, foo x) $upd:bar:MkT :: T y -> (Int -> T y, Int) - $upd:bar:MkT (MkT { foo = x1, bar = x2 }) - = (\y -> MkT { foo = x1, bar = y}, x2) + $upd:bar:MkT x = (\ y -> t { bar = y }, foo x) These are used to produce instances of GHC.Records.HasField automatically as described in Note [HasField instances] in GHC.Tc.Instance.Class. @@ -1347,11 +1321,49 @@ Note that: and an updater (see Note [GADT record selectors]). +Note [Updaters use record update syntax] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Most updaters are defined by generating a record update expression and a call to +the selector function, like this: + + $upd:foo:MkT x = (\ y -> x { foo = y }, foo x) + +Since we are generating renamed syntax, we can emit a call to the selector +function, even if it is not technically in scope (due to NoFieldSelectors). +When RecordDotSyntax is implemented, it will redefine the meaning of record +update syntax, but here we really need the "traditional" version. + +We use a record update expression, rather than generating an explicit case +statement, because type-checking the explicit case statement is expensive for +datatypes with many constructors and/or many fields. + +When type-checking the updater bindings, we disable -Wincomplete-record-updates, +otherwise it would emit a warning on the definition of a partial field, which is +not intended (there is a separate warning -Wpartial-fields for this). + +An annoying wrinkle is #2595: we cannot use record update for some GADTs, even +though the desugaring is in principle type-correct, because the type-checker +rejects the update. Thus we *do* generate an explicit case statement when the +constructor has existential type variables. For example, we generate: + + data S a where + MkS :: { soo :: Either p q, f :: Int } -> S (p,q) + + $sel:soo:MkS :: S (p,q) -> Either p q + $sel:soo:MkS MkS{soo=x} = x + + $upd:soo:MkS :: S (p,q) -> (Either p q -> S (p,q), Either p q) + $upd:soo:MkS x = (\ y -> case x of { MkS{soo=x0,f=x1} -> MkS{soo=y,f=x1} } + , $sel:soo:MkS x + ) + + Note [Naughty record updaters] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are a few cases in which we cannot generate an updater for a field: -1. The field has an existential tyvar, e.g. +1. The field has an existential tyvar that would escape its scope, e.g. data T = forall a . MkT { foo :: a } This is the same as for selectors (see Note [Naughty record selectors]). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18968fd1a25769ae82ba5ae7709f88885560a8a8...e82c38ebd0059584e166e17cc8e120422b291320 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18968fd1a25769ae82ba5ae7709f88885560a8a8...e82c38ebd0059584e166e17cc8e120422b291320 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 3 23:33:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 03 Oct 2020 19:33:13 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Minor TTG clean-up: comments, unused families, bottom Message-ID: <5f790a39350cd_80bb5b7484163263cc@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - 30 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Validity.hs - docs/users_guide/9.0.1-notes.rst - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/gadt_syntax.rst - docs/users_guide/exts/instances.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst - libraries/ghc-bignum/cbits/gmp_wrappers.c - libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs - libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs - libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs - libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs-boot - libraries/ghc-bignum/src/GHC/Num/Integer.hs - libraries/ghc-bignum/src/GHC/Num/Integer.hs-boot - libraries/ghc-bignum/src/GHC/Num/Natural.hs-boot - libraries/integer-gmp/src/GHC/Integer/GMP/Internals.hs - rts/rts.cabal.in - testsuite/tests/lib/integer/all.T - testsuite/tests/lib/integer/integerGmpInternals.hs - testsuite/tests/lib/integer/integerGmpInternals.stdout - testsuite/tests/lib/integer/integerPowMod.hs - testsuite/tests/lib/integer/integerPowMod.stdout - + testsuite/tests/lib/integer/integerRecipMod.hs - + testsuite/tests/lib/integer/integerRecipMod.stdout - testsuite/tests/linear/should_fail/LinearKind.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6224bb32a32f2e79061ad02d261763b93b8f60d0...70dc2f09a33a4c3f485d8b63e92a21955643a0b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6224bb32a32f2e79061ad02d261763b93b8f60d0...70dc2f09a33a4c3f485d8b63e92a21955643a0b7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 00:11:33 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 03 Oct 2020 20:11:33 -0400 Subject: [Git][ghc/ghc][wip/T16762] 68 commits: Make sizeExpr strict in the size threshold to facilitate WW. Message-ID: <5f791335a10a2_80bb2bb8981632809a@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - 94458def by Ryan Scott at 2020-10-03T16:32:08-04:00 WIP: T16762 [ci skip] - - - - - aed9df81 by Simon Peyton Jones at 2020-10-03T16:32:08-04:00 Wibbbles - - - - - 8eab4280 by Simon Peyton Jones at 2020-10-03T16:32:08-04:00 More wibbles - - - - - 92807a4d by Simon Peyton Jones at 2020-10-03T16:32:09-04:00 More wibbles - - - - - c08591da by Simon Peyton Jones at 2020-10-03T16:32:09-04:00 More wibbles --- getting there - - - - - 53f73ec2 by Ryan Scott at 2020-10-03T16:32:58-04:00 Push through some Haddock changes, disable warnings in GHC.Iface.Ext.Ast for now - - - - - ede4e914 by Simon Peyton Jones at 2020-10-03T16:32:58-04:00 More wibbles - - - - - 62f6bf5c by Ryan Scott at 2020-10-03T20:10:38-04:00 Use TTG in HsOuterTyVarBndrs - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a476d4b0207b5d9a791c129a9a7fd919715118b...62f6bf5ccfa499a9b2f2666f7a81c8df64bebebb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a476d4b0207b5d9a791c129a9a7fd919715118b...62f6bf5ccfa499a9b2f2666f7a81c8df64bebebb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 05:33:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 04 Oct 2020 01:33:27 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Small documentation fixes Message-ID: <5f795ea755521_80b101cbeec16336755@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - 8 changed files: - docs/users_guide/9.0.1-notes.rst - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/deriving_extra.rst - docs/users_guide/exts/gadt_syntax.rst - docs/users_guide/exts/instances.rst - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst - rts/rts.cabal.in Changes: ===================================== docs/users_guide/9.0.1-notes.rst ===================================== @@ -193,7 +193,7 @@ Language * GHC more strictly enforces the rule that the type in the top of an instance declaration is not permitted to contain nested ``forall``\ s or contexts, as documented in :ref:`formal-instance-syntax`. For example, the following - examples, which previous versions of GHC would accept, are now rejected: + examples, which previous versions of GHC would accept, are now rejected: :: instance (forall a. C a) where ... instance (Show a => C a) where ... @@ -349,9 +349,6 @@ Haddock - Add a known-key ``cstringLength#`` to ``GHC.CString`` that is eligible for constant folding by a built-in rule. -- ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. - Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. - ``ghc`` library ~~~~~~~~~~~~~~~ ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -11,13 +11,13 @@ Language impredicative types, as described in in the paper `A quick look at impredicativity `__ - (Serrano et al, ICFP 2020). More information here: :ref:`impredicative-polymorphism`. - This replaces the old (undefined, flaky) behaviour of the :extension:`ImpredicativeTypes` extension. + (Serrano et al, ICFP 2020). More information here: :ref:`impredicative-polymorphism`. + This replaces the old (undefined, flaky) behaviour of the :extension:`ImpredicativeTypes` extension. Compiler ~~~~~~~~ -- New '-Wredundant-bang-patterns' flag that enables checks for "dead" bangs. +- New ``-Wredundant-bang-patterns`` flag that enables checks for "dead" bangs. For instance, given this program: :: f :: Bool -> Bool @@ -26,4 +26,10 @@ Compiler GHC would report that the bang on ``x`` is redundant and can be removed since the argument was already forced in the first equation. For more - details see :ghc-flag:`-Wredundant-bang-patterns` + details see :ghc-flag:`-Wredundant-bang-patterns`. + +``ghc-prim`` library +~~~~~~~~~~~~~~~~~~~~ + +- ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. + Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. ===================================== docs/users_guide/exts/deriving_extra.rst ===================================== @@ -233,7 +233,7 @@ simply force the (bottom) value of the argument using data V a deriving Functor type role V nominal -will produce +will produce :: instance Functor V where fmap _ z = case z of ===================================== docs/users_guide/exts/gadt_syntax.rst ===================================== @@ -110,7 +110,9 @@ Formal syntax for GADTs To make more precise what is and what is not permitted inside of a GADT-style constructor, we provide a BNF-style grammar for GADT below. Note that this -grammar is subject to change in the future. :: +grammar is subject to change in the future. + +.. code-block:: none gadt_con ::= conids '::' opt_forall opt_ctxt gadt_body ===================================== docs/users_guide/exts/instances.rst ===================================== @@ -106,7 +106,9 @@ Formal syntax for instance declaration types The top of an instance declaration only permits very specific forms of types. To make more precise what forms of types are or are not permitted, we provide a -BNF-style grammar for the tops of instance declarations below: :: +BNF-style grammar for the tops of instance declarations below. + +.. code-block:: none inst_top ::= 'instance' opt_forall opt_ctxt inst_head opt_where ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -90,7 +90,7 @@ therefore constructors appear to have regular function types. :: - mkList :: [a] -> [MkT1 a] + mkList :: [a] -> [T1 a] mkList xs = map MkT1 xs Hence the linearity of type constructors is invisible when ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -860,8 +860,8 @@ of ``-W(no-)*``. .. ghc-flag:: -Wincomplete-uni-patterns - :shortdesc: warn when a pattern match in a lambda expression or - pattern binding could fail + :shortdesc: warn when a pattern match in a lambda expression, + pattern binding or a lazy pattern could fail :type: dynamic :reverse: -Wno-incomplete-uni-patterns :category: @@ -874,6 +874,10 @@ of ``-W(no-)*``. h = \[] -> 2 Just k = f y + Furthermore, this flag also applies to lazy patterns, since they are + syntactic sugar for pattern bindings. For example, ``f ~(Just x) = (x,x)`` + is equivalent to ``f y = let Just x = y in (x,x)``. + .. ghc-flag:: -fmax-pmcheck-models=⟨n⟩ :shortdesc: soft limit on the number of parallel models the pattern match checker should check a pattern match clause against ===================================== rts/rts.cabal.in ===================================== @@ -401,9 +401,9 @@ library -- AutoApply is generated AutoApply.cmm - if arch(i386) || arch(powerpc) || arch(powerpc64) + if arch(i386) || arch(ppc) || arch(ppc64) asm-sources: AdjustorAsm.S - if arch(powerpc) || arch(powerpc64) || arch(powerpc64le) || arch(s390x) + if arch(ppc) || arch(ppc64) || arch(s390x) asm-sources: StgCRunAsm.S c-sources: Adjustor.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1033a720abf4a23a30c5cb0dfcb18b2bae3acc68...70dc2f09a33a4c3f485d8b63e92a21955643a0b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1033a720abf4a23a30c5cb0dfcb18b2bae3acc68...70dc2f09a33a4c3f485d8b63e92a21955643a0b7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 08:42:43 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 04 Oct 2020 04:42:43 -0400 Subject: [Git][ghc/ghc][wip/T18791] Preserve as-parsed arrow type for HsUnrestrictedArrow Message-ID: <5f798b036bf11_80b3f83acdda990163369d@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/T18791 at Glasgow Haskell Compiler / GHC Commits: 1314c472 by Alan Zimmerman at 2020-10-04T09:42:12+01:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 7 changed files: - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - + testsuite/tests/printer/T18791.hs - + testsuite/tests/printer/T18791.stderr - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -639,16 +639,12 @@ mkGadtDecl :: [Located RdrName] -> LHsType GhcPs -> P (ConDecl GhcPs) mkGadtDecl names ty = do - linearEnabled <- getBit LinearTypesBit - let (args, res_ty) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty = (RecCon (L loc rf), res_ty) | otherwise = let (arg_types, res_type) = splitHsFunType body_ty - arg_types' | linearEnabled = arg_types - | otherwise = map (hsLinear . hsScaledThing) arg_types - in (PrefixCon arg_types', res_type) + in (PrefixCon arg_types, res_type) pure $ ConDeclGADT { con_g_ext = noExtField , con_names = names ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Tc.Deriv (DerivInfo(..)) import GHC.Tc.Gen.HsType import GHC.Tc.Instance.Class( AssocInstInfo(..) ) import GHC.Tc.Utils.TcMType -import GHC.Builtin.Types ( unitTy, makeRecoveryTyCon ) +import GHC.Builtin.Types (oneDataConTy, unitTy, makeRecoveryTyCon ) import GHC.Tc.Utils.TcType import GHC.Core.Multiplicity import GHC.Rename.Env( lookupConstructorFields ) @@ -3411,10 +3411,23 @@ tcConArg exp_kind (HsScaled w bty) = do { traceTc "tcConArg 1" (ppr bty) ; arg_ty <- tcCheckLHsType (getBangType bty) exp_kind ; w' <- tcMult w + ; linearEnabled <- xoptM LangExt.LinearTypes + ; let interp_w -- See Note [Function arrows in GADT constructors] + | linearEnabled = w' + | otherwise = oneDataConTy ; traceTc "tcConArg 2" (ppr bty) - ; return (Scaled w' arg_ty, getBangStrictness bty) } + ; return (Scaled interp_w arg_ty, getBangStrictness bty) } {- +Note [Function arrows in GADT constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the absence of -XLinearTypes, we always interpret function arrows +in GADT constructor types as linear, even if the user wrote an +unrestricted arrow. See the "Without -XLinearTypes" section of the +linear types GHC proposal (#111). We opt to do this in the +typechecker, and not in an earlier pass, to ensure that the AST +matches what the user wrote (#18791). + Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We do not currently have syntax to declare an infix constructor in GADT syntax, ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -370,7 +370,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) ===================================== testsuite/tests/printer/T18791.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE GADTs #-} +module T18791 where + +data T where + MkT :: Int -> T ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -0,0 +1,63 @@ + +==================== Parser AST ==================== + +({ T18791.hs:1:1 } + (HsModule + (VirtualBraces + (1)) + (Just + ({ T18791.hs:2:8-13 } + {ModuleName: T18791})) + (Nothing) + [] + [({ T18791.hs:(4,1)-(5,17) } + (TyClD + (NoExtField) + (DataDecl + (NoExtField) + ({ T18791.hs:4:6 } + (Unqual + {OccName: T})) + (HsQTvs + (NoExtField) + []) + (Prefix) + (HsDataDefn + (NoExtField) + (DataType) + ({ } + []) + (Nothing) + (Nothing) + [({ T18791.hs:5:3-17 } + (ConDeclGADT + (NoExtField) + [({ T18791.hs:5:3-5 } + (Unqual + {OccName: MkT}))] + ({ T18791.hs:5:10-17 } + (False)) + [] + (Nothing) + (PrefixCon + [(HsScaled + (HsUnrestrictedArrow) + ({ T18791.hs:5:10-12 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:10-12 } + (Unqual + {OccName: Int})))))]) + ({ T18791.hs:5:17 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:17 } + (Unqual + {OccName: T})))) + (Nothing)))] + ({ } + [])))))] + (Nothing) + (Nothing))) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -58,3 +58,4 @@ test('T14343b', normal, compile_fail, ['']) test('T15761', normal, compile_fail, ['']) test('T18052a', normal, compile, ['-ddump-simpl -ddump-types -dno-typeable-binds -dsuppress-uniques']) +test('T18791', normal, compile, ['-ddump-parsed-ast']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1314c472713fd94c818d26c495efd57eb416f1a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1314c472713fd94c818d26c495efd57eb416f1a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 10:31:57 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 04 Oct 2020 06:31:57 -0400 Subject: [Git][ghc/ghc][wip/T18791] Preserve as-parsed arrow type for HsUnrestrictedArrow Message-ID: <5f79a49d6204e_80b3f837d049b981634124e@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/T18791 at Glasgow Haskell Compiler / GHC Commits: 147770b5 by Alan Zimmerman at 2020-10-04T11:31:31+01:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 7 changed files: - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - + testsuite/tests/printer/T18791.hs - + testsuite/tests/printer/T18791.stderr - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -639,16 +639,12 @@ mkGadtDecl :: [Located RdrName] -> LHsType GhcPs -> P (ConDecl GhcPs) mkGadtDecl names ty = do - linearEnabled <- getBit LinearTypesBit - let (args, res_ty) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty = (RecCon (L loc rf), res_ty) | otherwise = let (arg_types, res_type) = splitHsFunType body_ty - arg_types' | linearEnabled = arg_types - | otherwise = map (hsLinear . hsScaledThing) arg_types - in (PrefixCon arg_types', res_type) + in (PrefixCon arg_types, res_type) pure $ ConDeclGADT { con_g_ext = noExtField , con_names = names ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Tc.Deriv (DerivInfo(..)) import GHC.Tc.Gen.HsType import GHC.Tc.Instance.Class( AssocInstInfo(..) ) import GHC.Tc.Utils.TcMType -import GHC.Builtin.Types ( unitTy, makeRecoveryTyCon ) +import GHC.Builtin.Types (oneDataConTy, unitTy, makeRecoveryTyCon ) import GHC.Tc.Utils.TcType import GHC.Core.Multiplicity import GHC.Rename.Env( lookupConstructorFields ) @@ -3410,11 +3410,27 @@ tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatype tcConArg exp_kind (HsScaled w bty) = do { traceTc "tcConArg 1" (ppr bty) ; arg_ty <- tcCheckLHsType (getBangType bty) exp_kind - ; w' <- tcMult w + ; w' <- tcDataConMult w ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcDataConMult :: HsArrow GhcRn -> TcM Mult +tcDataConMult arr at HsUnrestrictedArrow = do + -- See Note [Function arrows in GADT constructors] + linearEnabled <- xoptM LangExt.LinearTypes + if linearEnabled then tcMult arr else return oneDataConTy +tcDataConMult arr = tcMult arr + {- +Note [Function arrows in GADT constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the absence of -XLinearTypes, we always interpret function arrows +in GADT constructor types as linear, even if the user wrote an +unrestricted arrow. See the "Without -XLinearTypes" section of the +linear types GHC proposal (#111). We opt to do this in the +typechecker, and not in an earlier pass, to ensure that the AST +matches what the user wrote (#18791). + Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We do not currently have syntax to declare an infix constructor in GADT syntax, ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -370,7 +370,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) ===================================== testsuite/tests/printer/T18791.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE GADTs #-} +module T18791 where + +data T where + MkT :: Int -> T ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -0,0 +1,63 @@ + +==================== Parser AST ==================== + +({ T18791.hs:1:1 } + (HsModule + (VirtualBraces + (1)) + (Just + ({ T18791.hs:2:8-13 } + {ModuleName: T18791})) + (Nothing) + [] + [({ T18791.hs:(4,1)-(5,17) } + (TyClD + (NoExtField) + (DataDecl + (NoExtField) + ({ T18791.hs:4:6 } + (Unqual + {OccName: T})) + (HsQTvs + (NoExtField) + []) + (Prefix) + (HsDataDefn + (NoExtField) + (DataType) + ({ } + []) + (Nothing) + (Nothing) + [({ T18791.hs:5:3-17 } + (ConDeclGADT + (NoExtField) + [({ T18791.hs:5:3-5 } + (Unqual + {OccName: MkT}))] + ({ T18791.hs:5:10-17 } + (False)) + [] + (Nothing) + (PrefixCon + [(HsScaled + (HsUnrestrictedArrow) + ({ T18791.hs:5:10-12 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:10-12 } + (Unqual + {OccName: Int})))))]) + ({ T18791.hs:5:17 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:17 } + (Unqual + {OccName: T})))) + (Nothing)))] + ({ } + [])))))] + (Nothing) + (Nothing))) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -58,3 +58,4 @@ test('T14343b', normal, compile_fail, ['']) test('T15761', normal, compile_fail, ['']) test('T18052a', normal, compile, ['-ddump-simpl -ddump-types -dno-typeable-binds -dsuppress-uniques']) +test('T18791', normal, compile, ['-ddump-parsed-ast']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/147770b5e3376d84a50266ab9ab7eda739c03b50 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/147770b5e3376d84a50266ab9ab7eda739c03b50 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 12:37:49 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 04 Oct 2020 08:37:49 -0400 Subject: [Git][ghc/ghc][wip/T18791] Preserve as-parsed arrow type for HsUnrestrictedArrow Message-ID: <5f79c21d69525_80b3f84929e6de81636044c@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/T18791 at Glasgow Haskell Compiler / GHC Commits: 8c3bc4a9 by Alan Zimmerman at 2020-10-04T13:37:18+01:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 7 changed files: - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - + testsuite/tests/printer/T18791.hs - + testsuite/tests/printer/T18791.stderr - testsuite/tests/printer/all.T Changes: ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -631,24 +631,16 @@ mkConDeclH98 name mb_forall mb_cxt args -- provided), context (if provided), argument types, and result type, and -- records whether this is a prefix or record GADT constructor. See -- Note [GADT abstract syntax] in "GHC.Hs.Decls" for more details. --- --- * If -XLinearTypes is not enabled, the function arrows in a prefix GADT --- constructor are always interpreted as linear. If -XLinearTypes is enabled, --- we faithfully record whether -> or %1 -> was used. mkGadtDecl :: [Located RdrName] -> LHsType GhcPs -> P (ConDecl GhcPs) mkGadtDecl names ty = do - linearEnabled <- getBit LinearTypesBit - let (args, res_ty) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty = (RecCon (L loc rf), res_ty) | otherwise = let (arg_types, res_type) = splitHsFunType body_ty - arg_types' | linearEnabled = arg_types - | otherwise = map (hsLinear . hsScaledThing) arg_types - in (PrefixCon arg_types', res_type) + in (PrefixCon arg_types, res_type) pure $ ConDeclGADT { con_g_ext = noExtField , con_names = names ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -43,7 +43,7 @@ import GHC.Tc.Deriv (DerivInfo(..)) import GHC.Tc.Gen.HsType import GHC.Tc.Instance.Class( AssocInstInfo(..) ) import GHC.Tc.Utils.TcMType -import GHC.Builtin.Types ( unitTy, makeRecoveryTyCon ) +import GHC.Builtin.Types (oneDataConTy, unitTy, makeRecoveryTyCon ) import GHC.Tc.Utils.TcType import GHC.Core.Multiplicity import GHC.Rename.Env( lookupConstructorFields ) @@ -3410,11 +3410,27 @@ tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatype tcConArg exp_kind (HsScaled w bty) = do { traceTc "tcConArg 1" (ppr bty) ; arg_ty <- tcCheckLHsType (getBangType bty) exp_kind - ; w' <- tcMult w + ; w' <- tcDataConMult w ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcDataConMult :: HsArrow GhcRn -> TcM Mult +tcDataConMult arr at HsUnrestrictedArrow = do + -- See Note [Function arrows in GADT constructors] + linearEnabled <- xoptM LangExt.LinearTypes + if linearEnabled then tcMult arr else return oneDataConTy +tcDataConMult arr = tcMult arr + {- +Note [Function arrows in GADT constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In the absence of -XLinearTypes, we always interpret function arrows +in GADT constructor types as linear, even if the user wrote an +unrestricted arrow. See the "Without -XLinearTypes" section of the +linear types GHC proposal (#111). We opt to do this in the +typechecker, and not in an earlier pass, to ensure that the AST +matches what the user wrote (#18791). + Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We do not currently have syntax to declare an infix constructor in GADT syntax, ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -370,7 +370,7 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) ===================================== testsuite/tests/printer/T18791.hs ===================================== @@ -0,0 +1,5 @@ +{-# LANGUAGE GADTs #-} +module T18791 where + +data T where + MkT :: Int -> T ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -0,0 +1,63 @@ + +==================== Parser AST ==================== + +({ T18791.hs:1:1 } + (HsModule + (VirtualBraces + (1)) + (Just + ({ T18791.hs:2:8-13 } + {ModuleName: T18791})) + (Nothing) + [] + [({ T18791.hs:(4,1)-(5,17) } + (TyClD + (NoExtField) + (DataDecl + (NoExtField) + ({ T18791.hs:4:6 } + (Unqual + {OccName: T})) + (HsQTvs + (NoExtField) + []) + (Prefix) + (HsDataDefn + (NoExtField) + (DataType) + ({ } + []) + (Nothing) + (Nothing) + [({ T18791.hs:5:3-17 } + (ConDeclGADT + (NoExtField) + [({ T18791.hs:5:3-5 } + (Unqual + {OccName: MkT}))] + ({ T18791.hs:5:10-17 } + (False)) + [] + (Nothing) + (PrefixCon + [(HsScaled + (HsUnrestrictedArrow) + ({ T18791.hs:5:10-12 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:10-12 } + (Unqual + {OccName: Int})))))]) + ({ T18791.hs:5:17 } + (HsTyVar + (NoExtField) + (NotPromoted) + ({ T18791.hs:5:17 } + (Unqual + {OccName: T})))) + (Nothing)))] + ({ } + [])))))] + (Nothing) + (Nothing))) \ No newline at end of file ===================================== testsuite/tests/printer/all.T ===================================== @@ -58,3 +58,4 @@ test('T14343b', normal, compile_fail, ['']) test('T15761', normal, compile_fail, ['']) test('T18052a', normal, compile, ['-ddump-simpl -ddump-types -dno-typeable-binds -dsuppress-uniques']) +test('T18791', normal, compile, ['-ddump-parsed-ast']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c3bc4a94e8e00c9bd99a350cdb8069742d887d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c3bc4a94e8e00c9bd99a350cdb8069742d887d9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 4 21:00:04 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 04 Oct 2020 17:00:04 -0400 Subject: [Git][ghc/ghc][wip/az/master-gadt-parens] 24 commits: hadrian/doc: Clarify documentation of key-value configuration Message-ID: <5f7a37d4b755d_80b3f84866b79f8163996f8@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/master-gadt-parens at Glasgow Haskell Compiler / GHC Commits: 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - 341607b9 by Alan Zimmerman at 2020-10-04T21:59:18+01:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. Note: for ease of cherry-picking, this diff was created on the ghc-9.0 branch as c83ac326ea61277a31cc0a42a5027028edcb664e, and then adapted for master. The linear types annotations are slightly different for each. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Backpack/Syntax.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90e401b0fe97dacae82367afb6187e8577302422...341607b93673740ff2c21def53b637d02a7848c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90e401b0fe97dacae82367afb6187e8577302422...341607b93673740ff2c21def53b637d02a7848c4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 5 01:29:32 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 04 Oct 2020 21:29:32 -0400 Subject: [Git][ghc/ghc][wip/T16762] 9 commits: Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f7a76fcc7a10_80b56312581640469b@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 4d4db316 by Ryan Scott at 2020-10-04T21:28:57-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - fb083404 by Simon Peyton Jones at 2020-10-04T21:28:57-04:00 Wibbbles - - - - - 5131aaf8 by Simon Peyton Jones at 2020-10-04T21:28:57-04:00 More wibbles - - - - - c5057c0f by Simon Peyton Jones at 2020-10-04T21:28:57-04:00 More wibbles - - - - - 0185828e by Simon Peyton Jones at 2020-10-04T21:28:57-04:00 More wibbles --- getting there - - - - - bd5642ea by Ryan Scott at 2020-10-04T21:28:57-04:00 Push through some Haddock changes, disable warnings in GHC.Iface.Ext.Ast for now - - - - - d253231f by Simon Peyton Jones at 2020-10-04T21:28:57-04:00 More wibbles - - - - - 96b211a7 by Ryan Scott at 2020-10-04T21:28:57-04:00 Use TTG in HsOuterTyVarBndrs - - - - - f028c81f by Ryan Scott at 2020-10-04T21:28:57-04:00 Add some documentation, minor code cleanup - - - - - 20 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62f6bf5ccfa499a9b2f2666f7a81c8df64bebebb...f028c81fcfc94ea37bfedc586f3501ad24caeb3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62f6bf5ccfa499a9b2f2666f7a81c8df64bebebb...f028c81fcfc94ea37bfedc586f3501ad24caeb3f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 07:11:40 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Fri, 09 Oct 2020 03:11:40 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] 194 commits: rts: Add stg_copyArray_barrier to RtsSymbols list Message-ID: <5f800d2c410a7_80b3f83f25daa38177194d0@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - f52abbd7 by John Ericson at 2020-10-09T09:04:11+02:00 Make fixed-size `Int32#` and `Int64#` The boxed Int64 uses Int64#, but Int32# still uses Int#. The 32-bit case is less pressing to change because it is not a source of brittle CPP---it is the same thing on all platforms. We need Int64/Word64 constant folding to avoid the let/app restriction on Core, so that is implemented now. 32-bit constant unfolding and 32-bit literals are left as follow-up. This is the bulk of #11953 ghc-bignum: add support for Word64#/Int64# on 64-bit arch Fix fingerprint Core generation Fix some tests Co-authored-by: Sylvain Henry <hsyl20 at gmail.com> - - - - - af35c212 by John Ericson at 2020-10-09T09:04:11+02:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 9c49c0de by Sylvain Henry at 2020-10-09T09:04:11+02:00 Fix toArgRep - - - - - 1803690b by Sylvain Henry at 2020-10-09T09:04:11+02:00 Adapt rules from #16402 to Word64#/Int64# - - - - - 8a80a59a by John Ericson at 2020-10-09T09:04:11+02:00 Copy enumFrom* implementations from Int/Word for Int64/Word64 Without this, we don't get proper list fusion. I think this sort of copying is OK for now, but we absolutely need something better if we are going to make `IntN` use `IntN#` for all `N`. The degree to which proper metaprogramming has been punted upon by factoring everything through the native-sized types is disconcerting. - - - - - 1d0be873 by John Ericson at 2020-10-09T09:04:11+02:00 `integerFromInt64#` can be inlined when the word size is >= 64 bits Maybe this will help with the renaming test failure? - - - - - f3421863 by John Ericson at 2020-10-09T09:04:11+02:00 Add builtin rule for `divInt64#` and `modInt64#` - - - - - 3e2ba78a by John Ericson at 2020-10-09T09:04:11+02:00 WIP: Add missing floats <-> int/word 64 rule and primops - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - README.md - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8e97fddf37c900dce00bc6fe83fd588372d33c9...3e2ba78a1198e693eef8148e339dea5acc9c5e8e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8e97fddf37c900dce00bc6fe83fd588372d33c9...3e2ba78a1198e693eef8148e339dea5acc9c5e8e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 07:40:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 03:40:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 24 commits: Use UnitId in the backend instead of Unit Message-ID: <5f8013ec34f26_80b3f848cdcf19017729150@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 374a6846 by Sylvain Henry at 2020-10-09T03:39:48-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - 4a47fafe by Simon Jakobi at 2020-10-09T03:39:48-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - 40cf985e by Tamar Christina at 2020-10-09T03:39:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - db5c8bb0 by Sylvain Henry at 2020-10-09T03:39:52-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - 228f1040 by MaxGabriel at 2020-10-09T03:39:53-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - 2a1fbc88 by Krzysztof Gogolewski at 2020-10-09T03:39:55-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - 86d0ca76 by Hécate at 2020-10-09T03:39:56-04:00 Add linting of `base` to the CI - - - - - e4c1fba5 by Andreas Klebinger at 2020-10-09T03:39:57-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - 1f475bb1 by Andreas Klebinger at 2020-10-09T03:39:57-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - b49e3edf by Sylvain Henry at 2020-10-09T03:39:59-04:00 Hadrian: add quick-debug flavour - - - - - c773a63f by Sylvain Henry at 2020-10-09T03:40:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 61b0d1ff by Alan Zimmerman at 2020-10-09T03:40:01-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - f6613828 by Krzysztof Gogolewski at 2020-10-09T03:40:02-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 0859ea6b by Ben Gamari at 2020-10-09T03:40:03-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - 18b2ee27 by Tamar Christina at 2020-10-09T03:40:05-04:00 winio: fixed timeouts non-threaded. - - - - - 2e225124 by Tamar Christina at 2020-10-09T03:40:06-04:00 winio: fix array splat - - - - - 3fecacac by Tamar Christina at 2020-10-09T03:40:10-04:00 winio: fixed bytestring reading interface. - - - - - f8c269ff by Tamar Christina at 2020-10-09T03:40:12-04:00 winio: fixed more data error. - - - - - c1e7dbdd by Simon Peyton Jones at 2020-10-09T03:40:12-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - 4e326d8e by Ben Gamari at 2020-10-09T03:40:14-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - c419430e by Andreas Klebinger at 2020-10-09T03:40:15-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - 023eda0f by Krzysztof Gogolewski at 2020-10-09T03:40:17-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - 7a75713e by Sylvain Henry at 2020-10-09T03:40:19-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 4d699082 by Sylvain Henry at 2020-10-09T03:40:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d5d4f518635a41b787573ff56ddcfaad77b2cd5...4d699082b520bdd143d240c53c313d9a4ba71b01 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7d5d4f518635a41b787573ff56ddcfaad77b2cd5...4d699082b520bdd143d240c53c313d9a4ba71b01 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 07:47:57 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 09 Oct 2020 03:47:57 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] Accepting metric changes to advance CI Message-ID: <5f8015adc40dd_80bb690770177712c5@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 6716c5fa by Sebastian Graf at 2020-10-09T09:47:42+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T7360.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -190,6 +190,7 @@ T7360.$tc'Foo2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo9 [InlPrag=NOUSERINLINE[~]] :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] T7360.$tc'Foo9 = GHC.Types.KindRepFun $krep T7360.$tc'Foo4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -219,3 +220,6 @@ T7360.$tc'Foo3 T7360.$tc'Foo10 0# T7360.$tc'Foo9 + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6716c5fa3f566fcce2ac17c99bfc7c628c08e0f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6716c5fa3f566fcce2ac17c99bfc7c628c08e0f0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 09:01:58 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 09 Oct 2020 05:01:58 -0400 Subject: [Git][ghc/ghc][wip/T18793] 3 commits: Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Message-ID: <5f802706446ab_80b3f848707f558177795f9@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: a6dc4633 by Sebastian Graf at 2020-10-09T11:01:16+02:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 8a5f97cb by Sebastian Graf at 2020-10-09T11:01:42+02:00 Arity analysis: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. - - - - - 9d61d7fe by Sebastian Graf at 2020-10-09T11:01:50+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr - testsuite/tests/arityanal/f1.hs → testsuite/tests/arityanal/should_compile/Arity01.hs - + testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/f2.hs → testsuite/tests/arityanal/should_compile/Arity02.hs - + testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/f3.hs → testsuite/tests/arityanal/should_compile/Arity03.hs - + testsuite/tests/arityanal/should_compile/Arity03.stderr - testsuite/tests/arityanal/f4.hs → testsuite/tests/arityanal/should_compile/Arity04.hs - + testsuite/tests/arityanal/should_compile/Arity04.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afb26d12794f98f55e35f5c8115b93ca1f77c686...9d61d7fe431486768ed10d53b9f10887bf8bdc06 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/afb26d12794f98f55e35f5c8115b93ca1f77c686...9d61d7fe431486768ed10d53b9f10887bf8bdc06 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 09:02:12 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 09 Oct 2020 05:02:12 -0400 Subject: [Git][ghc/ghc][wip/fix-arity-anal] Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Message-ID: <5f802714b2996_80b83c6024177801ec@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/fix-arity-anal at Glasgow Haskell Compiler / GHC Commits: a6dc4633 by Sebastian Graf at 2020-10-09T11:01:16+02:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 2 changed files: - compiler/GHC/Core/Opt/Arity.hs - testsuite/tests/simplCore/should_compile/T18231.stderr Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -174,13 +174,10 @@ exprBotStrictness_maybe :: CoreExpr -> Maybe (Arity, StrictSig) -- and gives them a suitable strictness signatures. It's used during -- float-out exprBotStrictness_maybe e - = case getBotArity (arityType env e) of + = case getBotArity (arityType botStrictnessArityEnv e) of Nothing -> Nothing Just ar -> Just (ar, sig ar) where - env = AE { ae_ped_bot = True - , ae_cheap_fn = \ _ _ -> False - , ae_joins = emptyVarSet } sig ar = mkClosedStrictSig (replicate ar topDmd) botDiv {- @@ -551,34 +548,18 @@ maxWithArity at@(ATop oss) ar vanillaArityType :: ArityType vanillaArityType = ATop [] -- Totally uninformative --- ^ The Arity returned is the number of value args the +-- | The Arity returned is the number of value args the -- expression can be applied to without doing much work exprEtaExpandArity :: DynFlags -> CoreExpr -> ArityType -- exprEtaExpandArity is used when eta expanding -- e ==> \xy -> e x y -exprEtaExpandArity dflags e - = arityType env e - where - env = AE { ae_cheap_fn = mk_cheap_fn dflags isCheapApp - , ae_ped_bot = gopt Opt_PedanticBottoms dflags - , ae_joins = emptyVarSet } +exprEtaExpandArity dflags e = arityType (initArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function getBotArity (ABot n) = Just n getBotArity _ = Nothing -mk_cheap_fn :: DynFlags -> CheapAppFun -> CheapFun -mk_cheap_fn dflags cheap_app - | not (gopt Opt_DictsCheap dflags) - = \e _ -> exprIsCheapX cheap_app e - | otherwise - = \e mb_ty -> exprIsCheapX cheap_app e - || case mb_ty of - Nothing -> False - Just ty -> isDictTy ty - - ---------------------- findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- This implements the fixpoint loop for arity analysis @@ -588,20 +569,16 @@ findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- so it is safe to expand e ==> (\x1..xn. e x1 .. xn) -- (b) if is_bot=True, then e applied to n args is guaranteed bottom findRhsArity dflags bndr rhs old_arity - = go (get_arity init_cheap_app) - -- We always call exprEtaExpandArity once, but usually - -- that produces a result equal to old_arity, and then - -- we stop right away (since arities should not decrease) - -- Result: the common case is that there is just one iteration + = go (step botArityType) + -- We always do one step, but usually that produces a result equal to + -- old_arity, and then we stop right away (since arities should not + -- decrease) + -- Result: the common case is that there is just one iteration where - init_cheap_app :: CheapAppFun - init_cheap_app fn n_val_args - | fn == bndr = True -- On the first pass, this binder gets infinite arity - | otherwise = isCheapApp fn n_val_args - go :: ArityType -> ArityType + go cur_atype@(ATop oss) + | length oss <= old_arity = cur_atype go cur_atype - | cur_arity <= old_arity = cur_atype | new_atype == cur_atype = cur_atype | otherwise = #if defined(DEBUG) @@ -611,20 +588,12 @@ findRhsArity dflags bndr rhs old_arity #endif go new_atype where - new_atype = get_arity cheap_app - - cur_arity = arityTypeArity cur_atype - cheap_app :: CheapAppFun - cheap_app fn n_val_args - | fn == bndr = n_val_args < cur_arity - | otherwise = isCheapApp fn n_val_args + new_atype = step cur_atype - get_arity :: CheapAppFun -> ArityType - get_arity cheap_app = arityType env rhs + step :: ArityType -> ArityType + step at = arityType env rhs where - env = AE { ae_cheap_fn = mk_cheap_fn dflags cheap_app - , ae_ped_bot = gopt Opt_PedanticBottoms dflags - , ae_joins = emptyVarSet } + env = extendSigEnv (initArityEnv dflags) bndr at {- Note [Arity analysis] @@ -756,22 +725,80 @@ encountered a cast, but that is far too conservative: see #5475 -} --------------------------- -type CheapFun = CoreExpr -> Maybe Type -> Bool - -- How to decide if an expression is cheap - -- If the Maybe is Just, the type is the type - -- of the expression; Nothing means "don't know" + +data AnalysisMode + = BotStrictness + -- ^ Used during 'exprBotStrictness_maybe'. + | ArityAnalysis { aa_ped_bot :: !Bool + , aa_dicts_cheap :: !Bool + , aa_sigs :: !(IdEnv ArityType) } + -- ^ Used for regular arity analysis ('exprEtaExpandArity', 'findRhsArity'). data ArityEnv - = AE { ae_cheap_fn :: CheapFun - , ae_ped_bot :: Bool -- True <=> be pedantic about bottoms - , ae_joins :: IdSet -- In-scope join points - -- See Note [Eta-expansion and join points] + = AE + { ae_mode :: !AnalysisMode + -- ^ The analysis mode. Called during 'exprBotStrictness_maybe' or not? + , ae_joins :: !IdSet + -- ^ In-scope join points. See Note [Eta-expansion and join points] } +-- | A regular, initial @ArityEnv@ used in arity analysis. +initArityEnv :: DynFlags -> ArityEnv +initArityEnv dflags + = AE { ae_mode = ArityAnalysis { aa_ped_bot = gopt Opt_PedanticBottoms dflags + , aa_dicts_cheap = gopt Opt_DictsCheap dflags + , aa_sigs = emptyVarEnv } + , ae_joins = emptyVarSet } + +-- | The @ArityEnv@ used by 'exprBotStrictness_maybe'. Pedantic about bottoms +-- and no application is ever considered cheap. +botStrictnessArityEnv :: ArityEnv +botStrictnessArityEnv = AE { ae_mode = BotStrictness, ae_joins = emptyVarSet } + extendJoinEnv :: ArityEnv -> [JoinId] -> ArityEnv extendJoinEnv env@(AE { ae_joins = joins }) join_ids = env { ae_joins = joins `extendVarSetList` join_ids } +extendSigEnv :: ArityEnv -> Id -> ArityType -> ArityEnv +extendSigEnv env id ar_ty = env { ae_mode = go (ae_mode env) } + where + go BotStrictness = BotStrictness + go aa = aa { aa_sigs = extendVarEnv (aa_sigs aa) id ar_ty } + +lookupSigEnv :: ArityEnv -> Id -> Maybe ArityType +lookupSigEnv AE{ ae_mode = mode } id = case mode of + BotStrictness -> Nothing + ArityAnalysis{ aa_sigs = sigs } -> lookupVarEnv sigs id + +-- | Whether the analysis should be pedantic about bottoms. +-- 'exprBotStrictness_maybe' always is. +pedanticBottoms :: ArityEnv -> Bool +pedanticBottoms AE{ ae_mode = mode } = case mode of + BotStrictness -> True + ArityAnalysis{ aa_ped_bot = ped_bot } -> ped_bot + +-- | A version of 'exprIsCheap' that considers results from arity analysis +-- and optionally the expression's type. +-- Under 'exprBotStrictness_maybe', no expressions are cheap. +myExprIsCheap :: ArityEnv -> CoreExpr -> Maybe Type -> Bool +myExprIsCheap AE{ae_mode = mode} e mb_ty = case mode of + BotStrictness -> False + ArityAnalysis{aa_dicts_cheap = dicts_cheap, aa_sigs = sigs} -> + cheap_dict || exprIsCheapX (myIsCheapApp sigs) e + where + cheap_dict = dicts_cheap && fmap isDictTy mb_ty == Just True + +-- | A version of 'isCheapApp' that considers results from arity analysis. +myIsCheapApp :: IdEnv ArityType -> CheapAppFun +myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of + -- Nothing means not a local function, fall back to regular + -- 'GHC.Core.Utils.isCheapApp' + Nothing -> isCheapApp fn n_val_args + -- @Just at@ means local function with @at@ as current ArityType. + -- Roughly approximate what 'isCheapApp' is doing. + Just (ABot _) -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils + Just (ATop oss) -> n_val_args < length oss -- Essentially isWorkFreeApp + ---------------- arityType :: ArityEnv -> CoreExpr -> ArityType @@ -792,6 +819,8 @@ arityType env (Cast e co) arityType env (Var v) | v `elemVarSet` ae_joins env = botArityType -- See Note [Eta-expansion and join points] + | Just at <- lookupSigEnv env v -- Local binding + = at | otherwise = idArityType v @@ -804,7 +833,7 @@ arityType env (Lam x e) arityType env (App fun (Type _)) = arityType env fun arityType env (App fun arg ) - = arityApp (arityType env fun) (ae_cheap_fn env arg Nothing) + = arityApp (arityType env fun) (myExprIsCheap env arg Nothing) -- Case/Let; keep arity if either the expression is cheap -- or it's a 1-shot lambda @@ -824,10 +853,10 @@ arityType env (Case scrut _ _ alts) | otherwise -> botArityType -- if RHS is bottomming -- See Note [Dealing with bottom (2)] - ATop as | not (ae_ped_bot env) -- See Note [Dealing with bottom (3)] - , ae_cheap_fn env scrut Nothing -> ATop as - | exprOkForSpeculation scrut -> ATop as - | otherwise -> ATop (takeWhile isOneShotInfo as) + ATop as | not (pedanticBottoms env) -- See Note [Dealing with bottom (3)] + , myExprIsCheap env scrut Nothing -> ATop as + | exprOkForSpeculation scrut -> ATop as + | otherwise -> ATop (takeWhile isOneShotInfo as) where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] @@ -854,11 +883,12 @@ arityType env (Let (Rec pairs) body) = pprPanic "arityType:joinrec" (ppr pairs) arityType env (Let b e) - = floatIn (cheap_bind b) (arityType env e) + = floatIn cheap_bind (arityType env e) where - cheap_bind (NonRec b e) = is_cheap (b,e) - cheap_bind (Rec prs) = all is_cheap prs - is_cheap (b,e) = ae_cheap_fn env e (Just (idType b)) + cheap_bind = case b of + NonRec b e -> is_cheap (b,e) + Rec prs -> all is_cheap prs + is_cheap (b,e) = myExprIsCheap env e (Just (idType b)) arityType env (Tick t e) | not (tickishIsCode t) = arityType env e @@ -1742,4 +1772,3 @@ freshEtaId n subst ty -- "OrCoVar" since this can be used to eta-expand -- coercion abstractions subst' = extendTCvInScope subst eta_id' - ===================================== testsuite/tests/simplCore/should_compile/T18231.stderr ===================================== @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 30, types: 22, coercions: 5, joins: 0/0} +Result size of Tidy Core = {terms: 24, types: 20, coercions: 5, joins: 0/0} -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} T18231.$trModule4 :: GHC.Prim.Addr# @@ -23,14 +23,14 @@ T18231.$trModule :: GHC.Types.Module T18231.$trModule = GHC.Types.Module T18231.$trModule3 T18231.$trModule1 Rec { --- RHS size: {terms: 6, types: 1, coercions: 0, joins: 0/0} -lvl :: GHC.Prim.Int# -> Data.Functor.Identity.Identity ((), Int) -lvl = \ (x :: GHC.Prim.Int#) -> T18231.m1 (GHC.Types.I# (GHC.Prim.+# x 1#)) +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +lvl :: Data.Functor.Identity.Identity ((), Int) +lvl = lvl +end Rec } --- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} +-- RHS size: {terms: 5, types: 3, coercions: 0, joins: 0/0} T18231.m1 :: Int -> Data.Functor.Identity.Identity ((), Int) -T18231.m1 = \ (s1 :: Int) -> case s1 of { GHC.Types.I# x -> lvl x } -end Rec } +T18231.m1 = \ (eta2 :: Int) -> case eta2 of { GHC.Types.I# x -> lvl } -- RHS size: {terms: 1, types: 0, coercions: 5, joins: 0/0} m :: State Int () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6dc4633905c3f51a8d2baac9043a03db2581b7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6dc4633905c3f51a8d2baac9043a03db2581b7a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 10:47:26 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 09 Oct 2020 06:47:26 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 7 commits: [MachO] cleanup compiler warnings Message-ID: <5f803fbebdf9f_80b3f846ab655d417793227@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 00440cdd by Moritz Angermann at 2020-10-08T11:57:15+08:00 [MachO] cleanup compiler warnings - - - - - a6d2c4d0 by Moritz Angermann at 2020-10-08T11:57:57+08:00 [macOS/arm64] do not use read_only_relocs on arm64 The linker simply doesn't support it and will complain loudly. - - - - - 37a62ae9 by Moritz Angermann at 2020-10-08T11:58:51+08:00 [Storage/Adjustor] Drop size check in allocExec This is violated by ghci, in InfoTable.hsc we call _allocateExec with a size that does not guarantee to be of ffi_closure size. Other allocateExec implementations do not have this check either; I highly doubt it's sensible to have this check in the presence of ghci's allocateExec calls. - - - - - 2dac1fda by Moritz Angermann at 2020-10-09T18:43:37+08:00 [linker/elf] better errors (with error message) - - - - - a40bc126 by Moritz Angermann at 2020-10-09T18:44:09+08:00 [darwin] always pic, ios AND mac AND tv AND ... - - - - - 05a8a2f5 by Moritz Angermann at 2020-10-09T18:45:08+08:00 [aarch64/codegen] pack ccall arguments on darwin This is annoying, but the darwinpcs does not match the default aapcs :facepalm: - - - - - 046365b3 by Moritz Angermann at 2020-10-09T18:47:00+08:00 [linker:MachO] split PLT logic out. Why was this missing in the first place? It's now a bit more aligned to the elf plt logic. - - - - - 15 changed files: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/SysTools.hs - includes/rts/Flags.h - rts/Linker.c - rts/ghc.mk - rts/linker/Elf.c - rts/linker/MachO.c - rts/linker/MachOTypes.h - + rts/linker/macho/plt.c - + rts/linker/macho/plt.h - + rts/linker/macho/plt_aarch64.c - + rts/linker/macho/plt_aarch64.h - rts/package.conf.in - rts/rts.cabal.in - rts/sm/Storage.c Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1092,7 +1092,16 @@ genCCall target dest_regs arg_regs bid = do -- this will give us the format information to match on. arg_regs' <- mapM getSomeReg arg_regs - (stackArgs, passRegs, passArgumentsCode) <- passArguments allGpArgRegs allFpArgRegs arg_regs' 0 [] nilOL + platform <- getPlatform + let packStack = platformOS platform == OSDarwin + + (stackSpace', passRegs, passArgumentsCode) <- passArguments packStack allGpArgRegs allFpArgRegs arg_regs' 0 [] nilOL + + -- if we pack the stack, we may need to adjust to multiple of 8byte. + -- if we don't pack the stack, it will always be multiple of 8. + let stackSpace = if stackSpace' `mod` 8 /= 0 + then 8 * (stackSpace' `div` 8 + 1) + else stackSpace' (returnRegs, readResultsCode) <- readResults allGpArgRegs allFpArgRegs dest_regs [] nilOL @@ -1110,11 +1119,11 @@ genCCall target dest_regs arg_regs bid = do , DELTA 0 ] let code = call_target_code -- compute the label (possibly into a register) - `appOL` moveStackDown stackArgs + `appOL` moveStackDown (stackSpace `div` 8) `appOL` passArgumentsCode -- put the arguments into x0, ... `appOL` (unitOL $ BL call_target passRegs returnRegs) -- branch and link. `appOL` readResultsCode -- parse the results into registers - `appOL` moveStackUp stackArgs + `appOL` moveStackUp (stackSpace `div` 8) return (code, Nothing) -- or a possibly side-effecting machine operation @@ -1237,17 +1246,17 @@ genCCall target dest_regs arg_regs bid = do genCCall (ForeignTarget target cconv) dest_regs arg_regs bid -- XXX: Optimize using paired load LDP - passArguments :: [Reg] -> [Reg] -> [(Reg, Format, InstrBlock)] -> Int -> [Reg] -> InstrBlock -> NatM (Int, [Reg], InstrBlock) - passArguments _ _ [] stackArgs accumRegs accumCode = return (stackArgs, accumRegs, accumCode) - -- passArguments _ _ [] accumCode stackArgs | isEven stackArgs = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * stackArgs)) - -- passArguments _ _ [] accumCode stackArgs = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * (stackArgs + 1))) + passArguments :: Bool -> [Reg] -> [Reg] -> [(Reg, Format, InstrBlock)] -> Int -> [Reg] -> InstrBlock -> NatM (Int, [Reg], InstrBlock) + passArguments _packStack _ _ [] stackSpace accumRegs accumCode = return (stackSpace, accumRegs, accumCode) + -- passArguments _ _ [] accumCode stackSpace | isEven stackSpace = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * stackSpace)) + -- passArguments _ _ [] accumCode stackSpace = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * (stackSpace + 1))) -- passArguments [] fpRegs (arg0:arg1:args) stack accumCode = do -- -- allocate this on the stack -- (r0, format0, code_r0) <- getSomeReg arg0 -- (r1, format1, code_r1) <- getSomeReg arg1 -- let w0 = formatToWidth format0 -- w1 = formatToWidth format1 - -- stackCode = unitOL $ STP (OpReg w0 r0) (OpReg w1 R1), (OpAddr (AddrRegImm x31 (ImmInt (stackArgs * 8))) + -- stackCode = unitOL $ STP (OpReg w0 r0) (OpReg w1 R1), (OpAddr (AddrRegImm x31 (ImmInt (stackSpace * 8))) -- passArguments gpRegs (fpReg:fpRegs) args (stackCode `appOL` accumCode) -- float promotion. @@ -1276,34 +1285,40 @@ genCCall target dest_regs arg_regs bid = do -- For AArch64 specificies see: https://developer.arm.com/docs/ihi0055/latest/procedure-call-standard-for-the-arm-64-bit-architecture -- -- Still have GP regs, and we want to pass an GP argument. - passArguments (gpReg:gpRegs) fpRegs ((r, format, code_r):args) stackArgs accumRegs accumCode | isIntFormat format = do + passArguments pack (gpReg:gpRegs) fpRegs ((r, format, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do let w = formatToWidth format - passArguments gpRegs fpRegs args stackArgs (gpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass gp argument: " ++ show r) $ MOV (OpReg w gpReg) (OpReg w r))) + passArguments pack gpRegs fpRegs args stackSpace (gpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass gp argument: " ++ show r) $ MOV (OpReg w gpReg) (OpReg w r))) -- Still have FP regs, and we want to pass an FP argument. - passArguments gpRegs (fpReg:fpRegs) ((r, format, code_r):args) stackArgs accumRegs accumCode | isFloatFormat format = do + passArguments pack gpRegs (fpReg:fpRegs) ((r, format, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do let w = formatToWidth format - passArguments gpRegs fpRegs args stackArgs (fpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass fp argument: " ++ show r) $ MOV (OpReg w fpReg) (OpReg w r))) + passArguments pack gpRegs fpRegs args stackSpace (fpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass fp argument: " ++ show r) $ MOV (OpReg w fpReg) (OpReg w r))) -- No mor regs left to pass. Must pass on stack. - passArguments [] [] ((r, format, code_r):args) stackArgs accumRegs accumCode = do + passArguments pack [] [] ((r, format, code_r):args) stackSpace accumRegs accumCode = do let w = formatToWidth format - stackCode = code_r `snocOL` (ANN (text $ "Pass argument: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt (stackArgs * 8))))) - passArguments [] [] args (stackArgs+1) accumRegs (stackCode `appOL` accumCode) + bytes = widthInBits w `div` 8 + space = if pack then bytes else 8 + stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) + passArguments pack [] [] args (stackSpace+space) accumRegs (stackCode `appOL` accumCode) -- Still have fpRegs left, but want to pass a GP argument. Must be passed on the stack then. - passArguments [] fpRegs ((r, format, code_r):args) stackArgs accumRegs accumCode | isIntFormat format = do + passArguments pack [] fpRegs ((r, format, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do let w = formatToWidth format - stackCode = code_r `snocOL` (ANN (text $ "Pass argument: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt (stackArgs * 8))))) - passArguments [] fpRegs args (stackArgs+1) accumRegs (stackCode `appOL` accumCode) + bytes = widthInBits w `div` 8 + space = if pack then bytes else 8 + stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) + passArguments pack [] fpRegs args (stackSpace+space) accumRegs (stackCode `appOL` accumCode) -- Still have gpRegs left, but want to pass a FP argument. Must be passed on the stack then. - passArguments gpRegs [] ((r, format, code_r):args) stackArgs accumRegs accumCode | isFloatFormat format = do + passArguments pack gpRegs [] ((r, format, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do let w = formatToWidth format - stackCode = code_r `snocOL` (ANN (text $ "Pass argument: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt (stackArgs * 8))))) - passArguments gpRegs [] args (stackArgs+1) accumRegs (stackCode `appOL` accumCode) + bytes = widthInBits w `div` 8 + space = if pack then bytes else 8 + stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) + passArguments pack gpRegs [] args (stackSpace+space) accumRegs (stackCode `appOL` accumCode) - passArguments _ _ _ _ _ _ = pprPanic "passArguments" (text "invalid state") + passArguments _ _ _ _ _ _ _ = pprPanic "passArguments" (text "invalid state") readResults :: [Reg] -> [Reg] -> [LocalReg] -> [Reg]-> InstrBlock -> NatM ([Reg], InstrBlock) readResults _ _ [] accumRegs accumCode = return (accumRegs, accumCode) ===================================== compiler/GHC/SysTools.hs ===================================== @@ -380,7 +380,7 @@ linkDynLib dflags0 o_files dep_packages ++ [ Option "-undefined", Option "dynamic_lookup", Option "-single_module" ] - ++ (if platformArch platform == ArchX86_64 + ++ (if platformArch platform `elem` [ ArchX86_64, ArchAArch64 ] then [ ] else [ Option "-Wl,-read_only_relocs,suppress" ]) ++ [ Option "-install_name", Option instName ] ===================================== includes/rts/Flags.h ===================================== @@ -199,8 +199,10 @@ typedef struct _CONCURRENT_FLAGS { * When linkerAlwaysPic is true, the runtime linker assume that all object * files were compiled with -fPIC -fexternal-dynamic-refs and load them * anywhere in the address space. + * Note that there is no 32bit darwin system we can realistically expect to + * run on or compile for. */ -#if defined(x86_64_HOST_ARCH) && defined(darwin_HOST_OS) +#if defined(darwin_HOST_OS) #define DEFAULT_LINKER_ALWAYS_PIC true #else #define DEFAULT_LINKER_ALWAYS_PIC false ===================================== rts/Linker.c ===================================== @@ -1522,7 +1522,7 @@ preloadObjectFile (pathchar *path) * * See also the misalignment logic for darwin below. */ -#if defined(ios_HOST_OS) +#if defined(darwin_HOST_OS) image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); #else image = mmapForLinker(fileSize, PROT_READ|PROT_WRITE|PROT_EXEC, ===================================== rts/ghc.mk ===================================== @@ -37,7 +37,7 @@ $(eval $(call all-target,rts,$(ALL_RTS_LIBS))) # ----------------------------------------------------------------------------- # Defining the sources -ALL_DIRS = hooks sm eventlog linker +ALL_DIRS = hooks sm eventlog linker linker/macho ifeq "$(TargetOS_CPP)" "mingw32" ALL_DIRS += win32 @@ -329,8 +329,8 @@ $(eval $(call distdir-opts,rts,dist,1)) # We like plenty of warnings. WARNING_OPTS += -Wall WARNING_OPTS += -Wextra -WARNING_OPTS += -Wstrict-prototypes -WARNING_OPTS += -Wmissing-prototypes +WARNING_OPTS += -Wstrict-prototypes +WARNING_OPTS += -Wmissing-prototypes WARNING_OPTS += -Wmissing-declarations WARNING_OPTS += -Winline WARNING_OPTS += -Wpointer-arith @@ -346,7 +346,7 @@ WARNING_OPTS += -Wno-aggregate-return #WARNING_OPTS += -Wshadow #WARNING_OPTS += -Wcast-qual -# This one seems buggy on GCC 4.1.2, which is the only GCC version we +# This one seems buggy on GCC 4.1.2, which is the only GCC version we # have that can bootstrap the SPARC build. We end up with lots of supurious # warnings of the form "cast increases required alignment of target type". # Some legitimate warnings can be fixed by adding an intermediate cast to @@ -383,7 +383,7 @@ rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS endif # We *want* type-checking of hand-written cmm. -rts_HC_OPTS += -dcmm-lint +rts_HC_OPTS += -dcmm-lint # -fno-strict-aliasing is required for the runtime, because we often # use a variety of types to represent closure pointers (StgPtr, @@ -658,4 +658,3 @@ install_libffi_headers : $(eval $(call clean-target,rts,dist,rts/dist)) BINDIST_EXTRAS += rts/package.conf.in - ===================================== rts/linker/Elf.c ===================================== @@ -754,8 +754,8 @@ ocGetNames_ELF ( ObjectCode* oc ) void * mem = mmapForLinker(size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); if( mem == MAP_FAILED ) { - barf("failed to mmap allocated memory to load section %d. " - "errno = %d", i, errno); + sysErrorBelch("failed to mmap allocated memory to load section %d. " + "errno = %d", i, errno); } /* copy only the image part over; we don't want to copy data ===================================== rts/linker/MachO.c ===================================== @@ -42,6 +42,9 @@ *) add still more sanity checks. */ #if defined(aarch64_HOST_ARCH) +# define NEED_PLT +# include "macho/plt.h" + /* aarch64 linker by moritz angermann */ /* often times we need to extend some value of certain number of bits @@ -49,7 +52,7 @@ */ int64_t signExtend(uint64_t val, uint8_t bits); /* Helper functions to check some instruction properties */ -bool isVectorPp(uint32_t *p); +bool isVectorOp(uint32_t *p); bool isLoadStore(uint32_t *p); /* aarch64 relocations may contain an addend already in the position @@ -65,9 +68,9 @@ void encodeAddend(ObjectCode * oc, Section * section, /* finding and making stubs. We don't need to care about the symbol they * represent. As long as two stubs point to the same address, they are identical */ -bool findStub(Section * section, void ** addr); -bool makeStub(Section * section, void ** addr); -void freeStubs(Section * section); +// bool findStub(Section * section, void ** addr); +// bool makeStub(Section * section, void ** addr); +// void freeStubs(Section * section); /* Global Offset Table logic */ bool isGotLoad(MachORelocationInfo * ri); @@ -272,12 +275,12 @@ signExtend(uint64_t val, uint8_t bits) { return (int64_t)(val << (64-bits)) >> (64-bits); } -bool +inline bool isVectorOp(uint32_t *p) { return (*p & 0x04800000) == 0x04800000; } -bool +inline bool isLoadStore(uint32_t *p) { return (*p & 0x3B000000) == 0x39000000; } @@ -345,7 +348,7 @@ decodeAddend(ObjectCode * oc, Section * section, MachORelocationInfo * ri) { inline bool fitsBits(size_t bits, int64_t value) { if(bits == 64) return true; - if(bits > 64) barf("fits_bits with %d bits and an 64bit integer!", bits); + if(bits > 64) barf("fits_bits with %zu bits and an 64bit integer!", bits); return 0 == (value >> bits) // All bits off: 0 || -1 == (value >> bits); // All bits on: -1 } @@ -425,67 +428,6 @@ isGotLoad(struct relocation_info * ri) { || ri->r_type == ARM64_RELOC_GOT_LOAD_PAGEOFF12; } -/* This is very similar to makeSymbolExtra - * However, as we load sections into different - * pages, that may be further apart than - * branching allows, we'll use some extra - * space at the end of each section allocated - * for stubs. - */ -bool -findStub(Section * section, void ** addr) { - - for(Stub * s = section->info->stubs; s != NULL; s = s->next) { - if(s->target == *addr) { - *addr = s->addr; - return EXIT_SUCCESS; - } - } - return EXIT_FAILURE; -} - -bool -makeStub(Section * section, void ** addr) { - - Stub * s = stgCallocBytes(1, sizeof(Stub), "makeStub(Stub)"); - s->target = *addr; - s->addr = (uint8_t*)section->info->stub_offset - + ((8+8)*section->info->nstubs) + 8; - s->next = NULL; - - /* target address */ - *(uint64_t*)((uint8_t*)s->addr - 8) = (uint64_t)s->target; - /* ldr x16, - (8 bytes) */ - *(uint32_t*)(s->addr) = (uint32_t)0x58ffffd0; - /* br x16 */ - *(uint32_t*)((uint8_t*)s->addr + 4) = (uint32_t)0xd61f0200; - - if(section->info->nstubs == 0) { - /* no stubs yet, let's just create this one */ - section->info->stubs = s; - } else { - Stub * tail = section->info->stubs; - while(tail->next != NULL) tail = tail->next; - tail->next = s; - } - section->info->nstubs += 1; - *addr = s->addr; - return EXIT_SUCCESS; -} -void -freeStubs(Section * section) { - if(section->info->nstubs == 0) - return; - Stub * last = section->info->stubs; - while(last->next != NULL) { - Stub * t = last; - last = last->next; - stgFree(t); - } - section->info->stubs = NULL; - section->info->nstubs = 0; -} - /* * Check if we need a global offset table slot for a * given symbol @@ -618,9 +560,9 @@ relocateSectionAarch64(ObjectCode * oc, Section * section) if((value - pc + addend) >> (2 + 26)) { /* we need a stub */ /* check if we already have that stub */ - if(findStub(section, (void**)&value)) { + if(findStub(section, (void**)&value, 0)) { /* did not find it. Crete a new stub. */ - if(makeStub(section, (void**)&value)) { + if(makeStub(section, (void**)&value, 0)) { barf("could not find or make stub"); } } @@ -1231,9 +1173,15 @@ ocGetNames_MachO(ObjectCode* oc) size_t alignment = 1 << section->align; SectionKind kind = getSectionKind_MachO(section); + SectionAlloc alloc = SECTION_NOMEM; + void *start = NULL, *mapped_start = NULL; + StgWord mapped_size = 0, mapped_offset = 0; + StgWord size = section->size; void *secMem = (void *)roundUpToAlign((size_t)curMem, alignment); + start = secMem; + IF_DEBUG(linker, debugBelch("ocGetNames_MachO: loading section %d in segment %d " "(#%d, %s %s)\n" @@ -1246,28 +1194,56 @@ ocGetNames_MachO(ObjectCode* oc) case S_GB_ZEROFILL: IF_DEBUG(linker, debugBelch("ocGetNames_MachO: memset to 0 a ZEROFILL section\n")); memset(secMem, 0, section->size); + addSection(&secArray[sec_idx], kind, alloc, start, size, + mapped_offset, mapped_start, mapped_size); break; default: IF_DEBUG(linker, debugBelch("ocGetNames_MachO: copying from %p to %p" " a block of %" PRIu64 " bytes\n", (void *) (oc->image + section->offset), secMem, section->size)); +#if defined(NEED_PLT) + unsigned nstubs = numberOfStubsForSection(oc, sec_idx); + unsigned stub_space = STUB_SIZE * nstubs; - memcpy(secMem, oc->image + section->offset, section->size); - } + void * mem = mmapForLinker(section->size+stub_space, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if( mem == MAP_FAILED ) { + sysErrorBelch("failed to mmap allocated memory to load section %d. " + "errno = %d", sec_idx, errno); + } + /* copy only the image part over; we don't want to copy data + * into the stub part. + */ + memcpy( mem, oc->image + section->offset, size ); + + alloc = SECTION_MMAP; + mapped_offset = 0; + mapped_size = roundUpToPage(size+stub_space); + start = mem; + mapped_start = mem; +#else + memcpy(secMem, oc->image + section->offset, section->size); +#endif + addSection(&secArray[sec_idx], kind, alloc, start, size, + mapped_offset, mapped_start, mapped_size); /* SECTION_NOMEM since memory is already allocated in segments */ - addSection(&secArray[sec_idx], kind, SECTION_NOMEM, - secMem, section->size, - 0, 0, 0); - addProddableBlock(oc, secMem, section->size); - curMem = (char*) secMem + section->size; +#if defined(NEED_PLT) + secArray[sec_idx].info->nstubs = 0; + secArray[sec_idx].info->stub_offset = (uint8_t*)mem + size; + secArray[sec_idx].info->stub_size = stub_space; + secArray[sec_idx].info->stubs = NULL; +#else + secArray[sec_idx].info->nstubs = 0; + secArray[sec_idx].info->stub_offset = NULL; + secArray[sec_idx].info->stub_size = 0; + secArray[sec_idx].info->stubs = NULL; +#endif + addProddableBlock(oc, start, section->size); + } - secArray[sec_idx].info->nstubs = 0; - secArray[sec_idx].info->stub_offset = NULL; - secArray[sec_idx].info->stub_size = 0; - secArray[sec_idx].info->stubs = NULL; + curMem = (char*) secMem + section->size; secArray[sec_idx].info->macho_section = section; secArray[sec_idx].info->relocation_info @@ -1451,6 +1427,26 @@ ocMprotect_MachO( ObjectCode *oc ) mmapForLinkerMarkExecutable(segment->start, segment->size); } } + + // Also mark mmaped, sections executable. Those are not part of the + // segments anymore and have been mapped separately. + for(int i=0; i < oc->n_sections; i++) { + Section *section = &oc->sections[i]; + if(section->size == 0) continue; + if(section->alloc != SECTION_MMAP) continue; + // N.B. m32 handles protection of its allocations during + // flushing. + if(section->alloc == SECTION_M32) continue; + switch (section->kind) { + case SECTIONKIND_CODE_OR_RODATA: { + mmapForLinkerMarkExecutable(section->mapped_start, section->mapped_size); + break; + } + default: + break; + } + } + return true; } ===================================== rts/linker/MachOTypes.h ===================================== @@ -103,6 +103,11 @@ typedef struct _Stub { void * addr; void * target; + /* flags can hold architecture specific information they are used during + * lookup of stubs as well. Thus two stubs for the same target with + * different flags are considered unequal. + */ + uint8_t flags; struct _Stub * next; } Stub; ===================================== rts/linker/macho/plt.c ===================================== @@ -0,0 +1,93 @@ +#include "Rts.h" +#include "plt.h" + +#if defined(aarch64_HOST_ARCH) + +#if defined(OBJFORMAT_MACHO) + +#include +#include +#include +#include +#include + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +#define _makeStub ADD_SUFFIX(makeStub) +#define needStubForRel ADD_SUFFIX(needStubForRel) + +unsigned +numberOfStubsForSection( ObjectCode *oc, unsigned sectionIndex) { + unsigned n = 0; + + MachOSection *section = &oc->info->macho_sections[sectionIndex]; + MachORelocationInfo *relocation_info = (MachORelocationInfo*)(oc->image + section->reloff); + if(section->size > 0) + for(size_t i = 0; i < section->nreloc; i++) + if(needStubForRel(&relocation_info[i])) + n += 1; + + return n; +} + +bool +findStub(Section * section, + void* * addr, + uint8_t flags) { + for(Stub * s = section->info->stubs; s != NULL; s = s->next) { + if( s->target == *addr + && s->flags == flags) { + *addr = s->addr; + return EXIT_SUCCESS; + } + } + return EXIT_FAILURE; +} + +bool +makeStub(Section * section, + void* * addr, + uint8_t flags) { + + Stub * s = calloc(1, sizeof(Stub)); + ASSERT(s != NULL); + s->target = *addr; + s->flags = flags; + s->next = NULL; + s->addr = (uint8_t *)section->info->stub_offset + 8 + + STUB_SIZE * section->info->nstubs; + + if((*_makeStub)(s)) + return EXIT_FAILURE; + + if(section->info->stubs == NULL) { + ASSERT(section->info->nstubs == 0); + /* no stubs yet, let's just create this one */ + section->info->stubs = s; + } else { + Stub * tail = section->info->stubs; + while(tail->next != NULL) tail = tail->next; + tail->next = s; + } + section->info->nstubs += 1; + *addr = s->addr; + return EXIT_SUCCESS; +} + +void +freeStubs(Section * section) { + if(section->info->nstubs == 0) + return; + Stub * last = section->info->stubs; + while(last->next != NULL) { + Stub * t = last; + last = last->next; + free(t); + } + section->info->stubs = NULL; + section->info->nstubs = 0; +} + +#endif // OBJECTFORMAT_MACHO +#endif // aarch64_HOST_ARCH \ No newline at end of file ===================================== rts/linker/macho/plt.h ===================================== @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include "plt_aarch64.h" + +#if defined(aarch64_HOST_ARCH) + +#if defined(OBJFORMAT_MACHO) + +#if defined(__x86_64__) +#define __suffix__ X86_64 +#elif defined(__aarch64__) || defined(__arm64__) +#define __suffix__ Aarch64 +#else +#error "unknown architecture" +#endif + +#define PASTE(x,y) x ## y +#define EVAL(x,y) PASTE(x,y) +#define ADD_SUFFIX(x) EVAL(PASTE(x,),__suffix__) + +unsigned numberOfStubsForSection( ObjectCode *oc, unsigned sectionIndex); + +#define STUB_SIZE ADD_SUFFIX(stubSize) + +bool findStub(Section * section, void* * addr, uint8_t flags); +bool makeStub(Section * section, void* * addr, uint8_t flags); + +void freeStubs(Section * section); + +#endif // OBJECTFORMAT_MACHO + +#endif // aarch64_HOST_ARCH \ No newline at end of file ===================================== rts/linker/macho/plt_aarch64.c ===================================== @@ -0,0 +1,61 @@ +#include "Rts.h" +#include "plt_aarch64.h" + +#include + +#if defined(aarch64_HOST_ARCH) + +#if defined(OBJFORMAT_MACHO) + +#include +#include +#include +#include +#include + +/* five 4 byte instructions */ +const size_t instSizeAarch64 = 4; +const size_t stubSizeAarch64 = 5 * 4; + +bool needStubForRelAarch64(MachORelocationInfo * rel) { + switch(rel->r_type) { + case ARM64_RELOC_BRANCH26: + return true; + default: + return false; + } +} + +/* see the elf_plt_aarch64.c for the discussion on this */ +bool +makeStubAarch64(Stub * s) { + uint32_t mov__hw0_x16 = 0xd2800000 | 16; + uint32_t movk_hw0_x16 = mov__hw0_x16 | (1 << 29); + + uint32_t mov__hw3_x16 = mov__hw0_x16 | (3 << 21); + uint32_t movk_hw2_x16 = movk_hw0_x16 | (2 << 21); + uint32_t movk_hw1_x16 = movk_hw0_x16 | (1 << 21); + + + uint32_t br_x16 = 0xd61f0000 | 16 << 5; + + uint32_t *P = (uint32_t*)s->addr; + + /* target address */ + uint64_t addr = (uint64_t)s->target; + uint16_t addr_hw0 = (uint16_t)(addr >> 0); + uint16_t addr_hw1 = (uint16_t)(addr >> 16); + uint16_t addr_hw2 = (uint16_t)(addr >> 32); + uint16_t addr_hw3 = (uint16_t)(addr >> 48); + + P[0] = mov__hw3_x16 | ((uint32_t)addr_hw3 << 5); + P[1] = movk_hw2_x16 | ((uint32_t)addr_hw2 << 5); + P[2] = movk_hw1_x16 | ((uint32_t)addr_hw1 << 5); + P[3] = movk_hw0_x16 | ((uint32_t)addr_hw0 << 5); + P[4] = br_x16; + + return EXIT_SUCCESS; +} + +#endif +#endif \ No newline at end of file ===================================== rts/linker/macho/plt_aarch64.h ===================================== @@ -0,0 +1,22 @@ +#pragma once + +#include + +#if defined(OBJFORMAT_MACHO) + +#if defined(x86_64_HOST_ARCH) +# include +#endif + +#if defined(aarch64_HOST_ARCH) +# include +#endif + +#include "../MachOTypes.h" + + +extern const size_t stubSizeAarch64; +bool needStubForRelAarch64(MachORelocationInfo * rel); +bool makeStubAarch64(Stub * s); + +#endif \ No newline at end of file ===================================== rts/package.conf.in ===================================== @@ -318,7 +318,7 @@ ld-options: , "-Wl,-search_paths_first" #endif -#if defined(darwin_HOST_OS) && !defined(x86_64_HOST_ARCH) +#if defined(darwin_HOST_OS) && !defined(x86_64_HOST_ARCH) && !defined(aarch64_HOST_ARCH) , "-read_only_relocs", "warning" #endif ===================================== rts/rts.cabal.in ===================================== @@ -385,7 +385,7 @@ library if os(osx) ld-options: "-Wl,-search_paths_first" - if !arch(x86_64) + if !arch(x86_64) && !arch(aarch64) ld-options: -read_only_relocs warning cmm-sources: Apply.cmm @@ -478,6 +478,8 @@ library linker/LoadArchive.c linker/M32Alloc.c linker/MachO.c + linker/macho/plt.c + linker/macho/plt_aarch64.c linker/PEi386.c linker/SymbolExtras.c linker/elf_got.c ===================================== rts/sm/Storage.c ===================================== @@ -1733,9 +1733,6 @@ AdjustorWritable allocateExec(W_ bytes, AdjustorExecutable *exec_ret) { AdjustorWritable writ; ffi_closure* cl; - if (bytes != sizeof(ffi_closure)) { - barf("allocateExec: for ffi_closure only"); - } ACQUIRE_SM_LOCK; cl = writ = ffi_closure_alloc((size_t)bytes, exec_ret); if (cl != NULL) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9d9d48daaeebedf97d10269524bc8e8e76b53cd...046365b34996756242037e8f62c1ac8c6e4687ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9d9d48daaeebedf97d10269524bc8e8e76b53cd...046365b34996756242037e8f62c1ac8c6e4687ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:11:40 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 08:11:40 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f80537cb8dd_80b3f84680dd410178086cc@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 7b39efaf by Daniel Rogozin at 2020-10-09T15:11:22+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 17 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName is in scope and can be promoted to the type level, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1051,28 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was +out of scope. We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int + +Previously, such errors contained only the info that a given value was out of scope (#18740). -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -889,8 +889,19 @@ cvtImplicitParamBind n e = do cvtl :: TH.Exp -> CvtM (LHsExpr GhcPs) cvtl e = wrapL (cvt e) where - cvt (VarE s) = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } - cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } + cvt (VarE s) + | isVarName s = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } + | isTyConName s = cvt (ConE s) + -- If a variable name contains a type constructor, + -- then we process this name as a data constructor + -- in order to cause an "Illegal term-level + -- use of a type constructor" error. + -- See Note [Promotion] in GHC.Rename.Env. + -- In particular, this clause (together with the next one) + -- improves the error messages in test cases like + -- T14627, T7667a, and T15270B. + | otherwise = failWith (badOcc OccName.varName (nameBase s)) + cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } cvt (LitE l) | overloadedLit l = go cvtOverLit (HsOverLit noExtField) (hsOverLitNeedsParens appPrec) @@ -1915,6 +1926,12 @@ isVarName (TH.Name occ _) "" -> False (c:_) -> startsVarId c || startsVarSym c +isTyConName :: TH.Name -> Bool +isTyConName name + = case nameSpace name of + Just TcClsName -> True + _ -> False + badOcc :: OccName.NameSpace -> String -> SDoc badOcc ctxt_ns occ = text "Illegal" <+> pprNameSpace ctxt_ns ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,4 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b39efafa8951560554a1ac58db2fdbb1e8947f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b39efafa8951560554a1ac58db2fdbb1e8947f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:22:08 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 09 Oct 2020 08:22:08 -0400 Subject: [Git][ghc/ghc][wip/T18793] 2 commits: Add a proper EtaExpandArity AnalysisMode for efficiency Message-ID: <5f8055f0cd5fe_80b3f849249476417816147@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: 89a88b84 by Sebastian Graf at 2020-10-09T14:22:02+02:00 Add a proper EtaExpandArity AnalysisMode for efficiency - - - - - a8780644 by Sebastian Graf at 2020-10-09T14:22:02+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr - testsuite/tests/arityanal/f1.hs → testsuite/tests/arityanal/should_compile/Arity01.hs - + testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/f2.hs → testsuite/tests/arityanal/should_compile/Arity02.hs - + testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/f3.hs → testsuite/tests/arityanal/should_compile/Arity03.hs - + testsuite/tests/arityanal/should_compile/Arity03.stderr - testsuite/tests/arityanal/f4.hs → testsuite/tests/arityanal/should_compile/Arity04.hs - + testsuite/tests/arityanal/should_compile/Arity04.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9d61d7fe431486768ed10d53b9f10887bf8bdc06...a8780644f9d715723da36998386d160505fe4ad8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9d61d7fe431486768ed10d53b9f10887bf8bdc06...a8780644f9d715723da36998386d160505fe4ad8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:40:39 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:40:39 -0400 Subject: [Git][ghc/ghc][master] Use UnitId in the backend instead of Unit Message-ID: <5f805a4799382_80b3f84862127181782137d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - 2 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/StgToCmm/Foreign.hs Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -387,7 +387,7 @@ instance Ord CLabel where data ForeignLabelSource -- | Label is in a named package - = ForeignLabelInPackage Unit + = ForeignLabelInPackage UnitId -- | Label is in some external, system package that doesn't also -- contain compiled Haskell code, and is not associated with any .hi files. @@ -1087,15 +1087,15 @@ labelDynamic config this_mod lbl = case lbl of -- is the RTS in a DLL or not? RtsLabel _ -> - externalDynamicRefs && (this_pkg /= rtsUnit) + externalDynamicRefs && (this_unit /= rtsUnitId) IdLabel n _ _ -> externalDynamicRefs && isDynLinkName platform this_mod n -- When compiling in the "dyn" way, each package is to be linked into -- its own shared library. - CmmLabel pkg _ _ _ - | os == OSMinGW32 -> externalDynamicRefs && (toUnitId this_pkg /= pkg) + CmmLabel lbl_unit _ _ _ + | os == OSMinGW32 -> externalDynamicRefs && (this_unit /= lbl_unit) | otherwise -> externalDynamicRefs LocalBlockLabel _ -> False @@ -1114,7 +1114,7 @@ labelDynamic config this_mod lbl = -- When compiling in the "dyn" way, each package is to be -- linked into its own DLL. ForeignLabelInPackage pkgId -> - externalDynamicRefs && (this_pkg /= pkgId) + externalDynamicRefs && (this_unit /= pkgId) else -- On Mac OS X and on ELF platforms, false positives are OK, -- so we claim that all foreign imports come from dynamic @@ -1136,7 +1136,7 @@ labelDynamic config this_mod lbl = externalDynamicRefs = ncgExternalDynamicRefs config platform = ncgPlatform config os = platformOS platform - this_pkg = moduleUnit this_mod + this_unit = toUnitId (moduleUnit this_mod) ----------------------------------------------------------------------------- ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -47,6 +47,7 @@ import GHC.Data.Maybe import GHC.Utils.Panic import GHC.Types.Unique.Supply import GHC.Types.Basic +import GHC.Unit.Types import GHC.Core.TyCo.Rep import GHC.Builtin.Types.Prim @@ -91,7 +92,7 @@ cgForeignCall (CCall (CCallSpec target cconv safety)) typ stg_args res_ty -> let labelSource = case mPkgId of Nothing -> ForeignLabelInThisPackage - Just pkgId -> ForeignLabelInPackage pkgId + Just pkgId -> ForeignLabelInPackage (toUnitId pkgId) size = call_size cmm_args in ( unzip cmm_args , CmmLit (CmmLabel View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/386c2d7ff80843051ad15eab5de3766430ee98a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/386c2d7ff80843051ad15eab5de3766430ee98a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:41:16 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:41:16 -0400 Subject: [Git][ghc/ghc][master] Update containers to v0.6.4.1 Message-ID: <5f805a6cdc87a_80b3f84697816e41782656e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - 2 changed files: - libraries/containers - testsuite/tests/driver/T10970.stdout Changes: ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit aaeda192b34a66b1c5359a85271adf8fed26dd12 +Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a ===================================== testsuite/tests/driver/T10970.stdout ===================================== @@ -1,2 +1,2 @@ -0.6.2.1 +0.6.4.1 OK View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a566c83d4fc3a90b209b33131a2972ea53ec81b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a566c83d4fc3a90b209b33131a2972ea53ec81b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:41:58 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:41:58 -0400 Subject: [Git][ghc/ghc][master] rts: fix race condition in StgCRun Message-ID: <5f805a969f95f_80baa1b8781783074a@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - 6 changed files: - compiler/GHC/CmmToAsm/X86/Instr.hs - rts/RtsStartup.c - rts/RtsSymbols.c - rts/Schedule.c - rts/StgCRun.c - rts/StgRun.h Changes: ===================================== compiler/GHC/CmmToAsm/X86/Instr.hs ===================================== @@ -832,13 +832,14 @@ mkJumpInstr id -- In essence each allocation larger than a page size needs to be chunked and -- a probe emitted after each page allocation. You have to hit the guard -- page so the kernel can map in the next page, otherwise you'll segfault. +-- See Note [Windows stack allocations]. -- needs_probe_call :: Platform -> Int -> Bool needs_probe_call platform amount = case platformOS platform of OSMinGW32 -> case platformArch platform of ArchX86 -> amount > (4 * 1024) - ArchX86_64 -> amount > (8 * 1024) + ArchX86_64 -> amount > (4 * 1024) _ -> False _ -> False @@ -862,7 +863,7 @@ mkStackAllocInstr platform amount -- -- We emit a call because the stack probes are quite involved and -- would bloat code size a lot. GHC doesn't really have an -Os. - -- __chkstk is guaranteed to leave all nonvolatile registers and AX + -- ___chkstk is guaranteed to leave all nonvolatile registers and AX -- untouched. It's part of the standard prologue code for any Windows -- function dropping the stack more than a page. -- See Note [Windows stack layout] ===================================== rts/RtsStartup.c ===================================== @@ -71,7 +71,7 @@ static bool rts_shutdown = false; #if defined(mingw32_HOST_OS) /* Indicates CodePage to set program to after exit. */ -static int64_t __codePage = 0; +static int64_t __codePage = -1; #endif static void flushStdHandles(void); ===================================== rts/RtsSymbols.c ===================================== @@ -135,7 +135,7 @@ SymI_HasProto(rts_InstallConsoleEvent) \ SymI_HasProto(rts_ConsoleHandlerDone) \ SymI_HasProto(atexit) \ - RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \ + RTS_WIN32_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \ RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \ ===================================== rts/Schedule.c ===================================== @@ -137,7 +137,6 @@ static Capability *schedule (Capability *initialCapability, Task *task); // abstracted only to make the structure and control flow of the // scheduler clearer. // -static void schedulePreLoop (void); static void scheduleFindWork (Capability **pcap); #if defined(THREADED_RTS) static void scheduleYield (Capability **pcap, Task *task); @@ -207,8 +206,6 @@ schedule (Capability *initialCapability, Task *task) debugTrace (DEBUG_sched, "cap %d: schedule()", initialCapability->no); - schedulePreLoop(); - // ----------------------------------------------------------- // Scheduler loop starts here: @@ -613,20 +610,6 @@ promoteInRunQueue (Capability *cap, StgTSO *tso) pushOnRunQueue(cap, tso); } -/* ---------------------------------------------------------------------------- - * Setting up the scheduler loop - * ------------------------------------------------------------------------- */ - -static void -schedulePreLoop(void) -{ - // initialisation for scheduler - what cannot go into initScheduler() - -#if defined(mingw32_HOST_OS) && !defined(USE_MINIINTERPRETER) - win32AllocStack(); -#endif -} - /* ----------------------------------------------------------------------------- * scheduleFindWork() * ===================================== rts/StgCRun.c ===================================== @@ -96,25 +96,6 @@ StgFunPtr StgReturn(void) } #else /* !USE_MINIINTERPRETER */ - -#if defined(mingw32_HOST_OS) -/* - * Note [Windows Stack allocations] - * - * On windows the stack has to be allocated 4k at a time, otherwise - * we get a segfault. The C compiler knows how to do this (it calls - * _alloca()), so we make sure that we can allocate as much stack as - * we need. However since we are doing a local stack allocation and the value - * isn't valid outside the frame, compilers are free to optimize this allocation - * and the corresponding stack check away. So to prevent that we request that - * this function never be optimized (See #14669). */ -STG_NO_OPTIMIZE StgWord8 *win32AllocStack(void) -{ - StgWord8 stack[RESERVED_C_STACK_BYTES + 16 + 12]; - return stack; -} -#endif - /* ----------------------------------------------------------------------------- x86 architecture -------------------------------------------------------------------------- */ @@ -166,7 +147,21 @@ STG_NO_OPTIMIZE StgWord8 *win32AllocStack(void) * * If you edit the sequence below be sure to update the unwinding information * for stg_stop_thread in StgStartup.cmm. - */ + * + * Note [Windows Stack allocations] + * + * On windows the stack has to be allocated 4k at a time, otherwise + * we get a segfault. This is done by using a helper ___chkstk_ms that is + * provided by libgcc. The Haskell side already knows how to handle this +(see GHC.CmmToAsm.X86.Instr.needs_probe_call) + * but we need to do the same from STG. Previously we would drop the stack + * in StgRun but would only make it valid whenever the scheduler loop ran. + * + * This approach was fundamentally broken in that it falls apart when you + * take a signal from the OS (See #14669, #18601, #18548 and #18496). + * Concretely this means we must always keep the stack valid. + * */ + static void GNUC3_ATTRIBUTE(used) StgRunIsImplementedInAssembler(void) @@ -186,7 +181,13 @@ StgRunIsImplementedInAssembler(void) * bytes from here - this is a requirement of the C ABI, so * that C code can assign SSE2 registers directly to/from * stack locations. + * + * See Note [Windows Stack allocations] */ +#if defined(mingw32_HOST_OS) + "movl %0, %%eax\n\t" + "call ___chkstk_ms\n\t" +#endif "subl %0, %%esp\n\t" /* @@ -383,6 +384,14 @@ StgRunIsImplementedInAssembler(void) STG_HIDDEN STG_RUN "\n" #endif STG_RUN ":\n\t" + /* + * See Note [Windows Stack allocations] + */ +#if defined(mingw32_HOST_OS) + "movq %1, %%rax\n\t" + "addq %0, %%rax\n\t" + "callq ___chkstk_ms\n\t" +#endif "subq %1, %%rsp\n\t" "movq %%rsp, %%rax\n\t" "subq %0, %%rsp\n\t" ===================================== rts/StgRun.h ===================================== @@ -9,7 +9,3 @@ #pragma once RTS_PRIVATE StgRegTable * StgRun (StgFunPtr f, StgRegTable *basereg); - -#if defined(mingw32_HOST_OS) -StgWord8 *win32AllocStack(void); -#endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd984d68e5ec4b04bc79395c099434e653eb1060 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd984d68e5ec4b04bc79395c099434e653eb1060 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:42:55 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:42:55 -0400 Subject: [Git][ghc/ghc][master] Expose RTS-only ways (#18651) Message-ID: <5f805acfe697f_80b3f848be6b61817833950@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - 8 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Platform/Ways.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Unit/State.hs - ghc/Main.hs - includes/Rts.h - rts/RtsSymbols.c - rts/RtsUtils.c Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2182,7 +2182,7 @@ dynamic_flags_deps = [ ------- ways --------------------------------------------------------------- , make_ord_flag defGhcFlag "prof" (NoArg (addWay WayProf)) - , make_ord_flag defGhcFlag "eventlog" (NoArg (addWay WayEventLog)) + , make_ord_flag defGhcFlag "eventlog" (NoArg (addWay WayTracing)) , make_ord_flag defGhcFlag "debug" (NoArg (addWay WayDebug)) , make_ord_flag defGhcFlag "threaded" (NoArg (addWay WayThreaded)) ===================================== compiler/GHC/Platform/Ways.hs ===================================== @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | Ways -- -- The central concept of a "way" is that all objects in a given @@ -33,13 +35,21 @@ module GHC.Platform.Ways , wayTag , waysTag , waysBuildTag + , fullWays + , rtsWays -- * Host GHC ways + , hostWays , hostFullWays , hostIsProfiled , hostIsDynamic + , hostIsThreaded + , hostIsDebugged + , hostIsTracing ) where +#include "HsVersions.h" + import GHC.Prelude import GHC.Platform import GHC.Driver.Flags @@ -47,7 +57,6 @@ import GHC.Driver.Flags import qualified Data.Set as Set import Data.Set (Set) import Data.List (intersperse) -import System.IO.Unsafe ( unsafeDupablePerformIO ) -- | A way -- @@ -58,7 +67,7 @@ data Way | WayThreaded -- ^ (RTS only) Multithreaded runtime system | WayDebug -- ^ Debugging, enable trace messages and extra checks | WayProf -- ^ Profiling, enable cost-centre stacks and profiling reports - | WayEventLog -- ^ (RTS only) enable event logging + | WayTracing -- ^ (RTS only) enable event logging (tracing) | WayDyn -- ^ Dynamic linking deriving (Eq, Ord, Show) @@ -96,7 +105,7 @@ wayTag WayThreaded = "thr" wayTag WayDebug = "debug" wayTag WayDyn = "dyn" wayTag WayProf = "p" -wayTag WayEventLog = "l" +wayTag WayTracing = "l" -- "l" for "logging" -- | Return true for ways that only impact the RTS, not the generated code wayRTSOnly :: Way -> Bool @@ -105,7 +114,15 @@ wayRTSOnly WayDyn = False wayRTSOnly WayProf = False wayRTSOnly WayThreaded = True wayRTSOnly WayDebug = True -wayRTSOnly WayEventLog = True +wayRTSOnly WayTracing = True + +-- | Filter ways that have an impact on compilation +fullWays :: Ways -> Ways +fullWays ws = Set.filter (not . wayRTSOnly) ws + +-- | Filter RTS-only ways (ways that don't have an impact on compilation) +rtsWays :: Ways -> Ways +rtsWays ws = Set.filter wayRTSOnly ws wayDesc :: Way -> String wayDesc (WayCustom xs) = xs @@ -113,7 +130,7 @@ wayDesc WayThreaded = "Threaded" wayDesc WayDebug = "Debug" wayDesc WayDyn = "Dynamic" wayDesc WayProf = "Profiling" -wayDesc WayEventLog = "RTS Event Logging" +wayDesc WayTracing = "Tracing" -- | Turn these flags on when enabling this way wayGeneralFlags :: Platform -> Way -> [GeneralFlag] @@ -129,7 +146,7 @@ wayGeneralFlags _ WayDyn = [Opt_PIC, Opt_ExternalDynamicRefs] -- PIC objects can be linked into a .so, we have to compile even -- modules of the main program with -fPIC when using -dynamic. wayGeneralFlags _ WayProf = [] -wayGeneralFlags _ WayEventLog = [] +wayGeneralFlags _ WayTracing = [] -- | Turn these flags off when enabling this way wayUnsetGeneralFlags :: Platform -> Way -> [GeneralFlag] @@ -140,7 +157,7 @@ wayUnsetGeneralFlags _ WayDyn = [Opt_SplitSections] -- There's no point splitting when we're going to be dynamically linking. -- Plus it breaks compilation on OSX x86. wayUnsetGeneralFlags _ WayProf = [] -wayUnsetGeneralFlags _ WayEventLog = [] +wayUnsetGeneralFlags _ WayTracing = [] -- | Pass these options to the C compiler when enabling this way wayOptc :: Platform -> Way -> [String] @@ -152,7 +169,7 @@ wayOptc platform WayThreaded = case platformOS platform of wayOptc _ WayDebug = [] wayOptc _ WayDyn = [] wayOptc _ WayProf = ["-DPROFILING"] -wayOptc _ WayEventLog = ["-DTRACING"] +wayOptc _ WayTracing = ["-DTRACING"] -- | Pass these options to linker when enabling this way wayOptl :: Platform -> Way -> [String] @@ -168,7 +185,7 @@ wayOptl platform WayThreaded = wayOptl _ WayDebug = [] wayOptl _ WayDyn = [] wayOptl _ WayProf = [] -wayOptl _ WayEventLog = [] +wayOptl _ WayTracing = [] -- | Pass these options to the preprocessor when enabling this way wayOptP :: Platform -> Way -> [String] @@ -177,29 +194,74 @@ wayOptP _ WayThreaded = [] wayOptP _ WayDebug = [] wayOptP _ WayDyn = [] wayOptP _ WayProf = ["-DPROFILING"] -wayOptP _ WayEventLog = ["-DTRACING"] +wayOptP _ WayTracing = ["-DTRACING"] -- | Consult the RTS to find whether it has been built with profiling enabled. hostIsProfiled :: Bool -hostIsProfiled = unsafeDupablePerformIO rtsIsProfiledIO /= 0 +hostIsProfiled = rtsIsProfiled_ /= 0 -foreign import ccall unsafe "rts_isProfiled" rtsIsProfiledIO :: IO Int +foreign import ccall unsafe "rts_isProfiled" rtsIsProfiled_ :: Int -- | Consult the RTS to find whether GHC itself has been built with -- dynamic linking. This can't be statically known at compile-time, -- because we build both the static and dynamic versions together with -- -dynamic-too. hostIsDynamic :: Bool -hostIsDynamic = unsafeDupablePerformIO rtsIsDynamicIO /= 0 +hostIsDynamic = rtsIsDynamic_ /= 0 -foreign import ccall unsafe "rts_isDynamic" rtsIsDynamicIO :: IO Int +foreign import ccall unsafe "rts_isDynamic" rtsIsDynamic_ :: Int --- | Return host "full" ways (i.e. ways that have an impact on the compilation, --- not RTS only ways). These ways must be used when compiling codes targeting --- the internal interpreter. -hostFullWays :: Ways -hostFullWays = Set.unions - [ if hostIsDynamic then Set.singleton WayDyn else Set.empty - , if hostIsProfiled then Set.singleton WayProf else Set.empty +-- we need this until the bootstrap GHC is always recent enough +#if MIN_VERSION_GLASGOW_HASKELL(9,1,0,0) + +-- | Consult the RTS to find whether it is threaded. +hostIsThreaded :: Bool +hostIsThreaded = rtsIsThreaded_ /= 0 + +foreign import ccall unsafe "rts_isThreaded" rtsIsThreaded_ :: Int + +-- | Consult the RTS to find whether it is debugged. +hostIsDebugged :: Bool +hostIsDebugged = rtsIsDebugged_ /= 0 + +foreign import ccall unsafe "rts_isDebugged" rtsIsDebugged_ :: Int + +-- | Consult the RTS to find whether it is tracing. +hostIsTracing :: Bool +hostIsTracing = rtsIsTracing_ /= 0 + +foreign import ccall unsafe "rts_isTracing" rtsIsTracing_ :: Int + + +#else + +hostIsThreaded :: Bool +hostIsThreaded = False + +hostIsDebugged :: Bool +hostIsDebugged = False + +hostIsTracing :: Bool +hostIsTracing = False + +#endif + + +-- | Host ways. +hostWays :: Ways +hostWays = Set.unions + [ if hostIsDynamic then Set.singleton WayDyn else Set.empty + , if hostIsProfiled then Set.singleton WayProf else Set.empty + , if hostIsThreaded then Set.singleton WayThreaded else Set.empty + , if hostIsDebugged then Set.singleton WayDebug else Set.empty + , if hostIsTracing then Set.singleton WayTracing else Set.empty ] + +-- | Host "full" ways (i.e. ways that have an impact on the compilation, +-- not RTS only ways). +-- +-- These ways must be used when compiling codes targeting the internal +-- interpreter. +hostFullWays :: Ways +hostFullWays = fullWays hostWays ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -596,7 +596,7 @@ checkNonStdWay hsc_env srcspan | otherwise = return (Just (hostWayTag ++ "o")) where - targetFullWays = Set.filter (not . wayRTSOnly) (ways (hsc_dflags hsc_env)) + targetFullWays = fullWays (ways (hsc_dflags hsc_env)) hostWayTag = case waysTag hostFullWays of "" -> "" tag -> tag ++ "_" ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -1856,11 +1856,11 @@ packageHsLibs dflags p = map (mkDynName . addSuffix) (unitLibraries p) -- debug and profiled RTSs include support for -eventlog ways2 | WayDebug `Set.member` ways1 || WayProf `Set.member` ways1 - = Set.filter (/= WayEventLog) ways1 + = Set.filter (/= WayTracing) ways1 | otherwise = ways1 - tag = waysTag (Set.filter (not . wayRTSOnly) ways2) + tag = waysTag (fullWays ways2) rts_tag = waysTag ways2 mkDynName x ===================================== ghc/Main.hs ===================================== @@ -348,12 +348,12 @@ checkOptions mode dflags srcs objs = do let unknown_opts = [ f | (f@('-':_), _) <- srcs ] when (notNull unknown_opts) (unknownFlagsErr unknown_opts) - when (not (Set.null (Set.filter wayRTSOnly (ways dflags))) + when (not (Set.null (rtsWays (ways dflags))) && isInterpretiveMode mode) $ hPutStrLn stderr ("Warning: -debug, -threaded and -ticky are ignored by GHCi") -- -prof and --interactive are not a good combination - when ((Set.filter (not . wayRTSOnly) (ways dflags) /= hostFullWays) + when ((fullWays (ways dflags) /= hostFullWays) && isInterpretiveMode mode && not (gopt Opt_ExternalInterpreter dflags)) $ do throwGhcException (UsageError ===================================== includes/Rts.h ===================================== @@ -263,6 +263,15 @@ int rts_isProfiled(void); // Returns non-zero if the RTS is a dynamically-linked version int rts_isDynamic(void); +// Returns non-zero if the RTS is a threaded version +int rts_isThreaded(void); + +// Returns non-zero if the RTS is a debugged version +int rts_isDebugged(void); + +// Returns non-zero if the RTS is a tracing version (event log) +int rts_isTracing(void); + /* ----------------------------------------------------------------------------- RTS Exit codes -------------------------------------------------------------------------- */ ===================================== rts/RtsSymbols.c ===================================== @@ -803,6 +803,9 @@ SymI_HasProto(rtsSupportsBoundThreads) \ SymI_HasProto(rts_isProfiled) \ SymI_HasProto(rts_isDynamic) \ + SymI_HasProto(rts_isThreaded) \ + SymI_HasProto(rts_isDebugged) \ + SymI_HasProto(rts_isTracing) \ SymI_HasProto(rts_setInCallCapability) \ SymI_HasProto(rts_enableThreadAllocationLimit) \ SymI_HasProto(rts_disableThreadAllocationLimit) \ ===================================== rts/RtsUtils.c ===================================== @@ -363,6 +363,39 @@ int rts_isDynamic(void) #endif } +// Provides a way for Haskell programs to tell whether they're +// linked with the threaded runtime or not. +int rts_isThreaded(void) +{ +#if defined(THREADED_RTS) + return 1; +#else + return 0; +#endif +} + +// Provides a way for Haskell programs to tell whether they're +// linked with the debug runtime or not. +int rts_isDebugged(void) +{ +#if defined(DEBUG) + return 1; +#else + return 0; +#endif +} + +// Provides a way for Haskell programs to tell whether they're +// linked with the tracing runtime or not. +int rts_isTracing(void) +{ +#if defined(TRACING) + return 1; +#else + return 0; +#endif +} + // Used for detecting a non-empty FPU stack on x86 (see #4914) void checkFPUStack(void) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/accdb24a086b80fe74776246aa33bce5a920e3c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/accdb24a086b80fe74776246aa33bce5a920e3c8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:43:23 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:43:23 -0400 Subject: [Git][ghc/ghc][master] Document -Wderiving-typeable Message-ID: <5f805aebb02fd_80b11148ab4178375e1@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - 2 changed files: - docs/users_guide/expected-undocumented-flags.txt - docs/users_guide/using-warnings.rst Changes: ===================================== docs/users_guide/expected-undocumented-flags.txt ===================================== @@ -4,7 +4,6 @@ --show-packages -Onot -Walternative-layout-rule-transitional --Wderiving-typeable -XAlternativeLayoutRule -XAlternativeLayoutRuleTransitional -XAutoDeriveTypeable ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -1881,6 +1881,20 @@ of ``-W(no-)*``. Does nothing. +.. ghc-flag:: -Wderiving-typeable + :shortdesc: warn when Typeable is derived + :type: dynamic + :reverse: -Wno-deriving-typeable + :category: + + :since: 7.10 + + This flag warns when ``Typeable`` is listed in a deriving clause + or derived with :extension:`StandaloneDeriving`. + + Since GHC 7.10, ``Typeable`` is automatically derived for all types. + Thus, deriving ``Typeable`` yourself is redundant. + If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice. It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's sanity, not yours.) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d360f3438da7f6eb51e217c6697db6fb338c6fd7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d360f3438da7f6eb51e217c6697db6fb338c6fd7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:43:59 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:43:59 -0400 Subject: [Git][ghc/ghc][master] Add a flag to indicate that gcc supports -no-pie Message-ID: <5f805b0f7384d_80b11148ab41784192c@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - 2 changed files: - compiler/GHC/Driver/Session.hs - docs/users_guide/phases.rst Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2232,6 +2232,8 @@ dynamic_flags_deps = [ -- (see #15319) toolSettings_ccSupportsNoPie = False } + , make_ord_flag defFlag "pgmc-supports-no-pie" + $ noArg $ alterToolSettings $ \s -> s { toolSettings_ccSupportsNoPie = True } , make_ord_flag defFlag "pgms" (HasArg (\_ -> addWarn "Object splitting was removed in GHC 8.8")) , make_ord_flag defFlag "pgma" ===================================== docs/users_guide/phases.rst ===================================== @@ -180,6 +180,20 @@ the following flags: Pass ⟨option⟩ to the C compiler. +.. ghc-flag:: -pgmc-supports-no-pie + :shortdesc: Indicate that the C compiler supports ``-no-pie`` + :type: dynamic + :category: phase-options + + When ``-pgmc`` is used, GHC by default will never pass the ``-no-pie`` + command line flag. The rationale is that it is not known whether the + specified compiler will support it. This flag can be used to indicate + that ``-no-pie`` is supported. It has to be passed after ``-pgmc``. + + This flag is not neccessary when ``-pgmc`` is not used, since GHC + remembers whether the default C compiler supports ``-no-pie`` in + an internal settings file. + .. ghc-flag:: -optcxx ⟨option⟩ :shortdesc: pass ⟨option⟩ to the C++ compiler :type: dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e48cab2a57f2342891f985bcb44817e17e985275 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e48cab2a57f2342891f985bcb44817e17e985275 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:44:36 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:44:36 -0400 Subject: [Git][ghc/ghc][master] Add linting of `base` to the CI Message-ID: <5f805b34d3049_80b3f84697804601784315c@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 10 changed files: - .gitlab-ci.yml - libraries/base/GHC/Event/EPoll.hsc - libraries/base/GHC/Event/KQueue.hsc - libraries/base/GHC/Event/Poll.hsc - libraries/base/GHC/ExecutionStack/Internal.hsc - libraries/base/GHC/IO/Handle/Lock/LinuxOFD.hsc - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - libraries/base/GHC/RTS/Flags.hsc - libraries/base/System/Environment/ExecutablePath.hsc - libraries/base/tests/Concurrent/ThreadDelay001.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: e1cdfaea745989faa266f09c1d6c4c981aa34dc6 + DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8 # Sequential version number capturing the versions of all tools fetched by # .gitlab/ci.sh. @@ -17,13 +17,14 @@ variables: GIT_SUBMODULE_STRATEGY: "recursive" stages: - - lint # Source linting - - quick-build # A very quick smoke-test to weed out broken commits - - build # A quick smoke-test to weed out broken commits - - full-build # Build all the things - - packaging # Source distribution, etc. - - testing # head.hackage correctness and compiler performance testing - - deploy # push documentation + - tool-lint # Source linting of the tools + - quick-build # A very quick smoke-test to weed out broken commits + - lint # Source linting of GHC + - build # A quick smoke-test to weed out broken commits + - full-build # Build all the things + - packaging # Source distribution, etc. + - testing # head.hackage correctness and compiler performance testing + - deploy # push documentation # Note [The CI Story] # ~~~~~~~~~~~~~~~~~~~ @@ -81,11 +82,11 @@ workflow: ############################################################ -# Linting +# tool linting ############################################################ ghc-linters: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME @@ -105,7 +106,7 @@ ghc-linters: # Run mypy Python typechecker on linter scripts. lint-linters: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - mypy .gitlab/linters/*.py @@ -115,7 +116,7 @@ lint-linters: # Check that .T files all parse by listing broken tests. lint-testsuite: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" script: - make -Ctestsuite list_broken TEST_HC=$GHC @@ -125,7 +126,7 @@ lint-testsuite: # Run mypy Python typechecker on testsuite driver typecheck-testsuite: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - mypy testsuite/driver/runtests.py @@ -137,7 +138,7 @@ typecheck-testsuite: # accommodate, e.g., haddock changes not yet upstream) but not on `master` or # Marge jobs. .lint-submods: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" script: - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME @@ -169,7 +170,7 @@ lint-submods-branch: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' .lint-changelogs: - stage: lint + stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" dependencies: [] tags: @@ -189,7 +190,6 @@ lint-release-changelogs: rules: - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/' - ############################################################ # Validation via Pipelines (hadrian) ############################################################ @@ -235,10 +235,12 @@ lint-release-changelogs: validate-x86_64-linux-deb9-hadrian: extends: .validate-linux-hadrian + needs: [hadrian-ghc-in-ghci] stage: build validate-x86_64-linux-deb9-unreg-hadrian: extends: .validate-linux-hadrian + needs: [validate-x86_64-linux-deb9-hadrian] stage: full-build variables: CONFIGURE_ARGS: --enable-unregisterised @@ -246,6 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build + needs: [ghc-linters, lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -273,6 +276,37 @@ hadrian-ghc-in-ghci: paths: - cabal-cache +############################################################ +# GHC source code linting +############################################################ + +.lint-params: + stage: lint + needs: [ghc-linters, lint-submods] + tags: + - lint + image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" + before_script: + - export PATH="/opt/toolchain/bin:$PATH" + # workaround for docker permissions + - sudo chown ghc:ghc -R . + - git submodule sync --recursive + - git submodule update --init --recursive + - git checkout .gitmodules + - .gitlab/ci.sh setup + - cabal update + - cd hadrian; cabal new-build -j`../mk/detect-cpu-count.sh` --with-compiler=$GHC --project-file=ci.project; cd .. + variables: + GHC_FLAGS: -Werror + +lint-base: + extends: .lint-params + script: + - hadrian/build -c -j stage1:lib:base + - hadrian/build -j lint:base + cache: + key: lint + ############################################################ # Validation via Pipelines (make) ############################################################ @@ -301,7 +335,9 @@ hadrian-ghc-in-ghci: ################################# .build-x86_64-freebsd: + stage: full-build extends: .validate + needs: [validate-x86_64-linux-deb9-hadrian] tags: - x86_64-freebsd allow_failure: true @@ -331,23 +367,19 @@ hadrian-ghc-in-ghci: # Conditional due to lack of builder capacity validate-x86_64-freebsd: extends: .build-x86_64-freebsd - stage: full-build rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/' nightly-x86_64-freebsd: <<: *nightly extends: .build-x86_64-freebsd - stage: full-build release-x86_64-freebsd: <<: *release extends: .build-x86_64-freebsd - stage: full-build .build-x86_64-freebsd-hadrian: extends: .validate-hadrian - stage: full-build tags: - x86_64-freebsd allow_failure: true @@ -374,7 +406,6 @@ release-x86_64-freebsd: # Disabled due to lack of builder capacity .validate-x86_64-freebsd-hadrian: extends: .build-x86_64-freebsd-hadrian - stage: full-build ################################# # x86_64-darwin @@ -382,6 +413,7 @@ release-x86_64-freebsd: validate-x86_64-darwin: extends: .validate + needs: [validate-x86_64-linux-deb9-hadrian] stage: full-build tags: - x86_64-darwin @@ -411,6 +443,7 @@ validate-x86_64-darwin: # Disabled because of OS X CI capacity .validate-x86_64-darwin-hadrian: stage: full-build + needs: [validate-x86_64-linux-deb9-hadrian] tags: - x86_64-darwin variables: @@ -440,6 +473,7 @@ validate-x86_64-darwin: .validate-linux: extends: .validate + needs: [validate-x86_64-linux-deb9-hadrian] tags: - x86_64-linux variables: @@ -809,6 +843,7 @@ validate-x86_64-linux-fedora27: .build-windows: # For the reasons given in #17777 this build isn't reliable. + needs: [validate-x86_64-linux-deb9-hadrian] allow_failure: true before_script: - git clean -xdf @@ -929,6 +964,7 @@ release-x86_64-windows-integer-simple: doc-tarball: stage: packaging + needs: [validate-x86_64-linux-deb9-debug, validate-x86_64-windows-hadrian, validate-x86_64-linux-deb9-unreg-hadrian] tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" @@ -964,6 +1000,7 @@ doc-tarball: source-tarball: stage: packaging + needs: [validate-x86_64-linux-deb9-unreg-hadrian] tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" @@ -998,6 +1035,7 @@ source-tarball: .hackage: stage: testing + needs: [doc-tarball] image: ghcci/x86_64-linux-deb9:0.2 tags: - x86_64-linux @@ -1026,6 +1064,7 @@ nightly-hackage: perf-nofib: stage: testing + needs: [validate-x86_64-linux-deb9-dwarf, doc-tarball] dependencies: - validate-x86_64-linux-deb9-dwarf image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" @@ -1062,6 +1101,7 @@ perf-nofib: perf: stage: testing + needs: [validate-x86_64-linux-deb9-dwarf, doc-tarball] dependencies: - validate-x86_64-linux-deb9-dwarf image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" @@ -1097,6 +1137,7 @@ perf: pages: stage: deploy + needs: [doc-tarball] dependencies: - doc-tarball image: ghcci/x86_64-linux-deb9:0.2 ===================================== libraries/base/GHC/Event/EPoll.hsc ===================================== @@ -1,8 +1,7 @@ -{-# LANGUAGE Trustworthy #-} -{-# LANGUAGE GeneralizedNewtypeDeriving - , NoImplicitPrelude - , BangPatterns - #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- -- | @@ -50,8 +49,7 @@ import GHC.Base import GHC.Num (Num(..)) import GHC.Real (fromIntegral, div) import GHC.Show (Show) -import System.Posix.Internals (c_close) -import System.Posix.Internals (setCloseOnExec) +import System.Posix.Internals (c_close, setCloseOnExec) import System.Posix.Types (Fd(..)) import qualified GHC.Event.Array as A ===================================== libraries/base/GHC/Event/KQueue.hsc ===================================== @@ -1,10 +1,11 @@ -{-# LANGUAGE Trustworthy #-} -{-# LANGUAGE CApiFFI - , GeneralizedNewtypeDeriving - , NoImplicitPrelude - , RecordWildCards - , BangPatterns - #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CApiFFI #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE Trustworthy #-} + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} +{-# HLINT ignore "Unused LANGUAGE pragma" #-} module GHC.Event.KQueue ( ===================================== libraries/base/GHC/Event/Poll.hsc ===================================== @@ -91,7 +91,7 @@ poll p mtout f = do c_pollLoop ptr (fromIntegral len) (fromTimeout tout) Nothing -> c_poll_unsafe ptr (fromIntegral len) 0 - when (n /= 0) $ do + when (n /= 0) $ A.loop a 0 $ \i e -> do let r = pfdRevents e if r /= 0 ===================================== libraries/base/GHC/ExecutionStack/Internal.hsc ===================================== @@ -171,7 +171,7 @@ stackFrames st@(StackTrace fptr) = unsafePerformIO $ withSession $ \sess -> do frame' = frame `plusPtr` sizeOf (undefined :: Addr) lookupFrame :: Addr -> IO (Maybe Location) - lookupFrame pc = withForeignPtr fptr $ const $ do + lookupFrame pc = withForeignPtr fptr $ const $ allocaBytes locationSize $ \buf -> do ret <- withForeignPtr sess $ \sessPtr -> libdw_lookup_location sessPtr buf pc case ret of ===================================== libraries/base/GHC/IO/Handle/Lock/LinuxOFD.hsc ===================================== @@ -60,7 +60,7 @@ instance Storable FLock where #{poke struct flock, l_start} ptr (l_start x) #{poke struct flock, l_len} ptr (l_len x) #{poke struct flock, l_pid} ptr (l_pid x) - peek ptr = do + peek ptr = FLock <$> #{peek struct flock, l_type} ptr <*> #{peek struct flock, l_whence} ptr <*> #{peek struct flock, l_start} ptr ===================================== libraries/base/GHC/IO/Handle/Lock/Windows.hsc ===================================== @@ -1,7 +1,5 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE InterruptibleFFI #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE NoImplicitPrelude #-} -- | File locking for Windows. ===================================== libraries/base/GHC/RTS/Flags.hsc ===================================== @@ -1,6 +1,5 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE RecordWildCards #-} -- | Accessors to GHC RTS flags. -- Descriptions of flags can be seen in @@ -392,7 +391,7 @@ data RTSFlags = RTSFlags foreign import ccall "&RtsFlags" rtsFlagsPtr :: Ptr RTSFlags getRTSFlags :: IO RTSFlags -getRTSFlags = do +getRTSFlags = RTSFlags <$> getGCFlags <*> getConcFlags <*> getMiscFlags ===================================== libraries/base/System/Environment/ExecutablePath.hsc ===================================== @@ -132,7 +132,7 @@ foreign import ccall unsafe "readlink" -- See readlink(2) readSymbolicLink :: FilePath -> IO FilePath readSymbolicLink file = - allocaArray0 4096 $ \buf -> do + allocaArray0 4096 $ \buf -> withFilePath file $ \s -> do len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ c_readlink s buf 4096 ===================================== libraries/base/tests/Concurrent/ThreadDelay001.hs ===================================== @@ -1,5 +1,7 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# HLINT ignore "Unused LANGUAGE pragma" #-} + -- Test that threadDelay actually sleeps for (at least) as long as we -- ask it @@ -16,6 +18,7 @@ import Data.Time #if defined(mingw32_HOST_OS) import GHC.Event.Windows.Clock #endif + main :: IO () main = mapM_ delay (0 : take 7 (iterate (*5) 100)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7e2fff96975128397e2dab7d57da3c9c6b8c76b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7e2fff96975128397e2dab7d57da3c9c6b8c76b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:45:08 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:45:08 -0400 Subject: [Git][ghc/ghc][master] Use proper RTS flags when collecting residency in perf tests. Message-ID: <5f805b54d2142_80b3f848be6b618178458f2@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - 2 changed files: - testsuite/tests/perf/should_run/all.T - testsuite/tests/perf/space_leaks/all.T Changes: ===================================== testsuite/tests/perf/should_run/all.T ===================================== @@ -88,15 +88,15 @@ test('T4321', test('T3736', [], makefile_test, ['T3736']) test('T3738', [extra_clean(['T3738a.hi', 'T3738a.o']), - collect_stats('peak_megabytes_allocated', 0), + collect_runtime_residency(1), collect_stats('bytes allocated',8), - only_ways(['normal']) + only_ways(['normal']), ], compile_and_run, ['-O']) test('MethSharing', - [collect_stats('peak_megabytes_allocated', 0), + [collect_runtime_residency(1), collect_stats('bytes allocated',5), only_ways(['normal']) ], @@ -177,7 +177,7 @@ test('T5536', test('T7257', [collect_stats('bytes allocated',10), - collect_stats('peak_megabytes_allocated',5), + collect_runtime_residency(5), only_ways(['normal']) ], compile_and_run, ['-O']) @@ -192,14 +192,14 @@ test('T7507', omit_ways(['ghci']), compile_and_run, ['-O']) # For 7507, stack overflow is the bad case test('T7436', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, ['-O']) test('T7436b', - [collect_stats('max_bytes_used',4), + [collect_runtime_residency(4), only_ways(['normal']) ], compile_and_run, @@ -221,7 +221,7 @@ test('T7954', ['-O']) test('T7850', - [collect_stats('peak_megabytes_allocated',10), + [collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) @@ -308,7 +308,7 @@ test('T12990', test('T13218', [collect_stats('bytes allocated',5), - collect_stats('max_bytes_used',10), + collect_runtime_residency(10), only_ways(['normal'])], compile_and_run, ['-O']) ===================================== testsuite/tests/perf/space_leaks/all.T ===================================== @@ -3,7 +3,7 @@ test('space_leak_001', # This could potentially be replaced with # collect_stats('all',5) to test all 3 with # 5% possible deviation. - [collect_stats(['peak_megabytes_allocated','bytes allocated'],5), + [ collect_stats(['bytes allocated'],5), collect_runtime_residency(15), omit_ways(['profasm','profthreaded','threaded1','threaded2','nonmoving_thr']) ], @@ -13,7 +13,7 @@ test('space_leak_001', test('T4334', # Test for a space leak in Data.List.lines (fixed with #4334) [extra_run_opts('1000000 2 t'), - collect_stats('peak_megabytes_allocated',2), + collect_runtime_residency(2), # prof ways don't work well with +RTS -V0, nonmoving way residency is # highly variable. omit_ways(['profasm','profthreaded','nonmoving_thr']) @@ -21,9 +21,8 @@ test('T4334', compile_and_run, ['']) test('T2762', - [collect_stats('peak_megabytes_allocated',2), + [collect_runtime_residency(2), only_ways(['normal']), - extra_run_opts('+RTS -G1 -RTS' ), extra_clean(['T2762A.hi', 'T2762A.o'])], compile_and_run, ['-O']) @@ -32,9 +31,7 @@ test('T4018', compile_and_run, ['-fno-state-hack']) test('T4029', - [collect_stats(['peak_megabytes_allocated'],10), - collect_runtime_residency(10), - extra_hc_opts('+RTS -G1 -RTS' ), + [collect_runtime_residency(10), ], ghci_script, ['T4029.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45a1d493ec877f5fa0b3228deee3e019033c89db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/45a1d493ec877f5fa0b3228deee3e019033c89db You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:45:49 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:45:49 -0400 Subject: [Git][ghc/ghc][master] testsuite/timeout: Fix windows specific errors. Message-ID: <5f805b7d861b_80b3f84862938e01785185c@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - 2 changed files: - testsuite/timeout/WinCBindings.hsc - testsuite/timeout/timeout.hs Changes: ===================================== testsuite/timeout/WinCBindings.hsc ===================================== @@ -29,11 +29,11 @@ data PROCESS_INFORMATION = PROCESS_INFORMATION instance Storable PROCESS_INFORMATION where sizeOf = const #size PROCESS_INFORMATION alignment = sizeOf - poke buf pi = do - (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pi) - (#poke PROCESS_INFORMATION, hThread) buf (piThread pi) - (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pi) - (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pi) + poke buf pinfo = do + (#poke PROCESS_INFORMATION, hProcess) buf (piProcess pinfo) + (#poke PROCESS_INFORMATION, hThread) buf (piThread pinfo) + (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pinfo) + (#poke PROCESS_INFORMATION, dwThreadId) buf (piThreadId pinfo) peek buf = do vhProcess <- (#peek PROCESS_INFORMATION, hProcess) buf @@ -361,7 +361,7 @@ createCompletionPort hJob = do return nullPtr waitForJobCompletion :: HANDLE -> HANDLE -> DWORD -> IO BOOL -waitForJobCompletion hJob ioPort timeout +waitForJobCompletion _hJob ioPort timeout = alloca $ \p_CompletionCode -> alloca $ \p_CompletionKey -> alloca $ \p_Overlapped -> do ===================================== testsuite/timeout/timeout.hs ===================================== @@ -2,22 +2,25 @@ {-# LANGUAGE LambdaCase #-} module Main where -import Control.Concurrent (forkIO, threadDelay) -import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) import Control.Monad import Control.Exception -import Data.Maybe (isNothing) import System.Environment (getArgs) import System.Exit -import System.IO (hPutStrLn, stderr) +import Prelude hiding (pi) #if !defined(mingw32_HOST_OS) +import Control.Concurrent (forkIO, threadDelay) +import Control.Concurrent.MVar (putMVar, takeMVar, newEmptyMVar) + +import Data.Maybe (isNothing) + import System.Posix hiding (killProcess) import System.IO.Error hiding (try,catch) +import System.IO (hPutStrLn, stderr) #endif #if defined(mingw32_HOST_OS) -import System.Process +-- import System.Process import WinCBindings import Foreign import System.Win32.DebugApi @@ -114,8 +117,8 @@ run secs cmd = -- We're explicitly turning off handle inheritance to prevent misc handles -- from being inherited by the child. Notable we don't want the I/O Completion -- Ports and Job handles to be inherited. So we mark them as non-inheritable. - setHandleInformation job cHANDLE_FLAG_INHERIT 0 - setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation job cHANDLE_FLAG_INHERIT 0 + _ <- setHandleInformation ioPort cHANDLE_FLAG_INHERIT 0 -- Now create the process suspended so we can add it to the job and then resume. -- This is so we don't miss any events on the receiving end of the I/O port. @@ -132,30 +135,30 @@ run secs cmd = let handleInterrupt action = action `onException` terminateJobObject job 99 handleCtrl _ = do - terminateJobObject job 99 - closeHandle ioPort - closeHandle job - exitWith (ExitFailure 99) + _ <- terminateJobObject job 99 + _ <- closeHandle ioPort + _ <- closeHandle job + _ <- exitWith (ExitFailure 99) return True withConsoleCtrlHandler handleCtrl $ handleInterrupt $ do - resumeThread (piThread pi) + _ <- resumeThread (piThread pi) -- The program is now running - let handle = piProcess pi + let p_handle = piProcess pi let millisecs = secs * 1000 rc <- waitForJobCompletion job ioPort (fromIntegral millisecs) - closeHandle ioPort + _ <- closeHandle ioPort if not rc - then do terminateJobObject job 99 - closeHandle job + then do _ <- terminateJobObject job 99 + _ <- closeHandle job exitWith (ExitFailure 99) else alloca $ \p_exitCode -> - do terminateJobObject job 0 + do _ <- terminateJobObject job 0 -- Ensured it's all really dead. - closeHandle job - r <- getExitCodeProcess handle p_exitCode + _ <- closeHandle job + r <- getExitCodeProcess p_handle p_exitCode if r then peek p_exitCode >>= \case 0 -> exitWith ExitSuccess View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef65b1546ad01fdd10386f713fc246d49269a196 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef65b1546ad01fdd10386f713fc246d49269a196 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:46:31 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:46:31 -0400 Subject: [Git][ghc/ghc][master] Hadrian: add quick-debug flavour Message-ID: <5f805ba716ece_80b3f8454535c9c1785622c@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 3 changed files: - hadrian/doc/flavours.md - hadrian/src/Settings.hs - hadrian/src/Settings/Flavours/Quick.hs Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -35,8 +35,8 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH default
- -O
-H64m
- -O2
-H64m + -O
-H32m
+ -O2
-H32m -haddock @@ -55,6 +55,28 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH -O + + quick-validate + -O0
-H64m
-Werror + -O0
-H64m
-Werror + + -O + -O2 + -O + -O + + + + quick-debug + -O0
-H64m + -O0
-H64m + + -O + -O2 + -O + -O + -debug (link) + quickest -O0
-H64m @@ -190,7 +212,7 @@ information. The following table lists ways that are built in different flavours Only in
prof
flavour - quick
quick-llvm + quick
quick-llvm
quick-validate
quick-debug vanilla vanilla
dynamic logging
debug
threaded
threadedDebug
threadedLogging ===================================== hadrian/src/Settings.hs ===================================== @@ -54,7 +54,8 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ benchmarkFlavour, defaultFlavour, developmentFlavour Stage1 , developmentFlavour Stage2, performanceFlavour, profiledFlavour - , quickFlavour, quickValidateFlavour, quickestFlavour + , quickFlavour, quickValidateFlavour, quickDebugFlavour + , quickestFlavour , quickCrossFlavour, benchmarkLlvmFlavour , performanceLlvmFlavour, profiledLlvmFlavour, quickLlvmFlavour , ghcInGhciFlavour, validateFlavour, slowValidateFlavour ] ===================================== hadrian/src/Settings/Flavours/Quick.hs ===================================== @@ -1,6 +1,7 @@ module Settings.Flavours.Quick ( quickFlavour , quickValidateFlavour + , quickDebugFlavour ) where @@ -39,3 +40,9 @@ quickValidateFlavour :: Flavour quickValidateFlavour = werror $ quickFlavour { name = "quick-validate" } + +quickDebugFlavour :: Flavour +quickDebugFlavour = quickFlavour + { name = "quick-debug" + , ghcDebugged = True + } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e691a5a04692beb601d480ccf9f283199a70ed62 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e691a5a04692beb601d480ccf9f283199a70ed62 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:47:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:47:04 -0400 Subject: [Git][ghc/ghc][master] Bignum: match on small Integer/Natural Message-ID: <5f805bc832aca_80b3f847218e3f0178566e2@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 4 changed files: - compiler/GHC/Core/SimpleOpt.hs - testsuite/tests/lib/integer/all.T - + testsuite/tests/lib/integer/bignumMatch.hs - + testsuite/tests/lib/integer/bignumMatch.stderr Changes: ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1279,13 +1279,24 @@ exprIsLiteral_maybe env@(_, id_unf) e -> Just l Var v | Just rhs <- expandUnfolding_maybe (id_unf v) - , Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env rhs + , Just b <- matchBignum env rhs + -> Just b + e + | Just b <- matchBignum env e + -> Just b + + | otherwise + -> Nothing + where + matchBignum env e + | Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env e , Just (LitNumber _ i) <- exprIsLiteral_maybe env arg - -> if + = if | dc == naturalNSDataCon -> Just (mkLitNatural i) | dc == integerISDataCon -> Just (mkLitInteger i) | otherwise -> Nothing - _ -> Nothing + | otherwise + = Nothing {- Note [exprIsLambda_maybe] ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -10,6 +10,7 @@ test('gcdeInteger', normal, compile_and_run, ['']) test('integerPowMod', [], compile_and_run, ['']) test('integerGcdExt', [], compile_and_run, ['']) test('integerRecipMod', [], compile_and_run, ['']) +test('bignumMatch', [], compile, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/bignumMatch.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -ddump-rule-firings -O0 -v0 #-} + +module Test where + +import GHC.Num.Integer + +foo :: Integer +foo = IS 45# `integerAdd` (IS 0# `integerMul` IS 18#) ===================================== testsuite/tests/lib/integer/bignumMatch.stderr ===================================== @@ -0,0 +1,2 @@ +Rule fired: integerMul (BUILTIN) +Rule fired: integerAdd (BUILTIN) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12191a99d3b978b697ec0fb4412276fbea5dce8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12191a99d3b978b697ec0fb4412276fbea5dce8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:47:41 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:47:41 -0400 Subject: [Git][ghc/ghc][master] ApiAnnotations : preserve parens in GADTs Message-ID: <5f805bed93acf_80b3f84680460241785969e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 5 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -106,6 +106,7 @@ import GHC.Utils.Misc ( count ) import Data.Data hiding ( Fixity, Prefix, Infix ) import Data.Maybe +import GHC.Parser.Annotation {- ************************************************************************ @@ -1325,17 +1326,20 @@ mkHsAppKindTy ext ty k -- splitHsFunType decomposes a type (t1 -> t2 ... -> tn) -- Breaks up any parens in the result type: -- splitHsFunType (a -> (b -> c)) = ([a,b], c) +-- It returns API Annotations for any parens removed splitHsFunType :: LHsType (GhcPass p) - -> ([HsScaled (GhcPass p) (LHsType (GhcPass p))], LHsType (GhcPass p)) -splitHsFunType (L _ (HsParTy _ ty)) - = splitHsFunType ty + -> ([HsScaled (GhcPass p) (LHsType (GhcPass p))], LHsType (GhcPass p), [AddAnn]) +splitHsFunType ty = go ty [] + where + go (L l (HsParTy _ ty)) anns + = go ty (anns ++ mkParensApiAnn l) -splitHsFunType (L _ (HsFunTy _ mult x y)) - | (args, res) <- splitHsFunType y - = (HsScaled mult x:args, res) + go (L _ (HsFunTy _ mult x y)) anns + | (args, res, anns') <- go y anns + = (HsScaled mult x:args, res, anns') -splitHsFunType other = ([], other) + go other anns = ([], other, anns) -- | Retrieve the name of the \"head\" of a nested type application. -- This is somewhat like @GHC.Tc.Gen.HsType.splitHsAppTys@, but a little more ===================================== compiler/GHC/Parser.y ===================================== @@ -2055,12 +2055,14 @@ type :: { LHsType GhcPs } >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) [mu AnnRarrow $2] } - | btype mult '->' ctype {% hintLinear (getLoc $2) >> - ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) + | btype mult '->' ctype {% hintLinear (getLoc $2) + >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) [mu AnnRarrow $3] } - | btype '->.' ctype {% hintLinear (getLoc $2) >> - ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + | btype '->.' ctype {% hintLinear (getLoc $2) + >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) [mu AnnLollyU $2] } mult :: { Located (HsArrow GhcPs) } @@ -2285,9 +2287,9 @@ gadt_constr :: { LConDecl GhcPs } -- see Note [Difference in parsing GADT and data constructors] -- Returns a list because of: C,D :: ty : optSemi con_list '::' sigtype - {% do { decl <- mkGadtDecl (unLoc $2) $4 + {% do { (decl, anns) <- mkGadtDecl (unLoc $2) $4 ; ams (sLL $2 $> decl) - [mu AnnDcolon $3] } } + (mu AnnDcolon $3:anns) } } {- Note [Difference in parsing GADT and data constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -6,6 +6,7 @@ module GHC.Parser.Annotation ( ApiAnns(..), ApiAnnKey, AnnKeywordId(..), + AddAnn(..),mkParensApiAnn, AnnotationComment(..), IsUnicodeSyntax(..), unicodeAnn, @@ -148,6 +149,44 @@ data ApiAnns = type ApiAnnKey = (RealSrcSpan,AnnKeywordId) +-- --------------------------------------------------------------------- + +-- | Encapsulated call to addAnnotation, requiring only the SrcSpan of +-- the AST construct the annotation belongs to; together with the +-- AnnKeywordId, this is the key of the annotation map. +-- +-- This type is useful for places in the parser where it is not yet +-- known what SrcSpan an annotation should be added to. The most +-- common situation is when we are parsing a list: the annotations +-- need to be associated with the AST element that *contains* the +-- list, not the list itself. 'AddAnn' lets us defer adding the +-- annotations until we finish parsing the list and are now parsing +-- the enclosing element; we then apply the 'AddAnn' to associate +-- the annotations. Another common situation is where a common fragment of +-- the AST has been factored out but there is no separate AST node for +-- this fragment (this occurs in class and data declarations). In this +-- case, the annotation belongs to the parent data declaration. +-- +-- The usual way an 'AddAnn' is created is using the 'mj' ("make jump") +-- function, and then it can be discharged using the 'ams' function. +data AddAnn = AddAnn AnnKeywordId SrcSpan + +-- |Given a 'SrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate +-- 'AddAnn' values for the opening and closing bordering on the start +-- and end of the span +mkParensApiAnn :: SrcSpan -> [AddAnn] +mkParensApiAnn (UnhelpfulSpan _) = [] +mkParensApiAnn (RealSrcSpan ss _) = [AddAnn AnnOpenP lo,AddAnn AnnCloseP lc] + where + f = srcSpanFile ss + sl = srcSpanStartLine ss + sc = srcSpanStartCol ss + el = srcSpanEndLine ss + ec = srcSpanEndCol ss + lo = RealSrcSpan (mkRealSrcSpan (realSrcSpanStart ss) (mkRealSrcLoc f sl (sc+1))) Nothing + lc = RealSrcSpan (mkRealSrcSpan (mkRealSrcLoc f el (ec - 1)) (realSrcSpanEnd ss)) Nothing + +-- --------------------------------------------------------------------- -- | Retrieve a list of annotation 'SrcSpan's based on the 'SrcSpan' -- of the annotated AST element, and the known type of the annotation. getAnnotation :: ApiAnns -> RealSrcSpan -> AnnKeywordId -> [RealSrcSpan] ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -64,7 +64,6 @@ module GHC.Parser.Lexer ( ExtBits(..), xtest, xunset, xset, lexTokenStream, - AddAnn(..),mkParensApiAnn, addAnnsAt, commentToAnnotation, HdkComment(..), @@ -3299,45 +3298,12 @@ clean_pragma prag = canon_ws (map toLower (unprefix prag)) %************************************************************************ -} --- | Encapsulated call to addAnnotation, requiring only the SrcSpan of --- the AST construct the annotation belongs to; together with the --- AnnKeywordId, this is the key of the annotation map. --- --- This type is useful for places in the parser where it is not yet --- known what SrcSpan an annotation should be added to. The most --- common situation is when we are parsing a list: the annotations --- need to be associated with the AST element that *contains* the --- list, not the list itself. 'AddAnn' lets us defer adding the --- annotations until we finish parsing the list and are now parsing --- the enclosing element; we then apply the 'AddAnn' to associate --- the annotations. Another common situation is where a common fragment of --- the AST has been factored out but there is no separate AST node for --- this fragment (this occurs in class and data declarations). In this --- case, the annotation belongs to the parent data declaration. --- --- The usual way an 'AddAnn' is created is using the 'mj' ("make jump") --- function, and then it can be discharged using the 'ams' function. -data AddAnn = AddAnn AnnKeywordId SrcSpan addAnnotationOnly :: RealSrcSpan -> AnnKeywordId -> RealSrcSpan -> P () addAnnotationOnly l a v = P $ \s -> POk s { annotations = ((l,a), [v]) : annotations s } () --- |Given a 'SrcSpan' that surrounds a 'HsPar' or 'HsParTy', generate --- 'AddAnn' values for the opening and closing bordering on the start --- and end of the span -mkParensApiAnn :: SrcSpan -> [AddAnn] -mkParensApiAnn (UnhelpfulSpan _) = [] -mkParensApiAnn (RealSrcSpan ss _) = [AddAnn AnnOpenP lo,AddAnn AnnCloseP lc] - where - f = srcSpanFile ss - sl = srcSpanStartLine ss - sc = srcSpanStartCol ss - el = srcSpanEndLine ss - ec = srcSpanEndCol ss - lo = RealSrcSpan (mkRealSrcSpan (realSrcSpanStart ss) (mkRealSrcLoc f sl (sc+1))) Nothing - lc = RealSrcSpan (mkRealSrcSpan (mkRealSrcLoc f el (ec - 1)) (realSrcSpanEnd ss)) Nothing queueComment :: RealLocated Token -> P() queueComment c = P $ \s -> POk s { ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -633,16 +633,16 @@ mkConDeclH98 name mb_forall mb_cxt args -- Note [GADT abstract syntax] in "GHC.Hs.Decls" for more details. mkGadtDecl :: [Located RdrName] -> LHsType GhcPs - -> P (ConDecl GhcPs) + -> P (ConDecl GhcPs, [AddAnn]) mkGadtDecl names ty = do - let (args, res_ty) + let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty) + = (RecCon (L loc rf), res_ty, []) | otherwise - = let (arg_types, res_type) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type) + = let (arg_types, res_type, anns) = splitHsFunType body_ty + in (PrefixCon arg_types, res_type, anns) - pure $ ConDeclGADT { con_g_ext = noExtField + pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs @@ -650,6 +650,7 @@ mkGadtDecl names ty = do , con_args = args , con_res_ty = res_ty , con_doc = Nothing } + , anns ) where (mtvs, mcxt, body_ty) = splitLHsGadtTy ty View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36787bba78ae5acbb857c84b85b8feb7c83e54a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36787bba78ae5acbb857c84b85b8feb7c83e54a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:48:23 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:48:23 -0400 Subject: [Git][ghc/ghc][master] Linear types: fix roles in GADTs (#18799) Message-ID: <5f805c17caf31_80b3f8454535c9c17866082@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 4 changed files: - compiler/GHC/Tc/TyCl/Utils.hs - + testsuite/tests/linear/should_fail/LinearRole.hs - + testsuite/tests/linear/should_fail/LinearRole.stderr - testsuite/tests/linear/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -580,8 +580,8 @@ irDataCon :: DataCon -> RoleM () irDataCon datacon = setRoleInferenceVars univ_tvs $ irExTyVars ex_tvs $ \ ex_var_set -> - mapM_ (irType ex_var_set) - (map tyVarKind ex_tvs ++ eqSpecPreds eq_spec ++ theta ++ (map scaledThing arg_tys)) + do mapM_ (irType ex_var_set) (eqSpecPreds eq_spec ++ theta ++ map scaledThing arg_tys) + mapM_ (markNominal ex_var_set) (map tyVarKind ex_tvs ++ map scaledMult arg_tys) -- Field multiplicities are nominal (#18799) -- See Note [Role-checking data constructor arguments] where (univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _res_ty) ===================================== testsuite/tests/linear/should_fail/LinearRole.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE LinearTypes, GADTs, DataKinds #-} + +module LinearRole where -- #18799 + +import GHC.Types (Multiplicity(..)) +import Data.Coerce + +data T m a where + MkT :: a %m -> T m a + +f :: T 'One a -> T 'Many a +f x = coerce x ===================================== testsuite/tests/linear/should_fail/LinearRole.stderr ===================================== @@ -0,0 +1,6 @@ + +LinearRole.hs:12:7: error: + • Couldn't match type ‘'One’ with ‘'Many’ + arising from a use of ‘coerce’ + • In the expression: coerce x + In an equation for ‘f’: f x = coerce x ===================================== testsuite/tests/linear/should_fail/all.T ===================================== @@ -17,6 +17,7 @@ test('LinearSeq', normal, compile_fail, ['']) test('LinearViewPattern', normal, compile_fail, ['']) test('LinearConfusedDollar', normal, compile_fail, ['']) test('LinearPatSyn', normal, compile_fail, ['']) +test('LinearRole', normal, compile_fail, ['']) test('LinearGADTNewtype', normal, compile_fail, ['']) test('LinearPartialSig', normal, compile_fail, ['']) test('LinearKind', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32dc7698a0c38afe2889119a2df0f2a2b8debe0a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/32dc7698a0c38afe2889119a2df0f2a2b8debe0a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:49:01 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:49:01 -0400 Subject: [Git][ghc/ghc][master] sdist: Include hadrian sources in source distribution Message-ID: <5f805c3da19df_80b3f83f3fda0c817870514@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - 1 changed file: - ghc.mk Changes: ===================================== ghc.mk ===================================== @@ -1173,7 +1173,8 @@ SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME). # Files to include in source distributions # SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \ - utils docs rts compiler ghc driver libraries libffi-tarballs + utils docs rts compiler ghc driver libraries libffi-tarballs \ + hadrian SRC_DIST_GHC_FILES += \ configure.ac config.guess config.sub configure \ aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \ @@ -1214,6 +1215,7 @@ sdist-ghc-prep-tree : cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/) + $(call removeTrees,$(SRC_DIST_GHC_DIR)/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123]) $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk) $(call removeFiles,$(SRC_DIST_GHC_DIR)/rts/rts.cabal) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9657f6f34a1a00008a0db935dbf25733cb483cd4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9657f6f34a1a00008a0db935dbf25733cb483cd4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:49:37 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:49:37 -0400 Subject: [Git][ghc/ghc][master] winio: fixed timeouts non-threaded. Message-ID: <5f805c61ee3c2_80b3f848d5d1938178709e5@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 1 changed file: - rts/win32/AsyncWinIO.c Changes: ===================================== rts/win32/AsyncWinIO.c ===================================== @@ -203,9 +203,6 @@ static CONDITION_VARIABLE threadIOWait; static uint32_t num_callbacks = 32; /* Buffer for I/O request information. */ static OVERLAPPED_ENTRY *entries; -/* Number of I/O calls verified to have completed in the last round by the - Haskell I/O Manager. */ -static uint32_t num_last_completed; /* Notify the Haskell side of this many new finished requests */ static uint32_t num_notify; @@ -342,15 +339,15 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo bool interrupt = false; - if (num_req == 0 && !has_timeout) { + if (mssec == 0 && !has_timeout) { timeout = INFINITE; } else if(has_timeout) { timeout = mssec; } - outstanding_service_requests = pending_service; + outstanding_service_requests = false; - //Resize queue if required + /* Resize queue if required. */ if (queue_full) { num_callbacks *= 2; @@ -365,7 +362,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo /* If the new timeout is earlier than the old one we have to reschedule the wait. Do this by interrupting the current operation and setting the new timeout, since it must be the shortest one in the queue. */ - if (timeout > mssec) + if (timeout > mssec && mssec > 0) { timeout = mssec; interrupt = true; @@ -373,9 +370,9 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo ReleaseSRWLockExclusive (&wio_runner_lock); - // Since we call registerAlertableWait only after - // processing I/O requests it's always desireable to wake - // up the runner here. + /* Since we call registerAlertableWait only after + processing I/O requests it's always desireable to wake + up the runner here. */ WakeConditionVariable (&wakeEvent); if (interrupt) { @@ -394,7 +391,7 @@ void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, boo registerAlertableWait call. */ OVERLAPPED_ENTRY* getOverlappedEntries (uint32_t *num) { - *num = num_last_completed; + *num = num_notify; return entries; } @@ -428,8 +425,8 @@ void awaitAsyncRequests (bool wait) static void notifyScheduler(uint32_t num) { AcquireSRWLockExclusive (&wio_runner_lock); ASSERT(!canQueueIOThread); - canQueueIOThread = true; num_notify = num; + canQueueIOThread = true; WakeConditionVariable(&threadIOWait); ReleaseSRWLockExclusive (&wio_runner_lock); } @@ -454,7 +451,6 @@ bool queueIOThread() if(canQueueIOThread) { ASSERT(!outstanding_service_requests); - num_last_completed = num_notify; outstanding_service_requests = true; canQueueIOThread = false; Capability *cap = &MainCapability; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c832f7e2a9314cfd61257cb161b1795b612d12b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c832f7e2a9314cfd61257cb161b1795b612d12b5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:50:17 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:50:17 -0400 Subject: [Git][ghc/ghc][master] winio: fix array splat Message-ID: <5f805c894c8a9_80b3f848d5d1938178755be@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 1 changed file: - libraries/base/GHC/Event/Array.hs Changes: ===================================== libraries/base/GHC/Event/Array.hs ===================================== @@ -142,13 +142,17 @@ unsafeLoad (Array ref) load = do -- | Reads n elements from the pointer and copies them -- into the array. -unsafeCopyFromBuffer :: Array a -> Ptr a -> Int -> IO () +unsafeCopyFromBuffer :: Storable a => Array a -> Ptr a -> Int -> IO () unsafeCopyFromBuffer (Array ref) sptr n = readIORef ref >>= \(AC es _ cap) -> - CHECK_BOUNDS("unsafeCopyFromBuffer", cap, n-1) + CHECK_BOUNDS("unsafeCopyFromBuffer", cap, n) withForeignPtr es $ \pdest -> do - _ <- memcpy pdest sptr (fromIntegral n) + let size = sizeOfPtr sptr undefined + _ <- memcpy pdest sptr (fromIntegral $ n * size) writeIORef ref (AC es n cap) + where + sizeOfPtr :: Storable a => Ptr a -> a -> Int + sizeOfPtr _ a = sizeOf a ensureCapacity :: Storable a => Array a -> Int -> IO () ensureCapacity (Array ref) c = do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f0243ae5b359124936a8ff3dd0a287df3d7aca2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f0243ae5b359124936a8ff3dd0a287df3d7aca2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:50:57 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:50:57 -0400 Subject: [Git][ghc/ghc][master] winio: fixed bytestring reading interface. Message-ID: <5f805cb1e1ecf_80b3f848d5d193817879037@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - 4 changed files: - libraries/base/GHC/IO/Handle/Text.hs - libraries/base/tests/IO/all.T - + libraries/base/tests/IO/bytestringread001.hs - + libraries/base/tests/IO/bytestringread001.stdout Changes: ===================================== libraries/base/GHC/IO/Handle/Text.hs ===================================== @@ -1017,10 +1017,13 @@ hGetBufSome h !ptr count | otherwise = wantReadableHandle_ "hGetBufSome" h $ \ h_ at Handle__{..} -> do flushCharReadBuffer h_ - buf at Buffer{ bufSize=sz } <- readIORef haByteBuffer + buf at Buffer{ bufSize=sz, bufOffset=offset } <- readIORef haByteBuffer if isEmptyBuffer buf then case count > sz of -- large read? optimize it with a little special case: - True -> RawIO.read haDevice (castPtr ptr) 0 count + True -> do bytes <- RawIO.read haDevice (castPtr ptr) offset count + -- Update buffer with actual bytes written. + writeIORef haByteBuffer $! bufferAddOffset bytes buf + return bytes _ -> do (r,buf') <- Buffered.fillReadBuffer haDevice buf if r == 0 then return 0 @@ -1074,7 +1077,9 @@ bufReadNBEmpty h_ at Handle__{..} m <- RawIO.readNonBlocking haDevice ptr offset count case m of Nothing -> return so_far - Just n -> return (so_far + n) + Just n -> do -- Update buffer with actual bytes written. + writeIORef haByteBuffer $! bufferAddOffset n buf + return (so_far + n) | otherwise = do -- buf <- readIORef haByteBuffer ===================================== libraries/base/tests/IO/all.T ===================================== @@ -149,3 +149,4 @@ test('T17414', high_memory_usage], compile_and_run, ['']) test('T17510', expect_broken(17510), compile_and_run, ['']) +test('bytestringread001', extra_run_opts('test.data'), compile_and_run, ['']) ===================================== libraries/base/tests/IO/bytestringread001.hs ===================================== @@ -0,0 +1,33 @@ +import System.Environment +import qualified Data.ByteString.Lazy as BL +import Data.Word + +fold_tailrec :: (a -> b -> a) -> a -> [b] -> a +fold_tailrec _ acc [] = + acc +fold_tailrec foldFun acc (x : xs) = + fold_tailrec foldFun (foldFun acc x) xs + +fold_tailrec' :: (a -> b -> a) -> a -> [b] -> a +fold_tailrec' _ acc [] = + acc +fold_tailrec' foldFun acc (x : xs) = + let acc' = foldFun acc x + in seq acc' (fold_tailrec' foldFun acc' xs) + +main :: IO () +main = + do + args <- getArgs + let filename = head args + + -- generate file + let dt = replicate (65 * 1024) 'a' + writeFile filename dt + + byteString <- BL.readFile filename + let wordsList = BL.unpack byteString + -- wordsList is supposed to be lazy (bufferized) + let bytesCount = fold_tailrec (\acc word -> acc + 1) 0 wordsList + print ("Total bytes in " ++ filename ++ ": " + ++ (show bytesCount)) ===================================== libraries/base/tests/IO/bytestringread001.stdout ===================================== @@ -0,0 +1 @@ +"Total bytes in test.data: 66560" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fd3d360cab977e00fb6d90d0519962227b029bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fd3d360cab977e00fb6d90d0519962227b029bb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:51:36 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:51:36 -0400 Subject: [Git][ghc/ghc][master] winio: fixed more data error. Message-ID: <5f805cd89e8e4_80b3f848be6b61817883142@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - 1 changed file: - libraries/base/GHC/IO/Windows/Handle.hsc Changes: ===================================== libraries/base/GHC/IO/Windows/Handle.hsc ===================================== @@ -437,7 +437,7 @@ hwndRead hwnd ptr offset bytes | err == #{const STATUS_END_OF_FILE} = Mgr.ioSuccess 0 | err == #{const ERROR_BROKEN_PIPE} = Mgr.ioSuccess 0 | err == #{const STATUS_PIPE_BROKEN} = Mgr.ioSuccess 0 - | err == #{const ERROR_NO_MORE_ITEMS} = Mgr.ioSuccess 0 + | err == #{const ERROR_NO_MORE_ITEMS} = Mgr.ioSuccess $ fromIntegral dwBytes | err == #{const ERROR_MORE_DATA} = Mgr.ioSuccess $ fromIntegral dwBytes | otherwise = Mgr.ioFailed err View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dfaef1cae7a4a0cb8783933274dae7f39d7165a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dfaef1cae7a4a0cb8783933274dae7f39d7165a0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:52:14 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:52:14 -0400 Subject: [Git][ghc/ghc][master] Fix desugaring of record updates on data families Message-ID: <5f805cfe29561_80b3f8426c12c0017886239@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - 8 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Tc/Types/Evidence.hs - + testsuite/tests/indexed-types/should_compile/T18809.hs - testsuite/tests/indexed-types/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -41,6 +41,7 @@ module GHC.Core.Coercion ( downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, mkKindCo, castCoercionKind, castCoercionKindI, + mkFamilyTyConAppCo, mkHeteroCoercionType, mkPrimEqPred, mkReprPrimEqPred, mkPrimEqPredRole, @@ -1528,6 +1529,27 @@ castCoercionKindI g h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) where (Pair t1 t2, r) = coercionKindRole g +mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN +-- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the +-- corresponding family 'Coercion'. E.g: +-- +-- > data family T a +-- > data instance T (Maybe b) = MkT b +-- +-- Where the instance 'TyCon' is :RTL, so: +-- +-- > mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int) +-- +-- cf. 'mkFamilyTyConApp' +mkFamilyTyConAppCo tc cos + | Just (fam_tc, fam_tys) <- tyConFamInst_maybe tc + , let tvs = tyConTyVars tc + fam_cos = ASSERT2( tvs `equalLength` cos, ppr tc <+> ppr cos ) + map (liftCoSubstWith Nominal tvs cos) fam_tys + = mkTyConAppCo Nominal fam_tc fam_cos + | otherwise + = mkTyConAppCo Nominal tc cos + -- See note [Newtype coercions] in GHC.Core.TyCon mkPiCos :: Role -> [Var] -> Coercion -> Coercion ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -581,6 +581,7 @@ variables: purposes of TypeApplications, and as a consequence, they do not come equipped with visibilities (that is, they are TyVars/TyCoVars instead of TyCoVarBinders). + * dcUserTyVarBinders, for the type variables binders in the order in which they originally arose in the user-written type signature. Their order *does* matter for TypeApplications, so they are full TyVarBinders, complete with @@ -601,10 +602,10 @@ dcExTyCoVars. That is, the tyvars in dcUserTyVarBinders are a permutation of ordering, they in fact share the same type variables (with the same Uniques). We sometimes refer to this as "the dcUserTyVarBinders invariant". -dcUserTyVarBinders, as the name suggests, is the one that users will see most of -the time. It's used when computing the type signature of a data constructor (see -dataConWrapperType), and as a result, it's what matters from a TypeApplications -perspective. +dcUserTyVarBinders, as the name suggests, is the one that users will +see most of the time. It's used when computing the type signature of a +data constructor wrapper (see dataConWrapperType), and as a result, +it's what matters from a TypeApplications perspective. Note [The dcEqSpec domain invariant] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -436,8 +436,8 @@ mkTvSubstPrs prs = zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv zipTyEnv tyvars tys | debugIsOn - , not (all isTyVar tyvars) - = pprPanic "zipTyEnv" (ppr tyvars <+> ppr tys) + , not (all isTyVar tyvars && (tyvars `equalLength` tys)) + = pprPanic "zipTyEnv" (ppr tyvars $$ ppr tys) | otherwise = ASSERT( all (not . isCoercionTy) tys ) zipToUFM tyvars tys ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -577,8 +577,9 @@ data RecordUpdTc = RecordUpdTc , rupd_in_tys :: [Type] -- Argument types of *input* record type , rupd_out_tys :: [Type] -- and *output* record type - -- The original type can be reconstructed - -- with conLikeResTy + -- For a data family, these are the type args of the + -- /representation/ type constructor + , rupd_wrap :: HsWrapper -- See note [Record Update HsWrapper] } ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Tc.Types.Evidence import GHC.Tc.Utils.Monad import GHC.Core.Type import GHC.Core.Multiplicity +import GHC.Core.Coercion( Coercion ) import GHC.Core import GHC.Core.Utils import GHC.Core.Make @@ -53,6 +54,7 @@ import GHC.Driver.Session import GHC.Types.CostCentre import GHC.Types.Id import GHC.Types.Id.Make +import GHC.Types.Var.Env import GHC.Unit.Module import GHC.Core.ConLike import GHC.Core.DataCon @@ -61,14 +63,12 @@ import GHC.Builtin.Types import GHC.Builtin.Names import GHC.Types.Basic import GHC.Data.Maybe -import GHC.Types.Var.Env import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Data.Bag import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic import GHC.Core.PatSyn - import Control.Monad {- @@ -618,13 +618,70 @@ Note [Update for GADTs] ~~~~~~~~~~~~~~~~~~~~~~~ Consider data T a b where - T1 :: { f1 :: a } -> T a Int + MkT :: { foo :: a } -> T a Int + + upd :: T s t -> s -> T s t + upd z y = z { foo = y} + +We need to get this: + $WMkT :: a -> T a Int + MkT :: (b ~# Int) => a -> T a b + + upd = /\s t. \(z::T s t) (y::s) -> + case z of + MkT (co :: t ~# Int) _ -> $WMkT @s y |> T (Refl s) (Sym co) -Then the wrapper function for T1 has type - $WT1 :: a -> T a Int -But if x::T a b, then - x { f1 = v } :: T a b (not T a Int!) -So we need to cast (T a Int) to (T a b). Sigh. +Note the final cast + T (Refl s) (Sym co) :: T s Int ~ T s t +which uses co, bound by the GADT match. This is the wrap_co coercion +in wrapped_rhs. How do we produce it? + +* Start with raw materials + tc, the tycon: T + univ_tvs, the universally quantified tyvars of MkT: a,b + NB: these are in 1-1 correspondence with the tyvars of tc + +* Form univ_cos, a coercion for each of tc's args: (Refl s) (Sym co) + We replaced + a by (Refl s) since 's' instantiates 'a' + b by (Sym co) since 'b' is in the data-con's EqSpec + +* Then form the coercion T (Refl s) (Sym co) + +It gets more complicated when data families are involved (#18809). +Consider + data family F x + data instance F (a,b) where + MkF :: { foo :: Int } -> F (Int,b) + + bar :: F (s,t) -> Int -> F (s,t) + bar z y = z { foo = y} + +We have + data R:FPair a b where + MkF :: { foo :: Int } -> R:FPair Int b + + $WMkF :: Int -> F (Int,b) + MkF :: forall a b. (a ~# Int) => Int -> R:FPair a b + + bar :: F (s,t) -> Int -> F (s,t) + bar = /\s t. \(z::F (s,t)) \(y::Int) -> + case z |> co1 of + MkF (co2::s ~# Int) _ -> $WMkF @t y |> co3 + +(Side note: here (z |> co1) is built by typechecking the scrutinee, so +we ignore it here. In general the scrutinee is an aribtrary expression.) + +The question is: what is co3, the cast for the RHS? + co3 :: F (Int,t) ~ F (s,t) +Again, we can construct it using co2, bound by the GADT match. +We do /exactly/ the same as the non-family case up to building +univ_cos. But that gives us + rep_tc: R:FPair + univ_cos: (Sym co2) (Refl t) +But then we use mkTcFamilyTyConAppCo to "lift" this to the coercion +we want, namely + F (Sym co2, Refl t) :: F (Int,t) ~ F (s,t) -} @@ -711,8 +768,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields dict_req_wrap <.> mkWpTyApps [ lookupTyVar out_subst tv `orElse` mkTyVarTy tv - | tv <- user_tvs - , not (tv `elemVarEnv` wrap_subst) ] + | tv <- user_tvs ] -- Be sure to use user_tvs (which may be ordered -- differently than `univ_tvs ++ ex_tvs) above. -- See Note [DataCon user type variable binders] @@ -723,27 +779,30 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields -- Note [Update for GADTs] wrapped_rhs = case con of - RealDataCon data_con -> - let - wrap_co = - mkTcTyConAppCo Nominal - (dataConTyCon data_con) - [ lookup tv ty - | (tv,ty) <- univ_tvs `zip` out_inst_tys ] - lookup univ_tv ty = - case lookupVarEnv wrap_subst univ_tv of - Just co' -> co' - Nothing -> mkTcReflCo Nominal ty - in if null eq_spec - then rhs - else mkLHsWrap (mkWpCastN wrap_co) rhs + RealDataCon data_con + | null eq_spec -> rhs + | otherwise -> mkLHsWrap (mkWpCastN wrap_co) rhs + -- This wrap is the punchline: Note [Update for GADTs] + where + rep_tc = dataConTyCon data_con + wrap_co = mkTcFamilyTyConAppCo rep_tc univ_cos + univ_cos = zipWithEqual "dsExpr:upd" mk_univ_co univ_tvs out_inst_tys + + mk_univ_co :: TyVar -- Universal tyvar from the DataCon + -> Type -- Corresponding instantiating type + -> Coercion + mk_univ_co univ_tv inst_ty + = case lookupVarEnv eq_spec_env univ_tv of + Just co -> co + Nothing -> mkTcNomReflCo inst_ty + + eq_spec_env :: VarEnv Coercion + eq_spec_env = mkVarEnv [ (eqSpecTyVar spec, mkTcSymCo (mkTcCoVarCo eqs_var)) + | (spec,eqs_var) <- zipEqual "dsExpr:upd2" eq_spec eqs_vars ] + -- eq_spec is always null for a PatSynCon PatSynCon _ -> rhs - wrap_subst = - mkVarEnv [ (tv, mkTcSymCo (mkTcCoVarCo eq_var)) - | (spec, eq_var) <- eq_spec `zip` eqs_vars - , let tv = eqSpecTyVar spec ] req_wrap = dict_req_wrap <.> mkWpTyApps in_inst_tys ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -48,6 +48,7 @@ module GHC.Tc.Types.Evidence ( mkTcKindCo, tcCoercionKind, mkTcCoVarCo, + mkTcFamilyTyConAppCo, isTcReflCo, isTcReflexiveCo, tcCoercionRole, unwrapIP, wrapIP, @@ -141,6 +142,7 @@ mkTcCoherenceRightCo :: Role -> TcType -> TcCoercionN mkTcPhantomCo :: TcCoercionN -> TcType -> TcType -> TcCoercionP mkTcKindCo :: TcCoercion -> TcCoercionN mkTcCoVarCo :: CoVar -> TcCoercion +mkTcFamilyTyConAppCo :: TyCon -> [TcCoercionN] -> TcCoercionN tcCoercionKind :: TcCoercion -> Pair TcType tcCoercionRole :: TcCoercion -> Role @@ -174,6 +176,7 @@ mkTcCoherenceRightCo = mkCoherenceRightCo mkTcPhantomCo = mkPhantomCo mkTcKindCo = mkKindCo mkTcCoVarCo = mkCoVarCo +mkTcFamilyTyConAppCo = mkFamilyTyConAppCo tcCoercionKind = coercionKind tcCoercionRole = coercionRole ===================================== testsuite/tests/indexed-types/should_compile/T18809.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE GADTs, TypeFamilies #-} + +module T18809 where + +-- Ordinary +data F2 s where + MkF2 :: { foo2 :: Int } -> F2 s + +bar2 :: F2 s -> Int -> F2 s +bar2 z y = z { foo2 = y } + +-- GADT +data F1 s where + MkF1 :: { foo1 :: Int } -> F1 Int + +bar1 :: F1 s -> Int -> F1 s +bar1 z y = z { foo1 = y } + +-- Orinary data family +data family F3 a +data instance F3 (s,t) where + MkF2b :: { foo3 :: Int } -> F3 (s,t) + +bar3 :: F3 (s,t) -> Int -> F3 (s,t) +bar3 z y = z {foo3 = y} + +-- GADT + data family +data family F4 a +data instance F4 (s,t) where + MkF2a :: { foo4 :: Int } -> F4 (Int,t) + +bar4 :: F4 (s,t) -> Int -> F4 (s,t) +bar4 z y = z { foo4 = y} ===================================== testsuite/tests/indexed-types/should_compile/all.T ===================================== @@ -296,3 +296,4 @@ test('T17056', normal, compile, ['']) test('T17405', normal, multimod_compile, ['T17405c', '-v0']) test('T17923', normal, compile, ['']) test('T18065', normal, compile, ['-O']) +test('T18809', normal, compile, ['-O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfdccac6acce84e15292a454d12f4e0d87ef6f10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfdccac6acce84e15292a454d12f4e0d87ef6f10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:53:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:53:28 -0400 Subject: [Git][ghc/ghc][master] Add TyCon Set/Env and use them in a few places. Message-ID: <5f805d483e2e1_80bf54f8441789404@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - 17 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/HsToCore/Pmc/Solver.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/RepType.hs - compiler/ghc.cabal.in - testsuite/tests/parser/should_run/CountParserDeps.hs Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -135,6 +135,7 @@ import GHC.Core.TyCo.Subst import GHC.Core.TyCo.Tidy import GHC.Core.Type import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Core.Coercion.Axiom import {-# SOURCE #-} GHC.Core.Utils ( mkFunctionType ) import GHC.Types.Var ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -52,7 +52,8 @@ import GHC.Core.Type as Type import GHC.Core.Coercion as Type import GHC.Core.DataCon -import GHC.Core.TyCon ( initRecTc, checkRecTc, tyConArity ) +import GHC.Core.TyCon ( tyConArity ) +import GHC.Core.TyCon.RecWalk ( initRecTc, checkRecTc ) import GHC.Core.Predicate ( isDictTy ) import GHC.Core.Multiplicity import GHC.Types.Var.Set ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Core.DataCon import GHC.Core.Coercion hiding( substCo ) import GHC.Core.Rules import GHC.Core.Type hiding ( substTy ) -import GHC.Core.TyCon ( tyConName ) +import GHC.Core.TyCon ( tyConUnique ) import GHC.Core.Multiplicity import GHC.Types.Id import GHC.Core.Ppr ( pprParendExpr ) @@ -56,7 +56,7 @@ import GHC.Types.Unique.FM import GHC.Utils.Monad import Control.Monad ( zipWithM ) import Data.List -import GHC.Builtin.Names ( specTyConName ) +import GHC.Builtin.Names ( specTyConKey ) import GHC.Unit.Module import Data.Ord( comparing ) @@ -983,7 +983,7 @@ forceSpecArgTy env ty forceSpecArgTy env ty | Just (tycon, tys) <- splitTyConApp_maybe ty , tycon /= funTyCon - = tyConName tycon == specTyConName + = tyConUnique tycon == specTyConKey || any (forceSpecArgTy env) tys forceSpecArgTy _ _ = False ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -40,6 +40,7 @@ import GHC.Core.Coercion import GHC.Core.FamInstEnv import GHC.Types.Basic ( Boxity(..) ) import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Types.Unique.Supply import GHC.Types.Unique import GHC.Data.Maybe ===================================== compiler/GHC/Core/Predicate.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Prelude import GHC.Core.Type import GHC.Core.Class import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Types.Var import GHC.Core.Coercion import GHC.Core.Multiplicity ( scaledThing ) ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -126,10 +126,6 @@ module GHC.Core.TyCon( primRepsCompatible, primRepCompatible, - -- * Recursion breaking - RecTcChecker, initRecTc, defaultRecTcMaxBound, - setRecTcMaxBound, checkRecTc - ) where #include "HsVersions.h" @@ -2710,83 +2706,6 @@ instance Binary Injectivity where _ -> do { xs <- get bh ; return (Injective xs) } } -{- -************************************************************************ -* * - Walking over recursive TyCons -* * -************************************************************************ - -Note [Expanding newtypes and products] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When expanding a type to expose a data-type constructor, we need to be -careful about newtypes, lest we fall into an infinite loop. Here are -the key examples: - - newtype Id x = MkId x - newtype Fix f = MkFix (f (Fix f)) - newtype T = MkT (T -> T) - - Type Expansion - -------------------------- - T T -> T - Fix Maybe Maybe (Fix Maybe) - Id (Id Int) Int - Fix Id NO NO NO - -Notice that - * We can expand T, even though it's recursive. - * We can expand Id (Id Int), even though the Id shows up - twice at the outer level, because Id is non-recursive - -So, when expanding, we keep track of when we've seen a recursive -newtype at outermost level; and bail out if we see it again. - -We sometimes want to do the same for product types, so that the -strictness analyser doesn't unbox infinitely deeply. - -More precisely, we keep a *count* of how many times we've seen it. -This is to account for - data instance T (a,b) = MkT (T a) (T b) -Then (#10482) if we have a type like - T (Int,(Int,(Int,(Int,Int)))) -we can still unbox deeply enough during strictness analysis. -We have to treat T as potentially recursive, but it's still -good to be able to unwrap multiple layers. - -The function that manages all this is checkRecTc. --} - -data RecTcChecker = RC !Int (NameEnv Int) - -- The upper bound, and the number of times - -- we have encountered each TyCon - --- | Initialise a 'RecTcChecker' with 'defaultRecTcMaxBound'. -initRecTc :: RecTcChecker -initRecTc = RC defaultRecTcMaxBound emptyNameEnv - --- | The default upper bound (100) for the number of times a 'RecTcChecker' is --- allowed to encounter each 'TyCon'. -defaultRecTcMaxBound :: Int -defaultRecTcMaxBound = 100 --- Should we have a flag for this? - --- | Change the upper bound for the number of times a 'RecTcChecker' is allowed --- to encounter each 'TyCon'. -setRecTcMaxBound :: Int -> RecTcChecker -> RecTcChecker -setRecTcMaxBound new_bound (RC _old_bound rec_nts) = RC new_bound rec_nts - -checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker --- Nothing => Recursion detected --- Just rec_tcs => Keep going -checkRecTc (RC bound rec_nts) tc - = case lookupNameEnv rec_nts tc_name of - Just n | n >= bound -> Nothing - | otherwise -> Just (RC bound (extendNameEnv rec_nts tc_name (n+1))) - Nothing -> Just (RC bound (extendNameEnv rec_nts tc_name 1)) - where - tc_name = tyConName tc - -- | Returns whether or not this 'TyCon' is definite, or a hole -- that may be filled in at some later point. See Note [Skolem abstract data] tyConSkolem :: TyCon -> Bool ===================================== compiler/GHC/Core/TyCon/Env.hs ===================================== @@ -0,0 +1,140 @@ +{- +(c) The University of Glasgow 2006 +(c) The GRASP/AQUA Project, Glasgow University, 1992-1998 + +\section[TyConEnv]{@TyConEnv@: tyCon environments} +-} + +{-# LANGUAGE CPP, DeriveDataTypeable #-} + +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ScopedTypeVariables #-} + + +module GHC.Core.TyCon.Env ( + -- * TyCon environment (map) + TyConEnv, + + -- ** Manipulating these environments + mkTyConEnv, mkTyConEnvWith, + emptyTyConEnv, isEmptyTyConEnv, + unitTyConEnv, nameEnvElts, + extendTyConEnv_C, extendTyConEnv_Acc, extendTyConEnv, + extendTyConEnvList, extendTyConEnvList_C, + filterTyConEnv, anyTyConEnv, + plusTyConEnv, plusTyConEnv_C, plusTyConEnv_CD, plusTyConEnv_CD2, alterTyConEnv, + lookupTyConEnv, lookupTyConEnv_NF, delFromTyConEnv, delListFromTyConEnv, + elemTyConEnv, mapTyConEnv, disjointTyConEnv, + + DTyConEnv, + + emptyDTyConEnv, + lookupDTyConEnv, + delFromDTyConEnv, filterDTyConEnv, + mapDTyConEnv, + adjustDTyConEnv, alterDTyConEnv, extendDTyConEnv, + ) where + +#include "HsVersions.h" + +import GHC.Prelude + +import GHC.Types.Unique.FM +import GHC.Types.Unique.DFM +import GHC.Core.TyCon (TyCon) + +import GHC.Data.Maybe + +{- +************************************************************************ +* * +\subsection{TyCon environment} +* * +************************************************************************ +-} + +-- | TyCon Environment +type TyConEnv a = UniqFM TyCon a -- Domain is TyCon + +emptyTyConEnv :: TyConEnv a +isEmptyTyConEnv :: TyConEnv a -> Bool +mkTyConEnv :: [(TyCon,a)] -> TyConEnv a +mkTyConEnvWith :: (a -> TyCon) -> [a] -> TyConEnv a +nameEnvElts :: TyConEnv a -> [a] +alterTyConEnv :: (Maybe a-> Maybe a) -> TyConEnv a -> TyCon -> TyConEnv a +extendTyConEnv_C :: (a->a->a) -> TyConEnv a -> TyCon -> a -> TyConEnv a +extendTyConEnv_Acc :: (a->b->b) -> (a->b) -> TyConEnv b -> TyCon -> a -> TyConEnv b +extendTyConEnv :: TyConEnv a -> TyCon -> a -> TyConEnv a +plusTyConEnv :: TyConEnv a -> TyConEnv a -> TyConEnv a +plusTyConEnv_C :: (a->a->a) -> TyConEnv a -> TyConEnv a -> TyConEnv a +plusTyConEnv_CD :: (a->a->a) -> TyConEnv a -> a -> TyConEnv a -> a -> TyConEnv a +plusTyConEnv_CD2 :: (Maybe a->Maybe a->a) -> TyConEnv a -> TyConEnv a -> TyConEnv a +extendTyConEnvList :: TyConEnv a -> [(TyCon,a)] -> TyConEnv a +extendTyConEnvList_C :: (a->a->a) -> TyConEnv a -> [(TyCon,a)] -> TyConEnv a +delFromTyConEnv :: TyConEnv a -> TyCon -> TyConEnv a +delListFromTyConEnv :: TyConEnv a -> [TyCon] -> TyConEnv a +elemTyConEnv :: TyCon -> TyConEnv a -> Bool +unitTyConEnv :: TyCon -> a -> TyConEnv a +lookupTyConEnv :: TyConEnv a -> TyCon -> Maybe a +lookupTyConEnv_NF :: TyConEnv a -> TyCon -> a +filterTyConEnv :: (elt -> Bool) -> TyConEnv elt -> TyConEnv elt +anyTyConEnv :: (elt -> Bool) -> TyConEnv elt -> Bool +mapTyConEnv :: (elt1 -> elt2) -> TyConEnv elt1 -> TyConEnv elt2 +disjointTyConEnv :: TyConEnv a -> TyConEnv a -> Bool + +nameEnvElts x = eltsUFM x +emptyTyConEnv = emptyUFM +isEmptyTyConEnv = isNullUFM +unitTyConEnv x y = unitUFM x y +extendTyConEnv x y z = addToUFM x y z +extendTyConEnvList x l = addListToUFM x l +lookupTyConEnv x y = lookupUFM x y +alterTyConEnv = alterUFM +mkTyConEnv l = listToUFM l +mkTyConEnvWith f = mkTyConEnv . map (\a -> (f a, a)) +elemTyConEnv x y = elemUFM x y +plusTyConEnv x y = plusUFM x y +plusTyConEnv_C f x y = plusUFM_C f x y +plusTyConEnv_CD f x d y b = plusUFM_CD f x d y b +plusTyConEnv_CD2 f x y = plusUFM_CD2 f x y +extendTyConEnv_C f x y z = addToUFM_C f x y z +mapTyConEnv f x = mapUFM f x +extendTyConEnv_Acc x y z a b = addToUFM_Acc x y z a b +extendTyConEnvList_C x y z = addListToUFM_C x y z +delFromTyConEnv x y = delFromUFM x y +delListFromTyConEnv x y = delListFromUFM x y +filterTyConEnv x y = filterUFM x y +anyTyConEnv f x = foldUFM ((||) . f) False x +disjointTyConEnv x y = disjointUFM x y + +lookupTyConEnv_NF env n = expectJust "lookupTyConEnv_NF" (lookupTyConEnv env n) + +-- | Deterministic TyCon Environment +-- +-- See Note [Deterministic UniqFM] in "GHC.Types.Unique.DFM" for explanation why +-- we need DTyConEnv. +type DTyConEnv a = UniqDFM TyCon a + +emptyDTyConEnv :: DTyConEnv a +emptyDTyConEnv = emptyUDFM + +lookupDTyConEnv :: DTyConEnv a -> TyCon -> Maybe a +lookupDTyConEnv = lookupUDFM + +delFromDTyConEnv :: DTyConEnv a -> TyCon -> DTyConEnv a +delFromDTyConEnv = delFromUDFM + +filterDTyConEnv :: (a -> Bool) -> DTyConEnv a -> DTyConEnv a +filterDTyConEnv = filterUDFM + +mapDTyConEnv :: (a -> b) -> DTyConEnv a -> DTyConEnv b +mapDTyConEnv = mapUDFM + +adjustDTyConEnv :: (a -> a) -> DTyConEnv a -> TyCon -> DTyConEnv a +adjustDTyConEnv = adjustUDFM + +alterDTyConEnv :: (Maybe a -> Maybe a) -> DTyConEnv a -> TyCon -> DTyConEnv a +alterDTyConEnv = alterUDFM + +extendDTyConEnv :: DTyConEnv a -> TyCon -> a -> DTyConEnv a +extendDTyConEnv = addToUDFM ===================================== compiler/GHC/Core/TyCon/RecWalk.hs ===================================== @@ -0,0 +1,99 @@ +{- +(c) The University of Glasgow 2006 +(c) The GRASP/AQUA Project, Glasgow University, 1992-1998 + +Check for recursive type constructors. + +-} + +{-# LANGUAGE CPP, DeriveDataTypeable #-} + +module GHC.Core.TyCon.RecWalk ( + + -- * Recursion breaking + RecTcChecker, initRecTc, defaultRecTcMaxBound, + setRecTcMaxBound, checkRecTc + + ) where + +#include "HsVersions.h" + +import GHC.Prelude + +import GHC.Core.TyCon +import GHC.Core.TyCon.Env + +{- +************************************************************************ +* * + Walking over recursive TyCons +* * +************************************************************************ + +Note [Expanding newtypes and products] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When expanding a type to expose a data-type constructor, we need to be +careful about newtypes, lest we fall into an infinite loop. Here are +the key examples: + + newtype Id x = MkId x + newtype Fix f = MkFix (f (Fix f)) + newtype T = MkT (T -> T) + + Type Expansion + -------------------------- + T T -> T + Fix Maybe Maybe (Fix Maybe) + Id (Id Int) Int + Fix Id NO NO NO + +Notice that + * We can expand T, even though it's recursive. + * We can expand Id (Id Int), even though the Id shows up + twice at the outer level, because Id is non-recursive + +So, when expanding, we keep track of when we've seen a recursive +newtype at outermost level; and bail out if we see it again. + +We sometimes want to do the same for product types, so that the +strictness analyser doesn't unbox infinitely deeply. + +More precisely, we keep a *count* of how many times we've seen it. +This is to account for + data instance T (a,b) = MkT (T a) (T b) +Then (#10482) if we have a type like + T (Int,(Int,(Int,(Int,Int)))) +we can still unbox deeply enough during strictness analysis. +We have to treat T as potentially recursive, but it's still +good to be able to unwrap multiple layers. + +The function that manages all this is checkRecTc. +-} + +data RecTcChecker = RC !Int (TyConEnv Int) + -- The upper bound, and the number of times + -- we have encountered each TyCon + +-- | Initialise a 'RecTcChecker' with 'defaultRecTcMaxBound'. +initRecTc :: RecTcChecker +initRecTc = RC defaultRecTcMaxBound emptyTyConEnv + +-- | The default upper bound (100) for the number of times a 'RecTcChecker' is +-- allowed to encounter each 'TyCon'. +defaultRecTcMaxBound :: Int +defaultRecTcMaxBound = 100 +-- Should we have a flag for this? + +-- | Change the upper bound for the number of times a 'RecTcChecker' is allowed +-- to encounter each 'TyCon'. +setRecTcMaxBound :: Int -> RecTcChecker -> RecTcChecker +setRecTcMaxBound new_bound (RC _old_bound rec_nts) = RC new_bound rec_nts + +checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker +-- Nothing => Recursion detected +-- Just rec_tcs => Keep going +checkRecTc (RC bound rec_nts) tc + = case lookupTyConEnv rec_nts tc of + Just n | n >= bound -> Nothing + | otherwise -> Just (RC bound (extendTyConEnv rec_nts tc (n+1))) + Nothing -> Just (RC bound (extendTyConEnv rec_nts tc 1)) ===================================== compiler/GHC/Core/TyCon/Set.hs ===================================== @@ -0,0 +1,73 @@ +{- +(c) The University of Glasgow 2006 +(c) The GRASP/AQUA Project, Glasgow University, 1992-1998 + +-} + +{-# LANGUAGE CPP, DeriveDataTypeable #-} + +module GHC.Core.TyCon.Set ( + -- * TyCons set type + TyConSet, + + -- ** Manipulating these sets + emptyTyConSet, unitTyConSet, mkTyConSet, unionTyConSet, unionTyConSets, + minusTyConSet, elemTyConSet, extendTyConSet, extendTyConSetList, + delFromTyConSet, delListFromTyConSet, isEmptyTyConSet, filterTyConSet, + intersectsTyConSet, disjointTyConSet, intersectTyConSet, + nameSetAny, nameSetAll + ) where + +#include "HsVersions.h" + +import GHC.Prelude + +import GHC.Types.Unique.Set +import GHC.Core.TyCon (TyCon) + +type TyConSet = UniqSet TyCon + +emptyTyConSet :: TyConSet +unitTyConSet :: TyCon -> TyConSet +extendTyConSetList :: TyConSet -> [TyCon] -> TyConSet +extendTyConSet :: TyConSet -> TyCon -> TyConSet +mkTyConSet :: [TyCon] -> TyConSet +unionTyConSet :: TyConSet -> TyConSet -> TyConSet +unionTyConSets :: [TyConSet] -> TyConSet +minusTyConSet :: TyConSet -> TyConSet -> TyConSet +elemTyConSet :: TyCon -> TyConSet -> Bool +isEmptyTyConSet :: TyConSet -> Bool +delFromTyConSet :: TyConSet -> TyCon -> TyConSet +delListFromTyConSet :: TyConSet -> [TyCon] -> TyConSet +filterTyConSet :: (TyCon -> Bool) -> TyConSet -> TyConSet +intersectTyConSet :: TyConSet -> TyConSet -> TyConSet +intersectsTyConSet :: TyConSet -> TyConSet -> Bool +-- ^ True if there is a non-empty intersection. +-- @s1 `intersectsTyConSet` s2@ doesn't compute @s2@ if @s1@ is empty +disjointTyConSet :: TyConSet -> TyConSet -> Bool + +isEmptyTyConSet = isEmptyUniqSet +emptyTyConSet = emptyUniqSet +unitTyConSet = unitUniqSet +mkTyConSet = mkUniqSet +extendTyConSetList = addListToUniqSet +extendTyConSet = addOneToUniqSet +unionTyConSet = unionUniqSets +unionTyConSets = unionManyUniqSets +minusTyConSet = minusUniqSet +elemTyConSet = elementOfUniqSet +delFromTyConSet = delOneFromUniqSet +filterTyConSet = filterUniqSet +intersectTyConSet = intersectUniqSets +disjointTyConSet = disjointUniqSets + + +delListFromTyConSet set ns = foldl' delFromTyConSet set ns + +intersectsTyConSet s1 s2 = not (isEmptyTyConSet (s1 `intersectTyConSet` s2)) + +nameSetAny :: (TyCon -> Bool) -> TyConSet -> Bool +nameSetAny = uniqSetAny + +nameSetAll :: (TyCon -> Bool) -> TyConSet -> Bool +nameSetAll = uniqSetAll ===================================== compiler/GHC/HsToCore/Pmc/Solver.hs ===================================== @@ -67,6 +67,7 @@ import GHC.Core.ConLike import GHC.Core.DataCon import GHC.Core.PatSyn import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Builtin.Types import GHC.Builtin.Types.Prim (tYPETyCon) import GHC.Core.TyCo.Rep ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -58,6 +58,7 @@ import GHC.Types.Name import GHC.Types.Name.Reader import GHC.Core.DataCon import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Tc.Utils.TcType import GHC.Builtin.Names import GHC.Driver.Session ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -174,6 +174,7 @@ import GHC.Core.Predicate import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.DFM +import GHC.Core.TyCon.Env import GHC.Data.Maybe import GHC.Core.Map @@ -2640,7 +2641,7 @@ delFunEq :: FunEqMap a -> TyCon -> [Type] -> FunEqMap a delFunEq m tc tys = delTcApp m (getUnique tc) tys ------------------------------ -type ExactFunEqMap a = UniqFM TyCon (ListMap TypeMap a) +type ExactFunEqMap a = TyConEnv (ListMap TypeMap a) emptyExactFunEqs :: ExactFunEqMap a emptyExactFunEqs = emptyUFM ===================================== compiler/GHC/Tc/TyCl/Utils.hs ===================================== @@ -50,12 +50,13 @@ import GHC.Core.ConLike import GHC.Core.DataCon import GHC.Types.Name import GHC.Types.Name.Env -import GHC.Types.Name.Set hiding (unitFV) import GHC.Types.Name.Reader ( mkVarUnqual ) import GHC.Types.Id import GHC.Types.Id.Info import GHC.Types.Var.Env import GHC.Types.Var.Set +import GHC.Types.Unique.Set +import GHC.Core.TyCon.Set import GHC.Core.Coercion ( ltRole ) import GHC.Types.Basic import GHC.Types.SrcLoc @@ -156,7 +157,11 @@ newtype SynCycleM a = SynCycleM { runSynCycleM :: SynCycleState -> Either (SrcSpan, SDoc) (a, SynCycleState) } deriving (Functor) -type SynCycleState = NameSet +-- TODO: TyConSet is implemented as IntMap over uniques. +-- But we could get away with something based on IntSet +-- since we only check membershib, but never extract the +-- elements. +type SynCycleState = TyConSet instance Applicative SynCycleM where pure x = SynCycleM $ \state -> Right (x, state) @@ -174,12 +179,12 @@ failSynCycleM loc err = SynCycleM $ \_ -> Left (loc, err) -- | Test if a 'Name' is acyclic, short-circuiting if we've -- seen it already. -checkNameIsAcyclic :: Name -> SynCycleM () -> SynCycleM () -checkNameIsAcyclic n m = SynCycleM $ \s -> - if n `elemNameSet` s +checkTyConIsAcyclic :: TyCon -> SynCycleM () -> SynCycleM () +checkTyConIsAcyclic tc m = SynCycleM $ \s -> + if tc `elemTyConSet` s then Right ((), s) -- short circuit else case runSynCycleM m s of - Right ((), s') -> Right ((), extendNameSet s' n) + Right ((), s') -> Right ((), extendTyConSet s' tc) Left err -> Left err -- | Checks if any of the passed in 'TyCon's have cycles. @@ -189,7 +194,7 @@ checkNameIsAcyclic n m = SynCycleM $ \s -> -- can give better error messages. checkSynCycles :: Unit -> [TyCon] -> [LTyClDecl GhcRn] -> TcM () checkSynCycles this_uid tcs tyclds = do - case runSynCycleM (mapM_ (go emptyNameSet []) tcs) emptyNameSet of + case runSynCycleM (mapM_ (go emptyTyConSet []) tcs) emptyTyConSet of Left (loc, err) -> setSrcSpan loc $ failWithTc err Right _ -> return () where @@ -198,15 +203,15 @@ checkSynCycles this_uid tcs tyclds = do -- Short circuit if we've already seen this Name and concluded -- it was acyclic. - go :: NameSet -> [TyCon] -> TyCon -> SynCycleM () + go :: TyConSet -> [TyCon] -> TyCon -> SynCycleM () go so_far seen_tcs tc = - checkNameIsAcyclic (tyConName tc) $ go' so_far seen_tcs tc + checkTyConIsAcyclic tc $ go' so_far seen_tcs tc -- Expand type synonyms, complaining if you find the same -- type synonym a second time. - go' :: NameSet -> [TyCon] -> TyCon -> SynCycleM () + go' :: TyConSet -> [TyCon] -> TyCon -> SynCycleM () go' so_far seen_tcs tc - | n `elemNameSet` so_far + | tc `elemTyConSet` so_far = failSynCycleM (getSrcSpan (head seen_tcs)) $ sep [ text "Cycle in type synonym declarations:" , nest 2 (vcat (map ppr_decl seen_tcs)) ] @@ -221,7 +226,7 @@ checkSynCycles this_uid tcs tyclds = do isInteractiveModule mod) = return () | Just ty <- synTyConRhs_maybe tc = - go_ty (extendNameSet so_far (tyConName tc)) (tc:seen_tcs) ty + go_ty (extendTyConSet so_far tc) (tc:seen_tcs) ty | otherwise = return () where n = tyConName tc @@ -234,7 +239,7 @@ checkSynCycles this_uid tcs tyclds = do where n = tyConName tc - go_ty :: NameSet -> [TyCon] -> Type -> SynCycleM () + go_ty :: TyConSet -> [TyCon] -> Type -> SynCycleM () go_ty so_far seen_tcs ty = mapM_ (go so_far seen_tcs) (synonymTyConsOfType ty) @@ -284,11 +289,13 @@ and now expand superclasses for constraint (C Id): Each step expands superclasses one layer, and clearly does not terminate. -} +type ClassSet = UniqSet Class + checkClassCycles :: Class -> Maybe SDoc -- Nothing <=> ok -- Just err <=> possible cycle error checkClassCycles cls - = do { (definite_cycle, err) <- go (unitNameSet (getName cls)) + = do { (definite_cycle, err) <- go (unitUniqSet cls) cls (mkTyVarTys (classTyVars cls)) ; let herald | definite_cycle = text "Superclass cycle for" | otherwise = text "Potential superclass cycle for" @@ -304,12 +311,12 @@ checkClassCycles cls -- NB: this code duplicates TcType.transSuperClasses, but -- with more error message generation clobber -- Make sure the two stay in sync. - go :: NameSet -> Class -> [Type] -> Maybe (Bool, SDoc) + go :: ClassSet -> Class -> [Type] -> Maybe (Bool, SDoc) go so_far cls tys = firstJusts $ map (go_pred so_far) $ immSuperClasses cls tys - go_pred :: NameSet -> PredType -> Maybe (Bool, SDoc) + go_pred :: ClassSet -> PredType -> Maybe (Bool, SDoc) -- Nothing <=> ok -- Just (True, err) <=> definite cycle -- Just (False, err) <=> possible cycle @@ -322,7 +329,7 @@ checkClassCycles cls | otherwise = Nothing - go_tc :: NameSet -> PredType -> TyCon -> [Type] -> Maybe (Bool, SDoc) + go_tc :: ClassSet -> PredType -> TyCon -> [Type] -> Maybe (Bool, SDoc) go_tc so_far pred tc tys | isFamilyTyCon tc = Just (False, hang (text "one of whose superclass constraints is headed by a type family:") @@ -332,18 +339,16 @@ checkClassCycles cls | otherwise -- Equality predicate, for example = Nothing - go_cls :: NameSet -> Class -> [Type] -> Maybe (Bool, SDoc) + go_cls :: ClassSet -> Class -> [Type] -> Maybe (Bool, SDoc) go_cls so_far cls tys - | cls_nm `elemNameSet` so_far + | cls `elementOfUniqSet` so_far = Just (True, text "one of whose superclasses is" <+> quotes (ppr cls)) | isCTupleClass cls = go so_far cls tys | otherwise - = do { (b,err) <- go (so_far `extendNameSet` cls_nm) cls tys + = do { (b,err) <- go (so_far `addOneToUniqSet` cls) cls tys ; return (b, text "one of whose superclasses is" <+> quotes (ppr cls) $$ err) } - where - cls_nm = getName cls {- ************************************************************************ ===================================== compiler/GHC/Types/Literal.hs ===================================== @@ -646,6 +646,7 @@ absentLiteralOf :: TyCon -> Maybe Literal -- 2. This would need to return a type application to a literal absentLiteralOf tc = lookupUFM absent_lits tc +-- We do not use TyConEnv here to avoid import cycles. absent_lits :: UniqFM TyCon Literal absent_lits = listToUFM_Directly -- Explicitly construct the mape from the known ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -30,6 +30,7 @@ import GHC.Core.DataCon import GHC.Builtin.Names import GHC.Core.Coercion import GHC.Core.TyCon +import GHC.Core.TyCon.RecWalk import GHC.Core.TyCo.Rep import GHC.Core.Type import GHC.Builtin.Types.Prim ===================================== compiler/ghc.cabal.in ===================================== @@ -531,6 +531,9 @@ Library GHC.Core.Multiplicity GHC.Core.UsageEnv GHC.Core.TyCon + GHC.Core.TyCon.Env + GHC.Core.TyCon.Set + GHC.Core.TyCon.RecWalk GHC.Core.Coercion.Axiom GHC.Core.Type GHC.Core.TyCo.Rep ===================================== testsuite/tests/parser/should_run/CountParserDeps.hs ===================================== @@ -28,7 +28,7 @@ main = do [libdir] <- getArgs modules <- parserDeps libdir let num = sizeUniqSet modules - max_num = 203 + max_num = 205 min_num = max_num - 10 -- so that we don't forget to change the number -- when the number of dependencies decreases -- putStrLn $ "Found " ++ show num ++ " parser module dependencies" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef950b19c04bc9c41920ecc9f94382653981d4bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef950b19c04bc9c41920ecc9f94382653981d4bb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:52:52 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:52:52 -0400 Subject: [Git][ghc/ghc][master] Bump win32-tarballs version to 0.3 Message-ID: <5f805d24e71d4_80bf54f8441789325e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - 2 changed files: - .gitlab-ci.yml - mk/get-win32-tarballs.py Changes: ===================================== .gitlab-ci.yml ===================================== @@ -6,7 +6,7 @@ variables: # Sequential version number capturing the versions of all tools fetched by # .gitlab/ci.sh. - WINDOWS_TOOLCHAIN_VERSION: 2 + WINDOWS_TOOLCHAIN_VERSION: 3 # Disable shallow clones; they break our linting rules GIT_DEPTH: 0 ===================================== mk/get-win32-tarballs.py ===================================== @@ -8,7 +8,7 @@ import argparse import sys from sys import stderr -TARBALL_VERSION = '0.2' +TARBALL_VERSION = '0.3' BASE_URL = "https://downloads.haskell.org/ghc/mingw/{}".format(TARBALL_VERSION) DEST = Path('ghc-tarballs/mingw-w64') ARCHS = ['i686', 'x86_64', 'sources'] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5c7c9c8578de1248826c21ebd08e475d094a552 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5c7c9c8578de1248826c21ebd08e475d094a552 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:54:08 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:54:08 -0400 Subject: [Git][ghc/ghc][master] Add -pgmlm and -optlm flags Message-ID: <5f805d70ebeba_80b3f840f0b48ac178991b9@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - 1 changed file: - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2217,6 +2217,8 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lo = (f,[]) } , make_ord_flag defFlag "pgmlc" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lc = (f,[]) } + , make_ord_flag defFlag "pgmlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lm = (f,[]) } , make_ord_flag defFlag "pgmi" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_i = f } , make_ord_flag defFlag "pgmL" @@ -2257,6 +2259,8 @@ dynamic_flags_deps = [ -- need to appear before -optl/-opta to be parsed as LLVM flags. + , make_ord_flag defFlag "optlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lm = f : toolSettings_opt_lm s } , make_ord_flag defFlag "optlo" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lo = f : toolSettings_opt_lo s } , make_ord_flag defFlag "optlc" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd302e938ebf48c73d9f715d67ce8cd990f972ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fd302e938ebf48c73d9f715d67ce8cd990f972ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:54:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:54:51 -0400 Subject: [Git][ghc/ghc][master] Testsuite: increase timeout for T18223 (#18795) Message-ID: <5f805d9be9b59_80b101149a417902550@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 1 changed file: - testsuite/tests/perf/compiler/all.T Changes: ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -423,6 +423,8 @@ test ('T13253-spj', ['-v0 -O']) test ('T18223', [ collect_compiler_stats('bytes allocated',2) + , compile_timeout_multiplier(2) + # needed for the unregistered build (#18795) ], compile, ['-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db236ffc03e5e17f71295469040da96b03ec2f87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/db236ffc03e5e17f71295469040da96b03ec2f87 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 12:55:32 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 08:55:32 -0400 Subject: [Git][ghc/ghc][master] Cache HomeUnit in HscEnv (#17957) Message-ID: <5f805dc4e5624_80b3f847218e3f0179047b2@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 29 changed files: - compiler/GHC.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/Usage.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/Backpack.hs - compiler/GHC/Tc/Utils/Env.hs - compiler/GHC/Tc/Utils/Monad.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -600,9 +600,9 @@ checkBrokenTablesNextToCode' dflags -- can ignore the list of packages returned. -- setSessionDynFlags :: GhcMonad m => DynFlags -> m () -setSessionDynFlags dflags = do - dflags' <- checkNewDynFlags dflags - dflags''' <- liftIO $ initUnits dflags' +setSessionDynFlags dflags0 = do + dflags1 <- checkNewDynFlags dflags0 + dflags <- liftIO $ initUnits dflags1 -- Interpreter interp <- if gopt Opt_ExternalInterpreter dflags @@ -637,11 +637,12 @@ setSessionDynFlags dflags = do return Nothing #endif - modifySession $ \h -> h{ hsc_dflags = dflags''' - , hsc_IC = (hsc_IC h){ ic_dflags = dflags''' } + modifySession $ \h -> h{ hsc_dflags = dflags + , hsc_IC = (hsc_IC h){ ic_dflags = dflags } , hsc_interp = hsc_interp h <|> interp -- we only update the interpreter if there wasn't -- already one set up + , hsc_home_unit = mkHomeUnitFromFlags dflags } invalidateModSummaryCache @@ -1171,7 +1172,7 @@ getPrintUnqual = withSession $ \hsc_env -> do let dflags = hsc_dflags hsc_env return $ icPrintUnqual (unitState dflags) - (mkHomeUnitFromFlags dflags) + (hsc_home_unit hsc_env) (hsc_IC hsc_env) -- | Container for information about a 'Module'. @@ -1270,7 +1271,7 @@ mkPrintUnqualifiedForModule minf = withSession $ \hsc_env -> do let dflags = hsc_dflags hsc_env mk_print_unqual = mkPrintUnqualified (unitState dflags) - (mkHomeUnitFromFlags dflags) + (hsc_home_unit hsc_env) return (fmap mk_print_unqual (minf_rdr_env minf)) modInfoLookupName :: GhcMonad m => @@ -1279,10 +1280,7 @@ modInfoLookupName :: GhcMonad m => modInfoLookupName minf name = withSession $ \hsc_env -> do case lookupTypeEnv (minf_type_env minf) name of Just tyThing -> return (Just tyThing) - Nothing -> do - eps <- liftIO $ readIORef (hsc_EPS hsc_env) - return $! lookupType (hsc_dflags hsc_env) - (hsc_HPT hsc_env) (eps_PTE eps) name + Nothing -> liftIO (lookupType hsc_env name) modInfoIface :: ModuleInfo -> Maybe ModIface modInfoIface = minf_iface @@ -1308,7 +1306,7 @@ isDictonaryId id -- 'setContext'. lookupGlobalName :: GhcMonad m => Name -> m (Maybe TyThing) lookupGlobalName name = withSession $ \hsc_env -> do - liftIO $ lookupTypeHscEnv hsc_env name + liftIO $ lookupType hsc_env name findGlobalAnns :: (GhcMonad m, Typeable a) => ([Word8] -> a) -> AnnTarget Name -> m [a] findGlobalAnns deserialize target = withSession $ \hsc_env -> do @@ -1501,7 +1499,7 @@ showRichTokenStream ts = go startLoc ts "" findModule :: GhcMonad m => ModuleName -> Maybe FastString -> m Module findModule mod_name maybe_pkg = withSession $ \hsc_env -> do let dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env case maybe_pkg of Just pkg | not (isHomeUnit home_unit (fsToUnit pkg)) && pkg /= fsLit "this" -> liftIO $ do res <- findImportedModule hsc_env mod_name maybe_pkg ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -103,7 +103,7 @@ core2core hsc_env guts@(ModGuts { mg_module = mod hpt_rule_base = mkRuleBase home_pkg_rules print_unqual = mkPrintUnqualified (unitState dflags) - (mkHomeUnitFromFlags dflags) + (hsc_home_unit hsc_env) rdr_env -- mod: get the module out of the current HscEnv so we can retrieve it from the monad. -- This is very convienent for the users of the monad (e.g. plugins do not have to @@ -696,7 +696,7 @@ simplifyPgmIO pass@(CoreDoSimplify max_iterations mode) } where dflags = hsc_dflags hsc_env - print_unqual = mkPrintUnqualified (unitState dflags) (mkHomeUnitFromFlags dflags) rdr_env + print_unqual = mkPrintUnqualified (unitState dflags) (hsc_home_unit hsc_env) rdr_env simpl_env = mkSimplEnv mode active_rule = activeRule mode active_unf = activeUnfolding mode ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -1556,7 +1556,7 @@ mkConvertNumLiteral hsc_env = do let dflags = hsc_dflags hsc_env platform = targetPlatform dflags - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env guardBignum act | isHomeUnitInstanceOf home_unit primUnitId = return $ panic "Bignum literals are not supported in ghc-prim" ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -288,7 +288,7 @@ buildUnit session cid insts lunit = do conf <- withBkpSession cid insts deps_w_rns session $ do dflags <- getDynFlags - mod_graph <- hsunitModuleGraph dflags (unLoc lunit) + mod_graph <- hsunitModuleGraph (unLoc lunit) msg <- mkBackpackMsg ok <- load' LoadAllTargets (Just msg) mod_graph @@ -312,7 +312,7 @@ buildUnit session cid insts lunit = do let compat_fs = unitIdFS (indefUnit cid) compat_pn = PackageName compat_fs - unit_id = homeUnitId (mkHomeUnitFromFlags (hsc_dflags hsc_env)) + unit_id = homeUnitId (hsc_home_unit hsc_env) return GenericUnitInfo { -- Stub data @@ -378,8 +378,7 @@ compileExe lunit = do forM_ (zip [1..] deps) $ \(i, dep) -> compileInclude (length deps) (i, dep) withBkpExeSession deps_w_rns $ do - dflags <- getDynFlags - mod_graph <- hsunitModuleGraph dflags (unLoc lunit) + mod_graph <- hsunitModuleGraph (unLoc lunit) msg <- mkBackpackMsg ok <- load' LoadAllTargets (Just msg) mod_graph when (failed ok) (liftIO $ exitWith (ExitFailure 1)) @@ -645,11 +644,12 @@ convertHsModuleId (HsModuleId (L _ hsuid) (L _ modname)) = mkModule (convertHsCo -- -- We don't bother trying to support GHC.Driver.Make for now, it's more trouble -- than it's worth for inline modules. -hsunitModuleGraph :: DynFlags -> HsUnit HsComponentId -> BkpM ModuleGraph -hsunitModuleGraph dflags unit = do +hsunitModuleGraph :: HsUnit HsComponentId -> BkpM ModuleGraph +hsunitModuleGraph unit = do + hsc_env <- getSession let decls = hsunitBody unit pn = hsPackageName (unLoc (hsunitName unit)) - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env -- 1. Create a HsSrcFile/HsigFile summary for every -- explicitly mentioned module/signature. ===================================== compiler/GHC/Driver/Finder.hs ===================================== @@ -81,7 +81,7 @@ flushFinderCaches hsc_env = atomicModifyIORef' fc_ref $ \fm -> (filterInstalledModuleEnv is_ext fm, ()) where fc_ref = hsc_FC hsc_env - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + home_unit = hsc_home_unit hsc_env is_ext mod _ = not (isHomeInstalledModule home_unit mod) addToFinderCache :: IORef FinderCache -> InstalledModule -> InstalledFindResult -> IO () @@ -139,7 +139,7 @@ findPluginModule hsc_env mod_name = findExactModule :: HscEnv -> InstalledModule -> IO InstalledFindResult findExactModule hsc_env mod = - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env in if isHomeInstalledModule home_unit mod then findInstalledHomeModule hsc_env (moduleName mod) else findPackageModule hsc_env mod @@ -179,7 +179,7 @@ orIfNotFound this or_this = do -- was successful.) homeSearchCache :: HscEnv -> ModuleName -> IO InstalledFindResult -> IO InstalledFindResult homeSearchCache hsc_env mod_name do_this = do - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env mod = mkHomeInstalledModule home_unit mod_name modLocationCache hsc_env mod do_this @@ -255,14 +255,14 @@ modLocationCache hsc_env mod do_this = do -- This returns a module because it's more convenient for users addHomeModuleToFinder :: HscEnv -> ModuleName -> ModLocation -> IO Module addHomeModuleToFinder hsc_env mod_name loc = do - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env mod = mkHomeInstalledModule home_unit mod_name addToFinderCache (hsc_FC hsc_env) mod (InstalledFound loc mod) return (mkHomeModule home_unit mod_name) uncacheModule :: HscEnv -> ModuleName -> IO () uncacheModule hsc_env mod_name = do - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env mod = mkHomeInstalledModule home_unit mod_name removeFromFinderCache (hsc_FC hsc_env) mod @@ -284,9 +284,8 @@ findHomeModule hsc_env mod_name = do fr_suggestions = [] } where - dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags - uid = homeUnitAsUnit (mkHomeUnitFromFlags dflags) + home_unit = hsc_home_unit hsc_env + uid = homeUnitAsUnit home_unit -- | Implements the search for a module name in the home package only. Calling -- this function directly is usually *not* what you want; currently, it's used @@ -309,7 +308,7 @@ findInstalledHomeModule hsc_env mod_name = homeSearchCache hsc_env mod_name $ let dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env home_path = importPaths dflags hisuf = hiSuf dflags mod = mkHomeInstalledModule home_unit mod_name ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -214,6 +214,7 @@ newHscEnv dflags = do , hsc_type_env_var = Nothing , hsc_interp = Nothing , hsc_dynLinker = emptyDynLinker + , hsc_home_unit = home_unit } -- ----------------------------------------------------------------------------- @@ -477,7 +478,7 @@ hsc_typecheck keep_rn mod_summary mb_rdr_module = do hsc_env <- getHscEnv let hsc_src = ms_hsc_src mod_summary dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env outer_mod = ms_mod mod_summary mod_name = moduleName outer_mod outer_mod' = mkHomeModule home_unit mod_name @@ -1123,9 +1124,9 @@ hscGetSafe hsc_env m l = runHsc hsc_env $ do hscCheckSafe' :: Module -> SrcSpan -> Hsc (Maybe UnitId, Set UnitId) hscCheckSafe' m l = do - dflags <- getDynFlags - let home_unit = mkHomeUnitFromFlags dflags - (tw, pkgs) <- isModSafe m l + hsc_env <- getHscEnv + let home_unit = hsc_home_unit hsc_env + (tw, pkgs) <- isModSafe home_unit m l case tw of False -> return (Nothing, pkgs) True | isHomeModule home_unit m -> return (Nothing, pkgs) @@ -1133,8 +1134,8 @@ hscCheckSafe' m l = do -- Not necessary if that is reflected in dependencies | otherwise -> return (Just $ toUnitId (moduleUnit m), pkgs) where - isModSafe :: Module -> SrcSpan -> Hsc (Bool, Set UnitId) - isModSafe m l = do + isModSafe :: HomeUnit -> Module -> SrcSpan -> Hsc (Bool, Set UnitId) + isModSafe home_unit m l = do dflags <- getDynFlags iface <- lookup' m case iface of @@ -1150,7 +1151,7 @@ hscCheckSafe' m l = do -- check module is trusted safeM = trust `elem` [Sf_Safe, Sf_SafeInferred, Sf_Trustworthy] -- check package is trusted - safeP = packageTrusted dflags trust trust_own_pkg m + safeP = packageTrusted dflags home_unit trust trust_own_pkg m -- pkg trust reqs pkgRs = S.fromList . map fst $ filter snd $ dep_pkgs $ mi_deps iface' -- warn if Safe module imports Safe-Inferred module. @@ -1195,16 +1196,16 @@ hscCheckSafe' m l = do -- modules are trusted without requiring that their package is trusted. For -- trustworthy modules, modules in the home package are trusted but -- otherwise we check the package trust flag. - packageTrusted :: DynFlags -> SafeHaskellMode -> Bool -> Module -> Bool - packageTrusted _ Sf_None _ _ = False -- shouldn't hit these cases - packageTrusted _ Sf_Ignore _ _ = False -- shouldn't hit these cases - packageTrusted _ Sf_Unsafe _ _ = False -- prefer for completeness. - packageTrusted dflags _ _ _ + packageTrusted :: DynFlags -> HomeUnit -> SafeHaskellMode -> Bool -> Module -> Bool + packageTrusted _ _ Sf_None _ _ = False -- shouldn't hit these cases + packageTrusted _ _ Sf_Ignore _ _ = False -- shouldn't hit these cases + packageTrusted _ _ Sf_Unsafe _ _ = False -- prefer for completeness. + packageTrusted dflags _ _ _ _ | not (packageTrustOn dflags) = True - packageTrusted _ Sf_Safe False _ = True - packageTrusted _ Sf_SafeInferred False _ = True - packageTrusted dflags _ _ m - | isHomeModule (mkHomeUnitFromFlags dflags) m = True + packageTrusted _ _ Sf_Safe False _ = True + packageTrusted _ _ Sf_SafeInferred False _ = True + packageTrusted dflags home_unit _ _ m + | isHomeModule home_unit m = True | otherwise = unitIsTrusted $ unsafeLookupUnit (unitState dflags) (moduleUnit m) lookup' :: Module -> Hsc (Maybe ModIface) @@ -1500,7 +1501,7 @@ hscInteractive hsc_env cgguts location = do hscCompileCmmFile :: HscEnv -> FilePath -> FilePath -> IO () hscCompileCmmFile hsc_env filename output_filename = runHsc hsc_env $ do let dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env platform = targetPlatform dflags cmm <- ioMsgMaybe $ do ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -661,7 +661,7 @@ discardIC hsc_env | nameIsFromExternalPackage home_unit old_name = old_name | otherwise = ic_name empty_ic where - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env old_name = ic_name old_ic -- | If there is no -o option, guess the name of target executable @@ -1078,7 +1078,8 @@ parUpsweep n_jobs mHscMessage old_hpt stable_mods cleanup sccs = do -- work to compile the module (see parUpsweep_one). m_res <- MC.try $ unmask $ prettyPrintGhcErrors lcl_dflags $ parUpsweep_one mod home_mod_map comp_graph_loops - lcl_dflags mHscMessage cleanup + lcl_dflags (hsc_home_unit hsc_env) + mHscMessage cleanup par_sem hsc_env_var old_hpt_var stable_mods mod_idx (length sccs) @@ -1180,6 +1181,8 @@ parUpsweep_one -- ^ The list of all module loops within the compilation graph. -> DynFlags -- ^ The thread-local DynFlags + -> HomeUnit + -- ^ The home-unit -> Maybe Messager -- ^ The messager -> (HscEnv -> IO ()) @@ -1198,14 +1201,13 @@ parUpsweep_one -- ^ The total number of modules -> IO SuccessFlag -- ^ The result of this compile -parUpsweep_one mod home_mod_map comp_graph_loops lcl_dflags mHscMessage cleanup par_sem +parUpsweep_one mod home_mod_map comp_graph_loops lcl_dflags home_unit mHscMessage cleanup par_sem hsc_env_var old_hpt_var stable_mods mod_index num_mods = do let this_build_mod = mkBuildModule mod let home_imps = map unLoc $ ms_home_imps mod let home_src_imps = map unLoc $ ms_home_srcimps mod - let home_unit = mkHomeUnitFromFlags lcl_dflags -- All the textual imports of this module. let textual_deps = Set.fromList $ @@ -2117,8 +2119,9 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- otherwise those modules will fail to compile. -- See Note [-fno-code mode] #8025 let default_backend = platformDefaultBackend (targetPlatform dflags) + home_unit = hsc_home_unit hsc_env map1 <- case backend dflags of - NoBackend -> enableCodeGenForTH default_backend map0 + NoBackend -> enableCodeGenForTH home_unit default_backend map0 Interpreter -> enableCodeGenForUnboxedTuplesOrSums default_backend map0 _ -> return map0 if null errs @@ -2203,10 +2206,10 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots -- the specified target, disable optimization and change the .hi -- and .o file locations to be temporary files. -- See Note [-fno-code mode] -enableCodeGenForTH :: Backend +enableCodeGenForTH :: HomeUnit -> Backend -> NodeMap [Either ErrorMessages ModSummary] -> IO (NodeMap [Either ErrorMessages ModSummary]) -enableCodeGenForTH = +enableCodeGenForTH home_unit = enableCodeGenWhen condition should_modify TFL_CurrentModule TFL_GhcSession where condition = isTemplateHaskellOrQQNonBoot @@ -2214,7 +2217,7 @@ enableCodeGenForTH = backend dflags == NoBackend && -- Don't enable codegen for TH on indefinite packages; we -- can't compile anything anyway! See #16219. - isHomeUnitDefinite (mkHomeUnitFromFlags dflags) + isHomeUnitDefinite home_unit -- | Update the every ModSummary that is depended on -- by a module that needs unboxed tuples. We enable codegen to @@ -2503,7 +2506,7 @@ summariseModule hsc_env old_summary_map is_boot (L loc wanted_mod) | otherwise = find_it where dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env check_timestamp old_summary location src_fn = checkSummaryTimestamp ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -384,7 +384,7 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- https://gitlab.haskell.org/ghc/ghc/issues/12673 -- and https://github.com/haskell/cabal/issues/2257 empty_stub <- newTempName dflags TFL_CurrentModule "c" - let home_unit = mkHomeUnitFromFlags dflags + let home_unit = hsc_home_unit hsc_env src = text "int" <+> ppr (mkHomeModule home_unit mod_name) <+> text "= 0;" writeFile empty_stub (showSDoc dflags (pprCode CStyle src)) _ <- runPipeline StopLn hsc_env @@ -1297,7 +1297,7 @@ runPhase (RealPhase cc_phase) input_fn dflags pkg_include_dirs <- liftIO $ getUnitIncludePath (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit pkgs let include_paths_global = foldr (\ x xs -> ("-I" ++ x) : xs) [] (includePathsGlobal cmdline_include_paths ++ pkg_include_dirs) @@ -1329,7 +1329,7 @@ runPhase (RealPhase cc_phase) input_fn dflags else getUnitExtraCcOpts (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit pkgs framework_paths <- @@ -1337,7 +1337,7 @@ runPhase (RealPhase cc_phase) input_fn dflags then do pkgFrameworkPaths <- liftIO $ getUnitFrameworkPath (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit pkgs let cmdlineFrameworkPaths = frameworkPaths dflags return $ map ("-F"++) @@ -1732,6 +1732,7 @@ linkBinary' staticLink dflags o_files dep_units = do toolSettings' = toolSettings dflags verbFlags = getVerbFlags dflags output_fn = exeFileName staticLink dflags + home_unit = mkHomeUnitFromFlags dflags -- get the full list of packages to link with, by combining the -- explicit packages with the auto packages and all of their @@ -1744,7 +1745,7 @@ linkBinary' staticLink dflags o_files dep_units = do pkg_lib_paths <- getUnitLibraryPath (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit (ways dflags) dep_units let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths @@ -2016,6 +2017,7 @@ linkStaticLib dflags o_files dep_units = do let extra_ld_inputs = [ f | FileOption _ f <- ldInputs dflags ] modules = o_files ++ extra_ld_inputs output_fn = exeFileName True dflags + home_unit = mkHomeUnitFromFlags dflags full_output_fn <- if isAbsolute output_fn then return output_fn @@ -2027,7 +2029,7 @@ linkStaticLib dflags o_files dep_units = do pkg_cfgs_init <- getPreloadUnitsAnd (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit dep_units let pkg_cfgs @@ -2056,11 +2058,12 @@ doCpp :: DynFlags -> Bool -> FilePath -> FilePath -> IO () doCpp dflags raw input_fn output_fn = do let hscpp_opts = picPOpts dflags let cmdline_include_paths = includePaths dflags + let home_unit = mkHomeUnitFromFlags dflags pkg_include_dirs <- getUnitIncludePath (initSDocContext dflags defaultUserStyle) (unitState dflags) - (mkHomeUnitFromFlags dflags) + home_unit [] let include_paths_global = foldr (\ x xs -> ("-I" ++ x) : xs) [] (includePathsGlobal cmdline_include_paths ++ pkg_include_dirs) ===================================== compiler/GHC/Driver/Types.hs ===================================== @@ -102,7 +102,7 @@ module GHC.Driver.Types ( implicitTyThings, implicitTyConThings, implicitClassThings, isImplicitTyThing, - TypeEnv, lookupType, lookupTypeHscEnv, mkTypeEnv, emptyTypeEnv, + TypeEnv, lookupType, mkTypeEnv, emptyTypeEnv, typeEnvFromEntities, mkTypeEnvWithImplicits, extendTypeEnv, extendTypeEnvList, extendTypeEnvWithIds, plusTypeEnv, @@ -490,6 +490,9 @@ data HscEnv , hsc_dynLinker :: DynLinker -- ^ dynamic linker. + , hsc_home_unit :: !HomeUnit + -- ^ Home-unit + } {- @@ -2286,34 +2289,24 @@ plusTypeEnv env1 env2 = plusNameEnv env1 env2 -- compiled modules in other packages that live in 'PackageTypeEnv'. Note -- that this does NOT look up the 'TyThing' in the module being compiled: you -- have to do that yourself, if desired -lookupType :: DynFlags - -> HomePackageTable - -> PackageTypeEnv - -> Name - -> Maybe TyThing - -lookupType dflags hpt pte name - | isOneShot (ghcMode dflags) -- in one-shot, we don't use the HPT - = lookupNameEnv pte name - | otherwise - = case lookupHptByModule hpt mod of - Just hm -> lookupNameEnv (md_types (hm_details hm)) name - Nothing -> lookupNameEnv pte name - where - mod = ASSERT2( isExternalName name, ppr name ) - if isHoleName name - then mkHomeModule (mkHomeUnitFromFlags dflags) (moduleName (nameModule name)) - else nameModule name - --- | As 'lookupType', but with a marginally easier-to-use interface --- if you have a 'HscEnv' -lookupTypeHscEnv :: HscEnv -> Name -> IO (Maybe TyThing) -lookupTypeHscEnv hsc_env name = do - eps <- readIORef (hsc_EPS hsc_env) - return $! lookupType dflags hpt (eps_PTE eps) name - where - dflags = hsc_dflags hsc_env - hpt = hsc_HPT hsc_env +lookupType :: HscEnv -> Name -> IO (Maybe TyThing) +lookupType hsc_env name = do + eps <- liftIO $ readIORef (hsc_EPS hsc_env) + let pte = eps_PTE eps + hpt = hsc_HPT hsc_env + + mod = ASSERT2( isExternalName name, ppr name ) + if isHoleName name + then mkHomeModule (hsc_home_unit hsc_env) (moduleName (nameModule name)) + else nameModule name + + !ty = if isOneShot (ghcMode (hsc_dflags hsc_env)) + -- in one-shot, we don't use the HPT + then lookupNameEnv pte name + else case lookupHptByModule hpt mod of + Just hm -> lookupNameEnv (md_types (hm_details hm)) name + Nothing -> lookupNameEnv pte name + pure ty -- | Get the 'TyCon' from a 'TyThing' if it is a type constructor thing. Panics otherwise tyThingTyCon :: HasDebugCallStack => TyThing -> TyCon ===================================== compiler/GHC/HsToCore.hs ===================================== @@ -120,7 +120,7 @@ deSugar hsc_env }) = do { let dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env print_unqual = mkPrintUnqualified (unitState dflags) home_unit @@ -183,7 +183,7 @@ deSugar hsc_env ; let used_names = mkUsedNames tcg_env pluginModules = map lpModule (cachedPlugins (hsc_dflags hsc_env)) - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + home_unit = hsc_home_unit hsc_env ; deps <- mkDependencies (homeUnitId home_unit) (map mi_module pluginModules) tcg_env ===================================== compiler/GHC/HsToCore/Monad.hs ===================================== @@ -78,6 +78,8 @@ import GHC.HsToCore.Types import GHC.HsToCore.Pmc.Solver.Types (Nablas, initNablas) import GHC.Types.Id import GHC.Unit.Module +import GHC.Unit.Home +import GHC.Unit.State import GHC.Utils.Outputable import GHC.Types.SrcLoc import GHC.Core.Type @@ -213,6 +215,8 @@ mkDsEnvsFromTcGbl hsc_env msg_var tcg_env = do { cc_st_var <- liftIO $ newIORef newCostCentreState ; eps <- liftIO $ hscEPS hsc_env ; let dflags = hsc_dflags hsc_env + home_unit = hsc_home_unit hsc_env + unit_state = unitState dflags this_mod = tcg_mod tcg_env type_env = tcg_type_env tcg_env rdr_env = tcg_rdr_env tcg_env @@ -220,7 +224,7 @@ mkDsEnvsFromTcGbl hsc_env msg_var tcg_env complete_matches = hptCompleteSigs hsc_env -- from the home package ++ tcg_complete_matches tcg_env -- from the current module ++ eps_complete_matches eps -- from imports - ; return $ mkDsEnvs dflags this_mod rdr_env type_env fam_inst_env + ; return $ mkDsEnvs unit_state home_unit this_mod rdr_env type_env fam_inst_env msg_var cc_st_var complete_matches } @@ -244,6 +248,8 @@ initDsWithModGuts hsc_env guts thing_inside ; msg_var <- newIORef emptyMessages ; eps <- liftIO $ hscEPS hsc_env ; let dflags = hsc_dflags hsc_env + home_unit = hsc_home_unit hsc_env + unit_state = unitState dflags type_env = typeEnvFromEntities ids (mg_tcs guts) (mg_fam_insts guts) rdr_env = mg_rdr_env guts fam_inst_env = mg_fam_inst_env guts @@ -256,7 +262,7 @@ initDsWithModGuts hsc_env guts thing_inside bindsToIds (Rec binds) = map fst binds ids = concatMap bindsToIds (mg_binds guts) - envs = mkDsEnvs dflags this_mod rdr_env type_env + envs = mkDsEnvs unit_state home_unit this_mod rdr_env type_env fam_inst_env msg_var cc_st_var complete_matches ; runDs hsc_env envs thing_inside @@ -285,10 +291,10 @@ initTcDsForSolver thing_inside updGblEnv (\tc_gbl -> tc_gbl { tcg_fam_inst_env = fam_inst_env }) $ thing_inside } -mkDsEnvs :: DynFlags -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv +mkDsEnvs :: UnitState -> HomeUnit -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv -> IORef Messages -> IORef CostCentreState -> CompleteMatches -> (DsGblEnv, DsLclEnv) -mkDsEnvs dflags mod rdr_env type_env fam_inst_env msg_var cc_st_var +mkDsEnvs unit_state home_unit mod rdr_env type_env fam_inst_env msg_var cc_st_var complete_matches = let if_genv = IfGblEnv { if_doc = text "mkDsEnvs", if_rec_types = Just (mod, return type_env) } @@ -298,10 +304,7 @@ mkDsEnvs dflags mod rdr_env type_env fam_inst_env msg_var cc_st_var gbl_env = DsGblEnv { ds_mod = mod , ds_fam_inst_env = fam_inst_env , ds_if_env = (if_genv, if_lenv) - , ds_unqual = mkPrintUnqualified - (unitState dflags) - (mkHomeUnitFromFlags dflags) - rdr_env + , ds_unqual = mkPrintUnqualified unit_state home_unit rdr_env , ds_msgs = msg_var , ds_complete_matches = complete_matches , ds_cc_st = cc_st_var ===================================== compiler/GHC/HsToCore/Usage.hs ===================================== @@ -253,7 +253,7 @@ mk_mod_usage_info pit hsc_env this_mod direct_imports used_names where hpt = hsc_HPT hsc_env dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env used_mods = moduleEnvKeys ent_map dir_imp_mods = moduleEnvKeys direct_imports ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -121,7 +121,7 @@ tcLookupImported_maybe :: Name -> TcM (MaybeErr MsgDoc TyThing) -- Returns (Failed err) if we can't find the interface file for the thing tcLookupImported_maybe name = do { hsc_env <- getTopEnv - ; mb_thing <- liftIO (lookupTypeHscEnv hsc_env name) + ; mb_thing <- liftIO (lookupType hsc_env name) ; case mb_thing of Just thing -> return (Succeeded thing) Nothing -> tcImportDecl_maybe name } @@ -402,8 +402,8 @@ loadInterface :: SDoc -> Module -> WhereFrom loadInterface doc_str mod from | isHoleModule mod -- Hole modules get special treatment - = do dflags <- getDynFlags - let home_unit = mkHomeUnitFromFlags dflags + = do hsc_env <- getTopEnv + let home_unit = hsc_home_unit hsc_env -- Redo search for our local hole module loadInterface doc_str (mkHomeModule home_unit (moduleName mod)) from | otherwise @@ -416,7 +416,8 @@ loadInterface doc_str mod from -- Check whether we have the interface already ; dflags <- getDynFlags - ; let home_unit = mkHomeUnitFromFlags dflags + ; hsc_env <- getTopEnv + ; let home_unit = hsc_home_unit hsc_env ; case lookupIfaceByModule hpt (eps_PIT eps) mod of { Just iface -> return (Succeeded iface) ; -- Already loaded @@ -643,8 +644,8 @@ computeInterface :: -> TcRnIf gbl lcl (MaybeErr MsgDoc (ModIface, FilePath)) computeInterface doc_str hi_boot_file mod0 = do MASSERT( not (isHoleModule mod0) ) - dflags <- getDynFlags - let home_unit = mkHomeUnitFromFlags dflags + hsc_env <- getTopEnv + let home_unit = hsc_home_unit hsc_env case getModuleInstantiation mod0 of (imod, Just indef) | isHomeUnitIndefinite home_unit -> do r <- findAndReadIface doc_str imod mod0 hi_boot_file @@ -925,7 +926,7 @@ findAndReadIface doc_str mod wanted_mod_with_insts hi_boot_file -- Look for the file hsc_env <- getTopEnv mb_found <- liftIO (findExactModule hsc_env mod) - let home_unit = mkHomeUnitFromFlags dflags + let home_unit = hsc_home_unit hsc_env case mb_found of InstalledFound loc mod -> do -- Found file, so read it ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -172,7 +172,7 @@ mkIfaceTc hsc_env safe_mode mod_details = do let used_names = mkUsedNames tc_result let pluginModules = map lpModule (cachedPlugins (hsc_dflags hsc_env)) - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env deps <- mkDependencies (homeUnitId home_unit) (map mi_module pluginModules) tc_result let hpc_info = emptyHpcInfo other_hpc_info @@ -228,7 +228,7 @@ mkIface_ hsc_env -- to expose in the interface = do - let home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + let home_unit = hsc_home_unit hsc_env semantic_mod = homeModuleNameInstantiation home_unit (moduleName this_mod) entities = typeEnvElts type_env show_linear_types = xopt LangExt.LinearTypes (hsc_dflags hsc_env) ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -256,7 +256,7 @@ checkVersions hsc_env mod_summary iface ; return (recomp, Just iface) }}}}}}}}}} where - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + home_unit = hsc_home_unit hsc_env -- This is a bit of a hack really mod_deps :: ModuleNameEnv ModuleNameWithIsBoot mod_deps = mkModDeps (dep_mods (mi_deps iface)) @@ -335,8 +335,8 @@ pluginRecompileToRecompileRequired old_fp new_fp pr -- implementing module has changed. checkHsig :: ModSummary -> ModIface -> IfG RecompileRequired checkHsig mod_summary iface = do - dflags <- getDynFlags - let home_unit = mkHomeUnitFromFlags dflags + hsc_env <- getTopEnv + let home_unit = hsc_home_unit hsc_env outer_mod = ms_mod mod_summary inner_mod = homeModuleNameInstantiation home_unit (moduleName outer_mod) MASSERT( isHomeModule home_unit outer_mod ) @@ -453,7 +453,7 @@ checkDependencies hsc_env summary iface prev_dep_mods = dep_mods (mi_deps iface) prev_dep_plgn = dep_plgins (mi_deps iface) prev_dep_pkgs = dep_pkgs (mi_deps iface) - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + home_unit = hsc_home_unit hsc_env dep_missing (mb_pkg, L _ mod) = do find_res <- liftIO $ findImportedModule hsc_env mod (mb_pkg) @@ -486,7 +486,6 @@ checkDependencies hsc_env summary iface isOldHomeDeps = flip Set.member old_deps checkForNewHomeDependency (L _ mname) = do let - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) mod = mkHomeModule home_unit mname str_mname = moduleNameString mname reason = str_mname ++ " changed" @@ -1359,8 +1358,7 @@ mkHashFun hsc_env eps name | otherwise = lookup orig_mod where - dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env hpt = hsc_HPT hsc_env pit = eps_PIT eps occ = nameOccName name ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -300,7 +300,7 @@ rnIfaceGlobal :: Name -> ShIfM Name rnIfaceGlobal n = do hsc_env <- getTopEnv let dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env iface_semantic_mod <- fmap sh_if_semantic_module getGblEnv mb_nsubst <- fmap sh_if_shape getGblEnv hmap <- getHoleSubst ===================================== compiler/GHC/Iface/Tidy.hs ===================================== @@ -371,7 +371,7 @@ tidyProgram hsc_env (ModGuts { mg_module = mod ; expose_all = gopt Opt_ExposeAllUnfoldings dflags ; print_unqual = mkPrintUnqualified (unitState dflags) - (mkHomeUnitFromFlags dflags) + (hsc_home_unit hsc_env) rdr_env ; implicit_binds = concatMap getImplicitBinds tcs } ===================================== compiler/GHC/Iface/Tidy/StaticPtrTable.hs ===================================== @@ -241,11 +241,11 @@ sptCreateStaticBinds hsc_env this_mod binds PW8 -> mkWordLit platform . toInteger lookupIdHscEnv :: Name -> IO Id - lookupIdHscEnv n = lookupTypeHscEnv hsc_env n >>= + lookupIdHscEnv n = lookupType hsc_env n >>= maybe (getError n) (return . tyThingId) lookupDataConHscEnv :: Name -> IO DataCon - lookupDataConHscEnv n = lookupTypeHscEnv hsc_env n >>= + lookupDataConHscEnv n = lookupType hsc_env n >>= maybe (getError n) (return . tyThingDataCon) getError n = pprPanic "sptCreateStaticBinds.get: not found" $ ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1669,7 +1669,7 @@ tcIfaceGlobal name where via_external = do { hsc_env <- getTopEnv - ; mb_thing <- liftIO (lookupTypeHscEnv hsc_env name) + ; mb_thing <- liftIO (lookupType hsc_env name) ; case mb_thing of { Just thing -> return thing ; Nothing -> do ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -43,7 +43,6 @@ import GHC.Tc.Utils.Monad import GHC.Types.ForeignCall ( CCallTarget(..) ) import GHC.Unit -import GHC.Driver.Types ( Warnings(..), plusWarns ) import GHC.Builtin.Names( applicativeClassName, pureAName, thenAName , monadClassName, returnMName, thenMName , semigroupClassName, sappendName @@ -61,7 +60,7 @@ import GHC.Types.SrcLoc as SrcLoc import GHC.Driver.Session import GHC.Utils.Misc ( debugIsOn, lengthExceeds, partitionWith ) import GHC.Utils.Panic -import GHC.Driver.Types ( HscEnv, hsc_dflags ) +import GHC.Driver.Types ( Warnings(..), plusWarns, HscEnv(..)) import GHC.Data.List.SetOps ( findDupsEq, removeDups, equivClasses ) import GHC.Data.Graph.Directed ( SCC, flattenSCC, flattenSCCs, Node(..) , stronglyConnCompFromEdgedVerticesUniq ) @@ -350,7 +349,7 @@ rnHsForeignDecl (ForeignImport { fd_name = name, fd_sig_ty = ty, fd_fi = spec }) ; (ty', fvs) <- rnHsSigType (ForeignDeclCtx name) TypeLevel ty -- Mark any PackageTarget style imports as coming from the current package - ; let home_unit = mkHomeUnitFromFlags (hsc_dflags topEnv) + ; let home_unit = hsc_home_unit topEnv spec' = patchForeignImport (homeUnitAsUnit home_unit) spec ; return (ForeignImport { fd_i_ext = noExtField ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -365,7 +365,9 @@ rnImportDecl this_mod || (not implicit && safeDirectImpsReq dflags) || (implicit && safeImplicitImpsReq dflags) - let imv = ImportedModsVal + hsc_env <- getTopEnv + let home_unit = hsc_home_unit hsc_env + imv = ImportedModsVal { imv_name = qual_mod_name , imv_span = loc , imv_is_safe = mod_safe' @@ -373,7 +375,7 @@ rnImportDecl this_mod , imv_all_exports = potential_gres , imv_qualified = qual_only } - imports = calculateAvails dflags iface mod_safe' want_boot (ImportedByUser imv) + imports = calculateAvails home_unit iface mod_safe' want_boot (ImportedByUser imv) -- Complain if we import a deprecated module whenWOptM Opt_WarnWarningsDeprecations ( @@ -395,13 +397,13 @@ rnImportDecl this_mod -- | Calculate the 'ImportAvails' induced by an import of a particular -- interface, but without 'imp_mods'. -calculateAvails :: DynFlags +calculateAvails :: HomeUnit -> ModIface -> IsSafeImport -> IsBootInterface -> ImportedBy -> ImportAvails -calculateAvails dflags iface mod_safe' want_boot imported_by = +calculateAvails home_unit iface mod_safe' want_boot imported_by = let imp_mod = mi_module iface imp_sem_mod= mi_semantic_module iface orph_iface = mi_orphan (mi_final_exts iface) @@ -451,8 +453,6 @@ calculateAvails dflags iface mod_safe' want_boot imported_by = -- to be trusted? See Note [Trust Own Package] ptrust = trust == Sf_Trustworthy || trust_pkg - home_unit = mkHomeUnitFromFlags dflags - (dependent_mods, dependent_pkgs, pkg_trust_req) | isHomeUnit home_unit pkg = -- Imported module is from the home package ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -811,7 +811,7 @@ getContext = withSession $ \HscEnv{ hsc_IC=ic } -> -- its full top-level scope available. moduleIsInterpreted :: GhcMonad m => Module -> m Bool moduleIsInterpreted modl = withSession $ \h -> - if notHomeModule (mkHomeUnitFromFlags (hsc_dflags h)) modl + if notHomeModule (hsc_home_unit h) modl then return False else case lookupHpt (hsc_HPT h) (moduleName modl) of Just details -> return (isJust (mi_globals (hm_iface details))) ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -682,7 +682,7 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods let pkg = moduleUnit mod deps = mi_deps iface - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env pkg_deps = dep_pkgs deps (boot_deps, mod_deps) = flip partitionWith (dep_mods deps) $ ===================================== compiler/GHC/Runtime/Loader.hs ===================================== @@ -161,7 +161,7 @@ forceLoadTyCon :: HscEnv -> Name -> IO TyCon forceLoadTyCon hsc_env con_name = do forceLoadNameModuleInterface hsc_env (text "contains a name used in an invocation of loadTyConTy") con_name - mb_con_thing <- lookupTypeHscEnv hsc_env con_name + mb_con_thing <- lookupType hsc_env con_name case mb_con_thing of Nothing -> throwCmdLineErrorS dflags $ missingTyThingError con_name Just (ATyCon tycon) -> return tycon @@ -193,7 +193,7 @@ getHValueSafely :: HscEnv -> Name -> Type -> IO (Maybe HValue) getHValueSafely hsc_env val_name expected_type = do forceLoadNameModuleInterface hsc_env (text "contains a name used in an invocation of getHValueSafely") val_name -- Now look up the names for the value and type constructor in the type environment - mb_val_thing <- lookupTypeHscEnv hsc_env val_name + mb_val_thing <- lookupType hsc_env val_name case mb_val_thing of Nothing -> throwCmdLineErrorS dflags $ missingTyThingError val_name Just (AnId id) -> do ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -184,7 +184,7 @@ tcRnModule hsc_env mod_sum save_rn_syntax where hsc_src = ms_hsc_src mod_sum dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env err_msg = mkPlainErrMsg dflags loc $ text "Module does not have a RealSrcSpan:" <+> ppr this_mod @@ -2832,7 +2832,7 @@ loadUnqualIfaces hsc_env ictxt = initIfaceTcRn $ do mapM_ (loadSysInterface doc) (moduleSetElts (mkModuleSet unqual_mods)) where - home_unit = mkHomeUnitFromFlags (hsc_dflags hsc_env) + home_unit = hsc_home_unit hsc_env unqual_mods = [ nameModule name | gre <- globalRdrEnvElts (ic_rn_gbl_env ictxt) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -7,6 +7,7 @@ {-# LANGUAGE CPP, TupleSections, ScopedTypeVariables, MultiWayIf #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -173,7 +174,7 @@ tcTyClGroup (TyClGroup { group_tyclds = tyclds -- Step 1.5: Make sure we don't have any type synonym cycles ; traceTc "Starting synonym cycle check" (ppr tyclss) - ; home_unit <- mkHomeUnitFromFlags <$> getDynFlags + ; home_unit <- hsc_home_unit <$> getTopEnv ; checkSynCycles (homeUnitAsUnit home_unit) tyclss tyclds ; traceTc "Done synonym cycle check" (ppr tyclss) @@ -4094,6 +4095,36 @@ checkValidDataCon dflags existential_ok tc con -- Check that UNPACK pragmas and bangs work out -- E.g. reject data T = MkT {-# UNPACK #-} Int -- No "!" -- data T = MkT {-# UNPACK #-} !a -- Can't unpack + ; hsc_env <- getTopEnv + ; let check_bang :: HsSrcBang -> HsImplBang -> Int -> TcM () + check_bang bang rep_bang n + | HsSrcBang _ _ SrcLazy <- bang + , not (xopt LangExt.StrictData dflags) + = addErrTc (bad_bang n (text "Lazy annotation (~) without StrictData")) + + | HsSrcBang _ want_unpack strict_mark <- bang + , isSrcUnpacked want_unpack, not (is_strict strict_mark) + = addWarnTc NoReason (bad_bang n (text "UNPACK pragma lacks '!'")) + + | HsSrcBang _ want_unpack _ <- bang + , isSrcUnpacked want_unpack + , case rep_bang of { HsUnpack {} -> False; _ -> True } + -- If not optimising, we don't unpack (rep_bang is never + -- HsUnpack), so don't complain! This happens, e.g., in Haddock. + -- See dataConSrcToImplBang. + , not (gopt Opt_OmitInterfacePragmas dflags) + -- When typechecking an indefinite package in Backpack, we + -- may attempt to UNPACK an abstract type. The test here will + -- conclude that this is unusable, but it might become usable + -- when we actually fill in the abstract type. As such, don't + -- warn in this case (it gives users the wrong idea about whether + -- or not UNPACK on abstract types is supported; it is!) + , isHomeUnitDefinite (hsc_home_unit hsc_env) + = addWarnTc NoReason (bad_bang n (text "Ignoring unusable UNPACK pragma")) + + | otherwise + = return () + ; zipWith3M_ check_bang (dataConSrcBangs con) (dataConImplBangs con) [1..] -- Check the dcUserTyVarBinders invariant @@ -4125,36 +4156,9 @@ checkValidDataCon dflags existential_ok tc con } where ctxt = ConArgCtxt (dataConName con) - - check_bang :: HsSrcBang -> HsImplBang -> Int -> TcM () - check_bang (HsSrcBang _ _ SrcLazy) _ n - | not (xopt LangExt.StrictData dflags) - = addErrTc - (bad_bang n (text "Lazy annotation (~) without StrictData")) - check_bang (HsSrcBang _ want_unpack strict_mark) rep_bang n - | isSrcUnpacked want_unpack, not is_strict - = addWarnTc NoReason (bad_bang n (text "UNPACK pragma lacks '!'")) - | isSrcUnpacked want_unpack - , case rep_bang of { HsUnpack {} -> False; _ -> True } - -- If not optimising, we don't unpack (rep_bang is never - -- HsUnpack), so don't complain! This happens, e.g., in Haddock. - -- See dataConSrcToImplBang. - , not (gopt Opt_OmitInterfacePragmas dflags) - -- When typechecking an indefinite package in Backpack, we - -- may attempt to UNPACK an abstract type. The test here will - -- conclude that this is unusable, but it might become usable - -- when we actually fill in the abstract type. As such, don't - -- warn in this case (it gives users the wrong idea about whether - -- or not UNPACK on abstract types is supported; it is!) - , isHomeUnitDefinite (mkHomeUnitFromFlags dflags) - = addWarnTc NoReason (bad_bang n (text "Ignoring unusable UNPACK pragma")) - where - is_strict = case strict_mark of - NoSrcStrict -> xopt LangExt.StrictData dflags - bang -> isSrcStrict bang - - check_bang _ _ _ - = return () + is_strict = \case + NoSrcStrict -> xopt LangExt.StrictData dflags + bang -> isSrcStrict bang bad_bang n herald = hang herald 2 (text "on the" <+> speakNth n ===================================== compiler/GHC/Tc/Utils/Backpack.hs ===================================== @@ -313,8 +313,7 @@ implicitRequirements' hsc_env normal_imports Found _ mod | not (isHomeModule home_unit mod) -> return (uniqDSetToList (moduleFreeHoles mod)) _ -> return [] - where dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + where home_unit = hsc_home_unit hsc_env -- | Given a 'Unit', make sure it is well typed. This is because -- unit IDs come from Cabal, which does not know if things are well-typed or @@ -538,7 +537,7 @@ mergeSignatures inner_mod = tcg_semantic_mod tcg_env mod_name = moduleName (tcg_mod tcg_env) unit_state = unitState dflags - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env -- STEP 1: Figure out all of the external signature interfaces -- we are going to merge in. @@ -830,6 +829,7 @@ mergeSignatures -- we hope that we get lucky / the overlapping instances never -- get used, but it is not a very good situation to be in. -- + hsc_env <- getTopEnv let merge_inst (insts, inst_env) inst | memberInstEnv inst_env inst -- test DFun Type equality = (insts, inst_env) @@ -844,8 +844,9 @@ mergeSignatures -- in the listing. We don't want it because a module is NOT -- supposed to include itself in its dep_orphs/dep_finsts. See #13214 iface' = iface { mi_final_exts = (mi_final_exts iface){ mi_orphan = False, mi_finsts = False } } + home_unit = hsc_home_unit hsc_env avails = plusImportAvails (tcg_imports tcg_env) $ - calculateAvails dflags iface' False NotBoot ImportedBySystem + calculateAvails home_unit iface' False NotBoot ImportedBySystem return tcg_env { tcg_inst_env = inst_env, tcg_insts = insts, @@ -912,7 +913,9 @@ impl_msg unit_state impl_mod (Module req_uid req_mod_name) checkImplements :: Module -> InstantiatedModule -> TcRn TcGblEnv checkImplements impl_mod req_mod@(Module uid mod_name) = do dflags <- getDynFlags + hsc_env <- getTopEnv let unit_state = unitState dflags + home_unit = hsc_home_unit hsc_env addErrCtxt (impl_msg unit_state impl_mod req_mod) $ do let insts = instUnitInsts uid @@ -933,7 +936,7 @@ checkImplements impl_mod req_mod@(Module uid mod_name) = do loadModuleInterfaces (text "Loading orphan modules (from implementor of hsig)") (dep_orphs (mi_deps impl_iface)) - let avails = calculateAvails dflags + let avails = calculateAvails home_unit impl_iface False{- safe -} NotBoot ImportedBySystem fix_env = mkNameEnv [ (gre_name rdr_elt, FixItem occ f) | (occ, f) <- mi_fixities impl_iface @@ -997,11 +1000,11 @@ checkImplements impl_mod req_mod@(Module uid mod_name) = do -- checking that the implementation matches the signature. instantiateSignature :: TcRn TcGblEnv instantiateSignature = do + hsc_env <- getTopEnv tcg_env <- getGblEnv - dflags <- getDynFlags let outer_mod = tcg_mod tcg_env inner_mod = tcg_semantic_mod tcg_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env -- TODO: setup the local RdrEnv so the error messages look a little better. -- But this information isn't stored anywhere. Should we RETYPECHECK -- the local one just to get the information? Hmm... ===================================== compiler/GHC/Tc/Utils/Env.hs ===================================== @@ -146,8 +146,7 @@ lookupGlobal_maybe :: HscEnv -> Name -> IO (MaybeErr MsgDoc TyThing) lookupGlobal_maybe hsc_env name = do { -- Try local envt let mod = icInteractiveModule (hsc_IC hsc_env) - dflags = hsc_dflags hsc_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env tcg_semantic_mod = homeModuleInstantiation home_unit mod ; if nameIsLocalOrFrom tcg_semantic_mod name @@ -162,7 +161,7 @@ lookupGlobal_maybe hsc_env name lookupImported_maybe :: HscEnv -> Name -> IO (MaybeErr MsgDoc TyThing) -- Returns (Failed err) if we can't find the interface file for the thing lookupImported_maybe hsc_env name - = do { mb_thing <- lookupTypeHscEnv hsc_env name + = do { mb_thing <- lookupType hsc_env name ; case mb_thing of Just thing -> return (Succeeded thing) Nothing -> importDecl_maybe hsc_env name ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -242,7 +242,7 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this th_remote_state_var <- newIORef Nothing ; let { dflags = hsc_dflags hsc_env ; - home_unit = mkHomeUnitFromFlags dflags ; + home_unit = hsc_home_unit hsc_env ; maybe_rn_syntax :: forall a. a -> Maybe a ; maybe_rn_syntax empty_val @@ -774,8 +774,9 @@ wrapDocLoc doc = do getPrintUnqualified :: DynFlags -> TcRn PrintUnqualified getPrintUnqualified dflags = do { rdr_env <- getGlobalRdrEnv + ; hsc_env <- getTopEnv ; let unit_state = unitState dflags - ; let home_unit = mkHomeUnitFromFlags dflags + ; let home_unit = hsc_home_unit hsc_env ; return $ mkPrintUnqualified unit_state home_unit rdr_env } -- | Like logInfoTcRn, but for user consumption @@ -1967,9 +1968,9 @@ mkIfLclEnv mod loc boot initIfaceTcRn :: IfG a -> TcRn a initIfaceTcRn thing_inside = do { tcg_env <- getGblEnv - ; dflags <- getDynFlags + ; hsc_env <- getTopEnv ; let !mod = tcg_semantic_mod tcg_env - home_unit = mkHomeUnitFromFlags dflags + home_unit = hsc_home_unit hsc_env -- When we are instantiating a signature, we DEFINITELY -- do not want to knot tie. is_instantiate = isHomeUnitInstantiating home_unit View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a243e9daaa6c17c0859f47ae3a098e680aa28cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6a243e9daaa6c17c0859f47ae3a098e680aa28cf You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:06:47 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 09 Oct 2020 09:06:47 -0400 Subject: [Git][ghc/ghc][wip/T18793] 2 commits: Arity analysis: Record arity types for non-recursive lets Message-ID: <5f8060672cc6e_80b3f847218e3f01791005b@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: 28381a71 by Sebastian Graf at 2020-10-09T15:06:41+02:00 Arity analysis: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. - - - - - f98fafce by Sebastian Graf at 2020-10-09T15:06:41+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr - testsuite/tests/arityanal/f1.hs → testsuite/tests/arityanal/should_compile/Arity01.hs - + testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/f2.hs → testsuite/tests/arityanal/should_compile/Arity02.hs - + testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/f3.hs → testsuite/tests/arityanal/should_compile/Arity03.hs - + testsuite/tests/arityanal/should_compile/Arity03.stderr - testsuite/tests/arityanal/f4.hs → testsuite/tests/arityanal/should_compile/Arity04.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8780644f9d715723da36998386d160505fe4ad8...f98fafce3fc1bfb3833ac341ad95793cbdd4b513 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8780644f9d715723da36998386d160505fe4ad8...f98fafce3fc1bfb3833ac341ad95793cbdd4b513 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:27:01 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 09:27:01 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f8065259530c_80bf0c7218179215b9@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 507b06f5 by Daniel Rogozin at 2020-10-09T16:26:35+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 17 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName is in scope and can be promoted to the type level, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1051,28 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int + +Previously, such errors contained only the info that a given value was out of scope (#18740). -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -889,8 +889,19 @@ cvtImplicitParamBind n e = do cvtl :: TH.Exp -> CvtM (LHsExpr GhcPs) cvtl e = wrapL (cvt e) where - cvt (VarE s) = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } - cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } + cvt (VarE s) + | isVarName s = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } + | isTyConName s = cvt (ConE s) + -- If VarE contains a type constructor, + -- then we process this name as a data constructor + -- in order to cause an "Illegal term-level + -- use of a type constructor" error. + -- See Note [Promotion] in GHC.Rename.Env. + -- In particular, this clause (together with the next one) + -- improves the error messages in test cases like + -- T14627, T7667a, and T15270B. + | otherwise = failWith (badOcc OccName.varName (nameBase s)) + cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } cvt (LitE l) | overloadedLit l = go cvtOverLit (HsOverLit noExtField) (hsOverLitNeedsParens appPrec) @@ -1915,6 +1926,12 @@ isVarName (TH.Name occ _) "" -> False (c:_) -> startsVarId c || startsVarSym c +isTyConName :: TH.Name -> Bool +isTyConName name + = case nameSpace name of + Just TcClsName -> True + _ -> False + badOcc :: OccName.NameSpace -> String -> SDoc badOcc ctxt_ns occ = text "Illegal" <+> pprNameSpace ctxt_ns ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,4 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/507b06f5c47ec5216f06e3f7a32cc08315199b27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/507b06f5c47ec5216f06e3f7a32cc08315199b27 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:37:26 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Fri, 09 Oct 2020 09:37:26 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] 55 commits: Comments: change outdated reference to mergeOps Message-ID: <5f80679686cff_80b3f84861f19141792501a@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 6e75fcf0 by Alan Zimmerman at 2020-10-08T21:37:32+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations Remove LHsLocalBinds Fix up after rebasing to bring in XRec Main thing is to make type instance XRec (GhcPass p) a = GenLocated (Anno a) a type family Anno a = b But this has massive implications. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Specialise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5c8c5f245629c643eda2f573ae4dc762476b98...6e75fcf0b8b702d412c204add30855042bf7623c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd5c8c5f245629c643eda2f573ae4dc762476b98...6e75fcf0b8b702d412c204add30855042bf7623c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:38:53 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Fri, 09 Oct 2020 09:38:53 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] Proof of Concept implementation of in-tree API Annotations Message-ID: <5f8067ed1daf7_80b3f84861f191417926065@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: ccd9aa3b by Alan Zimmerman at 2020-10-09T14:38:15+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations Remove LHsLocalBinds Fix up after rebasing to bring in XRec Main thing is to make type instance XRec (GhcPass p) a = GenLocated (Anno a) a type family Anno a = b But this has massive implications. - - - - - 20 changed files: - compiler/GHC.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Ppr.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Dump.hs - + compiler/GHC/Hs/Exact.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Expr.hs-boot - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Pat.hs-boot - compiler/GHC/Hs/Stats.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccd9aa3ba98a6a376492852e77911243a470b224 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ccd9aa3ba98a6a376492852e77911243a470b224 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:53:23 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Fri, 09 Oct 2020 09:53:23 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] 39 commits: Small documentation fixes Message-ID: <5f806b53b0290_80bd33619017929841@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 524f22cb by Alan Zimmerman at 2020-10-09T14:51:56+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1612a6d2ac7c841290b5c98c4b9e6a30c6b82ff...524f22cbff824945333cef86a42d21c62bf26aae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1612a6d2ac7c841290b5c98c4b9e6a30c6b82ff...524f22cbff824945333cef86a42d21c62bf26aae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 13:54:48 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 09:54:48 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f806ba8aafe1_80bd336190179317ef@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: aa069ecc by Daniel Rogozin at 2020-10-09T16:54:27+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 17 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName is in scope and can be promoted to the type level, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1051,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1085,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -889,8 +889,19 @@ cvtImplicitParamBind n e = do cvtl :: TH.Exp -> CvtM (LHsExpr GhcPs) cvtl e = wrapL (cvt e) where - cvt (VarE s) = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } - cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } + cvt (VarE s) + | isVarName s = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } + | isTyConName s = cvt (ConE s) + -- If VarE contains a type constructor, + -- then we process this name as a data constructor + -- in order to cause an "Illegal term-level + -- use of a type constructor" error. + -- See Note [Promotion] in GHC.Rename.Env. + -- In particular, this clause (together with the next one) + -- improves the error messages in test cases like + -- T14627, T7667a, and T15270B. + | otherwise = failWith (badOcc OccName.varName (nameBase s)) + cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } cvt (LitE l) | overloadedLit l = go cvtOverLit (HsOverLit noExtField) (hsOverLitNeedsParens appPrec) @@ -1915,6 +1926,12 @@ isVarName (TH.Name occ _) "" -> False (c:_) -> startsVarId c || startsVarSym c +isTyConName :: TH.Name -> Bool +isTyConName name + = case nameSpace name of + Just TcClsName -> True + _ -> False + badOcc :: OccName.NameSpace -> String -> SDoc badOcc ctxt_ns occ = text "Illegal" <+> pprNameSpace ctxt_ns ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,4 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa069eccc1bfbdab586f73fad73007aa9b1aa869 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa069eccc1bfbdab586f73fad73007aa9b1aa869 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 14:16:59 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Fri, 09 Oct 2020 10:16:59 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f8070db51c92_80b3f8439a6cb4017936728@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: a6c8953a by Alan Zimmerman at 2020-10-09T15:16:42+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 18 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -879,7 +879,7 @@ type instance XForAllTy (GhcPass _) = NoExtField type instance XQualTy (GhcPass _) = NoExtField type instance XTyVar (GhcPass _) = NoExtField type instance XAppTy (GhcPass _) = NoExtField -type instance XFunTy (GhcPass _) = NoExtField +type instance XFunTy (GhcPass _) = IsUnicodeSyntax type instance XListTy (GhcPass _) = NoExtField type instance XTupleTy (GhcPass _) = NoExtField type instance XSumTy (GhcPass _) = NoExtField @@ -953,23 +953,23 @@ arrowToHsType (HsExplicitMult p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. -data HsScaled pass a = HsScaled (HsArrow pass) a +data HsScaled pass a = HsScaled IsUnicodeSyntax (HsArrow pass) a hsMult :: HsScaled pass a -> HsArrow pass -hsMult (HsScaled m _) = m +hsMult (HsScaled _ m _) = m hsScaledThing :: HsScaled pass a -> a -hsScaledThing (HsScaled _ t) = t +hsScaledThing (HsScaled _ _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled NormalSyntax HsUnrestrictedArrow +hsLinear = HsScaled NormalSyntax HsLinearArrow instance Outputable a => Outputable (HsScaled pass a) where - ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr (HsScaled _ _cnt t) = -- ppr cnt <> ppr t + ppr t instance (OutputableBndrId pass) => @@ -1335,9 +1335,9 @@ splitHsFunType ty = go ty [] go (L l (HsParTy _ ty)) anns = go ty (anns ++ mkParensApiAnn l) - go (L _ (HsFunTy _ mult x y)) anns + go (L _ (HsFunTy u mult x y)) anns | (args, res, anns') <- go y anns - = (HsScaled mult x:args, res, anns') + = (HsScaled u mult x:args, res, anns') go other anns = ([], other, anns) ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -542,7 +543,7 @@ nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy mult a b = noLoc (HsFunTy NormalSyntax mult (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1526,7 +1526,7 @@ instance ToHie (Located OverlapMode) where toHie (L span _) = locOnly span instance ToHie a => ToHie (HsScaled GhcRn a) where - toHie (HsScaled w t) = concatM [toHie (arrowToHsType w), toHie t] + toHie (HsScaled _ w t) = concatM [toHie (arrowToHsType w), toHie t] instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,18 +2051,18 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy NormalSyntax HsUnrestrictedArrow $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy NormalSyntax (unLoc $2) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams (sLL $1 $> $ HsFunTy UnicodeSyntax HsLinearArrow $1 $3) [mu AnnLollyU $2] } mult :: { Located (HsArrow GhcPs) } ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -784,10 +784,10 @@ getConDoc l = addHaddockConDeclFieldTy :: HsScaled GhcPs (LHsType GhcPs) -> ConHdkA (HsScaled GhcPs (LHsType GhcPs)) -addHaddockConDeclFieldTy (HsScaled mult (L l t)) = +addHaddockConDeclFieldTy (HsScaled u mult (L l t)) = WriterT $ extendHdkA l $ liftHdkA $ do mDoc <- getPrevNextDoc l - return (HsScaled mult (mkLHsDocTy (L l t) mDoc), + return (HsScaled u mult (mkLHsDocTy (L l t) mDoc), HasInnerDocs (isJust mDoc)) -- Add documentation comment to a data constructor field. @@ -837,7 +837,7 @@ addConTrailingDoc l_sep = if has_inner_docs then do let mk_doc_ty :: HsScaled GhcPs (LHsType GhcPs) -> HdkM (HsScaled GhcPs (LHsType GhcPs)) - mk_doc_ty x@(HsScaled _ (L _ HsDocTy{})) = + mk_doc_ty x@(HsScaled _ _ (L _ HsDocTy{})) = -- Happens in the following case: -- -- data T = @@ -848,9 +848,9 @@ addConTrailingDoc l_sep = -- -- See tests/.../haddockExtraDocs.hs x <$ reportExtraDocs trailingDocs - mk_doc_ty (HsScaled mult (L l' t)) = do + mk_doc_ty (HsScaled u mult (L l' t)) = do doc <- selectDocString trailingDocs - return $ HsScaled mult (mkLHsDocTy (L l' t) doc) + return $ HsScaled u mult (mkLHsDocTy (L l' t) doc) let mk_doc_fld :: LConDeclField GhcPs -> HdkM (LConDeclField GhcPs) mk_doc_fld x@(L _ (ConDeclField { cd_fld_doc = Just _ })) = @@ -928,7 +928,7 @@ We implement this in two steps: -} instance HasHaddock a => HasHaddock (HsScaled GhcPs a) where - addHaddock (HsScaled mult a) = HsScaled mult <$> addHaddock a + addHaddock (HsScaled u mult a) = HsScaled u mult <$> addHaddock a instance HasHaddock a => HasHaddock (HsWildCardBndrs GhcPs a) where addHaddock (HsWC _ t) = HsWC noExtField <$> addHaddock t @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -512,10 +512,10 @@ rnLHsTypes doc tys = mapFvRn (rnLHsType doc) tys rnScaledLHsType :: HsDocContext -> HsScaled GhcPs (LHsType GhcPs) -> RnM (HsScaled GhcRn (LHsType GhcRn), FreeVars) -rnScaledLHsType doc (HsScaled w ty) = do +rnScaledLHsType doc (HsScaled u w ty) = do (w' , fvs_w) <- rnHsArrow (mkTyKiEnv doc TypeLevel RnTypeBody) w (ty', fvs) <- rnLHsType doc ty - return (HsScaled w' ty', fvs `plusFV` fvs_w) + return (HsScaled u w' ty', fvs `plusFV` fvs_w) rnHsType :: HsDocContext -> HsType GhcPs -> RnM (HsType GhcRn, FreeVars) @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1245,13 +1246,13 @@ tc_fun_type mode mult ty1 ty2 exp_kind = case mode_tyki mode of ; ty1' <- tc_lhs_type mode ty1 arg_k ; ty2' <- tc_lhs_type mode ty2 res_k ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) (mkVisFunTy mult' ty1' ty2') + ; checkExpectedKind (HsFunTy NormalSyntax mult ty1 ty2) (mkVisFunTy mult' ty1' ty2') liftedTypeKind exp_kind } KindLevel -> -- no representation polymorphism in kinds. yet. do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind ; mult' <- tc_mult mode mult - ; checkExpectedKind (HsFunTy noExtField mult ty1 ty2) (mkVisFunTy mult' ty1' ty2') + ; checkExpectedKind (HsFunTy NormalSyntax mult ty1 ty2) (mkVisFunTy mult' ty1' ty2') liftedTypeKind exp_kind } {- Note [Skolem escape and forall-types] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1570,8 +1570,8 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc kcConArgTys :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () kcConArgTys new_or_data res_kind arg_tys = do { let exp_kind = getArgExpKind new_or_data res_kind - ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind - tcMult mult) + ; forM_ arg_tys (\(HsScaled _ mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind + tcMult mult) -- See Note [Implementation of UnliftedNewtypes], STEP 2 } @@ -3408,7 +3408,7 @@ tcConArgs exp_kind (RecCon fields) tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes -> HsScaled GhcRn (LHsType GhcRn) -> TcM (Scaled TcType, HsSrcBang) -tcConArg exp_kind (HsScaled w bty) +tcConArg exp_kind (HsScaled _ w bty) = do { traceTc "tcConArg 1" (ppr bty) ; arg_ty <- tcCheckLHsType (getBangType bty) exp_kind ; w' <- tcDataConMult w ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy NormalSyntax HsUnrestrictedArrow x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1487,7 +1488,7 @@ cvtTypeKind ty_str ty parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' w'' = hsTypeToArrow w' - returnL (HsFunTy noExtField w'' x'' y'') + returnL (HsFunTy NormalSyntax w'' x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName funTyCon))) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -43,7 +43,7 @@ (NoExtField) ({ T17544.hs:6:9-16 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544.hs:6:9 } (HsTyVar @@ -103,7 +103,7 @@ (NoExtField) ({ T17544.hs:10:9-16 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544.hs:10:9 } (HsTyVar @@ -160,7 +160,7 @@ (NoExtField) ({ T17544.hs:14:9-16 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544.hs:14:9 } (HsTyVar @@ -220,7 +220,7 @@ (NoExtField) ({ T17544.hs:18:9-16 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544.hs:18:9 } (HsTyVar @@ -247,7 +247,7 @@ (NoExtField) ({ T17544.hs:20:9-16 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544.hs:20:9 } (HsTyVar ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,6 +85,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsUnrestrictedArrow) ({ T17544_kw.hs:19:18-19 } (HsTupleTy ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,6 +66,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsLinearArrow) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar @@ -258,6 +259,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsLinearArrow) ({ DumpParsedAst.hs:14:25-29 } (HsParTy @@ -391,7 +393,7 @@ {OccName: f})) ({ DumpParsedAst.hs:16:31-39 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpParsedAst.hs:16:31 } (HsTyVar ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,6 +100,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsLinearArrow) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar @@ -253,7 +254,7 @@ (NoExtField) ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:15:20 } (HsTyVar @@ -263,7 +264,7 @@ {Name: k}))) ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:15:25 } (HsTyVar @@ -307,7 +308,7 @@ {Name: a}))) ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:18:28 } (HsTyVar @@ -331,14 +332,14 @@ (Just ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:18:43 } (HsTyVar @@ -370,6 +371,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy @@ -387,7 +389,7 @@ {Name: xx})))]) ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy @@ -496,6 +498,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsLinearArrow) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy @@ -619,7 +622,7 @@ {Name: f}) ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ DumpRenamedAst.hs:23:31 } (HsTyVar ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -275,7 +275,7 @@ (NoExtField) ({ KindSigs.hs:22:8-44 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ KindSigs.hs:22:8-20 } (HsParTy @@ -299,7 +299,7 @@ {OccName: Type})))))))) ({ KindSigs.hs:22:25-44 } (HsFunTy - (NoExtField) + (NormalSyntax) (HsUnrestrictedArrow) ({ KindSigs.hs:22:25-28 } (HsTyVar ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,6 +42,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsLinearArrow) ({ T14189.hs:6:18-20 } (HsTyVar ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,6 +41,7 @@ (Nothing) (PrefixCon [(HsScaled + (NormalSyntax) (HsUnrestrictedArrow) ({ T18791.hs:5:10-12 } (HsTyVar ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit a7c273efc6848583962f78cc84f97a4725f14b88 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6c8953a125adc241b5e5fdb5c73402d787b470f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a6c8953a125adc241b5e5fdb5c73402d787b470f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 14:23:37 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 10:23:37 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f80726929bf2_80b6f27e9c1794438a@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 991ddd69 by Daniel Rogozin at 2020-10-09T17:23:17+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: Type constructor 'Int' used where a value identifier was expected We also do this for type variables. - - - - - 17 changed files: - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName can be promoted to the type level and is in scope, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1051,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1085,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -889,8 +889,19 @@ cvtImplicitParamBind n e = do cvtl :: TH.Exp -> CvtM (LHsExpr GhcPs) cvtl e = wrapL (cvt e) where - cvt (VarE s) = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } - cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } + cvt (VarE s) + | isVarName s = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } + | isTyConName s = cvt (ConE s) + -- If VarE contains a type constructor, + -- then we process this name as a data constructor + -- in order to cause an "Illegal term-level + -- use of a type constructor" error. + -- See Note [Promotion] in GHC.Rename.Env. + -- In particular, this clause (together with the next one) + -- improves the error messages in test cases like + -- T14627, T7667a, and T15270B. + | otherwise = failWith (badOcc OccName.varName (nameBase s)) + cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } cvt (LitE l) | overloadedLit l = go cvtOverLit (HsOverLit noExtField) (hsOverLitNeedsParens appPrec) @@ -1915,6 +1926,12 @@ isVarName (TH.Name occ _) "" -> False (c:_) -> startsVarId c || startsVarSym c +isTyConName :: TH.Name -> Bool +isTyConName name + = case nameSpace name of + Just TcClsName -> True + _ -> False + badOcc :: OccName.NameSpace -> String -> SDoc badOcc ctxt_ns occ = text "Illegal" <+> pprNameSpace ctxt_ns ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,4 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/991ddd69249db8f6bdb42c25a776f79272c73acd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/991ddd69249db8f6bdb42c25a776f79272c73acd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 15:01:54 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Fri, 09 Oct 2020 11:01:54 -0400 Subject: [Git][ghc/ghc][wip/T16762] Wibbles from Simon Message-ID: <5f807b62d48d2_80b3f847d6d1744179560e1@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 76bbbda7 by Simon Peyton Jones at 2020-10-09T16:01:05+01:00 Wibbles from Simon - - - - - 5 changed files: - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Types/Var.hs Changes: ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -439,7 +439,12 @@ reportImplic ctxt implic@(Implic { ic_skols = tvs where tcl_env = ic_env implic insoluble = isInsolubleStatus status - (env1, tvs') = mapAccumL tidyVarBndr (cec_tidy ctxt) tvs + (env1, tvs') = mapAccumL tidyVarBndr (cec_tidy ctxt) $ + scopedSort tvs + -- scopedSort: the ic_skols may not be in dependency order + -- (see Note [Skolems in an implication] in GHC.Tc.Types.Constraint) + -- but tidying goes wrong on out-of-order constraints; + -- so we sort them here before tidying info' = tidySkolemInfo env1 info implic' = implic { ic_skols = tvs' , ic_given = map (tidyEvVar env1) given ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -4088,6 +4088,7 @@ promotionErr name err NoDataKindsDC -> text "perhaps you intended to use DataKinds" PatSynPE -> text "pattern synonyms cannot be promoted" _ -> text "it is defined and used in the same recursive group" + -- RecDataConPE, ClassPE, TyConPE {- ************************************************************************ ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -381,16 +381,19 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details univ_tvs = binderVars univ_bndrs ex_tvs = binderVars ex_bndrs - -- Skolemise the universals. This is necessary in order to check the actual pattern - -- type against the expected type. Even though the tyvars in the type are already - -- skolems, this step changes their TcLevels, avoiding level-check errors when - -- unifying. + -- Skolemise the quantified type variables. This is necessary + -- in order to check the actual pattern type against the + -- expected type. Even though the tyvars in the type are + -- already skolems, this step changes their TcLevels, + -- avoiding level-check errors when unifying. ; (skol_subst0, skol_univ_tvs) <- tcInstSkolTyVars univ_tvs - ; let skol_req_theta = substTheta skol_subst0 req_theta ; (skol_subst, skol_ex_tvs) <- tcInstSkolTyVarsX skol_subst0 ex_tvs - ; let skol_prov_theta = substTheta skol_subst prov_theta - skol_arg_tys = substTys skol_subst (map scaledThing arg_tys) - skol_pat_ty = substTy skol_subst pat_ty + ; let skol_univ_bndrs = transferArgFlags univ_bndrs skol_univ_tvs + skol_ex_bndrs = transferArgFlags ex_bndrs skol_ex_tvs + skol_req_theta = substTheta skol_subst0 req_theta + skol_prov_theta = substTheta skol_subst prov_theta + skol_arg_tys = substTys skol_subst (map scaledThing arg_tys) + skol_pat_ty = substTy skol_subst pat_ty univ_tv_prs = [ (getName orig_univ_tv, skol_univ_tv) | (orig_univ_tv, skol_univ_tv) <- univ_tvs `zip` skol_univ_tvs ] @@ -436,16 +439,6 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details -- Otherwise we may get a type error when typechecking the builder, -- when that should be impossible - -- Need to get Specificities right for univ_bndrs - ; let skol_univ_bndrs = zipWithEqual "tcCheckPatSynDecl" - xfer_specificity univ_bndrs skol_univ_tvs - skol_ex_bndrs = zipWithEqual "tcCheckPatSynDecl2" - xfer_specificity ex_bndrs skol_ex_tvs - - xfer_specificity :: VarBndr var Specificity -> TyVar - -> VarBndr TyVar Specificity - xfer_specificity bndr tv = mkTyVarBinder (binderArgFlag bndr) tv - ; traceTc "tcCheckPatSynDecl }" $ ppr name ; tc_patsyn_finish lname dir is_infix lpat' ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -1294,14 +1294,30 @@ worrying that 'b' might clash. Note [Skolems in an implication] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The skolems in an implication are not there to perform a skolem escape -check. That happens because all the environment variables are in the -untouchables, and therefore cannot be unified with anything at all, -let alone the skolems. - -Instead, ic_skols is used only when considering floating a constraint -outside the implication in GHC.Tc.Solver.floatEqualities or -GHC.Tc.Solver.approximateImplications +The skolems in an implication are used: + +* When considering floating a constraint outside the implication in + GHC.Tc.Solver.floatEqualities or GHC.Tc.Solver.approximateImplications + For this, we can treat ic_skols as a set. + +* When checking that a /user-specified/ forall (ic_info = ForAllSkol tvs) + has its variables in the correct order; see Note [Checking telescopes]. + Only for these implications does ic_skols need to be a list. + +Nota bene: Although ic_skols is a list, it is not necessarily +in dependency order: +- In the ic_info=ForAllSkol case, the user might have written them + in the wrong order +- In the case of a type signature like + f :: [a] -> [b] + the renamer gathers the implicit "outer" forall'd variables {a,b}, but + does not know what order to put them in. The type checker can sort them + into dependency order, but only after solving all the kind constraints; + and to do that it's convenient to create the Implication! + +So we accept that ic_skols may be out of order. Think of it as a set or +(in the case of ic_info=ForAllSkol, a list in user-specified, and possibly +wrong, order. Note [Insoluble constraints] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Types/Var.hs ===================================== @@ -79,6 +79,7 @@ module GHC.Types.Var ( isTyVarBinder, tyVarSpecToBinder, tyVarSpecToBinders, tyVarReqToBinder, tyVarReqToBinders, mapVarBndr, mapVarBndrs, lookupVarBndr, + transferArgFlag, transferArgFlags, -- ** Constructing TyVar's mkTyVar, mkTcTyVar, @@ -657,6 +658,12 @@ tyVarReqToBinders = map tyVarReqToBinder tyVarReqToBinder :: VarBndr a () -> VarBndr a ArgFlag tyVarReqToBinder (Bndr tv _) = Bndr tv Required +transferArgFlag :: VarBndr var1 argf1 -> var2 -> VarBndr var2 argf1 +transferArgFlag (Bndr _ af) v2 = Bndr v2 af + +transferArgFlags :: [VarBndr var1 argf1] -> [var2] -> [VarBndr var2 argf1] +transferArgFlags = zipWithEqual "transferArgFlags" transferArgFlag + binderVar :: VarBndr tv argf -> tv binderVar (Bndr v _) = v View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bbbda7e8715e07ec83fcf404af717a97b2ab2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bbbda7e8715e07ec83fcf404af717a97b2ab2d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 15:27:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 11:27:28 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 26 commits: Use UnitId in the backend instead of Unit Message-ID: <5f808160ab26a_80b3f84a105336c1795866f@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - e93934cf by Krzysztof Gogolewski at 2020-10-09T11:27:19-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 3366c54f by Simon Peyton Jones at 2020-10-09T11:27:24-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d699082b520bdd143d240c53c313d9a4ba71b01...3366c54f05d2d02f0f24bad29f38776c4fd30ad4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4d699082b520bdd143d240c53c313d9a4ba71b01...3366c54f05d2d02f0f24bad29f38776c4fd30ad4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 15:45:05 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 09 Oct 2020 11:45:05 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Undo the workaround in 'cvt', fix 'repVarOrCon' Message-ID: <5f8085811bb6e_80b866eefc179632b6@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 0560fa91 by Vladislav Zavialov at 2020-10-09T18:43:34+03:00 Undo the workaround in 'cvt', fix 'repVarOrCon' - - - - - 5 changed files: - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/ThToHs.hs - + testsuite/tests/th/T18740d.hs - + testsuite/tests/th/T18740d.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2248,8 +2248,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] --------------- Expressions ----------------- repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp)) -repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str - | otherwise = repVar str +repVarOrCon vc str + | isVarNameSpace ns = repVar str -- Both type and term variables (#18740) + | otherwise = repCon str + where + ns = nameNameSpace vc repVar :: Core TH.Name -> MetaM (Core (M TH.Exp)) repVar (MkC s) = rep2 varEName [s] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -889,19 +889,8 @@ cvtImplicitParamBind n e = do cvtl :: TH.Exp -> CvtM (LHsExpr GhcPs) cvtl e = wrapL (cvt e) where - cvt (VarE s) - | isVarName s = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } - | isTyConName s = cvt (ConE s) - -- If VarE contains a type constructor, - -- then we process this name as a data constructor - -- in order to cause an "Illegal term-level - -- use of a type constructor" error. - -- See Note [Promotion] in GHC.Rename.Env. - -- In particular, this clause (together with the next one) - -- improves the error messages in test cases like - -- T14627, T7667a, and T15270B. - | otherwise = failWith (badOcc OccName.varName (nameBase s)) - cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } + cvt (VarE s) = do { s' <- vName s; return $ HsVar noExtField (noLoc s') } + cvt (ConE s) = do { s' <- cName s; return $ HsVar noExtField (noLoc s') } cvt (LitE l) | overloadedLit l = go cvtOverLit (HsOverLit noExtField) (hsOverLitNeedsParens appPrec) @@ -1926,12 +1915,6 @@ isVarName (TH.Name occ _) "" -> False (c:_) -> startsVarId c || startsVarSym c -isTyConName :: TH.Name -> Bool -isTyConName name - = case nameSpace name of - Just TcClsName -> True - _ -> False - badOcc :: OccName.NameSpace -> String -> SDoc badOcc ctxt_ns occ = text "Illegal" <+> pprNameSpace ctxt_ns ===================================== testsuite/tests/th/T18740d.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T18740d where + +import Language.Haskell.TH + +-- If we used 'ConE' here, then we would expect this error message: +-- +-- Illegal term-level use of the type constructor ‘Bool’ +-- imported from ‘Prelude’ at T18740d.hs:3:8-14 +-- (and originally defined in ‘GHC.Types’) +-- +-- But we used 'VarE', so the error message should say: +-- +-- Illegal variable name: ‘Bool’ +-- +e1 = $(return (VarE ''Bool)) ===================================== testsuite/tests/th/T18740d.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740d.hs:17:7: error: + • Illegal variable name: ‘Bool’ + When splicing a TH expression: GHC.Types.Bool + • In the untyped splice: $(return (VarE ''Bool)) ===================================== testsuite/tests/th/all.T ===================================== @@ -516,3 +516,4 @@ test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) test('T18740c', normal, compile_fail, ['']) +test('T18740d', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0560fa91ba213800c1722ee6defc70d9efab58b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0560fa91ba213800c1722ee6defc70d9efab58b7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 15:49:54 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 11:49:54 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Apply suggestion to compiler/GHC/Rename/Env.hs Message-ID: <5f8086a2116b2_80b3f84643f6d941796394f@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: a80d2c5d by Danya Rogozin at 2020-10-09T11:49:51-04:00 Apply suggestion to compiler/GHC/Rename/Env.hs - - - - - 1 changed file: - compiler/GHC/Rename/Env.hs Changes: ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1005,7 +1005,7 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] --- If the given RdrName can be promoted to the type level and is in scope, +-- If the given RdrName can be promoted to the type level and its promoted variant is in scope, -- lookup_promoted returns the corresponding type-level Name. -- Otherwise, the function returns Nothing. -- See Note [Promotion] below. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a80d2c5dfb235c71e88df40a85f608e9f1fb2147 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a80d2c5dfb235c71e88df40a85f608e9f1fb2147 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 17:21:25 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Fri, 09 Oct 2020 13:21:25 -0400 Subject: [Git][ghc/ghc][wip/T16762] Still freshen existentials, though. Message-ID: <5f809c15efd5e_80b3f842924757417972226@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 7a777a49 by Richard Eisenberg at 2020-10-09T13:21:06-04:00 Still freshen existentials, though. - - - - - 2 changed files: - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Utils/Instantiate.hs Changes: ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -837,6 +837,15 @@ between alternatives. RIP GADT refinement: refinements have been replaced by the use of explicit equality constraints that are used in conjunction with implication constraints to express the local scope of GADT refinements. + +Note [Freshen existentials] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is essential that these existentials are freshened. +Otherwise, if we have something like + case (a :: Ex, b :: Ex) of (MkEx ..., MkEx ...) -> ... +we'll give both unpacked existential variables the +same name, leading to shadowing. + -} -- Running example: @@ -887,6 +896,7 @@ tcDataConPat penv (L con_span con_name) data_con pat_ty_scaled ; (tenv, ex_tvs') <- tcInstSuperSkolTyVarsX tenv ex_tvs -- Get location from monad, not from ex_tvs + -- This freshens: See Note [Freshen existentials] ; let -- pat_ty' = mkTyConApp tycon ctxt_res_tys -- pat_ty' is type of the actual constructor application @@ -973,6 +983,8 @@ tcPatSynPat penv (L con_span _) pat_syn pat_ty arg_pats thing_inside ; let all_arg_tys = ty : prov_theta ++ (map scaledThing arg_tys) ; checkExistentials ex_tvs all_arg_tys penv ; (tenv, ex_tvs') <- tcInstSuperSkolTyVarsX subst ex_tvs + -- This freshens: Note [Freshen existentials] + ; let ty' = substTy tenv ty arg_tys' = substScaledTys tenv arg_tys pat_mult = scaledMult pat_ty ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -486,7 +486,7 @@ tcInstTypeBndrs id tcSkolDFunType :: DFunId -> TcM ([TcTyVar], TcThetaType, TcType) -- Instantiate a type signature with skolem constants. --- We could give them fresh names, but no need to do so +-- This freshens the names, but no need to do so tcSkolDFunType dfun = do { (tv_prs, theta, tau) <- tcInstType tcInstSuperSkolTyVars dfun ; return (map snd tv_prs, theta, tau) } @@ -518,20 +518,34 @@ tcInstSkolTyVarsX = tcInstSkolTyVarsPushLevel False tcInstSuperSkolTyVars :: [TyVar] -> TcM (TCvSubst, [TcTyVar]) -- See Note [Skolemising type variables] +-- This version freshens the names and creates "super skolems"; +-- see comments around superSkolemTv. tcInstSuperSkolTyVars = tcInstSuperSkolTyVarsX emptyTCvSubst tcInstSuperSkolTyVarsX :: TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) -- See Note [Skolemising type variables] +-- This version freshens the names and creates "super skolems"; +-- see comments around superSkolemTv. tcInstSuperSkolTyVarsX subst = tcInstSkolTyVarsPushLevel True subst -tcInstSkolTyVarsPushLevel :: Bool -> TCvSubst -> [TyVar] +tcInstSkolTyVarsPushLevel :: Bool -- True <=> make "super skolem" AND + -- freshen names + -> TCvSubst -> [TyVar] -> TcM (TCvSubst, [TcTyVar]) -- Skolemise one level deeper, hence pushTcLevel -- See Note [Skolemising type variables] -tcInstSkolTyVarsPushLevel overlappable subst tvs +tcInstSkolTyVarsPushLevel overlappable_and_freshen subst tvs = do { tc_lvl <- getTcLevel ; let pushed_lvl = pushTcLevel tc_lvl - ; return (tcInstSkolTyVarsAt pushed_lvl overlappable subst tvs) } + ; if overlappable_and_freshen + then freshenTyCoVarsX (mk_skol pushed_lvl) subst tvs + else return (tcInstSkolTyVarsAt pushed_lvl overlappable_and_freshen + subst tvs) } + where + mk_skol :: TcLevel -> Name -> Kind -> TcTyVar + mk_skol lvl nm ki = mkTcTyVar nm ki details + where + details = SkolemTv lvl overlappable_and_freshen tcInstSkolTyVarsAt :: TcLevel -> Bool -> TCvSubst -> [TyVar] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a777a490038b2c6db8cdaa17ec4af18db5dc619 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a777a490038b2c6db8cdaa17ec4af18db5dc619 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 17:59:39 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 13:59:39 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] Fall back to types when looking up data constructors (#18740) Message-ID: <5f80a50bc9608_80b3f848646e80417978967@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 58bfa4eb by Daniel Rogozin at 2020-10-09T20:59:07+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 19 changed files: - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - + testsuite/tests/th/T18740d.hs - + testsuite/tests/th/T18740d.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2248,8 +2248,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] --------------- Expressions ----------------- repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp)) -repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str - | otherwise = repVar str +repVarOrCon vc str + | isVarNameSpace ns = repVar str -- Both type and term variables (#18740) + | otherwise = repCon str + where + ns = nameNameSpace vc repVar :: Core TH.Name -> MetaM (Core (M TH.Exp)) repVar (MkC s) = rep2 varEName [s] ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -5,7 +5,7 @@ GHC.Rename.Env contains functions which convert RdrNames into Names. -} -{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns #-} +{-# LANGUAGE CPP, MultiWayIf, NamedFieldPuns, TypeApplications #-} module GHC.Rename.Env ( newTopSrcBinder, @@ -1005,6 +1005,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName can be promoted to the type level and its promoted variant is in scope, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1040,6 +1051,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1054,14 +1085,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -751,6 +751,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -768,9 +769,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1140,4 +1163,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/T18740d.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T18740d where + +import Language.Haskell.TH + +-- If we used 'ConE' here, then we would expect this error message: +-- +-- Illegal term-level use of the type constructor ‘Bool’ +-- imported from ‘Prelude’ at T18740d.hs:3:8-14 +-- (and originally defined in ‘GHC.Types’) +-- +-- But we used 'VarE', so the error message should say: +-- +-- Illegal variable name: ‘Bool’ +-- +e1 = $(return (VarE ''Bool)) ===================================== testsuite/tests/th/T18740d.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740d.hs:17:7: error: + • Illegal variable name: ‘Bool’ + When splicing a TH expression: GHC.Types.Bool + • In the untyped splice: $(return (VarE ''Bool)) ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,5 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) +test('T18740d', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58bfa4eb4677ce7826dfa353b4b7cb0b1b1582a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58bfa4eb4677ce7826dfa353b4b7cb0b1b1582a9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 18:33:43 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 09 Oct 2020 14:33:43 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] 25 commits: Use UnitId in the backend instead of Unit Message-ID: <5f80ad07e64b_80b3f8494cfe84417982844@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - cb90acda by Daniel Rogozin at 2020-10-09T21:33:20+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58bfa4eb4677ce7826dfa353b4b7cb0b1b1582a9...cb90acda33947e09653620a80db6f4d744451099 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/58bfa4eb4677ce7826dfa353b4b7cb0b1b1582a9...cb90acda33947e09653620a80db6f4d744451099 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 20:47:54 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Fri, 09 Oct 2020 16:47:54 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Lots of bug-fixing. Message-ID: <5f80cc7ad3765_80b3f848750c9f41801579a@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: c2972870 by Richard Eisenberg at 2020-10-09T16:47:37-04:00 Lots of bug-fixing. - - - - - 26 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/indexed-types/should_compile/T3017.stderr - testsuite/tests/indexed-types/should_fail/T14369.stderr - testsuite/tests/indexed-types/should_fail/T2544.stderr - testsuite/tests/indexed-types/should_fail/T2627b.stderr - testsuite/tests/indexed-types/should_fail/T3330c.stderr - testsuite/tests/indexed-types/should_fail/T4174.stderr - testsuite/tests/indexed-types/should_fail/T4179.stderr - testsuite/tests/indexed-types/should_fail/T4272.stderr - testsuite/tests/indexed-types/should_fail/T5439.stderr - testsuite/tests/indexed-types/should_fail/T8227.stderr - testsuite/tests/indexed-types/should_fail/T8518.stderr Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -1226,7 +1226,7 @@ mkKindCo co | otherwise = KindCo co -mkSubCo :: Coercion -> Coercion +mkSubCo :: HasDebugCallStack => Coercion -> Coercion -- Input coercion is Nominal, result is Representational -- see also Note [Role twiddling functions] mkSubCo (Refl ty) = GRefl Representational ty MRefl ===================================== compiler/GHC/Core/Coercion.hs-boot ===================================== @@ -30,7 +30,7 @@ mkInstCo :: Coercion -> Coercion -> Coercion mkGReflCo :: Role -> Type -> MCoercionN -> Coercion mkNomReflCo :: Type -> Coercion mkKindCo :: Coercion -> Coercion -mkSubCo :: Coercion -> Coercion +mkSubCo :: HasDebugCallStack => Coercion -> Coercion mkProofIrrelCo :: Role -> Coercion -> Coercion -> Coercion -> Coercion mkAxiomRuleCo :: CoAxiomRule -> [Coercion] -> Coercion ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -24,7 +24,6 @@ import GHC.Core.TyCon import GHC.Core.Coercion.Axiom import GHC.Types.Var.Set import GHC.Types.Var.Env -import GHC.Core.FamInstEnv ( flattenTys ) import GHC.Data.Pair import GHC.Data.List.SetOps ( getNth ) import GHC.Core.Unify ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -33,10 +33,7 @@ module GHC.Core.FamInstEnv ( -- Normalisation topNormaliseType, topNormaliseType_maybe, normaliseType, normaliseTcApp, - topReduceTyFamApp_maybe, reduceTyFamApp_maybe, - - -- Flattening - flattenTys + topReduceTyFamApp_maybe, reduceTyFamApp_maybe ) where #include "HsVersions.h" @@ -54,11 +51,8 @@ import GHC.Types.Var.Env import GHC.Types.Name import GHC.Types.Unique.DFM import GHC.Data.Maybe -import GHC.Core.Map -import GHC.Types.Unique import GHC.Types.Var import GHC.Types.SrcLoc -import GHC.Data.FastString import Control.Monad import Data.List( mapAccumL ) import Data.Array( Array, assocs ) @@ -432,7 +426,7 @@ Here is how we do it: apart(target, pattern) = not (unify(flatten(target), pattern)) where flatten (implemented in flattenTys, below) converts all type-family -applications into fresh variables. (See Note [Flattening].) +applications into fresh variables. (See Note [Flattening] in GHC.Core.Unify.) Note [Compatibility] ~~~~~~~~~~~~~~~~~~~~ @@ -1179,7 +1173,7 @@ findBranch branches target_tys , cab_incomps = incomps }) = branch in_scope = mkInScopeSet (unionVarSets $ map (tyCoVarsOfTypes . coAxBranchLHS) incomps) - -- See Note [Flattening] below + -- See Note [Flattening] in GHC.Core.Unify flattened_target = flattenTys in_scope target_tys in case tcMatchTys tpl_lhs target_tys of Just subst -- matching worked. now, check for apartness. @@ -1197,7 +1191,8 @@ findBranch branches target_tys -- ('CoAxBranch') of a closed type family can be used to reduce a certain target -- type family application. apartnessCheck :: [Type] -- ^ /flattened/ target arguments. Make sure - -- they're flattened! See Note [Flattening]. + -- they're flattened! See Note [Flattening] + -- in GHC.Core.Unify -- (NB: This "flat" is a different -- "flat" than is used in GHC.Tc.Solver.Flatten.) -> CoAxBranch -- ^ the candidate equation we wish to use @@ -1563,292 +1558,3 @@ instance Monad NormM where instance Applicative NormM where pure x = NormM $ \ _ _ _ -> x (<*>) = ap - -{- -************************************************************************ -* * - Flattening -* * -************************************************************************ - -Note [Flattening] -~~~~~~~~~~~~~~~~~ -As described in "Closed type families with overlapping equations" -http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/axioms-extended.pdf -we need to flatten core types before unifying them, when checking for "surely-apart" -against earlier equations of a closed type family. -Flattening means replacing all top-level uses of type functions with -fresh variables, *taking care to preserve sharing*. That is, the type -(Either (F a b) (F a b)) should flatten to (Either c c), never (Either -c d). - -Here is a nice example of why it's all necessary: - - type family F a b where - F Int Bool = Char - F a b = Double - type family G a -- open, no instances - -How do we reduce (F (G Float) (G Float))? The first equation clearly doesn't match, -while the second equation does. But, before reducing, we must make sure that the -target can never become (F Int Bool). Well, no matter what G Float becomes, it -certainly won't become *both* Int and Bool, so indeed we're safe reducing -(F (G Float) (G Float)) to Double. - -This is necessary not only to get more reductions (which we might be -willing to give up on), but for substitutivity. If we have (F x x), we -can see that (F x x) can reduce to Double. So, it had better be the -case that (F blah blah) can reduce to Double, no matter what (blah) -is! Flattening as done below ensures this. - -The algorithm works by building up a TypeMap TyVar, mapping -type family applications to fresh variables. This mapping must -be threaded through all the function calls, as any entry in -the mapping must be propagated to all future nodes in the tree. - -The algorithm also must track the set of in-scope variables, in -order to make fresh variables as it flattens. (We are far from a -source of fresh Uniques.) See Wrinkle 2, below. - -There are wrinkles, of course: - -1. The flattening algorithm must account for the possibility - of inner `forall`s. (A `forall` seen here can happen only - because of impredicativity. However, the flattening operation - is an algorithm in Core, which is impredicative.) - Suppose we have (forall b. F b) -> (forall b. F b). Of course, - those two bs are entirely unrelated, and so we should certainly - not flatten the two calls F b to the same variable. Instead, they - must be treated separately. We thus carry a substitution that - freshens variables; we must apply this substitution (in - `coreFlattenTyFamApp`) before looking up an application in the environment. - Note that the range of the substitution contains only TyVars, never anything - else. - - For the sake of efficiency, we only apply this substitution when absolutely - necessary. Namely: - - * We do not perform the substitution at all if it is empty. - * We only need to worry about the arguments of a type family that are within - the arity of said type family, so we can get away with not applying the - substitution to any oversaturated type family arguments. - * Importantly, we do /not/ achieve this substitution by recursively - flattening the arguments, as this would be wrong. Consider `F (G a)`, - where F and G are type families. We might decide that `F (G a)` flattens - to `beta`. Later, the substitution is non-empty (but does not map `a`) and - so we flatten `G a` to `gamma` and try to flatten `F gamma`. Of course, - `F gamma` is unknown, and so we flatten it to `delta`, but it really - should have been `beta`! Argh! - - Moral of the story: instead of flattening the arguments, just substitute - them directly. - -2. There are two different reasons we might add a variable - to the in-scope set as we work: - - A. We have just invented a new flattening variable. - B. We have entered a `forall`. - - Annoying here is that in-scope variable source (A) must be - threaded through the calls. For example, consider (F b -> forall c. F c). - Suppose that, when flattening F b, we invent a fresh variable c. - Now, when we encounter (forall c. F c), we need to know c is already in - scope so that we locally rename c to c'. However, if we don't thread through - the in-scope set from one argument of (->) to the other, we won't know this - and might get very confused. - - In contrast, source (B) increases only as we go deeper, as in-scope sets - normally do. However, even here we must be careful. The TypeMap TyVar that - contains mappings from type family applications to freshened variables will - be threaded through both sides of (forall b. F b) -> (forall b. F b). We - thus must make sure that the two `b`s don't get renamed to the same b1. (If - they did, then looking up `F b1` would yield the same flatten var for - each.) So, even though `forall`-bound variables should really be in the - in-scope set only when they are in scope, we retain these variables even - outside of their scope. This ensures that, if we encounter a fresh - `forall`-bound b, we will rename it to b2, not b1. Note that keeping a - larger in-scope set than strictly necessary is always OK, as in-scope sets - are only ever used to avoid collisions. - - Sadly, the freshening substitution described in (1) really mustn't bind - variables outside of their scope: note that its domain is the *unrenamed* - variables. This means that the substitution gets "pushed down" (like a - reader monad) while the in-scope set gets threaded (like a state monad). - Because a TCvSubst contains its own in-scope set, we don't carry a TCvSubst; - instead, we just carry a TvSubstEnv down, tying it to the InScopeSet - traveling separately as necessary. - -3. Consider `F ty_1 ... ty_n`, where F is a type family with arity k: - - type family F ty_1 ... ty_k :: res_k - - It's tempting to just flatten `F ty_1 ... ty_n` to `alpha`, where alpha is a - flattening skolem. But we must instead flatten it to - `alpha ty_(k+1) ... ty_n`—that is, by only flattening up to the arity of the - type family. - - Why is this better? Consider the following concrete example from #16995: - - type family Param :: Type -> Type - - type family LookupParam (a :: Type) :: Type where - LookupParam (f Char) = Bool - LookupParam x = Int - - foo :: LookupParam (Param ()) - foo = 42 - - In order for `foo` to typecheck, `LookupParam (Param ())` must reduce to - `Int`. But if we flatten `Param ()` to `alpha`, then GHC can't be sure if - `alpha` is apart from `f Char`, so it won't fall through to the second - equation. But since the `Param` type family has arity 0, we can instead - flatten `Param ()` to `alpha ()`, about which GHC knows with confidence is - apart from `f Char`, permitting the second equation to be reached. - - Not only does this allow more programs to be accepted, it's also important - for correctness. Not doing this was the root cause of the Core Lint error - in #16995. - -flattenTys is defined here because of module dependencies. --} - -data FlattenEnv - = FlattenEnv { fe_type_map :: TypeMap TyVar - -- domain: exactly-saturated type family applications - -- range: fresh variables - , fe_in_scope :: InScopeSet } - -- See Note [Flattening] - -emptyFlattenEnv :: InScopeSet -> FlattenEnv -emptyFlattenEnv in_scope - = FlattenEnv { fe_type_map = emptyTypeMap - , fe_in_scope = in_scope } - -updateInScopeSet :: FlattenEnv -> (InScopeSet -> InScopeSet) -> FlattenEnv -updateInScopeSet env upd = env { fe_in_scope = upd (fe_in_scope env) } - -flattenTys :: InScopeSet -> [Type] -> [Type] --- See Note [Flattening] --- NB: the returned types may mention fresh type variables, --- arising from the flattening. We don't return the --- mapping from those fresh vars to the ty-fam --- applications they stand for (we could, but no need) -flattenTys in_scope tys - = snd $ coreFlattenTys emptyTvSubstEnv (emptyFlattenEnv in_scope) tys - -coreFlattenTys :: TvSubstEnv -> FlattenEnv - -> [Type] -> (FlattenEnv, [Type]) -coreFlattenTys subst = mapAccumL (coreFlattenTy subst) - -coreFlattenTy :: TvSubstEnv -> FlattenEnv - -> Type -> (FlattenEnv, Type) -coreFlattenTy subst = go - where - go env ty | Just ty' <- coreView ty = go env ty' - - go env (TyVarTy tv) - | Just ty <- lookupVarEnv subst tv = (env, ty) - | otherwise = let (env', ki) = go env (tyVarKind tv) in - (env', mkTyVarTy $ setTyVarKind tv ki) - go env (AppTy ty1 ty2) = let (env1, ty1') = go env ty1 - (env2, ty2') = go env1 ty2 in - (env2, AppTy ty1' ty2') - go env (TyConApp tc tys) - -- NB: Don't just check if isFamilyTyCon: this catches *data* families, - -- which are generative and thus can be preserved during flattening - | not (isGenerativeTyCon tc Nominal) - = coreFlattenTyFamApp subst env tc tys - - | otherwise - = let (env', tys') = coreFlattenTys subst env tys in - (env', mkTyConApp tc tys') - - go env ty@(FunTy { ft_mult = mult, ft_arg = ty1, ft_res = ty2 }) - = let (env1, ty1') = go env ty1 - (env2, ty2') = go env1 ty2 - (env3, mult') = go env2 mult in - (env3, ty { ft_mult = mult', ft_arg = ty1', ft_res = ty2' }) - - go env (ForAllTy (Bndr tv vis) ty) - = let (env1, subst', tv') = coreFlattenVarBndr subst env tv - (env2, ty') = coreFlattenTy subst' env1 ty in - (env2, ForAllTy (Bndr tv' vis) ty') - - go env ty@(LitTy {}) = (env, ty) - - go env (CastTy ty co) - = let (env1, ty') = go env ty - (env2, co') = coreFlattenCo subst env1 co in - (env2, CastTy ty' co') - - go env (CoercionTy co) - = let (env', co') = coreFlattenCo subst env co in - (env', CoercionTy co') - - --- when flattening, we don't care about the contents of coercions. --- so, just return a fresh variable of the right (flattened) type -coreFlattenCo :: TvSubstEnv -> FlattenEnv - -> Coercion -> (FlattenEnv, Coercion) -coreFlattenCo subst env co - = (env2, mkCoVarCo covar) - where - (env1, kind') = coreFlattenTy subst env (coercionType co) - covar = mkFlattenFreshCoVar (fe_in_scope env1) kind' - -- Add the covar to the FlattenEnv's in-scope set. - -- See Note [Flattening], wrinkle 2A. - env2 = updateInScopeSet env1 (flip extendInScopeSet covar) - -coreFlattenVarBndr :: TvSubstEnv -> FlattenEnv - -> TyCoVar -> (FlattenEnv, TvSubstEnv, TyVar) -coreFlattenVarBndr subst env tv - = (env2, subst', tv') - where - -- See Note [Flattening], wrinkle 2B. - kind = varType tv - (env1, kind') = coreFlattenTy subst env kind - tv' = uniqAway (fe_in_scope env1) (setVarType tv kind') - subst' = extendVarEnv subst tv (mkTyVarTy tv') - env2 = updateInScopeSet env1 (flip extendInScopeSet tv') - -coreFlattenTyFamApp :: TvSubstEnv -> FlattenEnv - -> TyCon -- type family tycon - -> [Type] -- args, already flattened - -> (FlattenEnv, Type) -coreFlattenTyFamApp tv_subst env fam_tc fam_args - = case lookupTypeMap type_map fam_ty of - Just tv -> (env', mkAppTys (mkTyVarTy tv) leftover_args') - Nothing -> let tyvar_name = mkFlattenFreshTyName fam_tc - tv = uniqAway in_scope $ - mkTyVar tyvar_name (typeKind fam_ty) - - ty' = mkAppTys (mkTyVarTy tv) leftover_args' - env'' = env' { fe_type_map = extendTypeMap type_map fam_ty tv - , fe_in_scope = extendInScopeSet in_scope tv } - in (env'', ty') - where - arity = tyConArity fam_tc - tcv_subst = TCvSubst (fe_in_scope env) tv_subst emptyVarEnv - (sat_fam_args, leftover_args) = ASSERT( arity <= length fam_args ) - splitAt arity fam_args - -- Apply the substitution before looking up an application in the - -- environment. See Note [Flattening], wrinkle 1. - -- NB: substTys short-cuts the common case when the substitution is empty. - sat_fam_args' = substTys tcv_subst sat_fam_args - (env', leftover_args') = coreFlattenTys tv_subst env leftover_args - -- `fam_tc` may be over-applied to `fam_args` (see Note [Flattening], - -- wrinkle 3), so we split it into the arguments needed to saturate it - -- (sat_fam_args') and the rest (leftover_args') - fam_ty = mkTyConApp fam_tc sat_fam_args' - FlattenEnv { fe_type_map = type_map - , fe_in_scope = in_scope } = env' - -mkFlattenFreshTyName :: Uniquable a => a -> Name -mkFlattenFreshTyName unq - = mkSysTvName (getUnique unq) (fsLit "flt") - -mkFlattenFreshCoVar :: InScopeSet -> Kind -> CoVar -mkFlattenFreshCoVar in_scope kind - = let uniq = unsafeGetFreshLocalUnique in_scope - name = mkSystemVarName uniq (fsLit "flc") - in mkCoVar name kind ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -40,6 +40,7 @@ import GHC.Unit import GHC.Core.Class import GHC.Types.Var import GHC.Types.Var.Set +import GHC.Types.Var.Env import GHC.Types.Name import GHC.Types.Name.Set import GHC.Types.Unique (getUnique) @@ -827,18 +828,23 @@ lookupInstEnv' ie vis_mods cls tys = find ms us rest | otherwise - = ASSERT2( tyCoVarsOfTypes tys `disjointVarSet` tpl_tv_set, + = ASSERT2( tys_tv_set `disjointVarSet` tpl_tv_set, (ppr cls <+> ppr tys <+> ppr all_tvs) $$ (ppr tpl_tvs <+> ppr tpl_tys) ) -- Unification will break badly if the variables overlap -- They shouldn't because we allocate separate uniques for them -- See Note [Template tyvars are fresh] - case tcUnifyTys instanceBindFun tpl_tys tys of - Just _ -> find ms (item:us) rest - Nothing -> find ms us rest + let in_scope = mkInScopeSet (tpl_tv_set `unionVarSet` tys_tv_set) + flattened_tys = flattenTys in_scope tys in + -- NB: important to flatten here. Otherwise, it looks like + -- instance C Int cannot match a target [W] C (F Bool). + case tcUnifyTysFG instanceBindFun tpl_tys flattened_tys of + SurelyApart -> find ms us rest + _ -> find ms (item:us) rest where tpl_tv_set = mkVarSet tpl_tvs + tys_tv_set = tyCoVarsOfTypes tys --------------- -- This is the common way to call this function. ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -55,7 +55,7 @@ module GHC.Core.TyCon( mustBeSaturated, isPromotedDataCon, isPromotedDataCon_maybe, isKindTyCon, isLiftedTypeKindTyConName, - isTauTyCon, isFamFreeTyCon, + isTauTyCon, isFamFreeTyCon, isForgetfulSynTyCon, isDataTyCon, isProductTyCon, isDataProductTyCon_maybe, isDataSumTyCon_maybe, @@ -820,10 +820,12 @@ data TyCon synIsTau :: Bool, -- True <=> the RHS of this synonym does not -- have any foralls, after expanding any -- nested synonyms - synIsFamFree :: Bool -- True <=> the RHS of this synonym does not mention + synIsFamFree :: Bool, -- True <=> the RHS of this synonym does not mention -- any type synonym families (data families -- are fine), again after expanding any -- nested synonyms + synIsForgetful :: Bool -- True <=> at least one argument is not mentioned + -- in the RHS } -- | Represents families (both type and data) @@ -1782,20 +1784,21 @@ mkPrimTyCon' name binders res_kind roles is_unlifted rep_nm -- | Create a type synonym 'TyCon' mkSynonymTyCon :: Name -> [TyConBinder] -> Kind -- ^ /result/ kind - -> [Role] -> Type -> Bool -> Bool -> TyCon -mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free + -> [Role] -> Type -> Bool -> Bool -> Bool -> TyCon +mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful = SynonymTyCon { - tyConName = name, - tyConUnique = nameUnique name, - tyConBinders = binders, - tyConResKind = res_kind, - tyConKind = mkTyConKind binders res_kind, - tyConArity = length binders, - tyConTyVars = binderVars binders, - tcRoles = roles, - synTcRhs = rhs, - synIsTau = is_tau, - synIsFamFree = is_fam_free + tyConName = name, + tyConUnique = nameUnique name, + tyConBinders = binders, + tyConResKind = res_kind, + tyConKind = mkTyConKind binders res_kind, + tyConArity = length binders, + tyConTyVars = binderVars binders, + tcRoles = roles, + synTcRhs = rhs, + synIsTau = is_tau, + synIsFamFree = is_fam_free, + synIsForgetful = is_forgetful } -- | Create a type family 'TyCon' @@ -2056,6 +2059,11 @@ isFamFreeTyCon (SynonymTyCon { synIsFamFree = fam_free }) = fam_free isFamFreeTyCon (FamilyTyCon { famTcFlav = flav }) = isDataFamFlav flav isFamFreeTyCon _ = True +-- | Is this a forgetful type synonym? +isForgetfulSynTyCon :: TyCon -> Bool +isForgetfulSynTyCon (SynonymTyCon { synIsForgetful = forget }) = forget +isForgetfulSynTyCon _ = False + -- As for newtypes, it is in some contexts important to distinguish between -- closed synonyms and synonym families, as synonym families have no unique -- right hand side to which a synonym family application can expand. ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1967,13 +1967,14 @@ isCoVarType ty buildSynTyCon :: Name -> [KnotTied TyConBinder] -> Kind -- ^ /result/ kind -> [Role] -> KnotTied Type -> TyCon --- This function is here beucase here is where we have +-- This function is here because here is where we have -- isFamFree and isTauTy buildSynTyCon name binders res_kind roles rhs - = mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free + = mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful where - is_tau = isTauTy rhs - is_fam_free = isFamFreeTy rhs + is_tau = isTauTy rhs + is_fam_free = isFamFreeTy rhs + is_forgetful = any (not . (`elemVarSet` tyCoVarsOfType rhs) . binderVar) binders {- ************************************************************************ ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -21,7 +21,10 @@ module GHC.Core.Unify ( UnifyResult, UnifyResultM(..), -- Matching a type against a lifted type (coercion) - liftCoMatch + liftCoMatch, + + -- The core flattening algorithm + flattenTys ) where #include "HsVersions.h" @@ -31,21 +34,26 @@ import GHC.Prelude import GHC.Types.Var import GHC.Types.Var.Env import GHC.Types.Var.Set -import GHC.Types.Name( Name ) +import GHC.Types.Name( Name, mkSysTvName, mkSystemVarName ) import GHC.Core.Type hiding ( getTvSubstEnv ) import GHC.Core.Coercion hiding ( getCvSubstEnv ) import GHC.Core.TyCon import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs ( tyCoVarsOfCoList, tyCoFVsOfTypes ) import GHC.Core.TyCo.Subst ( mkTvSubst ) +import GHC.Core.Map import GHC.Utils.FV( FV, fvVarSet, fvVarList ) import GHC.Utils.Misc import GHC.Data.Pair import GHC.Utils.Outputable +import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.Set import GHC.Exts( oneShot ) +import GHC.Utils.Panic +import GHC.Data.FastString +import Data.List ( mapAccumL ) import Control.Monad import Control.Applicative hiding ( empty ) import qualified Control.Applicative @@ -691,7 +699,7 @@ unifier It does /not/ work up to ~. The algorithm implemented here is rather delicate, and we depend on it to uphold certain properties. This is a summary of these required properties. Any reference to "flattening" refers to the flattening -algorithm in GHC.Core.FamInstEnv (See Note [Flattening] in GHC.Core.FamInstEnv), not +algorithm in GHC.Core.FamInstEnv (See Note [Flattening] in GHC.Core.Unify), not the flattening algorithm in the solver. Notation: @@ -1600,3 +1608,292 @@ pushRefl co = -> Just (ForAllCo tv (mkNomReflCo (varType tv)) (mkReflCo r ty)) -- NB: NoRefl variant. Otherwise, we get a loop! _ -> Nothing + +{- +************************************************************************ +* * + Flattening +* * +************************************************************************ + +Note [Flattening] +~~~~~~~~~~~~~~~~~ +As described in "Closed type families with overlapping equations" +http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/axioms-extended.pdf +we need to flatten core types before unifying them, when checking for "surely-apart" +against earlier equations of a closed type family. +Flattening means replacing all top-level uses of type functions with +fresh variables, *taking care to preserve sharing*. That is, the type +(Either (F a b) (F a b)) should flatten to (Either c c), never (Either +c d). + +Here is a nice example of why it's all necessary: + + type family F a b where + F Int Bool = Char + F a b = Double + type family G a -- open, no instances + +How do we reduce (F (G Float) (G Float))? The first equation clearly doesn't match, +while the second equation does. But, before reducing, we must make sure that the +target can never become (F Int Bool). Well, no matter what G Float becomes, it +certainly won't become *both* Int and Bool, so indeed we're safe reducing +(F (G Float) (G Float)) to Double. + +This is necessary not only to get more reductions (which we might be +willing to give up on), but for substitutivity. If we have (F x x), we +can see that (F x x) can reduce to Double. So, it had better be the +case that (F blah blah) can reduce to Double, no matter what (blah) +is! Flattening as done below ensures this. + +The algorithm works by building up a TypeMap TyVar, mapping +type family applications to fresh variables. This mapping must +be threaded through all the function calls, as any entry in +the mapping must be propagated to all future nodes in the tree. + +The algorithm also must track the set of in-scope variables, in +order to make fresh variables as it flattens. (We are far from a +source of fresh Uniques.) See Wrinkle 2, below. + +There are wrinkles, of course: + +1. The flattening algorithm must account for the possibility + of inner `forall`s. (A `forall` seen here can happen only + because of impredicativity. However, the flattening operation + is an algorithm in Core, which is impredicative.) + Suppose we have (forall b. F b) -> (forall b. F b). Of course, + those two bs are entirely unrelated, and so we should certainly + not flatten the two calls F b to the same variable. Instead, they + must be treated separately. We thus carry a substitution that + freshens variables; we must apply this substitution (in + `coreFlattenTyFamApp`) before looking up an application in the environment. + Note that the range of the substitution contains only TyVars, never anything + else. + + For the sake of efficiency, we only apply this substitution when absolutely + necessary. Namely: + + * We do not perform the substitution at all if it is empty. + * We only need to worry about the arguments of a type family that are within + the arity of said type family, so we can get away with not applying the + substitution to any oversaturated type family arguments. + * Importantly, we do /not/ achieve this substitution by recursively + flattening the arguments, as this would be wrong. Consider `F (G a)`, + where F and G are type families. We might decide that `F (G a)` flattens + to `beta`. Later, the substitution is non-empty (but does not map `a`) and + so we flatten `G a` to `gamma` and try to flatten `F gamma`. Of course, + `F gamma` is unknown, and so we flatten it to `delta`, but it really + should have been `beta`! Argh! + + Moral of the story: instead of flattening the arguments, just substitute + them directly. + +2. There are two different reasons we might add a variable + to the in-scope set as we work: + + A. We have just invented a new flattening variable. + B. We have entered a `forall`. + + Annoying here is that in-scope variable source (A) must be + threaded through the calls. For example, consider (F b -> forall c. F c). + Suppose that, when flattening F b, we invent a fresh variable c. + Now, when we encounter (forall c. F c), we need to know c is already in + scope so that we locally rename c to c'. However, if we don't thread through + the in-scope set from one argument of (->) to the other, we won't know this + and might get very confused. + + In contrast, source (B) increases only as we go deeper, as in-scope sets + normally do. However, even here we must be careful. The TypeMap TyVar that + contains mappings from type family applications to freshened variables will + be threaded through both sides of (forall b. F b) -> (forall b. F b). We + thus must make sure that the two `b`s don't get renamed to the same b1. (If + they did, then looking up `F b1` would yield the same flatten var for + each.) So, even though `forall`-bound variables should really be in the + in-scope set only when they are in scope, we retain these variables even + outside of their scope. This ensures that, if we encounter a fresh + `forall`-bound b, we will rename it to b2, not b1. Note that keeping a + larger in-scope set than strictly necessary is always OK, as in-scope sets + are only ever used to avoid collisions. + + Sadly, the freshening substitution described in (1) really mustn't bind + variables outside of their scope: note that its domain is the *unrenamed* + variables. This means that the substitution gets "pushed down" (like a + reader monad) while the in-scope set gets threaded (like a state monad). + Because a TCvSubst contains its own in-scope set, we don't carry a TCvSubst; + instead, we just carry a TvSubstEnv down, tying it to the InScopeSet + traveling separately as necessary. + +3. Consider `F ty_1 ... ty_n`, where F is a type family with arity k: + + type family F ty_1 ... ty_k :: res_k + + It's tempting to just flatten `F ty_1 ... ty_n` to `alpha`, where alpha is a + flattening skolem. But we must instead flatten it to + `alpha ty_(k+1) ... ty_n`—that is, by only flattening up to the arity of the + type family. + + Why is this better? Consider the following concrete example from #16995: + + type family Param :: Type -> Type + + type family LookupParam (a :: Type) :: Type where + LookupParam (f Char) = Bool + LookupParam x = Int + + foo :: LookupParam (Param ()) + foo = 42 + + In order for `foo` to typecheck, `LookupParam (Param ())` must reduce to + `Int`. But if we flatten `Param ()` to `alpha`, then GHC can't be sure if + `alpha` is apart from `f Char`, so it won't fall through to the second + equation. But since the `Param` type family has arity 0, we can instead + flatten `Param ()` to `alpha ()`, about which GHC knows with confidence is + apart from `f Char`, permitting the second equation to be reached. + + Not only does this allow more programs to be accepted, it's also important + for correctness. Not doing this was the root cause of the Core Lint error + in #16995. + +flattenTys is defined here because of module dependencies. +-} + +data FlattenEnv + = FlattenEnv { fe_type_map :: TypeMap TyVar + -- domain: exactly-saturated type family applications + -- range: fresh variables + , fe_in_scope :: InScopeSet } + -- See Note [Flattening] + +emptyFlattenEnv :: InScopeSet -> FlattenEnv +emptyFlattenEnv in_scope + = FlattenEnv { fe_type_map = emptyTypeMap + , fe_in_scope = in_scope } + +updateInScopeSet :: FlattenEnv -> (InScopeSet -> InScopeSet) -> FlattenEnv +updateInScopeSet env upd = env { fe_in_scope = upd (fe_in_scope env) } + +flattenTys :: InScopeSet -> [Type] -> [Type] +-- See Note [Flattening] +-- NB: the returned types may mention fresh type variables, +-- arising from the flattening. We don't return the +-- mapping from those fresh vars to the ty-fam +-- applications they stand for (we could, but no need) +flattenTys in_scope tys + = snd $ coreFlattenTys emptyTvSubstEnv (emptyFlattenEnv in_scope) tys + +coreFlattenTys :: TvSubstEnv -> FlattenEnv + -> [Type] -> (FlattenEnv, [Type]) +coreFlattenTys subst = mapAccumL (coreFlattenTy subst) + +coreFlattenTy :: TvSubstEnv -> FlattenEnv + -> Type -> (FlattenEnv, Type) +coreFlattenTy subst = go + where + go env ty | Just ty' <- coreView ty = go env ty' + + go env (TyVarTy tv) + | Just ty <- lookupVarEnv subst tv = (env, ty) + | otherwise = let (env', ki) = go env (tyVarKind tv) in + (env', mkTyVarTy $ setTyVarKind tv ki) + go env (AppTy ty1 ty2) = let (env1, ty1') = go env ty1 + (env2, ty2') = go env1 ty2 in + (env2, AppTy ty1' ty2') + go env (TyConApp tc tys) + -- NB: Don't just check if isFamilyTyCon: this catches *data* families, + -- which are generative and thus can be preserved during flattening + | not (isGenerativeTyCon tc Nominal) + = coreFlattenTyFamApp subst env tc tys + + | otherwise + = let (env', tys') = coreFlattenTys subst env tys in + (env', mkTyConApp tc tys') + + go env ty@(FunTy { ft_mult = mult, ft_arg = ty1, ft_res = ty2 }) + = let (env1, ty1') = go env ty1 + (env2, ty2') = go env1 ty2 + (env3, mult') = go env2 mult in + (env3, ty { ft_mult = mult', ft_arg = ty1', ft_res = ty2' }) + + go env (ForAllTy (Bndr tv vis) ty) + = let (env1, subst', tv') = coreFlattenVarBndr subst env tv + (env2, ty') = coreFlattenTy subst' env1 ty in + (env2, ForAllTy (Bndr tv' vis) ty') + + go env ty@(LitTy {}) = (env, ty) + + go env (CastTy ty co) + = let (env1, ty') = go env ty + (env2, co') = coreFlattenCo subst env1 co in + (env2, CastTy ty' co') + + go env (CoercionTy co) + = let (env', co') = coreFlattenCo subst env co in + (env', CoercionTy co') + + +-- when flattening, we don't care about the contents of coercions. +-- so, just return a fresh variable of the right (flattened) type +coreFlattenCo :: TvSubstEnv -> FlattenEnv + -> Coercion -> (FlattenEnv, Coercion) +coreFlattenCo subst env co + = (env2, mkCoVarCo covar) + where + (env1, kind') = coreFlattenTy subst env (coercionType co) + covar = mkFlattenFreshCoVar (fe_in_scope env1) kind' + -- Add the covar to the FlattenEnv's in-scope set. + -- See Note [Flattening], wrinkle 2A. + env2 = updateInScopeSet env1 (flip extendInScopeSet covar) + +coreFlattenVarBndr :: TvSubstEnv -> FlattenEnv + -> TyCoVar -> (FlattenEnv, TvSubstEnv, TyVar) +coreFlattenVarBndr subst env tv + = (env2, subst', tv') + where + -- See Note [Flattening], wrinkle 2B. + kind = varType tv + (env1, kind') = coreFlattenTy subst env kind + tv' = uniqAway (fe_in_scope env1) (setVarType tv kind') + subst' = extendVarEnv subst tv (mkTyVarTy tv') + env2 = updateInScopeSet env1 (flip extendInScopeSet tv') + +coreFlattenTyFamApp :: TvSubstEnv -> FlattenEnv + -> TyCon -- type family tycon + -> [Type] -- args, already flattened + -> (FlattenEnv, Type) +coreFlattenTyFamApp tv_subst env fam_tc fam_args + = case lookupTypeMap type_map fam_ty of + Just tv -> (env', mkAppTys (mkTyVarTy tv) leftover_args') + Nothing -> let tyvar_name = mkFlattenFreshTyName fam_tc + tv = uniqAway in_scope $ + mkTyVar tyvar_name (typeKind fam_ty) + + ty' = mkAppTys (mkTyVarTy tv) leftover_args' + env'' = env' { fe_type_map = extendTypeMap type_map fam_ty tv + , fe_in_scope = extendInScopeSet in_scope tv } + in (env'', ty') + where + arity = tyConArity fam_tc + tcv_subst = TCvSubst (fe_in_scope env) tv_subst emptyVarEnv + (sat_fam_args, leftover_args) = ASSERT( arity <= length fam_args ) + splitAt arity fam_args + -- Apply the substitution before looking up an application in the + -- environment. See Note [Flattening], wrinkle 1. + -- NB: substTys short-cuts the common case when the substitution is empty. + sat_fam_args' = substTys tcv_subst sat_fam_args + (env', leftover_args') = coreFlattenTys tv_subst env leftover_args + -- `fam_tc` may be over-applied to `fam_args` (see Note [Flattening], + -- wrinkle 3), so we split it into the arguments needed to saturate it + -- (sat_fam_args') and the rest (leftover_args') + fam_ty = mkTyConApp fam_tc sat_fam_args' + FlattenEnv { fe_type_map = type_map + , fe_in_scope = in_scope } = env' + +mkFlattenFreshTyName :: Uniquable a => a -> Name +mkFlattenFreshTyName unq + = mkSysTvName (getUnique unq) (fsLit "flt") + +mkFlattenFreshCoVar :: InScopeSet -> Kind -> CoVar +mkFlattenFreshCoVar in_scope kind + = let uniq = unsafeGetFreshLocalUnique in_scope + name = mkSystemVarName uniq (fsLit "flc") + in mkCoVar name kind ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -31,10 +31,9 @@ import GHC.Core.Type import GHC.Core.Coercion import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr ( pprTyVars, pprWithExplicitKindsWhen, pprSourceTyCon, pprWithTYPE ) -import GHC.Core.Unify ( tcMatchTys ) +import GHC.Core.Unify ( tcMatchTys, flattenTys ) import GHC.Unit.Module import GHC.Tc.Instance.Family -import GHC.Core.FamInstEnv ( flattenTys ) import GHC.Tc.Utils.Instantiate import GHC.Core.InstEnv import GHC.Core.TyCon ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -17,7 +17,7 @@ import GHC.Prelude import GHC.Tc.Types.Constraint import GHC.Core.Predicate import GHC.Tc.Types.Origin -import GHC.Tc.Utils.Unify( swapOverTyVars, metaTyVarUpdateOK, MetaTyVarUpdateResult(..) ) +import GHC.Tc.Utils.Unify import GHC.Tc.Utils.TcType import GHC.Core.Type import GHC.Tc.Solver.Flatten @@ -2155,6 +2155,16 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco ; canEqTyVarFunEq new_ev eq_rel IsSwapped tv2 ps_xi2 fun_tc1 fun_args1 ps_xi1 sym_mco } + | NomEq <- eq_rel + , TyFamLHS fun_tc1 fun_args1 <- lhs1 + , TyFamLHS fun_tc2 fun_args2 <- lhs2 + , fun_tc1 == fun_tc2 + , Injective inj <- tyConInjectivityInfo fun_tc1 + = do { traceTcS "CanEqCanLHS2 injective type family" (ppr lhs1 $$ ppr lhs2) + ; sequence_ [ unifyDerived (ctEvLoc ev) Nominal (Pair arg1 arg2) + | (arg1, arg2, True) <- zip3 fun_args1 fun_args2 inj ] + ; canEqCanLHSFinish ev eq_rel swapped lhs1 (ps_xi2 `mkCastTyMCo` mco) } + -- that's all the special cases. Now we just figure out which non-special case -- to continue to. | otherwise @@ -2213,11 +2223,11 @@ canEqCanLHSFinish ev eq_rel swapped lhs rhs -- #12593 -- guarantees (TyEq:OC), (TyEq:F), and (TyEq:H) ; case canEqOK dflags eq_rel lhs rhs of - CanEqOK rhs' -> - do { traceTcS "canEqOK" (ppr lhs $$ ppr rhs') - ; new_ev <- rewriteEqEvidence ev swapped lhs_ty rhs' rewrite_co1 rewrite_co2 + CanEqOK -> + do { traceTcS "canEqOK" (ppr lhs $$ ppr rhs) + ; new_ev <- rewriteEqEvidence ev swapped lhs_ty rhs rewrite_co1 rewrite_co2 ; continueWith (CEqCan { cc_ev = new_ev, cc_lhs = lhs - , cc_rhs = rhs', cc_eq_rel = eq_rel }) } + , cc_rhs = rhs, cc_eq_rel = eq_rel }) } -- it is possible that cc_rhs mentions the LHS if the LHS is a type -- family. This will cause later flattening to potentially loop, but -- that will be caught by the depth counter. The other option is an @@ -2269,11 +2279,11 @@ rewriteCastedEquality ev eq_rel swapped lhs rhs mco -- | Result of checking whether a RHS is suitable for pairing -- with a CanEqLHS in a CEqCan. data CanEqOK - = CanEqOK Xi -- use this RHS; it may have been occCheckExpand'ed + = CanEqOK -- RHS is good | CanEqNotOK CtIrredStatus -- don't proceed; explains why instance Outputable CanEqOK where - ppr (CanEqOK rhs) = text "CanEqOK" <+> ppr rhs + ppr CanEqOK = text "CanEqOK" ppr (CanEqNotOK status) = text "CanEqNotOK" <+> ppr status -- | This function establishes most of the invariants needed to make @@ -2287,11 +2297,9 @@ instance Outputable CanEqOK where -- TyEq:H: Checked here. canEqOK :: DynFlags -> EqRel -> CanEqLHS -> Xi -> CanEqOK canEqOK dflags eq_rel lhs rhs - | TyVarLHS tv <- lhs - = ASSERT( good_rhs ) -- I want to put this in the pattern guard, but - -- that confuses the pattern-match completeness checker - case metaTyVarUpdateOK dflags True {- type families are OK here -} tv rhs of - MTVU_OK rhs' -> CanEqOK rhs' + = ASSERT( good_rhs ) + case checkTypeEq dflags True {- type families are OK here -} lhs rhs of + MTVU_OK () -> CanEqOK MTVU_Bad -> CanEqNotOK OtherCIS -- Violation of TyEq:F @@ -2303,11 +2311,15 @@ canEqOK dflags eq_rel lhs rhs -- These are both a violation of TyEq:OC, but we -- want to differentiate for better production of -- error messages - MTVU_Occurs | isInsolubleOccursCheck eq_rel tv rhs -> CanEqNotOK InsolubleCIS + MTVU_Occurs | TyVarLHS tv <- lhs + , isInsolubleOccursCheck eq_rel tv rhs -> CanEqNotOK InsolubleCIS -- If we have a ~ [a], it is not canonical, and in particular -- we don't want to rewrite existing inerts with it, otherwise -- we'd risk divergence in the constraint solver + -- NB: no occCheckExpand here; see Note [Flattening synonyms] + -- in GHC.Tc.Solver.Flatten + | otherwise -> CanEqNotOK OtherCIS -- A representational equality with an occurs-check problem isn't -- insoluble! For example: @@ -2316,15 +2328,8 @@ canEqOK dflags eq_rel lhs rhs -- But, the occurs-check certainly prevents the equality from being -- canonical, and we might loop if we were to use it in rewriting. - -- ToDo: These checks are very close to what's done in metaTyVarUpdateOK; combine? - | TyFamLHS _fam_tc _fam_args <- lhs - = ASSERT2( good_rhs, ppr lhs <+> dcolon <+> ppr lhs_kind $$ - ppr rhs <+> dcolon <+> ppr rhs_kind $$ - ppr eq_rel ) - if | not (isTauTy rhs) -> CanEqNotOK OtherCIS -- TyEq:F - | badCoercionHole rhs -> CanEqNotOK BlockedCIS -- TyEq:H - | otherwise -> CanEqOK rhs - -- NB: TyEq:OC does not apply + -- This case also include type family occurs-check errors, which + -- are not generally insoluble where good_rhs = kinds_match && not bad_newtype ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1123,16 +1123,12 @@ flatten_one (TyVarTy tv) flatten_one (AppTy ty1 ty2) = flatten_app_tys ty1 [ty2] -flatten_one (TyConApp tc tys) +flatten_one ty@(TyConApp tc tys) -- Expand type synonyms that mention type families -- on the RHS; see Note [Flattening synonyms] - | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc tys - , let expanded_ty = mkAppTys (substTy (mkTvSubstPrs tenv) rhs) tys' - = do { mode <- getMode - ; case mode of - FM_FlattenAll | not (isFamFreeTyCon tc) - -> flatten_one expanded_ty - _ -> flatten_ty_con_app tc tys } + | isForgetfulSynTyCon tc + , Just expanded_ty <- tcView ty -- should always succeed + = flatten_one expanded_ty -- Otherwise, it's a type function application, and we have to -- flatten it away as well, and generate a new given equality constraint @@ -1301,17 +1297,17 @@ Not expanding synonyms aggressively improves error messages, and keeps types smaller. But we need to take care. Suppose - type T a = a -> a -and we want to flatten the type (T (F a)). Then we can safely flatten -the (F a) to a skolem, and return (T fsk). We don't need to expand the -synonym. This works because TcTyConAppCo can deal with synonyms -(unlike TyConAppCo), see Note [TcCoercions] in GHC.Tc.Types.Evidence. + type Syn a = Int + type instance F Bool = Syn (F Bool) -But (#8979) for - type T a = (F a, a) where F is a type function -we must expand the synonym in (say) T Int, to expose the type function -to the flattener. +If we don't expand the synonym, we'll fall into an unnecessary loop. +In addition, expanding the forgetful synonym like this +will generally yield a *smaller* type. We thus expand forgetful +synonyms, but not others. + +One nice consequence is that we never have to occCheckExpand flattened +types, as any forgetful synonyms are already expanded. Note [Flattening under a forall] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1387,20 +1383,21 @@ flatten_exact_fam_app_fully tc tys -- Now, look in the cache ; mb_ct <- liftTcS $ lookupFlatCache tc xis ; case mb_ct of - Just (co, rhs_ty, inert_fr) -- co :: F xis ~ fsk + Just (co, rhs_ty, inert_fr@(_, inert_eq_rel)) -- co :: F xis ~ fsk -- See Note [Type family equations] in GHC.Tc.Solver.Monad | inert_fr `eqCanRewriteFR` cur_fr -> -- Usable hit in the flat-cache do { traceFlat "flatten/flat-cache hit" $ (ppr tc <+> ppr xis $$ ppr rhs_ty) - ; (fsk_xi, fsk_co) <- flatten_one rhs_ty - -- The fsk may already have been unified, so + ; (rhs_xi, rhs_co) <- flatten_one rhs_ty + -- There may be more work to do on the rhs: -- flatten it - -- fsk_co :: fsk_xi ~ fsk - ; let xi = fsk_xi `mkCastTy` kind_co - co' = mkTcCoherenceLeftCo role fsk_xi kind_co fsk_co + -- rhs_co :: rhs_xi ~ rhs_ty + ; let xi = rhs_xi `mkCastTy` kind_co + co' = mkTcCoherenceLeftCo role rhs_xi kind_co rhs_co `mkTransCo` - maybeTcSubCo eq_rel (mkSymCo co) + tcDowngradeRole role (eqRelRole inert_eq_rel) + (mkTcSymCo co) `mkTransCo` ret_co ; return (xi, co') } ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -407,11 +407,6 @@ data InertSet -- flav is [G] -- -- Just a hash-cons cache for use when flattening only - -- These include entirely un-processed goals, so don't use - -- them to solve a top-level goal, else you may end up solving - -- (w:F ty ~ a) by setting w:=w! We just use the flat-cache - -- when allocating a new flatten-skolem. - -- Not necessarily inert wrt top-level equations (or inert_cans) -- -- Only nominal, Given equalities end up in here (along with -- top-level instances) @@ -683,11 +678,11 @@ Result data InertCans -- See Note [Detailed InertCans Invariants] for more = IC { inert_eqs :: InertEqs -- See Note [inert_eqs: the inert equalities] - -- All CEqCans; index is the LHS tyvar + -- All CEqCans with a TyVarLHS; index is the LHS tyvar -- Domain = skolems and untouchables; a touchable would be unified , inert_funeqs :: FunEqMap EqualCtList - -- All CEqCans; index is the whole family head type. + -- All CEqCans with a TyFamLHS; index is the whole family head type. -- LHS is fully rewritten (modulo eqCanRewrite constraints) -- wrt inert_eqs -- Can include all flavours, [G], [W], [WD], [D] @@ -3242,7 +3237,7 @@ newFlattenSkolem flav loc tc xis = do { fmv <- wrapTcS (TcM.newFmvTyVar fam_ty) -- See (2a) in "GHC.Tc.Solver.Canonical" -- Note [Equalities with incompatible kinds] - ; (ev, hole_co) <- newWantedEq_SI NoBlockSubst WDeriv loc Nominal + ; (ev, hole_co) <- newWantedEq_SI tcNoBlockSubst WDeriv loc Nominal fam_ty (mkTyVarTy fmv) ; return (ev, hole_co, fmv) } ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -152,7 +152,10 @@ data Ct | CEqCan { -- tv ~ rhs -- Invariants: -- * See Note [inert_eqs: the inert equalities] in GHC.Tc.Solver.Monad - -- * (TyEq:OC) if LHS is a variable tv, then tv not in deep tvs(rhs) (occurs check) + -- * Many are checked in checkTypeEq in GHC.Tc.Utils.Unify + -- * (TyEq:OC) lhs does not occur in rhs (occurs check) + -- (skips coercions if the lhs is a type family application, because + -- we don't rewrite type families in coercions) -- * (TyEq:F) rhs has no foralls -- (this avoids substituting a forall for the tyvar in other types) -- * (TyEq:K) tcTypeKind lhs `tcEqKind` tcTypeKind rhs; Note [Ct kind invariant] ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -134,7 +134,7 @@ mkTcForAllCo :: TyVar -> TcCoercionN -> TcCoercion -> TcCoercion mkTcForAllCos :: [(TyVar, TcCoercionN)] -> TcCoercion -> TcCoercion mkTcNthCo :: Role -> Int -> TcCoercion -> TcCoercion mkTcLRCo :: LeftOrRight -> TcCoercion -> TcCoercion -mkTcSubCo :: TcCoercionN -> TcCoercionR +mkTcSubCo :: HasDebugCallStack => TcCoercionN -> TcCoercionR tcDowngradeRole :: Role -> Role -> TcCoercion -> TcCoercion mkTcAxiomRuleCo :: CoAxiomRule -> [TcCoercion] -> TcCoercionR mkTcGReflRightCo :: Role -> TcType -> TcCoercionN -> TcCoercion @@ -192,7 +192,7 @@ isTcReflexiveCo = isReflexiveCo -- | If the EqRel is ReprEq, makes a SubCo; otherwise, does nothing. -- Note that the input coercion should always be nominal. -maybeTcSubCo :: EqRel -> TcCoercion -> TcCoercion +maybeTcSubCo :: HasDebugCallStack => EqRel -> TcCoercionN -> TcCoercion maybeTcSubCo NomEq = id maybeTcSubCo ReprEq = mkTcSubCo ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -35,7 +35,8 @@ module GHC.Tc.Utils.Unify ( matchExpectedFunKind, matchActualFunTySigma, matchActualFunTysRho, - metaTyVarUpdateOK, occCheckForErrors, MetaTyVarUpdateResult(..) + metaTyVarUpdateOK, occCheckForErrors, MetaTyVarUpdateResult(..), + checkTypeEq ) where @@ -72,6 +73,7 @@ import GHC.Utils.Misc import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Exts ( inline ) import Control.Monad import Control.Arrow ( second ) @@ -1953,7 +1955,7 @@ occCheckForErrors :: DynFlags -> TcTyVar -> Type -> MetaTyVarUpdateResult () -- a) the given variable occurs in the given type. -- b) there is a forall in the type (unless we have -XImpredicativeTypes) occCheckForErrors dflags tv ty - = case mtvu_check dflags True tv ty of + = case checkTyVarEq dflags True tv ty of MTVU_OK _ -> MTVU_OK () MTVU_Bad -> MTVU_Bad MTVU_HoleBlocker -> MTVU_HoleBlocker @@ -1999,7 +2001,7 @@ metaTyVarUpdateOK :: DynFlags -- See Note [Refactoring hazard: metaTyVarUpdateOK] metaTyVarUpdateOK dflags ty_fam_ok tv ty - = case mtvu_check dflags ty_fam_ok tv ty of + = case checkTyVarEq dflags ty_fam_ok tv ty of MTVU_OK _ -> MTVU_OK ty MTVU_Bad -> MTVU_Bad -- forall, predicate, type function MTVU_HoleBlocker -> MTVU_HoleBlocker -- coercion hole @@ -2007,20 +2009,31 @@ metaTyVarUpdateOK dflags ty_fam_ok tv ty Just expanded_ty -> MTVU_OK expanded_ty Nothing -> MTVU_Occurs -mtvu_check :: DynFlags -> Bool -> TcTyVar -> TcType -> MetaTyVarUpdateResult () +checkTyVarEq :: DynFlags -> Bool -> TcTyVar -> TcType -> MetaTyVarUpdateResult () +checkTyVarEq dflags ty_fam_ok tv ty + = inline checkTypeEq dflags ty_fam_ok (TyVarLHS tv) ty + -- inline checkTypeEq so that the `case`s over the CanEqLHS get blasted away + +checkTypeEq :: DynFlags -> Bool -> CanEqLHS -> TcType -> MetaTyVarUpdateResult () -- Checks the invariants for CEqCan. In particular: -- (a) a forall type (forall a. blah) -- (b) a predicate type (c => ty) -- (c) a type family; see Note [Prevent unification with type families] -- (d) a blocking coercion hole --- (e) an occurrence of the type variable (occurs check) +-- (e) an occurrence of the LHS (occurs check) -- -- For (a), (b), and (c) we check only the top level of the type, NOT -- inside the kinds of variables it mentions. For (d) we look deeply --- in coercions, and for (e) we do look in the kinds of course. +-- in coercions when the LHS is a tyvar (but skip coercions for type family +-- LHSs), and for (e) we do look in the kinds of course. +-- +-- Why skip coercions for type families? Because we don't rewrite type family +-- applications in coercions, so there's no point in looking there. On the +-- other hand, we must check for type variables, lest we mutably create an +-- infinite structure during unification. -mtvu_check dflags ty_fam_ok tv ty - = fast_check ty +checkTypeEq dflags ty_fam_ok lhs ty + = go ty where ok :: MetaTyVarUpdateResult () ok = MTVU_OK () @@ -2029,53 +2042,75 @@ mtvu_check dflags ty_fam_ok tv ty -- unification variables that can unify with a polytype -- or a TyCon that would usually be disallowed by bad_tc -- See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect - ghci_tv = case tcTyVarDetails tv of - MetaTv { mtv_info = RuntimeUnkTv } -> True - _ -> False - - fast_check :: TcType -> MetaTyVarUpdateResult () - fast_check (TyVarTy tv') - | tv == tv' = MTVU_Occurs - | otherwise = fast_check_occ (tyVarKind tv') - -- See Note [Occurrence checking: look inside kinds] - -- in GHC.Core.Type - - fast_check (TyConApp tc tys) - | bad_tc tc, not ghci_tv = MTVU_Bad - | otherwise = mapM fast_check tys >> ok - fast_check (LitTy {}) = ok - fast_check (FunTy{ft_af = af, ft_mult = w, ft_arg = a, ft_res = r}) + ghci_tv + | TyVarLHS tv <- lhs + , MetaTv { mtv_info = RuntimeUnkTv } <- tcTyVarDetails tv + = True + + | otherwise + = False + + go :: TcType -> MetaTyVarUpdateResult () + go (TyVarTy tv') = go_tv tv' + go (TyConApp tc tys) = go_tc tc tys + go (LitTy {}) = ok + go (FunTy{ft_af = af, ft_mult = w, ft_arg = a, ft_res = r}) | InvisArg <- af , not ghci_tv = MTVU_Bad - | otherwise = fast_check w >> fast_check a >> fast_check r - fast_check (AppTy fun arg) = fast_check fun >> fast_check arg - fast_check (CastTy ty co) = fast_check ty >> fast_check_co co - fast_check (CoercionTy co) = fast_check_co co - fast_check (ForAllTy (Bndr tv' _) ty) + | otherwise = go w >> go a >> go r + go (AppTy fun arg) = go fun >> go arg + go (CastTy ty co) = go ty >> go_co co + go (CoercionTy co) = go_co co + go (ForAllTy (Bndr tv' _) ty) | not ghci_tv = MTVU_Bad - | tv == tv' = ok - | otherwise = do { fast_check_occ (tyVarKind tv') - ; fast_check_occ ty } - -- Under a forall we look only for occurrences of - -- the type variable + | otherwise = case lhs of + TyVarLHS tv | tv == tv' -> ok + | otherwise -> do { go_occ tv (tyVarKind tv') + ; go ty } + _ -> go ty + + go_tv :: TcTyVar -> MetaTyVarUpdateResult () + -- this slightly peculiar way of defining this means + -- we don't have to evaluate this `case` at every variable + -- occurrence + go_tv = case lhs of + TyVarLHS tv -> \ tv' -> if tv == tv' + then MTVU_Occurs + else go_occ tv (tyVarKind tv') + TyFamLHS {} -> \ _tv' -> ok + -- See Note [Occurrence checking: look inside kinds] in GHC.Core.Type -- For kinds, we only do an occurs check; we do not worry -- about type families or foralls -- See Note [Checking for foralls] - fast_check_occ k | tv `elemVarSet` tyCoVarsOfType k = MTVU_Occurs - | otherwise = ok + go_occ tv k | tv `elemVarSet` tyCoVarsOfType k = MTVU_Occurs + | otherwise = ok + + go_tc :: TyCon -> [TcType] -> MetaTyVarUpdateResult () + -- this slightly peculiar way of defining this means + -- we don't have to evaluate this `case` at every tyconapp + go_tc = case lhs of + TyVarLHS {} -> \ tc tys -> if good_tc tc + then mapM go tys >> ok + else MTVU_Bad + TyFamLHS fam_tc fam_args -> \ tc tys -> + if | tcEqTyConApps fam_tc fam_args tc tys -> MTVU_Occurs + | good_tc tc -> mapM go tys >> ok + | otherwise -> MTVU_Bad -- no bother about impredicativity in coercions, as they're -- inferred - fast_check_co co | not (gopt Opt_DeferTypeErrors dflags) - , badCoercionHoleCo co = MTVU_HoleBlocker + go_co co | not (gopt Opt_DeferTypeErrors dflags) + , badCoercionHoleCo co = MTVU_HoleBlocker -- Wrinkle (4b) in "GHC.Tc.Solver.Canonical" Note [Equalities with incompatible kinds] - | tv `elemVarSet` tyCoVarsOfCo co = MTVU_Occurs - | otherwise = ok + | TyVarLHS tv <- lhs + , tv `elemVarSet` tyCoVarsOfCo co = MTVU_Occurs + -- Don't check coercions for type families; see commentary at top of function + | otherwise = ok - bad_tc :: TyCon -> Bool - bad_tc tc - | not (isTauTyCon tc) = True - | not (ty_fam_ok || isFamFreeTyCon tc) = True - | otherwise = False + good_tc :: TyCon -> Bool + good_tc + | ghci_tv = \ _tc -> True + | otherwise = \ tc -> isTauTyCon tc && + (ty_fam_ok || isFamFreeTyCon tc) ===================================== testsuite/tests/indexed-types/should_compile/T3017.stderr ===================================== @@ -4,7 +4,7 @@ TYPE SIGNATURES insert :: forall c. Coll c => Elem c -> c -> c test2 :: forall {c} {a} {b}. - (Coll c, Num a, Num b, Elem c ~ (a, b)) => + (Elem c ~ (a, b), Coll c, Num a, Num b) => c -> c TYPE CONSTRUCTORS class Coll{1} :: * -> Constraint @@ -20,4 +20,4 @@ CLASS INSTANCES FAMILY INSTANCES type instance Elem (ListColl a) = a -- Defined at T3017.hs:13:9 Dependent modules: [] -Dependent packages: [base-4.13.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/indexed-types/should_fail/T14369.stderr ===================================== @@ -1,9 +1,20 @@ T14369.hs:29:5: error: - • Couldn't match type: Demote a - with: Demote a1 + • Couldn't match type ‘a’ with ‘a1’ Expected: Sing x -> Maybe (Demote a1) Actual: Sing x -> Demote (Maybe a) + ‘a’ is a rigid type variable bound by + the type signature for: + f :: forall {a} (x :: forall a1. Maybe a1) a1. + SingKind a1 => + Sing x -> Maybe (Demote a1) + at T14369.hs:28:1-80 + ‘a1’ is a rigid type variable bound by + the type signature for: + f :: forall {a} (x :: forall a1. Maybe a1) a1. + SingKind a1 => + Sing x -> Maybe (Demote a1) + at T14369.hs:28:1-80 • In the expression: fromSing In an equation for ‘f’: f = fromSing • Relevant bindings include ===================================== testsuite/tests/indexed-types/should_fail/T2544.stderr ===================================== @@ -1,13 +1,13 @@ -T2544.hs:19:18: error: - • Couldn't match type: IxMap i0 - with: IxMap l - Expected: IxMap l [Int] - Actual: IxMap i0 [Int] +T2544.hs:19:12: error: + • Couldn't match type: IxMap i1 + with: IxMap r + Expected: IxMap (l :|: r) [Int] + Actual: BiApp (IxMap i0) (IxMap i1) [Int] NB: ‘IxMap’ is a non-injective type family - The type variable ‘i0’ is ambiguous - • In the first argument of ‘BiApp’, namely ‘empty’ - In the expression: BiApp empty empty + The type variable ‘i1’ is ambiguous + • In the expression: BiApp empty empty In an equation for ‘empty’: empty = BiApp empty empty + In the instance declaration for ‘Ix (l :|: r)’ • Relevant bindings include empty :: IxMap (l :|: r) [Int] (bound at T2544.hs:19:4) ===================================== testsuite/tests/indexed-types/should_fail/T2627b.stderr ===================================== @@ -1,6 +1,6 @@ T2627b.hs:20:24: error: - • Could not deduce: Dual (Dual b0) ~ b0 + • Could not deduce: a0 ~ Dual (Dual a0) arising from a use of ‘conn’ from the context: (Dual a ~ b, Dual b ~ a) bound by the type signature for: @@ -13,7 +13,12 @@ T2627b.hs:20:24: error: Rd :: forall c d. (c -> Comm d) -> Comm (R c d), in an equation for ‘conn’ at T2627b.hs:20:7-10 - The type variable ‘b0’ is ambiguous + or from: b ~ W e f + bound by a pattern with constructor: + Wr :: forall e f. e -> Comm f -> Comm (W e f), + in an equation for ‘conn’ + at T2627b.hs:20:14-19 + The type variable ‘a0’ is ambiguous • In the expression: conn undefined undefined In an equation for ‘conn’: conn (Rd k) (Wr a r) = conn undefined undefined ===================================== testsuite/tests/indexed-types/should_fail/T3330c.stderr ===================================== @@ -3,14 +3,14 @@ T3330c.hs:25:43: error: • Couldn't match kind ‘*’ with ‘* -> *’ When matching types f1 :: * -> * - f1 x :: * - Expected: Der ((->) x) (f1 x) + Der f1 x :: * + Expected: Der ((->) x) (Der f1 x) Actual: R f1 • In the first argument of ‘plug’, namely ‘rf’ In the first argument of ‘Inl’, namely ‘(plug rf df x)’ In the expression: Inl (plug rf df x) • Relevant bindings include x :: x (bound at T3330c.hs:25:29) - df :: f1 x (bound at T3330c.hs:25:25) + df :: Der f1 x (bound at T3330c.hs:25:25) rf :: R f1 (bound at T3330c.hs:25:13) plug' :: R f -> Der f x -> x -> f x (bound at T3330c.hs:25:1) ===================================== testsuite/tests/indexed-types/should_fail/T4174.stderr ===================================== @@ -1,9 +1,9 @@ T4174.hs:44:12: error: - • Couldn't match type ‘b’ with ‘RtsSpinLock’ + • Couldn't match type ‘a’ with ‘SmStep’ Expected: m (Field (Way (GHC6'8 minor) n t p) a b) Actual: m (Field (WayOf m) SmStep RtsSpinLock) - ‘b’ is a rigid type variable bound by + ‘a’ is a rigid type variable bound by the type signature for: testcase :: forall (m :: * -> *) minor n t p a b. Monad m => ===================================== testsuite/tests/indexed-types/should_fail/T4179.stderr ===================================== @@ -1,13 +1,13 @@ T4179.hs:26:16: error: - • Couldn't match type: A2 (x (A2 (FCon x) -> A3 (FCon x))) - with: A2 (FCon x) + • Couldn't match type: A3 (FCon x) + with: A3 (x (A2 (FCon x) -> A3 (FCon x))) Expected: x (A2 (FCon x) -> A3 (FCon x)) -> A2 (FCon x) -> A3 (FCon x) Actual: x (A2 (FCon x) -> A3 (FCon x)) -> A2 (x (A2 (FCon x) -> A3 (FCon x))) -> A3 (x (A2 (FCon x) -> A3 (FCon x))) - NB: ‘A2’ is a non-injective type family + NB: ‘A3’ is a non-injective type family • In the first argument of ‘foldDoC’, namely ‘op’ In the expression: foldDoC op In an equation for ‘fCon’: fCon = foldDoC op ===================================== testsuite/tests/indexed-types/should_fail/T4272.stderr ===================================== @@ -1,17 +1,16 @@ -T4272.hs:15:26: error: - • Couldn't match type ‘a’ with ‘TermFamily a a’ - Expected: TermFamily a (TermFamily a a) - Actual: TermFamily a a +T4272.hs:15:19: error: + • Couldn't match expected type ‘TermFamily a a’ + with actual type ‘a’ ‘a’ is a rigid type variable bound by the type signature for: laws :: forall a b. TermLike a => TermFamily a a -> b at T4272.hs:14:1-53 - • In the first argument of ‘terms’, namely - ‘(undefined :: TermFamily a a)’ - In the second argument of ‘prune’, namely + • In the second argument of ‘prune’, namely ‘(terms (undefined :: TermFamily a a))’ In the expression: prune t (terms (undefined :: TermFamily a a)) + In an equation for ‘laws’: + laws t = prune t (terms (undefined :: TermFamily a a)) • Relevant bindings include t :: TermFamily a a (bound at T4272.hs:15:6) laws :: TermFamily a a -> b (bound at T4272.hs:15:1) ===================================== testsuite/tests/indexed-types/should_fail/T5439.stderr ===================================== @@ -30,3 +30,28 @@ T5439.hs:82:39: error: ‘inj $ Failure (e :: SomeException)’ In a stmt of a 'do' block: c <- complete ev $ inj $ Failure (e :: SomeException) + +T5439.hs:245:15: error: + • Could not deduce: HDrop (PSucc PZero) l ~ HTail l + arising from a use of ‘HTailDropComm’ + from the context: (HDropClass n l, HNonEmpty (HDrop n l)) + bound by the type signature for: + hTailDropComm :: forall n l. + (HDropClass n l, HNonEmpty (HDrop n l)) => + HTailDropComm n l + at T5439.hs:(242,1)-(243,34) + or from: (n ~ PZero, HListClass l) + bound by a pattern with constructor: + HDropZero :: forall l. HListClass l => HDropWitness PZero l, + in a case alternative + at T5439.hs:245:3-11 + • In the expression: HTailDropComm + In a case alternative: HDropZero -> HTailDropComm + In the expression: + case hDropWitness :: HDropWitness n l of + HDropZero -> HTailDropComm + HDropSucc + -> case hTailDropComm :: HTailDropComm (PPred n) (HTail l) of { + HTailDropComm -> HTailDropComm } + • Relevant bindings include + hTailDropComm :: HTailDropComm n l (bound at T5439.hs:244:1) ===================================== testsuite/tests/indexed-types/should_fail/T8227.stderr ===================================== @@ -1,11 +1,10 @@ -T8227.hs:17:27: error: - • Couldn't match type: Scalar (V a) - with: Scalar (V a) -> Scalar (V a) - Expected: Scalar (V a) - Actual: Scalar (V (Scalar (V a) -> Scalar (V a))) - -> Scalar (V (Scalar (V a) -> Scalar (V a))) - • In the expression: arcLengthToParam eps eps +T8227.hs:17:44: error: + • Couldn't match expected type: Scalar (V (Scalar (V a))) + with actual type: Scalar (V a) + NB: ‘Scalar’ is a non-injective type family + • In the first argument of ‘arcLengthToParam’, namely ‘eps’ + In the expression: arcLengthToParam eps eps In an equation for ‘absoluteToParam’: absoluteToParam eps seg = arcLengthToParam eps eps • Relevant bindings include ===================================== testsuite/tests/indexed-types/should_fail/T8518.stderr ===================================== @@ -1,10 +1,9 @@ T8518.hs:14:18: error: - • Couldn't match expected type: Z c -> B c -> Maybe (F c) - with actual type: F c - • The function ‘rpt’ is applied to four value arguments, - but its type ‘Int -> c -> F c’ has only two - In the expression: rpt (4 :: Int) c z b + • Couldn't match type: F c + with: Z c -> B c -> F c + arising from a use of ‘rpt’ + • In the expression: rpt (4 :: Int) c z b In an equation for ‘callCont’: callCont c z b = rpt (4 :: Int) c z b @@ -16,17 +15,3 @@ T8518.hs:14:18: error: z :: Z c (bound at T8518.hs:14:12) c :: c (bound at T8518.hs:14:10) callCont :: c -> Z c -> B c -> Maybe (F c) (bound at T8518.hs:14:1) - -T8518.hs:16:9: error: - • Couldn't match type: F t1 - with: Z t1 -> B t1 -> F t1 - Expected: t -> t1 -> F t1 - Actual: t -> t1 -> Z t1 -> B t1 -> F t1 - • In an equation for ‘callCont’: - callCont c z b - = rpt (4 :: Int) c z b - where - rpt 0 c' z' b' = fromJust (fst <$> (continue c' z' b')) - rpt i c' z' b' = let ... in rpt (i - 1) c'' - • Relevant bindings include - rpt :: t -> t1 -> F t1 (bound at T8518.hs:16:9) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2972870447b7829038f7de5028e15df0ffdaf89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2972870447b7829038f7de5028e15df0ffdaf89 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 20:57:49 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 16:57:49 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Initial ShortText code and conversion of package db code Message-ID: <5f80cecd1c399_80b3f8438053b3c180188c0@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b03c1fd9 by Wander Hillen at 2020-10-09T16:57:40-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 508467c9 by Krzysztof Gogolewski at 2020-10-09T16:57:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 68bf51be by Simon Peyton Jones at 2020-10-09T16:57:45-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 30 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools/ExtraObj.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/State.hs - compiler/GHC/Utils/Binary.hs - compiler/ghc.cabal.in - + libraries/ghc-boot/GHC/Data/ShortText.hs - libraries/ghc-boot/GHC/Unit/Database.hs - compiler/GHC/Utils/Encoding.hs → libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-boot/ghc-boot.cabal.in - testsuite/tests/linear/should_compile/MultConstructor.hs - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles2.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3366c54f05d2d02f0f24bad29f38776c4fd30ad4...68bf51be4abe50701340026754cac7d0d9736b8d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3366c54f05d2d02f0f24bad29f38776c4fd30ad4...68bf51be4abe50701340026754cac7d0d9736b8d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 9 21:58:35 2020 From: gitlab at gitlab.haskell.org (davean) Date: Fri, 09 Oct 2020 17:58:35 -0400 Subject: [Git][ghc/ghc][wip/testing] Don't use brew with nix (incomplete fix). Message-ID: <5f80dd0bb434f_80b3f837638df181802875e@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: cac2d9b8 by davean at 2020-10-09T17:58:34-04:00 Don't use brew with nix (incomplete fix). - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -95,8 +95,8 @@ export TEMP="$TOP/tmp" function darwin_setup() { # It looks like we already have python2 here and just installing python3 # does not work. - brew upgrade python - brew install ghc cabal-install ncurses gmp + #brew upgrade python + #brew install ghc cabal-install ncurses gmp pip3 install sphinx # PDF documentation disabled as MacTeX apparently doesn't include xelatex. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cac2d9b8508a3cd322774933d63f2fbf7079435d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cac2d9b8508a3cd322774933d63f2fbf7079435d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 02:48:24 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 09 Oct 2020 22:48:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Move File Target parser to library #18596 Message-ID: <5f8120f826894_80b3f84901bd5d818069579@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - f46e0633 by Hécate at 2020-10-09T22:48:05-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 555ea907 by Krzysztof Gogolewski at 2020-10-09T22:48:10-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - c27622e1 by Sylvain Henry at 2020-10-09T22:48:17-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - c2de5679 by Simon Peyton Jones at 2020-10-09T22:48:18-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 30 changed files: - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68bf51be4abe50701340026754cac7d0d9736b8d...c2de5679cba5e06670c3c971d8707d44559c90a2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/68bf51be4abe50701340026754cac7d0d9736b8d...c2de5679cba5e06670c3c971d8707d44559c90a2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 03:20:59 2020 From: gitlab at gitlab.haskell.org (davean) Date: Fri, 09 Oct 2020 23:20:59 -0400 Subject: [Git][ghc/ghc][wip/testing] Fix shell variable names for tools and remove nix-less Darwin code. Message-ID: <5f81289ba56c7_80b3f8486655f78180780d1@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: 8734530a by davean at 2020-10-09T23:20:58-04:00 Fix shell variable names for tools and remove nix-less Darwin code. - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -92,17 +92,6 @@ mkdir -p "$TOP/tmp" export TMP="$TOP/tmp" export TEMP="$TOP/tmp" -function darwin_setup() { - # It looks like we already have python2 here and just installing python3 - # does not work. - #brew upgrade python - #brew install ghc cabal-install ncurses gmp - - pip3 install sphinx - # PDF documentation disabled as MacTeX apparently doesn't include xelatex. - #brew cask install mactex -} - function show_tool() { local tool="$1" info "$tool = ${!tool}" @@ -127,9 +116,9 @@ function set_toolchain_paths() { # we provide these handy fallbacks in case the # script isn't run from within a GHC CI docker image. if [ -z "$GHC" ]; then GHC="$(which ghc)"; fi - if [ -z "$CABAL" ]; then GHC="$(which cabal)"; fi - if [ -z "$HAPPY" ]; then GHC="$(which happy)"; fi - if [ -z "$ALEX" ]; then GHC="$(which alex)"; fi + if [ -z "$CABAL" ]; then CABAL="$(which cabal)"; fi + if [ -z "$HAPPY" ]; then HAPPY="$(which happy)"; fi + if [ -z "$ALEX" ]; then ALEX="$(which alex)"; fi fi export GHC @@ -149,10 +138,6 @@ function setup() { if [[ -n "$needs_toolchain" ]]; then setup_toolchain fi - case "$(uname)" in - Darwin) darwin_setup ;; - *) ;; - esac # Make sure that git works git config user.email "ghc-ci at gitlab-haskell.org" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8734530a2a723340092700cec9487728bcb48520 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8734530a2a723340092700cec9487728bcb48520 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 08:18:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 04:18:51 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Lint the compiler for extraneous LANGUAGE pragmas Message-ID: <5f816e6b70feb_80b8b0ce7818091534@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 42087614 by Hécate at 2020-10-10T04:18:36-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - f34695fb by Krzysztof Gogolewski at 2020-10-10T04:18:41-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - d3566895 by Sylvain Henry at 2020-10-10T04:18:46-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 132304d4 by Simon Peyton Jones at 2020-10-10T04:18:46-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 30 changed files: - + compiler/.hlint.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/StaticArgs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2de5679cba5e06670c3c971d8707d44559c90a2...132304d4c39997d303e03e7d16c6ef4a227dc171 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2de5679cba5e06670c3c971d8707d44559c90a2...132304d4c39997d303e03e7d16c6ef4a227dc171 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 13:49:16 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 09:49:16 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Lint the compiler for extraneous LANGUAGE pragmas Message-ID: <5f81bbdc83258_80b3f8491abed98181201d6@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a43779a8 by Hécate at 2020-10-10T09:49:04-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 06c7461a by Krzysztof Gogolewski at 2020-10-10T09:49:08-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 2de3d1d5 by Sylvain Henry at 2020-10-10T09:49:12-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 30 changed files: - + compiler/.hlint.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/StaticArgs.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/132304d4c39997d303e03e7d16c6ef4a227dc171...2de3d1d533eae11c37fdafb0316b13851781f81d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/132304d4c39997d303e03e7d16c6ef4a227dc171...2de3d1d533eae11c37fdafb0316b13851781f81d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 15:09:24 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Sat, 10 Oct 2020 11:09:24 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/no-typeable-proxy Message-ID: <5f81cea44d6ae_80b41847ec181370df@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/no-typeable-proxy at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/no-typeable-proxy You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 15:23:11 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Sat, 10 Oct 2020 11:23:11 -0400 Subject: [Git][ghc/ghc][wip/no-typeable-proxy] Remove ghc-linters from needs Message-ID: <5f81d1df2e71_80b3f848e61923c18140870@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed to branch wip/no-typeable-proxy at Glasgow Haskell Compiler / GHC Commits: aefbbb8b by Krzysztof Gogolewski at 2020-10-10T17:22:57+02:00 Remove ghc-linters from needs - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aefbbb8b08516ba7127a03daa31845b89dd2a5c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aefbbb8b08516ba7127a03daa31845b89dd2a5c9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 15:58:10 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Sat, 10 Oct 2020 11:58:10 -0400 Subject: [Git][ghc/ghc][wip/no-typeable-proxy] 2 commits: Remove ghc-linters from needs Message-ID: <5f81da1220fa1_80b3f8438dfa7b818148290@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed to branch wip/no-typeable-proxy at Glasgow Haskell Compiler / GHC Commits: e9a43b2e by Krzysztof Gogolewski at 2020-10-10T17:57:16+02:00 Remove ghc-linters from needs - - - - - 1da081eb by Krzysztof Gogolewski at 2020-10-10T17:57:43+02:00 Remove Proxy# argument in Data.Typeable.Internal Not neccessary. This was from the times TypeRep was not indexed. - - - - - 5 changed files: - .gitlab-ci.yml - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Instance/Class.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Exception.hs-boot Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -56,7 +56,6 @@ import GHC.Core.Coercion import GHC.Core.Multiplicity import GHC.Builtin.Types ( typeNatKind, typeSymbolKind ) import GHC.Types.Id -import GHC.Types.Id.Make(proxyHashId) import GHC.Types.Name import GHC.Types.Var.Set import GHC.Core.Rules @@ -1220,7 +1219,7 @@ dsEvTerm (EvFun { et_tvs = tvs, et_given = given dsEvTypeable :: Type -> EvTypeable -> DsM CoreExpr -- Return a CoreExpr :: Typeable ty -- This code is tightly coupled to the representation --- of TypeRep, in base library Data.Typeable.Internals +-- of TypeRep, in base library Data.Typeable.Internal dsEvTypeable ty ev = do { tyCl <- dsLookupTyCon typeableClassName -- Typeable ; let kind = typeKind ty @@ -1299,14 +1298,13 @@ ds_ev_typeable ty (EvTypeableTyLit ev) = -- See Note [Typeable for Nat and Symbol] in GHC.Tc.Solver.Interact do { fun <- dsLookupGlobalId tr_fun ; dict <- dsEvTerm ev -- Of type KnownNat/KnownSymbol - ; let proxy = mkTyApps (Var proxyHashId) [ty_kind, ty] - ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict, proxy ]) } + ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict ]) } where ty_kind = typeKind ty -- tr_fun is the Name of - -- typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a - -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a + -- typeNatTypeRep :: KnownNat a => TypeRep a + -- of typeSymbolTypeRep :: KnownSymbol a => TypeRep a tr_fun | ty_kind `eqType` typeNatKind = typeNatTypeRepName | ty_kind `eqType` typeSymbolKind = typeSymbolTypeRepName | otherwise = panic "dsEvTypeable: unknown type lit kind" ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -548,7 +548,7 @@ have this instance, implemented here by doTyLit: instance KnownNat n => Typeable (n :: Nat) where typeRep = typeNatTypeRep @n where - Data.Typeable.Internals.typeNatTypeRep :: KnownNat a => TypeRep a + Data.Typeable.Internal.typeNatTypeRep :: KnownNat a => TypeRep a Ultimately typeNatTypeRep uses 'natSing' from KnownNat to get a runtime value 'n'; it turns it into a string with 'show' and uses ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -979,12 +979,12 @@ mkTypeLitTyCon name kind_tycon where kind = KindRepTyConApp kind_tycon [] -- | Used to make `'Typeable' instance for things of kind Nat -typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a -typeNatTypeRep p = typeLitTypeRep (show (natVal' p)) tcNat +typeNatTypeRep :: forall a. KnownNat a => TypeRep a +typeNatTypeRep = typeLitTypeRep (show (natVal' (proxy# @a))) tcNat -- | Used to make `'Typeable' instance for things of kind Symbol -typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a -typeSymbolTypeRep p = typeLitTypeRep (show (symbolVal' p)) tcSymbol +typeSymbolTypeRep :: forall a. KnownSymbol a => TypeRep a +typeSymbolTypeRep = typeLitTypeRep (show (symbolVal' (proxy# @a))) tcSymbol mkTypeLitFromString :: TypeLitSort -> String -> SomeTypeRep mkTypeLitFromString TypeLitSymbol s = ===================================== libraries/base/GHC/Exception.hs-boot ===================================== @@ -14,7 +14,7 @@ More dramatically GHC.Exception imports Data.Typeable -imports Data.Typeable.Internals +imports Data.Typeable.Internal imports GHC.Arr (fingerprint representation etc) imports GHC.Real imports {-# SOURCE #-} GHC.Exception View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aefbbb8b08516ba7127a03daa31845b89dd2a5c9...1da081eb2bdb00798357de2a963111c71cfd9895 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aefbbb8b08516ba7127a03daa31845b89dd2a5c9...1da081eb2bdb00798357de2a963111c71cfd9895 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 18:49:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 14:49:27 -0400 Subject: [Git][ghc/ghc][master] Move File Target parser to library #18596 Message-ID: <5f820237f4022_80b3f841ef77aec181602f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - 2 changed files: - compiler/GHC.hs - ghc/Main.hs Changes: ===================================== compiler/GHC.hs ===================================== @@ -29,7 +29,7 @@ module GHC ( -- * Flags and settings DynFlags(..), GeneralFlag(..), Severity(..), Backend(..), gopt, GhcMode(..), GhcLink(..), - parseDynamicFlags, + parseDynamicFlags, parseTargetFiles, getSessionDynFlags, setSessionDynFlags, getProgramDynFlags, setProgramDynFlags, setLogAction, getInteractiveDynFlags, setInteractiveDynFlags, @@ -334,7 +334,8 @@ import GHC.Types.Avail import GHC.Types.SrcLoc import GHC.Core import GHC.Iface.Tidy -import GHC.Driver.Phases ( Phase(..), isHaskellSrcFilename ) +import GHC.Driver.Phases ( Phase(..), isHaskellSrcFilename + , isSourceFilename, startPhase ) import GHC.Driver.Finder import GHC.Driver.Types import GHC.Driver.CmdLine @@ -387,6 +388,7 @@ import GHC.Data.Maybe import System.IO.Error ( isDoesNotExistError ) import System.Environment ( getEnv ) import System.Directory +import Data.List (isPrefixOf) -- %************************************************************************ @@ -729,6 +731,88 @@ parseDynamicFlags dflags cmdline = do dflags2 <- liftIO $ interpretPackageEnv dflags1 return (dflags2, leftovers, warns) +-- | Parse command line arguments that look like files. +-- First normalises its arguments and then splits them into source files +-- and object files. +-- A source file can be turned into a 'Target' via 'guessTarget' +parseTargetFiles :: DynFlags -> [String] -> (DynFlags, [(String, Maybe Phase)], [String]) +parseTargetFiles dflags0 fileish_args = + let + normal_fileish_paths = map normalise_hyp fileish_args + (srcs, objs) = partition_args normal_fileish_paths [] [] + + dflags1 = dflags0 { ldInputs = map (FileOption "") objs + ++ ldInputs dflags0 } + {- + We split out the object files (.o, .dll) and add them + to ldInputs for use by the linker. + + The following things should be considered compilation manager inputs: + + - haskell source files (strings ending in .hs, .lhs or other + haskellish extension), + + - module names (not forgetting hierarchical module names), + + - things beginning with '-' are flags that were not recognised by + the flag parser, and we want them to generate errors later in + checkOptions, so we class them as source files (#5921) + + - and finally we consider everything without an extension to be + a comp manager input, as shorthand for a .hs or .lhs filename. + + Everything else is considered to be a linker object, and passed + straight through to the linker. + -} + in (dflags1, srcs, objs) + +-- ----------------------------------------------------------------------------- + +-- | Splitting arguments into source files and object files. This is where we +-- interpret the -x option, and attach a (Maybe Phase) to each source +-- file indicating the phase specified by the -x option in force, if any. +partition_args :: [String] -> [(String, Maybe Phase)] -> [String] + -> ([(String, Maybe Phase)], [String]) +partition_args [] srcs objs = (reverse srcs, reverse objs) +partition_args ("-x":suff:args) srcs objs + | "none" <- suff = partition_args args srcs objs + | StopLn <- phase = partition_args args srcs (slurp ++ objs) + | otherwise = partition_args rest (these_srcs ++ srcs) objs + where phase = startPhase suff + (slurp,rest) = break (== "-x") args + these_srcs = zip slurp (repeat (Just phase)) +partition_args (arg:args) srcs objs + | looks_like_an_input arg = partition_args args ((arg,Nothing):srcs) objs + | otherwise = partition_args args srcs (arg:objs) + + +looks_like_an_input :: String -> Bool +looks_like_an_input m = isSourceFilename m + || looksLikeModuleName m + || "-" `isPrefixOf` m + || not (hasExtension m) + + +-- | To simplify the handling of filepaths, we normalise all filepaths right +-- away. Note the asymmetry of FilePath.normalise: +-- Linux: p\/q -> p\/q; p\\q -> p\\q +-- Windows: p\/q -> p\\q; p\\q -> p\\q +-- #12674: Filenames starting with a hypen get normalised from ./-foo.hs +-- to -foo.hs. We have to re-prepend the current directory. +normalise_hyp :: FilePath -> FilePath +normalise_hyp fp + | strt_dot_sl && "-" `isPrefixOf` nfp = cur_dir ++ nfp + | otherwise = nfp + where +#if defined(mingw32_HOST_OS) + strt_dot_sl = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp +#else + strt_dot_sl = "./" `isPrefixOf` fp +#endif + cur_dir = '.' : [pathSeparator] + nfp = normalise fp + +----------------------------------------------------------------------------- -- | Checks the set of new DynFlags for possibly erroneous option -- combinations when invoking 'setSessionDynFlags' and friends, and if ===================================== ghc/Main.hs ===================================== @@ -16,7 +16,7 @@ module Main (main) where -- The official GHC API import qualified GHC -import GHC ( Ghc, GhcMonad(..), Backend (..), +import GHC (parseTargetFiles, Ghc, GhcMonad(..), Backend (..), LoadHowMuch(..) ) import GHC.Driver.CmdLine @@ -74,7 +74,6 @@ import GHC.Iface.Recomp.Binary ( fingerprintBinMem ) import System.IO import System.Environment import System.Exit -import System.FilePath import Control.Monad import Control.Monad.Trans.Class import Control.Monad.Trans.Except (throwE, runExceptT) @@ -219,29 +218,7 @@ main' postLoadMode dflags0 args flagWarnings = do liftIO $ showBanner postLoadMode dflags4 - let - -- To simplify the handling of filepaths, we normalise all filepaths right - -- away. Note the asymmetry of FilePath.normalise: - -- Linux: p/q -> p/q; p\q -> p\q - -- Windows: p/q -> p\q; p\q -> p\q - -- #12674: Filenames starting with a hypen get normalised from ./-foo.hs - -- to -foo.hs. We have to re-prepend the current directory. - normalise_hyp fp - | strt_dot_sl && "-" `isPrefixOf` nfp = cur_dir ++ nfp - | otherwise = nfp - where -#if defined(mingw32_HOST_OS) - strt_dot_sl = "./" `isPrefixOf` fp || ".\\" `isPrefixOf` fp -#else - strt_dot_sl = "./" `isPrefixOf` fp -#endif - cur_dir = '.' : [pathSeparator] - nfp = normalise fp - normal_fileish_paths = map (normalise_hyp . unLoc) fileish_args - (srcs, objs) = partition_args normal_fileish_paths [] [] - - dflags5 = dflags4 { ldInputs = map (FileOption "") objs - ++ ldInputs dflags4 } + let (dflags5, srcs, objs) = parseTargetFiles dflags4 (map unLoc fileish_args) -- we've finished manipulating the DynFlags, update the session _ <- GHC.setSessionDynFlags dflags5 @@ -289,51 +266,6 @@ ghciUI hsc_env dflags0 srcs maybe_expr = do interactiveUI defaultGhciSettings srcs maybe_expr #endif --- ----------------------------------------------------------------------------- --- Splitting arguments into source files and object files. This is where we --- interpret the -x option, and attach a (Maybe Phase) to each source --- file indicating the phase specified by the -x option in force, if any. - -partition_args :: [String] -> [(String, Maybe Phase)] -> [String] - -> ([(String, Maybe Phase)], [String]) -partition_args [] srcs objs = (reverse srcs, reverse objs) -partition_args ("-x":suff:args) srcs objs - | "none" <- suff = partition_args args srcs objs - | StopLn <- phase = partition_args args srcs (slurp ++ objs) - | otherwise = partition_args rest (these_srcs ++ srcs) objs - where phase = startPhase suff - (slurp,rest) = break (== "-x") args - these_srcs = zip slurp (repeat (Just phase)) -partition_args (arg:args) srcs objs - | looks_like_an_input arg = partition_args args ((arg,Nothing):srcs) objs - | otherwise = partition_args args srcs (arg:objs) - - {- - We split out the object files (.o, .dll) and add them - to ldInputs for use by the linker. - - The following things should be considered compilation manager inputs: - - - haskell source files (strings ending in .hs, .lhs or other - haskellish extension), - - - module names (not forgetting hierarchical module names), - - - things beginning with '-' are flags that were not recognised by - the flag parser, and we want them to generate errors later in - checkOptions, so we class them as source files (#5921) - - - and finally we consider everything without an extension to be - a comp manager input, as shorthand for a .hs or .lhs filename. - - Everything else is considered to be a linker object, and passed - straight through to the linker. - -} -looks_like_an_input :: String -> Bool -looks_like_an_input m = isSourceFilename m - || looksLikeModuleName m - || "-" `isPrefixOf` m - || not (hasExtension m) -- ----------------------------------------------------------------------------- -- Option sanity checks View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5884fd325248e75d40c9da431b4069e43a2c182c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5884fd325248e75d40c9da431b4069e43a2c182c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 18:50:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 14:50:04 -0400 Subject: [Git][ghc/ghc][master] Lint the compiler for extraneous LANGUAGE pragmas Message-ID: <5f82025cb5441_80b3f841ef77aec18161915@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 30 changed files: - + compiler/.hlint.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/StaticArgs.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea59fd4d0abe73e1127dcdd91855a39232e62d41 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea59fd4d0abe73e1127dcdd91855a39232e62d41 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 18:50:47 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 14:50:47 -0400 Subject: [Git][ghc/ghc][master] Linear types: fix quantification in GADTs (#18790) Message-ID: <5f8202873c3e8_80b3f8494cfe8d018163967@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 3 changed files: - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - testsuite/tests/linear/should_compile/MultConstructor.hs Changes: ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -31,6 +31,7 @@ module GHC.Rename.HsType ( extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, + extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1748,6 +1749,9 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] +extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars +extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args + -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1764,8 +1768,8 @@ extractHsTyRdrTyVarsKindVars (L _ ty) = -- | Extracts free type and kind variables from types in a list. -- When the same name occurs multiple times in the types, all occurrences -- are returned. -extractHsTysRdrTyVars :: [LHsType GhcPs] -> FreeKiTyVars -extractHsTysRdrTyVars tys = extract_ltys tys [] +extractHsTysRdrTyVars :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars +extractHsTysRdrTyVars tys = extract_ltys tys -- Returns the free kind variables of any explicitly-kinded binders, returning -- variable occurrences in left-to-right order. ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2213,7 +2213,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars (theta ++ map hsScaledThing arg_tys ++ [res_ty]) + $ extractHsTysRdrTyVars theta + $ extractHsScaledTysRdrTyVars arg_tys + $ extractHsTysRdrTyVars [res_ty] [] ; let ctxt = ConDeclCtx new_names ===================================== testsuite/tests/linear/should_compile/MultConstructor.hs ===================================== @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTSyntax, DataKinds, LinearTypes, KindSignatures, ExplicitForAll #-} +{-# LANGUAGE GADTs, DataKinds, LinearTypes, KindSignatures, ExplicitForAll, TypeApplications #-} module MultConstructor where import GHC.Types @@ -6,8 +6,23 @@ import GHC.Types data T p a where MkT :: a %p -> T p a -{- -this currently fails -g :: forall (b :: Type). T 'Many b %1 -> (b,b) -g (MkT x) = (x,x) --} +data Existential a where -- #18790 + MkE :: a %p -> Existential a + +f1 :: forall (a :: Type). T 'Many a %1 -> (a,a) +f1 (MkT x) = (x,x) + +f2 :: forall (a :: Type) m. T 'Many a %1 -> T m a +f2 (MkT x) = MkT x + +f3 :: forall (a :: Type). a %1 -> T 'One a +f3 = MkT + +g1 :: forall (a :: Type). a %1 -> Existential a +g1 x = MkE x + +g2 :: forall (a :: Type). Existential a -> a +g2 (MkE x) = x + +vta :: Int %1 -> Existential Int +vta x = MkE @Int @'One x View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22f218b729a751bc5e5965624a716fc542f502a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/22f218b729a751bc5e5965624a716fc542f502a5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 18:51:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 14:51:28 -0400 Subject: [Git][ghc/ghc][master] Bignum: fix bigNatCompareWord# bug (#18813) Message-ID: <5f8202b037ec8_80b3f84696c85041816931b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 4 changed files: - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - + testsuite/tests/lib/integer/T18813.hs - + testsuite/tests/lib/integer/T18813.stdout - testsuite/tests/lib/integer/all.T Changes: ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -339,7 +339,7 @@ bigNatCompareWord# a b | bigNatIsZero a = cmpW# 0## b | isTrue# (wordArraySize# a ># 1#) = GT | True - = cmpW# (indexWordArray# a 1#) b + = cmpW# (indexWordArray# a 0#) b -- | Compare a BigNat and a Word bigNatCompareWord :: BigNat# -> Word -> Ordering ===================================== testsuite/tests/lib/integer/T18813.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -O0 #-} + +import GHC.Exts +import GHC.Num.BigNat (bigNatCompareWord#, bigNatFromWord#) +import GHC.Num.Integer (integerGcd) + +main :: IO () +main = do + let + x = noinline (14205695611797621937 :: Integer) + y = noinline (2 :: Word) + print (integerGcd x (toInteger y)) + print (toInteger (gcd (fromInteger x) y :: Word)) + + let + x@(W# x#) = 1 :: Word + !x' = bigNatFromWord# x# + print (bigNatCompareWord# x' x#) + print (compare x x) ===================================== testsuite/tests/lib/integer/T18813.stdout ===================================== @@ -0,0 +1,4 @@ +1 +1 +EQ +EQ ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -11,6 +11,7 @@ test('integerPowMod', [], compile_and_run, ['']) test('integerGcdExt', [], compile_and_run, ['']) test('integerRecipMod', [], compile_and_run, ['']) test('bignumMatch', [], compile, ['']) +test('T18813', [], compile_and_run, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ee1237bf243dd7d8b758a53695575c364c3088 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ee1237bf243dd7d8b758a53695575c364c3088 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 20:27:09 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Sat, 10 Oct 2020 16:27:09 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] 5 commits: Move File Target parser to library #18596 Message-ID: <5f82191dda5e1_80b3f8468e9407c18174148@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - c9262d49 by Daniel Rogozin at 2020-10-10T23:24:32+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 30 changed files: - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/StaticArgs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb90acda33947e09653620a80db6f4d744451099...c9262d499599dcc5c706911da8272515322c53b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb90acda33947e09653620a80db6f4d744451099...c9262d499599dcc5c706911da8272515322c53b6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 21:23:16 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 17:23:16 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Lint the compiler for extraneous LANGUAGE pragmas Message-ID: <5f822644ab222_80b3f840fe1c864181784e9@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - df4ee0d6 by Simon Peyton Jones at 2020-10-10T17:23:03-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 22476b27 by Hécate at 2020-10-10T17:23:04-04:00 Remove the dependency on the ghc-linters stage - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2de3d1d533eae11c37fdafb0316b13851781f81d...22476b27c46c66293907180ae0d07fe3666bde5b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2de3d1d533eae11c37fdafb0316b13851781f81d...22476b27c46c66293907180ae0d07fe3666bde5b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 10 21:53:40 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sat, 10 Oct 2020 17:53:40 -0400 Subject: [Git][ghc/ghc][wip/T18599] Have the parser construct GetField syntax Message-ID: <5f822d643b8a1_80b3f8402b776c0181795c6@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: b3ec6df1 by Shayne Fletcher at 2020-10-10T17:51:08-04:00 Have the parser construct GetField syntax rnExpr (GetField {...}) calculates a GetField, tcExpr returns the enclosed typed getField function. - - - - - 6 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -668,7 +668,7 @@ type instance XRecordUpd GhcTc = RecordUpdTc type instance XGetField GhcPs = NoExtField type instance XGetField GhcRn = NoExtField -type instance XGetField GhcTc = GetFieldTc +type instance XGetField GhcTc = NoExtField type instance XExprWithTySig (GhcPass _) = NoExtField ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1162,6 +1162,9 @@ instance HiePass p => ToHie (Located (HsExpr (GhcPass p))) where HsSpliceE _ x -> [ toHie $ L mspan x ] + GetField _ expr _ _ -> + [ toHie expr + ] XExpr x | GhcTc <- ghcPass @p , WrapExpr (HsWrap w a) <- x ===================================== compiler/GHC/Parser.y ===================================== @@ -2625,8 +2625,8 @@ fexp :: { ECP } -- a projection 'r.a' (say) then we want the parse -- '(r.a).b'. ; return . ecpFromExp $ case $1 of - L _ (HsApp _ f arg) | not $ isGet f -> f `mkApp` mkGet arg $3 - _ -> mkGet $1 $3 + L _ (HsApp _ f arg) | not $ isGetField f -> f `mkApp` mkGetField (comb2 arg $3) arg $3 + _ -> mkGetField (comb2 $1 $>) $1 $3 }} | aexp { $1 } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -19,7 +19,7 @@ {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Parser.PostProcess ( - mkApp, mkGet, mkVar, mkFieldUpdater, mkProj, isGet, applyFieldUpdates, Fbind(..), -- RecordDot + mkApp, mkGetField, mkVar, mkFieldUpdater, mkProj, isGetField, applyFieldUpdates, Fbind(..), -- RecordDot mkHsOpApp, mkHsIntegral, mkHsFractional, mkHsIsString, mkHsDo, mkSpliceDecl, @@ -2967,9 +2967,9 @@ get_field = mkVar "getField" set_field = mkVar "setField" -- Test if the expression is a 'getField @"..."' expression. -isGet :: LHsExpr GhcPs -> Bool -isGet (L _ (HsAppType _ (L _ (HsVar _ (L _ name))) _)) = occNameString (rdrNameOcc name) == "getField" -isGet _ = False +isGetField :: LHsExpr GhcPs -> Bool +isGetField (L _ GetField{}) = True +isGetField _ = False zPat :: LPat GhcPs zVar, circ :: LHsExpr GhcPs @@ -2997,6 +2997,15 @@ mkGet' :: [LHsExpr GhcPs] -> Located FastString -> [LHsExpr GhcPs] mkGet' l@(r : _) (L _ fIELD) = get_field `mkAppType` mkSelector fIELD `mkApp` mkParen r : l mkGet' [] _ = panic "mkGet' : The impossible has happened!" +mkGetField :: SrcSpan -> LHsExpr GhcPs -> Located FastString -> LHsExpr GhcPs +mkGetField loc arg fIELD = + L loc GetField { + gf_ext = noExtField + , gf_expr = arg + , gf_fIELD = fIELD + , gf_getField = mkGet arg fIELD + } + -- mkSet a fIELD b calculates a set_field @fIELD expression. -- e.g mkSet a fIELD b = set_field @"fIELD" a b (read as "set field 'fIELD' on a to b"). mkSet :: LHsExpr GhcPs -> Located FastString -> LHsExpr GhcPs -> LHsExpr GhcPs ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -210,6 +210,14 @@ rnExpr (NegApp _ e _) ; final_e <- mkNegAppRn e' neg_name ; return (final_e, fv_e `plusFV` fv_neg) } +------------------------------------------ +-- Record dot syntax +rnExpr (GetField x e f g) + = do { (e', _) <- rnLExpr e + ; (g', fv) <- rnLExpr g + ; return (GetField x e' f g', fv) + } + ------------------------------------------ -- Template Haskell extensions rnExpr e@(HsBracket _ br_body) = rnBracket e br_body ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -1029,6 +1029,15 @@ tcExpr e@(HsRecFld _ f) res_ty tcExpr (ArithSeq _ witness seq) res_ty = tcArithSeq witness seq res_ty +{- +************************************************************************ +* * + Record dot syntax +* * +************************************************************************ +-} +tcExpr (GetField _ _ _ (L _ g)) res_ty = tcExpr g res_ty + {- ************************************************************************ * * View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3ec6df1e9a337b413756e3485cd94c5af9bdfda -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3ec6df1e9a337b413756e3485cd94c5af9bdfda You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 02:42:49 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Sat, 10 Oct 2020 22:42:49 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Break module cycle Message-ID: <5f827129c38ff_80b3f847d3dab94181859e@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 25f50147 by Richard Eisenberg at 2020-10-10T22:42:35-04:00 Break module cycle - - - - - 8 changed files: - compiler/GHC/Core/Map.hs - + compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Stg/CSE.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Core/Map.hs ===================================== @@ -12,24 +12,13 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -Wno-orphans #-} + -- Eq (DeBruijn CoreExpr) and Eq (DeBruijn CoreAlt) + module GHC.Core.Map ( -- * Maps over Core expressions CoreMap, emptyCoreMap, extendCoreMap, lookupCoreMap, foldCoreMap, - -- * Maps over 'Type's - TypeMap, emptyTypeMap, extendTypeMap, lookupTypeMap, foldTypeMap, - LooseTypeMap, - -- ** With explicit scoping - CmEnv, lookupCME, extendTypeMapWithScope, lookupTypeMapWithScope, - mkDeBruijnContext, - -- * Maps over 'Maybe' values - MaybeMap, - -- * Maps over 'List' values - ListMap, - -- * Maps over 'Literal's - LiteralMap, - -- * Map for compressing leaves. See Note [Compressed TrieMap] - GenMap, - -- * 'TrieMap' class + -- * 'TrieMap' class reexports TrieMap(..), insertTM, deleteTM, lkDFreeVar, xtDFreeVar, lkDNamed, xtDNamed, @@ -41,22 +30,15 @@ module GHC.Core.Map ( import GHC.Prelude import GHC.Data.TrieMap +import GHC.Core.Map.Type import GHC.Core -import GHC.Core.Coercion -import GHC.Types.Name import GHC.Core.Type -import GHC.Core.TyCo.Rep import GHC.Types.Var -import GHC.Data.FastString(FastString) import GHC.Utils.Misc import GHC.Utils.Outputable -import GHC.Utils.Panic import qualified Data.Map as Map -import qualified Data.IntMap as IntMap -import GHC.Types.Unique.FM -import GHC.Types.Var.Env import GHC.Types.Name.Env import Control.Monad( (>=>) ) @@ -76,27 +58,12 @@ numbered on the fly. -- Recall that -- Control.Monad.(>=>) :: (a -> Maybe b) -> (b -> Maybe c) -> a -> Maybe c --- NB: Be careful about RULES and type families (#5821). So we should make sure --- to specify @Key TypeMapX@ (and not @DeBruijn Type@, the reduced form) - -- The CoreMap makes heavy use of GenMap. However the CoreMap Types are not -- known when defining GenMap so we can only specialize them here. -{-# SPECIALIZE lkG :: Key TypeMapX -> TypeMapG a -> Maybe a #-} -{-# SPECIALIZE lkG :: Key CoercionMapX -> CoercionMapG a -> Maybe a #-} {-# SPECIALIZE lkG :: Key CoreMapX -> CoreMapG a -> Maybe a #-} - - -{-# SPECIALIZE xtG :: Key TypeMapX -> XT a -> TypeMapG a -> TypeMapG a #-} -{-# SPECIALIZE xtG :: Key CoercionMapX -> XT a -> CoercionMapG a -> CoercionMapG a #-} {-# SPECIALIZE xtG :: Key CoreMapX -> XT a -> CoreMapG a -> CoreMapG a #-} - -{-# SPECIALIZE mapG :: (a -> b) -> TypeMapG a -> TypeMapG b #-} -{-# SPECIALIZE mapG :: (a -> b) -> CoercionMapG a -> CoercionMapG b #-} {-# SPECIALIZE mapG :: (a -> b) -> CoreMapG a -> CoreMapG b #-} - -{-# SPECIALIZE fdG :: (a -> b -> b) -> TypeMapG a -> b -> b #-} -{-# SPECIALIZE fdG :: (a -> b -> b) -> CoercionMapG a -> b -> b #-} {-# SPECIALIZE fdG :: (a -> b -> b) -> CoreMapG a -> b -> b #-} @@ -108,13 +75,6 @@ numbered on the fly. ************************************************************************ -} -lkDNamed :: NamedThing n => n -> DNameEnv a -> Maybe a -lkDNamed n env = lookupDNameEnv env (getName n) - -xtDNamed :: NamedThing n => n -> XT a -> DNameEnv a -> DNameEnv a -xtDNamed tc f m = alterDNameEnv f m (getName tc) - - {- Note [Binders] ~~~~~~~~~~~~~~ @@ -408,431 +368,3 @@ fdA :: (a -> b -> b) -> AltMap a -> b -> b fdA k m = foldTM k (am_deflt m) . foldTM (foldTM k) (am_data m) . foldTM (foldTM k) (am_lit m) - -{- -************************************************************************ -* * - Coercions -* * -************************************************************************ --} - --- We should really never care about the contents of a coercion. Instead, --- just look up the coercion's type. -newtype CoercionMap a = CoercionMap (CoercionMapG a) - -instance TrieMap CoercionMap where - type Key CoercionMap = Coercion - emptyTM = CoercionMap emptyTM - lookupTM k (CoercionMap m) = lookupTM (deBruijnize k) m - alterTM k f (CoercionMap m) = CoercionMap (alterTM (deBruijnize k) f m) - foldTM k (CoercionMap m) = foldTM k m - mapTM f (CoercionMap m) = CoercionMap (mapTM f m) - -type CoercionMapG = GenMap CoercionMapX -newtype CoercionMapX a = CoercionMapX (TypeMapX a) - -instance TrieMap CoercionMapX where - type Key CoercionMapX = DeBruijn Coercion - emptyTM = CoercionMapX emptyTM - lookupTM = lkC - alterTM = xtC - foldTM f (CoercionMapX core_tm) = foldTM f core_tm - mapTM f (CoercionMapX core_tm) = CoercionMapX (mapTM f core_tm) - -instance Eq (DeBruijn Coercion) where - D env1 co1 == D env2 co2 - = D env1 (coercionType co1) == - D env2 (coercionType co2) - -lkC :: DeBruijn Coercion -> CoercionMapX a -> Maybe a -lkC (D env co) (CoercionMapX core_tm) = lkT (D env $ coercionType co) - core_tm - -xtC :: DeBruijn Coercion -> XT a -> CoercionMapX a -> CoercionMapX a -xtC (D env co) f (CoercionMapX m) - = CoercionMapX (xtT (D env $ coercionType co) f m) - -{- -************************************************************************ -* * - Types -* * -************************************************************************ --} - --- | @TypeMapG a@ is a map from @DeBruijn Type@ to @a at . The extended --- key makes it suitable for recursive traversal, since it can track binders, --- but it is strictly internal to this module. If you are including a 'TypeMap' --- inside another 'TrieMap', this is the type you want. Note that this --- lookup does not do a kind-check. Thus, all keys in this map must have --- the same kind. Also note that this map respects the distinction between --- @Type@ and @Constraint@, despite the fact that they are equivalent type --- synonyms in Core. -type TypeMapG = GenMap TypeMapX - --- | @TypeMapX a@ is the base map from @DeBruijn Type@ to @a@, but without the --- 'GenMap' optimization. -data TypeMapX a - = TM { tm_var :: VarMap a - , tm_app :: TypeMapG (TypeMapG a) - , tm_tycon :: DNameEnv a - , tm_forall :: TypeMapG (BndrMap a) -- See Note [Binders] - , tm_tylit :: TyLitMap a - , tm_coerce :: Maybe a - } - -- Note that there is no tyconapp case; see Note [Equality on AppTys] in GHC.Core.Type - --- | Squeeze out any synonyms, and change TyConApps to nested AppTys. Why the --- last one? See Note [Equality on AppTys] in "GHC.Core.Type" --- --- Note, however, that we keep Constraint and Type apart here, despite the fact --- that they are both synonyms of TYPE 'LiftedRep (see #11715). -trieMapView :: Type -> Maybe Type -trieMapView ty - -- First check for TyConApps that need to be expanded to - -- AppTy chains. - | Just (tc, tys@(_:_)) <- tcSplitTyConApp_maybe ty - = Just $ foldl' AppTy (TyConApp tc []) tys - - -- Then resolve any remaining nullary synonyms. - | Just ty' <- tcView ty = Just ty' -trieMapView _ = Nothing - -instance TrieMap TypeMapX where - type Key TypeMapX = DeBruijn Type - emptyTM = emptyT - lookupTM = lkT - alterTM = xtT - foldTM = fdT - mapTM = mapT - -instance Eq (DeBruijn Type) where - env_t@(D env t) == env_t'@(D env' t') - | Just new_t <- tcView t = D env new_t == env_t' - | Just new_t' <- tcView t' = env_t == D env' new_t' - | otherwise - = case (t, t') of - (CastTy t1 _, _) -> D env t1 == D env t' - (_, CastTy t1' _) -> D env t == D env t1' - - (TyVarTy v, TyVarTy v') - -> case (lookupCME env v, lookupCME env' v') of - (Just bv, Just bv') -> bv == bv' - (Nothing, Nothing) -> v == v' - _ -> False - -- See Note [Equality on AppTys] in GHC.Core.Type - (AppTy t1 t2, s) | Just (t1', t2') <- repSplitAppTy_maybe s - -> D env t1 == D env' t1' && D env t2 == D env' t2' - (s, AppTy t1' t2') | Just (t1, t2) <- repSplitAppTy_maybe s - -> D env t1 == D env' t1' && D env t2 == D env' t2' - (FunTy _ w1 t1 t2, FunTy _ w1' t1' t2') - -> D env w1 == D env w1' && D env t1 == D env' t1' && D env t2 == D env' t2' - (TyConApp tc tys, TyConApp tc' tys') - -> tc == tc' && D env tys == D env' tys' - (LitTy l, LitTy l') - -> l == l' - (ForAllTy (Bndr tv _) ty, ForAllTy (Bndr tv' _) ty') - -> D env (varType tv) == D env' (varType tv') && - D (extendCME env tv) ty == D (extendCME env' tv') ty' - (CoercionTy {}, CoercionTy {}) - -> True - _ -> False - -instance {-# OVERLAPPING #-} - Outputable a => Outputable (TypeMapG a) where - ppr m = text "TypeMap elts" <+> ppr (foldTM (:) m []) - -emptyT :: TypeMapX a -emptyT = TM { tm_var = emptyTM - , tm_app = emptyTM - , tm_tycon = emptyDNameEnv - , tm_forall = emptyTM - , tm_tylit = emptyTyLitMap - , tm_coerce = Nothing } - -mapT :: (a->b) -> TypeMapX a -> TypeMapX b -mapT f (TM { tm_var = tvar, tm_app = tapp, tm_tycon = ttycon - , tm_forall = tforall, tm_tylit = tlit - , tm_coerce = tcoerce }) - = TM { tm_var = mapTM f tvar - , tm_app = mapTM (mapTM f) tapp - , tm_tycon = mapTM f ttycon - , tm_forall = mapTM (mapTM f) tforall - , tm_tylit = mapTM f tlit - , tm_coerce = fmap f tcoerce } - ------------------ -lkT :: DeBruijn Type -> TypeMapX a -> Maybe a -lkT (D env ty) m = go ty m - where - go ty | Just ty' <- trieMapView ty = go ty' - go (TyVarTy v) = tm_var >.> lkVar env v - go (AppTy t1 t2) = tm_app >.> lkG (D env t1) - >=> lkG (D env t2) - go (TyConApp tc []) = tm_tycon >.> lkDNamed tc - go ty@(TyConApp _ (_:_)) = pprPanic "lkT TyConApp" (ppr ty) - go (LitTy l) = tm_tylit >.> lkTyLit l - go (ForAllTy (Bndr tv _) ty) = tm_forall >.> lkG (D (extendCME env tv) ty) - >=> lkBndr env tv - go ty@(FunTy {}) = pprPanic "lkT FunTy" (ppr ty) - go (CastTy t _) = go t - go (CoercionTy {}) = tm_coerce - ------------------ -xtT :: DeBruijn Type -> XT a -> TypeMapX a -> TypeMapX a -xtT (D env ty) f m | Just ty' <- trieMapView ty = xtT (D env ty') f m - -xtT (D env (TyVarTy v)) f m = m { tm_var = tm_var m |> xtVar env v f } -xtT (D env (AppTy t1 t2)) f m = m { tm_app = tm_app m |> xtG (D env t1) - |>> xtG (D env t2) f } -xtT (D _ (TyConApp tc [])) f m = m { tm_tycon = tm_tycon m |> xtDNamed tc f } -xtT (D _ (LitTy l)) f m = m { tm_tylit = tm_tylit m |> xtTyLit l f } -xtT (D env (CastTy t _)) f m = xtT (D env t) f m -xtT (D _ (CoercionTy {})) f m = m { tm_coerce = tm_coerce m |> f } -xtT (D env (ForAllTy (Bndr tv _) ty)) f m - = m { tm_forall = tm_forall m |> xtG (D (extendCME env tv) ty) - |>> xtBndr env tv f } -xtT (D _ ty@(TyConApp _ (_:_))) _ _ = pprPanic "xtT TyConApp" (ppr ty) -xtT (D _ ty@(FunTy {})) _ _ = pprPanic "xtT FunTy" (ppr ty) - -fdT :: (a -> b -> b) -> TypeMapX a -> b -> b -fdT k m = foldTM k (tm_var m) - . foldTM (foldTM k) (tm_app m) - . foldTM k (tm_tycon m) - . foldTM (foldTM k) (tm_forall m) - . foldTyLit k (tm_tylit m) - . foldMaybe k (tm_coerce m) - ------------------------- -data TyLitMap a = TLM { tlm_number :: Map.Map Integer a - , tlm_string :: UniqFM FastString a - } - -instance TrieMap TyLitMap where - type Key TyLitMap = TyLit - emptyTM = emptyTyLitMap - lookupTM = lkTyLit - alterTM = xtTyLit - foldTM = foldTyLit - mapTM = mapTyLit - -emptyTyLitMap :: TyLitMap a -emptyTyLitMap = TLM { tlm_number = Map.empty, tlm_string = emptyUFM } - -mapTyLit :: (a->b) -> TyLitMap a -> TyLitMap b -mapTyLit f (TLM { tlm_number = tn, tlm_string = ts }) - = TLM { tlm_number = Map.map f tn, tlm_string = mapUFM f ts } - -lkTyLit :: TyLit -> TyLitMap a -> Maybe a -lkTyLit l = - case l of - NumTyLit n -> tlm_number >.> Map.lookup n - StrTyLit n -> tlm_string >.> (`lookupUFM` n) - -xtTyLit :: TyLit -> XT a -> TyLitMap a -> TyLitMap a -xtTyLit l f m = - case l of - NumTyLit n -> m { tlm_number = Map.alter f n (tlm_number m) } - StrTyLit n -> m { tlm_string = alterUFM f (tlm_string m) n } - -foldTyLit :: (a -> b -> b) -> TyLitMap a -> b -> b -foldTyLit l m = flip (foldUFM l) (tlm_string m) - . flip (Map.foldr l) (tlm_number m) - -------------------------------------------------- --- | @TypeMap a@ is a map from 'Type' to @a at . If you are a client, this --- is the type you want. The keys in this map may have different kinds. -newtype TypeMap a = TypeMap (TypeMapG (TypeMapG a)) - -lkTT :: DeBruijn Type -> TypeMap a -> Maybe a -lkTT (D env ty) (TypeMap m) = lkG (D env $ typeKind ty) m - >>= lkG (D env ty) - -xtTT :: DeBruijn Type -> XT a -> TypeMap a -> TypeMap a -xtTT (D env ty) f (TypeMap m) - = TypeMap (m |> xtG (D env $ typeKind ty) - |>> xtG (D env ty) f) - --- Below are some client-oriented functions which operate on 'TypeMap'. - -instance TrieMap TypeMap where - type Key TypeMap = Type - emptyTM = TypeMap emptyTM - lookupTM k m = lkTT (deBruijnize k) m - alterTM k f m = xtTT (deBruijnize k) f m - foldTM k (TypeMap m) = foldTM (foldTM k) m - mapTM f (TypeMap m) = TypeMap (mapTM (mapTM f) m) - -foldTypeMap :: (a -> b -> b) -> b -> TypeMap a -> b -foldTypeMap k z m = foldTM k m z - -emptyTypeMap :: TypeMap a -emptyTypeMap = emptyTM - -lookupTypeMap :: TypeMap a -> Type -> Maybe a -lookupTypeMap cm t = lookupTM t cm - -extendTypeMap :: TypeMap a -> Type -> a -> TypeMap a -extendTypeMap m t v = alterTM t (const (Just v)) m - -lookupTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> Maybe a -lookupTypeMapWithScope m cm t = lkTT (D cm t) m - --- | Extend a 'TypeMap' with a type in the given context. --- @extendTypeMapWithScope m (mkDeBruijnContext [a,b,c]) t v@ is equivalent to --- @extendTypeMap m (forall a b c. t) v@, but allows reuse of the context over --- multiple insertions. -extendTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> a -> TypeMap a -extendTypeMapWithScope m cm t v = xtTT (D cm t) (const (Just v)) m - --- | Construct a deBruijn environment with the given variables in scope. --- e.g. @mkDeBruijnEnv [a,b,c]@ constructs a context @forall a b c.@ -mkDeBruijnContext :: [Var] -> CmEnv -mkDeBruijnContext = extendCMEs emptyCME - --- | A 'LooseTypeMap' doesn't do a kind-check. Thus, when lookup up (t |> g), --- you'll find entries inserted under (t), even if (g) is non-reflexive. -newtype LooseTypeMap a - = LooseTypeMap (TypeMapG a) - -instance TrieMap LooseTypeMap where - type Key LooseTypeMap = Type - emptyTM = LooseTypeMap emptyTM - lookupTM k (LooseTypeMap m) = lookupTM (deBruijnize k) m - alterTM k f (LooseTypeMap m) = LooseTypeMap (alterTM (deBruijnize k) f m) - foldTM f (LooseTypeMap m) = foldTM f m - mapTM f (LooseTypeMap m) = LooseTypeMap (mapTM f m) - -{- -************************************************************************ -* * - Variables -* * -************************************************************************ --} - -type BoundVar = Int -- Bound variables are deBruijn numbered -type BoundVarMap a = IntMap.IntMap a - -data CmEnv = CME { cme_next :: !BoundVar - , cme_env :: VarEnv BoundVar } - -emptyCME :: CmEnv -emptyCME = CME { cme_next = 0, cme_env = emptyVarEnv } - -extendCME :: CmEnv -> Var -> CmEnv -extendCME (CME { cme_next = bv, cme_env = env }) v - = CME { cme_next = bv+1, cme_env = extendVarEnv env v bv } - -extendCMEs :: CmEnv -> [Var] -> CmEnv -extendCMEs env vs = foldl' extendCME env vs - -lookupCME :: CmEnv -> Var -> Maybe BoundVar -lookupCME (CME { cme_env = env }) v = lookupVarEnv env v - --- | @DeBruijn a@ represents @a@ modulo alpha-renaming. This is achieved --- by equipping the value with a 'CmEnv', which tracks an on-the-fly deBruijn --- numbering. This allows us to define an 'Eq' instance for @DeBruijn a@, even --- if this was not (easily) possible for @a at . Note: we purposely don't --- export the constructor. Make a helper function if you find yourself --- needing it. -data DeBruijn a = D CmEnv a - --- | Synthesizes a @DeBruijn a@ from an @a@, by assuming that there are no --- bound binders (an empty 'CmEnv'). This is usually what you want if there --- isn't already a 'CmEnv' in scope. -deBruijnize :: a -> DeBruijn a -deBruijnize = D emptyCME - -instance Eq (DeBruijn a) => Eq (DeBruijn [a]) where - D _ [] == D _ [] = True - D env (x:xs) == D env' (x':xs') = D env x == D env' x' && - D env xs == D env' xs' - _ == _ = False - -instance Eq (DeBruijn a) => Eq (DeBruijn (Maybe a)) where - D _ Nothing == D _ Nothing = True - D env (Just x) == D env' (Just x') = D env x == D env' x' - _ == _ = False - ---------- Variable binders ------------- - --- | A 'BndrMap' is a 'TypeMapG' which allows us to distinguish between --- binding forms whose binders have different types. For example, --- if we are doing a 'TrieMap' lookup on @\(x :: Int) -> ()@, we should --- not pick up an entry in the 'TrieMap' for @\(x :: Bool) -> ()@: --- we can disambiguate this by matching on the type (or kind, if this --- a binder in a type) of the binder. --- --- We also need to do the same for multiplicity! Which, since multiplicities are --- encoded simply as a 'Type', amounts to have a Trie for a pair of types. Tries --- of pairs are composition. -data BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a)) - -instance TrieMap BndrMap where - type Key BndrMap = Var - emptyTM = BndrMap emptyTM - lookupTM = lkBndr emptyCME - alterTM = xtBndr emptyCME - foldTM = fdBndrMap - mapTM = mapBndrMap - -mapBndrMap :: (a -> b) -> BndrMap a -> BndrMap b -mapBndrMap f (BndrMap tm) = BndrMap (mapTM (mapTM f) tm) - -fdBndrMap :: (a -> b -> b) -> BndrMap a -> b -> b -fdBndrMap f (BndrMap tm) = foldTM (foldTM f) tm - - --- Note [Binders] --- ~~~~~~~~~~~~~~ --- We need to use 'BndrMap' for 'Coercion', 'CoreExpr' AND 'Type', since all --- of these data types have binding forms. - -lkBndr :: CmEnv -> Var -> BndrMap a -> Maybe a -lkBndr env v (BndrMap tymap) = do - multmap <- lkG (D env (varType v)) tymap - lookupTM (D env <$> varMultMaybe v) multmap - - -xtBndr :: forall a . CmEnv -> Var -> XT a -> BndrMap a -> BndrMap a -xtBndr env v xt (BndrMap tymap) = - BndrMap (tymap |> xtG (D env (varType v)) |>> (alterTM (D env <$> varMultMaybe v) xt)) - - ---------- Variable occurrence ------------- -data VarMap a = VM { vm_bvar :: BoundVarMap a -- Bound variable - , vm_fvar :: DVarEnv a } -- Free variable - -instance TrieMap VarMap where - type Key VarMap = Var - emptyTM = VM { vm_bvar = IntMap.empty, vm_fvar = emptyDVarEnv } - lookupTM = lkVar emptyCME - alterTM = xtVar emptyCME - foldTM = fdVar - mapTM = mapVar - -mapVar :: (a->b) -> VarMap a -> VarMap b -mapVar f (VM { vm_bvar = bv, vm_fvar = fv }) - = VM { vm_bvar = mapTM f bv, vm_fvar = mapTM f fv } - -lkVar :: CmEnv -> Var -> VarMap a -> Maybe a -lkVar env v - | Just bv <- lookupCME env v = vm_bvar >.> lookupTM bv - | otherwise = vm_fvar >.> lkDFreeVar v - -xtVar :: CmEnv -> Var -> XT a -> VarMap a -> VarMap a -xtVar env v f m - | Just bv <- lookupCME env v = m { vm_bvar = vm_bvar m |> alterTM bv f } - | otherwise = m { vm_fvar = vm_fvar m |> xtDFreeVar v f } - -fdVar :: (a -> b -> b) -> VarMap a -> b -> b -fdVar k m = foldTM k (vm_bvar m) - . foldTM k (vm_fvar m) - -lkDFreeVar :: Var -> DVarEnv a -> Maybe a -lkDFreeVar var env = lookupDVarEnv env var - -xtDFreeVar :: Var -> XT a -> DVarEnv a -> DVarEnv a -xtDFreeVar v f m = alterDVarEnv f m v ===================================== compiler/GHC/Core/Map/Type.hs ===================================== @@ -0,0 +1,501 @@ +{- +(c) The University of Glasgow 2006 +(c) The GRASP/AQUA Project, Glasgow University, 1992-1998 +-} + +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TypeFamilies #-} + +module GHC.Core.Map.Type ( + -- * Maps over 'Type's + TypeMap, emptyTypeMap, extendTypeMap, lookupTypeMap, foldTypeMap, + LooseTypeMap, + -- ** With explicit scoping + CmEnv, lookupCME, extendTypeMapWithScope, lookupTypeMapWithScope, + mkDeBruijnContext, extendCME, extendCMEs, emptyCME, + + -- * Utilities for use by friends only + TypeMapG, CoercionMapG, + + DeBruijn(..), deBruijnize, + + BndrMap, xtBndr, lkBndr, + VarMap, xtVar, lkVar, lkDFreeVar, xtDFreeVar, + + xtDNamed, lkDNamed + + ) where + +-- This module is separate from GHC.Core.Map to avoid a module loop +-- between GHC.Core.Unify (which depends on this module) and GHC.Core + +import GHC.Prelude + +import GHC.Core.Type +import GHC.Core.Coercion +import GHC.Core.TyCo.Rep +import GHC.Data.TrieMap + +import GHC.Data.FastString +import GHC.Types.Name +import GHC.Types.Name.Env +import GHC.Types.Var +import GHC.Types.Var.Env +import GHC.Types.Unique.FM +import GHC.Utils.Outputable + +import GHC.Utils.Panic + +import qualified Data.Map as Map +import qualified Data.IntMap as IntMap + +import Control.Monad ( (>=>) ) + +-- NB: Be careful about RULES and type families (#5821). So we should make sure +-- to specify @Key TypeMapX@ (and not @DeBruijn Type@, the reduced form) + +{-# SPECIALIZE lkG :: Key TypeMapX -> TypeMapG a -> Maybe a #-} +{-# SPECIALIZE lkG :: Key CoercionMapX -> CoercionMapG a -> Maybe a #-} + +{-# SPECIALIZE xtG :: Key TypeMapX -> XT a -> TypeMapG a -> TypeMapG a #-} +{-# SPECIALIZE xtG :: Key CoercionMapX -> XT a -> CoercionMapG a -> CoercionMapG a #-} + +{-# SPECIALIZE mapG :: (a -> b) -> TypeMapG a -> TypeMapG b #-} +{-# SPECIALIZE mapG :: (a -> b) -> CoercionMapG a -> CoercionMapG b #-} + +{-# SPECIALIZE fdG :: (a -> b -> b) -> TypeMapG a -> b -> b #-} +{-# SPECIALIZE fdG :: (a -> b -> b) -> CoercionMapG a -> b -> b #-} + +{- +************************************************************************ +* * + Coercions +* * +************************************************************************ +-} + +-- We should really never care about the contents of a coercion. Instead, +-- just look up the coercion's type. +newtype CoercionMap a = CoercionMap (CoercionMapG a) + +instance TrieMap CoercionMap where + type Key CoercionMap = Coercion + emptyTM = CoercionMap emptyTM + lookupTM k (CoercionMap m) = lookupTM (deBruijnize k) m + alterTM k f (CoercionMap m) = CoercionMap (alterTM (deBruijnize k) f m) + foldTM k (CoercionMap m) = foldTM k m + mapTM f (CoercionMap m) = CoercionMap (mapTM f m) + +type CoercionMapG = GenMap CoercionMapX +newtype CoercionMapX a = CoercionMapX (TypeMapX a) + +instance TrieMap CoercionMapX where + type Key CoercionMapX = DeBruijn Coercion + emptyTM = CoercionMapX emptyTM + lookupTM = lkC + alterTM = xtC + foldTM f (CoercionMapX core_tm) = foldTM f core_tm + mapTM f (CoercionMapX core_tm) = CoercionMapX (mapTM f core_tm) + +instance Eq (DeBruijn Coercion) where + D env1 co1 == D env2 co2 + = D env1 (coercionType co1) == + D env2 (coercionType co2) + +lkC :: DeBruijn Coercion -> CoercionMapX a -> Maybe a +lkC (D env co) (CoercionMapX core_tm) = lkT (D env $ coercionType co) + core_tm + +xtC :: DeBruijn Coercion -> XT a -> CoercionMapX a -> CoercionMapX a +xtC (D env co) f (CoercionMapX m) + = CoercionMapX (xtT (D env $ coercionType co) f m) + +{- +************************************************************************ +* * + Types +* * +************************************************************************ +-} + +-- | @TypeMapG a@ is a map from @DeBruijn Type@ to @a at . The extended +-- key makes it suitable for recursive traversal, since it can track binders, +-- but it is strictly internal to this module. If you are including a 'TypeMap' +-- inside another 'TrieMap', this is the type you want. Note that this +-- lookup does not do a kind-check. Thus, all keys in this map must have +-- the same kind. Also note that this map respects the distinction between +-- @Type@ and @Constraint@, despite the fact that they are equivalent type +-- synonyms in Core. +type TypeMapG = GenMap TypeMapX + +-- | @TypeMapX a@ is the base map from @DeBruijn Type@ to @a@, but without the +-- 'GenMap' optimization. +data TypeMapX a + = TM { tm_var :: VarMap a + , tm_app :: TypeMapG (TypeMapG a) + , tm_tycon :: DNameEnv a + , tm_forall :: TypeMapG (BndrMap a) -- See Note [Binders] in GHC.Core.Map + , tm_tylit :: TyLitMap a + , tm_coerce :: Maybe a + } + -- Note that there is no tyconapp case; see Note [Equality on AppTys] in GHC.Core.Type + +-- | Squeeze out any synonyms, and change TyConApps to nested AppTys. Why the +-- last one? See Note [Equality on AppTys] in "GHC.Core.Type" +-- +-- Note, however, that we keep Constraint and Type apart here, despite the fact +-- that they are both synonyms of TYPE 'LiftedRep (see #11715). +trieMapView :: Type -> Maybe Type +trieMapView ty + -- First check for TyConApps that need to be expanded to + -- AppTy chains. + | Just (tc, tys@(_:_)) <- tcSplitTyConApp_maybe ty + = Just $ foldl' AppTy (TyConApp tc []) tys + + -- Then resolve any remaining nullary synonyms. + | Just ty' <- tcView ty = Just ty' +trieMapView _ = Nothing + +instance TrieMap TypeMapX where + type Key TypeMapX = DeBruijn Type + emptyTM = emptyT + lookupTM = lkT + alterTM = xtT + foldTM = fdT + mapTM = mapT + +instance Eq (DeBruijn Type) where + env_t@(D env t) == env_t'@(D env' t') + | Just new_t <- tcView t = D env new_t == env_t' + | Just new_t' <- tcView t' = env_t == D env' new_t' + | otherwise + = case (t, t') of + (CastTy t1 _, _) -> D env t1 == D env t' + (_, CastTy t1' _) -> D env t == D env t1' + + (TyVarTy v, TyVarTy v') + -> case (lookupCME env v, lookupCME env' v') of + (Just bv, Just bv') -> bv == bv' + (Nothing, Nothing) -> v == v' + _ -> False + -- See Note [Equality on AppTys] in GHC.Core.Type + (AppTy t1 t2, s) | Just (t1', t2') <- repSplitAppTy_maybe s + -> D env t1 == D env' t1' && D env t2 == D env' t2' + (s, AppTy t1' t2') | Just (t1, t2) <- repSplitAppTy_maybe s + -> D env t1 == D env' t1' && D env t2 == D env' t2' + (FunTy _ w1 t1 t2, FunTy _ w1' t1' t2') + -> D env w1 == D env w1' && D env t1 == D env' t1' && D env t2 == D env' t2' + (TyConApp tc tys, TyConApp tc' tys') + -> tc == tc' && D env tys == D env' tys' + (LitTy l, LitTy l') + -> l == l' + (ForAllTy (Bndr tv _) ty, ForAllTy (Bndr tv' _) ty') + -> D env (varType tv) == D env' (varType tv') && + D (extendCME env tv) ty == D (extendCME env' tv') ty' + (CoercionTy {}, CoercionTy {}) + -> True + _ -> False + +instance {-# OVERLAPPING #-} + Outputable a => Outputable (TypeMapG a) where + ppr m = text "TypeMap elts" <+> ppr (foldTM (:) m []) + +emptyT :: TypeMapX a +emptyT = TM { tm_var = emptyTM + , tm_app = emptyTM + , tm_tycon = emptyDNameEnv + , tm_forall = emptyTM + , tm_tylit = emptyTyLitMap + , tm_coerce = Nothing } + +mapT :: (a->b) -> TypeMapX a -> TypeMapX b +mapT f (TM { tm_var = tvar, tm_app = tapp, tm_tycon = ttycon + , tm_forall = tforall, tm_tylit = tlit + , tm_coerce = tcoerce }) + = TM { tm_var = mapTM f tvar + , tm_app = mapTM (mapTM f) tapp + , tm_tycon = mapTM f ttycon + , tm_forall = mapTM (mapTM f) tforall + , tm_tylit = mapTM f tlit + , tm_coerce = fmap f tcoerce } + +----------------- +lkT :: DeBruijn Type -> TypeMapX a -> Maybe a +lkT (D env ty) m = go ty m + where + go ty | Just ty' <- trieMapView ty = go ty' + go (TyVarTy v) = tm_var >.> lkVar env v + go (AppTy t1 t2) = tm_app >.> lkG (D env t1) + >=> lkG (D env t2) + go (TyConApp tc []) = tm_tycon >.> lkDNamed tc + go ty@(TyConApp _ (_:_)) = pprPanic "lkT TyConApp" (ppr ty) + go (LitTy l) = tm_tylit >.> lkTyLit l + go (ForAllTy (Bndr tv _) ty) = tm_forall >.> lkG (D (extendCME env tv) ty) + >=> lkBndr env tv + go ty@(FunTy {}) = pprPanic "lkT FunTy" (ppr ty) + go (CastTy t _) = go t + go (CoercionTy {}) = tm_coerce + +----------------- +xtT :: DeBruijn Type -> XT a -> TypeMapX a -> TypeMapX a +xtT (D env ty) f m | Just ty' <- trieMapView ty = xtT (D env ty') f m + +xtT (D env (TyVarTy v)) f m = m { tm_var = tm_var m |> xtVar env v f } +xtT (D env (AppTy t1 t2)) f m = m { tm_app = tm_app m |> xtG (D env t1) + |>> xtG (D env t2) f } +xtT (D _ (TyConApp tc [])) f m = m { tm_tycon = tm_tycon m |> xtDNamed tc f } +xtT (D _ (LitTy l)) f m = m { tm_tylit = tm_tylit m |> xtTyLit l f } +xtT (D env (CastTy t _)) f m = xtT (D env t) f m +xtT (D _ (CoercionTy {})) f m = m { tm_coerce = tm_coerce m |> f } +xtT (D env (ForAllTy (Bndr tv _) ty)) f m + = m { tm_forall = tm_forall m |> xtG (D (extendCME env tv) ty) + |>> xtBndr env tv f } +xtT (D _ ty@(TyConApp _ (_:_))) _ _ = pprPanic "xtT TyConApp" (ppr ty) +xtT (D _ ty@(FunTy {})) _ _ = pprPanic "xtT FunTy" (ppr ty) + +fdT :: (a -> b -> b) -> TypeMapX a -> b -> b +fdT k m = foldTM k (tm_var m) + . foldTM (foldTM k) (tm_app m) + . foldTM k (tm_tycon m) + . foldTM (foldTM k) (tm_forall m) + . foldTyLit k (tm_tylit m) + . foldMaybe k (tm_coerce m) + +------------------------ +data TyLitMap a = TLM { tlm_number :: Map.Map Integer a + , tlm_string :: UniqFM FastString a + } + +instance TrieMap TyLitMap where + type Key TyLitMap = TyLit + emptyTM = emptyTyLitMap + lookupTM = lkTyLit + alterTM = xtTyLit + foldTM = foldTyLit + mapTM = mapTyLit + +emptyTyLitMap :: TyLitMap a +emptyTyLitMap = TLM { tlm_number = Map.empty, tlm_string = emptyUFM } + +mapTyLit :: (a->b) -> TyLitMap a -> TyLitMap b +mapTyLit f (TLM { tlm_number = tn, tlm_string = ts }) + = TLM { tlm_number = Map.map f tn, tlm_string = mapUFM f ts } + +lkTyLit :: TyLit -> TyLitMap a -> Maybe a +lkTyLit l = + case l of + NumTyLit n -> tlm_number >.> Map.lookup n + StrTyLit n -> tlm_string >.> (`lookupUFM` n) + +xtTyLit :: TyLit -> XT a -> TyLitMap a -> TyLitMap a +xtTyLit l f m = + case l of + NumTyLit n -> m { tlm_number = Map.alter f n (tlm_number m) } + StrTyLit n -> m { tlm_string = alterUFM f (tlm_string m) n } + +foldTyLit :: (a -> b -> b) -> TyLitMap a -> b -> b +foldTyLit l m = flip (foldUFM l) (tlm_string m) + . flip (Map.foldr l) (tlm_number m) + +------------------------------------------------- +-- | @TypeMap a@ is a map from 'Type' to @a at . If you are a client, this +-- is the type you want. The keys in this map may have different kinds. +newtype TypeMap a = TypeMap (TypeMapG (TypeMapG a)) + +lkTT :: DeBruijn Type -> TypeMap a -> Maybe a +lkTT (D env ty) (TypeMap m) = lkG (D env $ typeKind ty) m + >>= lkG (D env ty) + +xtTT :: DeBruijn Type -> XT a -> TypeMap a -> TypeMap a +xtTT (D env ty) f (TypeMap m) + = TypeMap (m |> xtG (D env $ typeKind ty) + |>> xtG (D env ty) f) + +-- Below are some client-oriented functions which operate on 'TypeMap'. + +instance TrieMap TypeMap where + type Key TypeMap = Type + emptyTM = TypeMap emptyTM + lookupTM k m = lkTT (deBruijnize k) m + alterTM k f m = xtTT (deBruijnize k) f m + foldTM k (TypeMap m) = foldTM (foldTM k) m + mapTM f (TypeMap m) = TypeMap (mapTM (mapTM f) m) + +foldTypeMap :: (a -> b -> b) -> b -> TypeMap a -> b +foldTypeMap k z m = foldTM k m z + +emptyTypeMap :: TypeMap a +emptyTypeMap = emptyTM + +lookupTypeMap :: TypeMap a -> Type -> Maybe a +lookupTypeMap cm t = lookupTM t cm + +extendTypeMap :: TypeMap a -> Type -> a -> TypeMap a +extendTypeMap m t v = alterTM t (const (Just v)) m + +lookupTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> Maybe a +lookupTypeMapWithScope m cm t = lkTT (D cm t) m + +-- | Extend a 'TypeMap' with a type in the given context. +-- @extendTypeMapWithScope m (mkDeBruijnContext [a,b,c]) t v@ is equivalent to +-- @extendTypeMap m (forall a b c. t) v@, but allows reuse of the context over +-- multiple insertions. +extendTypeMapWithScope :: TypeMap a -> CmEnv -> Type -> a -> TypeMap a +extendTypeMapWithScope m cm t v = xtTT (D cm t) (const (Just v)) m + +-- | Construct a deBruijn environment with the given variables in scope. +-- e.g. @mkDeBruijnEnv [a,b,c]@ constructs a context @forall a b c.@ +mkDeBruijnContext :: [Var] -> CmEnv +mkDeBruijnContext = extendCMEs emptyCME + +-- | A 'LooseTypeMap' doesn't do a kind-check. Thus, when lookup up (t |> g), +-- you'll find entries inserted under (t), even if (g) is non-reflexive. +newtype LooseTypeMap a + = LooseTypeMap (TypeMapG a) + +instance TrieMap LooseTypeMap where + type Key LooseTypeMap = Type + emptyTM = LooseTypeMap emptyTM + lookupTM k (LooseTypeMap m) = lookupTM (deBruijnize k) m + alterTM k f (LooseTypeMap m) = LooseTypeMap (alterTM (deBruijnize k) f m) + foldTM f (LooseTypeMap m) = foldTM f m + mapTM f (LooseTypeMap m) = LooseTypeMap (mapTM f m) + +{- +************************************************************************ +* * + Variables +* * +************************************************************************ +-} + +type BoundVar = Int -- Bound variables are deBruijn numbered +type BoundVarMap a = IntMap.IntMap a + +data CmEnv = CME { cme_next :: !BoundVar + , cme_env :: VarEnv BoundVar } + +emptyCME :: CmEnv +emptyCME = CME { cme_next = 0, cme_env = emptyVarEnv } + +extendCME :: CmEnv -> Var -> CmEnv +extendCME (CME { cme_next = bv, cme_env = env }) v + = CME { cme_next = bv+1, cme_env = extendVarEnv env v bv } + +extendCMEs :: CmEnv -> [Var] -> CmEnv +extendCMEs env vs = foldl' extendCME env vs + +lookupCME :: CmEnv -> Var -> Maybe BoundVar +lookupCME (CME { cme_env = env }) v = lookupVarEnv env v + +-- | @DeBruijn a@ represents @a@ modulo alpha-renaming. This is achieved +-- by equipping the value with a 'CmEnv', which tracks an on-the-fly deBruijn +-- numbering. This allows us to define an 'Eq' instance for @DeBruijn a@, even +-- if this was not (easily) possible for @a at . Note: we purposely don't +-- export the constructor. Make a helper function if you find yourself +-- needing it. +data DeBruijn a = D CmEnv a + +-- | Synthesizes a @DeBruijn a@ from an @a@, by assuming that there are no +-- bound binders (an empty 'CmEnv'). This is usually what you want if there +-- isn't already a 'CmEnv' in scope. +deBruijnize :: a -> DeBruijn a +deBruijnize = D emptyCME + +instance Eq (DeBruijn a) => Eq (DeBruijn [a]) where + D _ [] == D _ [] = True + D env (x:xs) == D env' (x':xs') = D env x == D env' x' && + D env xs == D env' xs' + _ == _ = False + +instance Eq (DeBruijn a) => Eq (DeBruijn (Maybe a)) where + D _ Nothing == D _ Nothing = True + D env (Just x) == D env' (Just x') = D env x == D env' x' + _ == _ = False + +--------- Variable binders ------------- + +-- | A 'BndrMap' is a 'TypeMapG' which allows us to distinguish between +-- binding forms whose binders have different types. For example, +-- if we are doing a 'TrieMap' lookup on @\(x :: Int) -> ()@, we should +-- not pick up an entry in the 'TrieMap' for @\(x :: Bool) -> ()@: +-- we can disambiguate this by matching on the type (or kind, if this +-- a binder in a type) of the binder. +-- +-- We also need to do the same for multiplicity! Which, since multiplicities are +-- encoded simply as a 'Type', amounts to have a Trie for a pair of types. Tries +-- of pairs are composition. +data BndrMap a = BndrMap (TypeMapG (MaybeMap TypeMapG a)) + +instance TrieMap BndrMap where + type Key BndrMap = Var + emptyTM = BndrMap emptyTM + lookupTM = lkBndr emptyCME + alterTM = xtBndr emptyCME + foldTM = fdBndrMap + mapTM = mapBndrMap + +mapBndrMap :: (a -> b) -> BndrMap a -> BndrMap b +mapBndrMap f (BndrMap tm) = BndrMap (mapTM (mapTM f) tm) + +fdBndrMap :: (a -> b -> b) -> BndrMap a -> b -> b +fdBndrMap f (BndrMap tm) = foldTM (foldTM f) tm + + +-- We need to use 'BndrMap' for 'Coercion', 'CoreExpr' AND 'Type', since all +-- of these data types have binding forms. + +lkBndr :: CmEnv -> Var -> BndrMap a -> Maybe a +lkBndr env v (BndrMap tymap) = do + multmap <- lkG (D env (varType v)) tymap + lookupTM (D env <$> varMultMaybe v) multmap + + +xtBndr :: forall a . CmEnv -> Var -> XT a -> BndrMap a -> BndrMap a +xtBndr env v xt (BndrMap tymap) = + BndrMap (tymap |> xtG (D env (varType v)) |>> (alterTM (D env <$> varMultMaybe v) xt)) + + +--------- Variable occurrence ------------- +data VarMap a = VM { vm_bvar :: BoundVarMap a -- Bound variable + , vm_fvar :: DVarEnv a } -- Free variable + +instance TrieMap VarMap where + type Key VarMap = Var + emptyTM = VM { vm_bvar = IntMap.empty, vm_fvar = emptyDVarEnv } + lookupTM = lkVar emptyCME + alterTM = xtVar emptyCME + foldTM = fdVar + mapTM = mapVar + +mapVar :: (a->b) -> VarMap a -> VarMap b +mapVar f (VM { vm_bvar = bv, vm_fvar = fv }) + = VM { vm_bvar = mapTM f bv, vm_fvar = mapTM f fv } + +lkVar :: CmEnv -> Var -> VarMap a -> Maybe a +lkVar env v + | Just bv <- lookupCME env v = vm_bvar >.> lookupTM bv + | otherwise = vm_fvar >.> lkDFreeVar v + +xtVar :: CmEnv -> Var -> XT a -> VarMap a -> VarMap a +xtVar env v f m + | Just bv <- lookupCME env v = m { vm_bvar = vm_bvar m |> alterTM bv f } + | otherwise = m { vm_fvar = vm_fvar m |> xtDFreeVar v f } + +fdVar :: (a -> b -> b) -> VarMap a -> b -> b +fdVar k m = foldTM k (vm_bvar m) + . foldTM k (vm_fvar m) + +lkDFreeVar :: Var -> DVarEnv a -> Maybe a +lkDFreeVar var env = lookupDVarEnv env var + +xtDFreeVar :: Var -> XT a -> DVarEnv a -> DVarEnv a +xtDFreeVar v f m = alterDVarEnv f m v + +------------------------------------------------- +lkDNamed :: NamedThing n => n -> DNameEnv a -> Maybe a +lkDNamed n env = lookupDNameEnv env (getName n) + +xtDNamed :: NamedThing n => n -> XT a -> DNameEnv a -> DNameEnv a +xtDNamed tc f m = alterDNameEnv f m (getName tc) ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -41,7 +41,7 @@ import GHC.Core.TyCon import GHC.Core.TyCo.Rep import GHC.Core.TyCo.FVs ( tyCoVarsOfCoList, tyCoFVsOfTypes ) import GHC.Core.TyCo.Subst ( mkTvSubst ) -import GHC.Core.Map +import GHC.Core.Map.Type import GHC.Utils.FV( FV, fvVarSet, fvVarList ) import GHC.Utils.Misc import GHC.Data.Pair ===================================== compiler/GHC/Iface/Ext/Utils.hs ===================================== @@ -8,7 +8,7 @@ module GHC.Iface.Ext.Utils where import GHC.Prelude -import GHC.Core.Map +import GHC.Core.Map.Type import GHC.Driver.Session ( DynFlags ) import GHC.Driver.Ppr import GHC.Data.FastString ( FastString, mkFastString ) ===================================== compiler/GHC/Stg/CSE.hs ===================================== @@ -103,6 +103,7 @@ import GHC.Core (AltCon(..)) import Data.List (mapAccumL) import Data.Maybe (fromMaybe) import GHC.Core.Map +import GHC.Data.TrieMap import GHC.Types.Name.Env import Control.Monad( (>=>) ) ===================================== compiler/GHC/Tc/Instance/Typeable.hs ===================================== @@ -39,7 +39,7 @@ import GHC.Hs import GHC.Driver.Session import GHC.Data.Bag import GHC.Types.Var ( VarBndr(..) ) -import GHC.Core.Map +import GHC.Core.Map.Type import GHC.Settings.Constants import GHC.Utils.Fingerprint(Fingerprint(..), fingerprintString, fingerprintFingerprints) import GHC.Utils.Outputable ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -174,7 +174,9 @@ import GHC.Types.Unique import GHC.Types.Unique.DFM import GHC.Data.Maybe -import GHC.Core.Map +import GHC.Core.Map.Type +import GHC.Data.TrieMap + import Control.Monad import GHC.Utils.Monad import Data.IORef ===================================== compiler/ghc.cabal.in ===================================== @@ -303,6 +303,7 @@ Library GHC.Core.Unfold.Make GHC.Core.Utils GHC.Core.Map + GHC.Core.Map.Type GHC.Core.Seq GHC.Core.Stats GHC.Core.Make View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25f50147f3472bf8a098eff1a9dff642b812e36c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25f50147f3472bf8a098eff1a9dff642b812e36c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 02:53:31 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 10 Oct 2020 22:53:31 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Fall back to types when looking up data constructors (#18740) Message-ID: <5f8273ab4bbf0_80b3f847d3dab94181918a@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c9262d49 by Daniel Rogozin at 2020-10-10T23:24:32+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - de2dbcba by Simon Peyton Jones at 2020-10-10T22:53:23-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - ee4d15bf by Hécate at 2020-10-10T22:53:24-04:00 Remove the dependency on the ghc-linters stage - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles2.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22476b27c46c66293907180ae0d07fe3666bde5b...ee4d15bfbc16bfd76328c0ace830b45a5a8c5560 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/22476b27c46c66293907180ae0d07fe3666bde5b...ee4d15bfbc16bfd76328c0ace830b45a5a8c5560 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 08:23:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 11 Oct 2020 04:23:50 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Fix some missed opportunities for preInlineUnconditionally Message-ID: <5f82c116b058e_80b3f8467ebec4c18208928@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: a22ac041 by Simon Peyton Jones at 2020-10-11T04:23:42-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 971b75be by Hécate at 2020-10-11T04:23:43-04:00 Remove the dependency on the ghc-linters stage - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles2.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/simplCore/should_compile/Makefile - testsuite/tests/simplCore/should_compile/T13143.stderr - + testsuite/tests/simplCore/should_compile/T18815.hs - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/T7865.stdout - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplCore/should_compile/spec-inline.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee4d15bfbc16bfd76328c0ace830b45a5a8c5560...971b75be2b68b328ecd699d9310e236992094084 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ee4d15bfbc16bfd76328c0ace830b45a5a8c5560...971b75be2b68b328ecd699d9310e236992094084 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 09:48:54 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sun, 11 Oct 2020 05:48:54 -0400 Subject: [Git][ghc/ghc][wip/T18815] 38 commits: Document profiling flags, warning flags, and no-pie Message-ID: <5f82d50673baa_80b3f84a097df38182155b8@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18815 at Glasgow Haskell Compiler / GHC Commits: 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 296bf434 by Simon Peyton Jones at 2020-10-11T05:48:51-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d235edfcaf155f484151c8d48101128be9510033...296bf434d6ac5959598e739af5aee24b19f577a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d235edfcaf155f484151c8d48101128be9510033...296bf434d6ac5959598e739af5aee24b19f577a0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 14:04:10 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 11 Oct 2020 10:04:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Remove the dependency on the ghc-linters stage Message-ID: <5f8310daf1ee7_80b3f8430f283b81823972e@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f283f889 by Hécate at 2020-10-11T10:04:04-04:00 Remove the dependency on the ghc-linters stage - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f283f889f27a50c195feed0d62127d067ec1c8a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f283f889f27a50c195feed0d62127d067ec1c8a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 14:42:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 11 Oct 2020 10:42:20 -0400 Subject: [Git][ghc/ghc][master] Remove the dependency on the ghc-linters stage Message-ID: <5f8319cc3695d_80b3f848701a694182440a@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/274e21f02fabb4b3761841972b1074d0c0146fae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/274e21f02fabb4b3761841972b1074d0c0146fae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 14:54:57 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 11 Oct 2020 10:54:57 -0400 Subject: [Git][ghc/ghc][wip/T18599] reduce imports; improve locs Message-ID: <5f831cc1aadd6_80b3f8469da4ecc1824462e@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 25dded33 by Shayne Fletcher at 2020-10-11T10:54:45-04:00 reduce imports; improve locs - - - - - 2 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2625,7 +2625,11 @@ fexp :: { ECP } -- a projection 'r.a' (say) then we want the parse -- '(r.a).b'. ; return . ecpFromExp $ case $1 of - L _ (HsApp _ f arg) | not $ isGetField f -> f `mkApp` mkGetField (comb2 arg $3) arg $3 + L _ (HsApp _ f arg) + | not $ isGetField f -> + let l = (comb2 arg $3) in + L (getLoc f `combineSrcSpans` l) + (HsApp noExtField f (mkGetField l arg $3)) _ -> mkGetField (comb2 $1 $>) $1 $3 }} ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -19,7 +19,7 @@ {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Parser.PostProcess ( - mkApp, mkGetField, mkVar, mkFieldUpdater, mkProj, isGetField, applyFieldUpdates, Fbind(..), -- RecordDot + mkGetField, mkFieldUpdater, mkProj, isGetField, Fbind(..), -- RecordDot mkHsOpApp, mkHsIntegral, mkHsFractional, mkHsIsString, mkHsDo, mkSpliceDecl, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25dded331792c1a74a640c77017b1d46543e18ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/25dded331792c1a74a640c77017b1d46543e18ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 15:21:51 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Sun, 11 Oct 2020 11:21:51 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Expand synonyms that mention families, obvs Message-ID: <5f83230f8bdcc_80b3f8469bea8ac182455c4@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 16e56ac1 by Richard Eisenberg at 2020-10-11T11:21:36-04:00 Expand synonyms that mention families, obvs - - - - - 1 changed file: - compiler/GHC/Tc/Solver/Flatten.hs Changes: ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1126,8 +1126,8 @@ flatten_one (AppTy ty1 ty2) flatten_one ty@(TyConApp tc tys) -- Expand type synonyms that mention type families -- on the RHS; see Note [Flattening synonyms] - | isForgetfulSynTyCon tc - , Just expanded_ty <- tcView ty -- should always succeed + | isForgetfulSynTyCon tc || not (isFamFreeTyCon tc) + , Just expanded_ty <- tcView ty = flatten_one expanded_ty -- Otherwise, it's a type function application, and we have to @@ -1309,6 +1309,9 @@ synonyms, but not others. One nice consequence is that we never have to occCheckExpand flattened types, as any forgetful synonyms are already expanded. +We also, of course, must expand type synonyms that mention type families, +so those families can get reduced. + Note [Flattening under a forall] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Under a forall, we View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16e56ac19b1b72223093b95bb462875c73289554 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16e56ac19b1b72223093b95bb462875c73289554 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 16:13:36 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 11 Oct 2020 12:13:36 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Fix MVar putting and implement tests Message-ID: <5f832f307ba6c_80b3f84962f0d3c1824768e@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 31272415 by Sven Tennie at 2020-10-11T18:13:16+02:00 Fix MVar putting and implement tests - - - - - 9 changed files: - libraries/base/GHC/Stack/CloneStack.hs - rts/CloneStack.c - rts/CloneStack.h - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/rts/all.T - testsuite/tests/rts/cloneMyStack.hs - testsuite/tests/rts/cloneStackLib.c - testsuite/tests/rts/cloneThreadStack.hs Changes: ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -21,6 +21,19 @@ foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# data StackSnapshot = StackSnapshot StackSnapshot# +{- Note [Stack Cloning] +"Cloning" a stack means that it's StgStack closure is copied including the +stack memory (stack[]). The stack pointer (sp) of the clone is adjusted to be +valid. +The clone is "offline"/"cold", i.e. it won't be evaluated any further. This is +useful for further analyses like stack unwinding or traversal. + +There are two different ways to clone a stack: +1. By the corresponding thread via a primop call (cloneMyStack#). +2. By sending a RTS message (Messages.c) with a MVar to the corresponding + thread and receiving the stack by taking it out of this MVar. +-} + -- | Clone the stack of a thread identified by it's 'ThreadId' cloneThreadStack :: ThreadId -> IO StackSnapshot cloneThreadStack (ThreadId tid#) = do @@ -31,7 +44,6 @@ cloneThreadStack (ThreadId tid#) = do -- into resultVar. sendCloneStackMessage tid# ptr freeStablePtr ptr - print "takeMVar" takeMVar resultVar -- | Clone the stack of the executing thread ===================================== rts/CloneStack.c ===================================== @@ -27,7 +27,12 @@ void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { void handleCloneStackMessage(MessageCloneStack *msg){ StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); - bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, newStackClosure); + // Lift StackSnapshot# to StackSnapshot by applying it's constructor. + // This is necessary because performTryPutMVar() puts the closure onto the + // stack for evaluation and stacks can not be evaluated (entered). + HaskellObj result = rts_apply(msg->tso->cap, StackSnapshot_constructor_closure, (HaskellObj) newStackClosure); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, result); if(!putMVarWasSuccessful) { barf("Can't put stack cloning result into MVar."); @@ -43,11 +48,6 @@ void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { #endif // end !defined(THREADED_RTS) StgStack* cloneStack(Capability* capability, StgStack* stack){ -#if defined(DEBUG) - debugBelch("Stack to clone\n"); - printStack(stack); -#endif - StgWord spOffset = stack->sp - stack->stack; StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); @@ -58,9 +58,7 @@ StgStack* cloneStack(Capability* capability, StgStack* stack){ newStackClosure->sp = newStackClosure->stack + spOffset; #if defined(DEBUG) - debugBelch("Cloned stack\n"); - printStack(newStackClosure); - // TODO: Check sanity + checkClosure(newStackClosure); #endif return newStackClosure; ===================================== rts/CloneStack.h ===================================== @@ -7,3 +7,6 @@ void handleCloneStackMessage(MessageCloneStack *msg); void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); StgStack* cloneStack(Capability* capability, StgStack* stack); + +extern StgClosure DLL_IMPORT_DATA_VARNAME(base_GHCziStackziCloneStack_StackSnapshot_closure); +#define StackSnapshot_constructor_closure DLL_IMPORT_DATA_REF(base_GHCziStackziCloneStack_StackSnapshot_closure) ===================================== rts/package.conf.in ===================================== @@ -194,6 +194,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,_findPtr" #endif + , "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" #else "-Wl,-u,base_GHCziTopHandler_runIO_closure" , "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" @@ -308,6 +309,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,findPtr" #endif + , "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" #endif /* Pick up static libraries in preference over dynamic if in earlier search ===================================== rts/rts.cabal.in ===================================== @@ -286,6 +286,7 @@ library "-Wl,-u,_hs_atomicwrite8" "-Wl,-u,_hs_atomicwrite16" "-Wl,-u,_hs_atomicwrite32" + "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -367,6 +368,7 @@ library "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" + "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, ===================================== testsuite/tests/rts/all.T ===================================== @@ -419,6 +419,6 @@ test('T17088', test('T15427', normal, compile_and_run, ['']) -test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -debug']) +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c']) -test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -debug -threaded']) +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -4,11 +4,17 @@ import GHC.Prim (StackSnapshot#) import GHC.Stack.CloneStack +import Foreign +import Foreign.C.Types (CUInt) -foreign import ccall "printy" printStack:: StackSnapshot# -> IO () +foreign import ccall "expectClosureTypes" expectClosureTypes:: StackSnapshot# -> Ptr CUInt -> Int -> IO () main :: IO () main = do stackSnapshot <- cloneMyStack + let (StackSnapshot stack) = stackSnapshot - printStack stack + let expectedClosureTypes = [34 -- CATCH_FRAME + ,36 -- STOP_FRAME + ] + withArray expectedClosureTypes (\ptr -> expectClosureTypes stack ptr (length expectedClosureTypes)) ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -1,9 +1,53 @@ #include "Rts.h" #include "RtsAPI.h" +#include "rts/Messages.h" -// TODO: Do not merge. Only exported for debugging. -extern void printStack( StgStack *stack ); -void printy(StgStack *stack) { - printStack(stack); +void checkClonedStack(StgStack *clonedStack, StgTSO *tso) { + StgStack *liveStack = tso->stackobj; + + if(liveStack->header.info != clonedStack->header.info){ + barf("info table pointer not equal! Expected same pointer address, but got %p and %p", liveStack->header.info, clonedStack->header.info); + } + + StgInfoTable *info = INFO_PTR_TO_STRUCT(liveStack->header.info); + + if (info->type != STACK) { + barf("Expected a closure of type STACK!"); + } + + if(liveStack->stack_size != clonedStack->stack_size){ + barf("Expected same stack_size!"); + } + + if(liveStack->dirty != clonedStack->dirty){ + barf("Expected same dirty flags!"); + } + + if(liveStack->marking != clonedStack->marking){ + barf("Expected same marking flags!"); + } + + for(StgWord i = liveStack->stack_size - 1; (liveStack->stack + i) >= liveStack->sp; i--){ + if(liveStack->stack[i] != clonedStack->stack[i]){ + barf("Expected stack word %lu to be equal on both stacks.", i); + } + } +} + +void expectClosureTypes(StgStack *stack, unsigned int types[], size_t typesSize){ + StgPtr sp = stack->sp; + StgPtr spBottom = stack->stack + stack->stack_size; + + for (StgWord i = 0; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp), i++) { + const StgInfoTable *info = get_itbl((StgClosure *)sp); + + if(i >= typesSize) { + barf("Stack size exceeds expectation!"); + } + + if(info->type != types[i]) { + barf("Wrong closure type on stack! Expected %u but got %u", types[i], info->type); + } + } } ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -2,22 +2,45 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnliftedFFITypes #-} -import GHC.Prim (StackSnapshot#) +import GHC.Prim (StackSnapshot#, ThreadId#) +import GHC.Conc.Sync (ThreadId(..)) import GHC.Stack.CloneStack import Control.Concurrent +import GHC.Conc -foreign import ccall "printy" printStack:: StackSnapshot# -> IO () +foreign import ccall "checkClonedStack" checkClonedStack:: StackSnapshot# -> ThreadId# -> IO () main :: IO () main = do mVarToBeBlockedOn <- newEmptyMVar threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + waitUntilBlocked threadId + stackSnapshot <- cloneThreadStack threadId + let (StackSnapshot stack) = stackSnapshot - printStack stack + let (ThreadId tid#) = threadId + checkClonedStack stack tid# immediatelyBlocking :: MVar Int -> IO () immediatelyBlocking mVarToBeBlockedOn = do takeMVar mVarToBeBlockedOn return () + +waitUntilBlocked :: ThreadId -> IO () +waitUntilBlocked tid = do + blocked <- isBlocked tid + if blocked then + return () + else + do + threadDelay 100000 + waitUntilBlocked tid + +isBlocked:: ThreadId -> IO Bool +isBlocked = fmap isThreadStatusBlocked . threadStatus + +isThreadStatusBlocked :: ThreadStatus -> Bool +isThreadStatusBlocked (ThreadBlocked _) = True +isThreadStatusBlocked _ = False View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31272415c6286ca0af812bdbc72504e28df6def6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31272415c6286ca0af812bdbc72504e28df6def6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 17:49:56 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 11 Oct 2020 13:49:56 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Add printStack Message-ID: <5f8345c4dbf2a_80b3f849aa3b6d8182520d4@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 14599b01 by Sven Tennie at 2020-10-11T19:49:36+02:00 Add printStack - - - - - 6 changed files: - + includes/rts/PrinterAPI.h - libraries/base/GHC/Stack/CloneStack.hs - rts/Disassembler.c - rts/Disassembler.h - rts/Printer.c - rts/Printer.h Changes: ===================================== includes/rts/PrinterAPI.h ===================================== @@ -0,0 +1,3 @@ +#pragma once + +extern void printStack (StgStack* stack); ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -8,6 +8,7 @@ module GHC.Stack.CloneStack ( cloneThreadStack, cloneMyStack, + printStack, StackSnapshot(..) ) where @@ -19,6 +20,8 @@ import GHC.IO (IO(..)) foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () +foreign import ccall "PrinterAPI.h printStack" printStack_c :: StackSnapshot# -> IO () + data StackSnapshot = StackSnapshot StackSnapshot# {- Note [Stack Cloning] @@ -50,3 +53,7 @@ cloneThreadStack (ThreadId tid#) = do cloneMyStack :: IO StackSnapshot cloneMyStack = IO $ \s -> case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) + +-- | Print the stack +printStack :: StackSnapshot -> IO () +printStack (StackSnapshot stack) = printStack_c stack ===================================== rts/Disassembler.c ===================================== @@ -8,8 +8,6 @@ * $Date: 2004/09/03 15:28:19 $ * ---------------------------------------------------------------------------*/ -#if defined(DEBUG) - #include "PosixSource.h" #include "Rts.h" #include "RtsAPI.h" @@ -358,5 +356,3 @@ void disassemble( StgBCO *bco ) debugBelch("\n"); } - -#endif /* DEBUG */ ===================================== rts/Disassembler.h ===================================== @@ -8,9 +8,5 @@ #pragma once -#if defined(DEBUG) - RTS_PRIVATE int disInstr ( StgBCO *bco, int pc ); RTS_PRIVATE void disassemble( StgBCO *bco ); - -#endif ===================================== rts/Printer.c ===================================== @@ -25,9 +25,10 @@ #include +#include "Disassembler.h" + #if defined(DEBUG) -#include "Disassembler.h" #include "Apply.h" /* -------------------------------------------------------------------------- @@ -58,402 +59,337 @@ void printObj( StgClosure *obj ) printClosure(obj); } -STATIC_INLINE void -printStdObjHdr( const StgClosure *obj, char* tag ) +void +printMutableList(bdescr *bd) { - debugBelch("%s(",tag); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif -} + StgPtr p; -static void -printStdObjPayload( const StgClosure *obj ) -{ - StgWord i, j; - const StgInfoTable* info; + debugBelch("mutable list %p: ", bd); - info = get_itbl(obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); + for (; bd != NULL; bd = bd->link) { + for (p = bd->start; p < bd->free; p++) { + debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); + } } - debugBelch(")\n"); + debugBelch("\n"); } -static void -printThunkPayload( StgThunk *obj ) +void printTSO( StgTSO *tso ) { - StgWord i, j; - const StgInfoTable* info; - - info = get_itbl((StgClosure *)obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); - } - debugBelch(")\n"); + printStack( tso->stackobj ); } -static void -printThunkObject( StgThunk *obj, char* tag ) +void printStaticObjects( StgClosure *p ) { - printStdObjHdr( (StgClosure *)obj, tag ); - printThunkPayload( obj ); + while (p != END_OF_STATIC_OBJECT_LIST) { + p = UNTAG_STATIC_LIST_PTR(p); + printClosure(p); + + const StgInfoTable *info = get_itbl(p); + p = *STATIC_LINK(info, p); + } } -void -printClosure( const StgClosure *obj ) +void printWeakLists() { - debugBelch("%p: ", obj); - obj = UNTAG_CONST_CLOSURE(obj); - const StgInfoTable* info = get_itbl(obj); + debugBelch("======= WEAK LISTS =======\n"); - while (IS_FORWARDING_PTR(info)) { - obj = (StgClosure*)UN_FORWARDING_PTR(info); - debugBelch("(forwarding to %p) ", (void*)obj); - info = get_itbl(obj); + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + debugBelch("Capability %d:\n", cap_idx); + Capability *cap = capabilities[cap_idx]; + for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } } - switch ( info->type ) { - case INVALID_OBJECT: - barf("Invalid object"); - - case CONSTR: - case CONSTR_1_0: case CONSTR_0_1: - case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: - case CONSTR_NOCAF: - { - StgWord i, j; - const StgConInfoTable *con_info = get_con_itbl (obj); - - debugBelch("%s(", GET_CON_DESC(con_info)); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - if (i != 0) debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - if (i != 0 || j != 0) debugBelch(", "); - debugBelch("%p#", obj->payload[i+j]); - } - debugBelch(")\n"); - break; + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current weaks:\n", gen_idx); + for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); } + debugBelch("Generation %d old weaks:\n", gen_idx); + for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } + } - case FUN: - case FUN_1_0: case FUN_0_1: - case FUN_1_1: case FUN_0_2: case FUN_2_0: - case FUN_STATIC: - debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif - printStdObjPayload(obj); - break; - - case PRIM: - debugBelch("PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case MUT_PRIM: - debugBelch("MUT_PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case THUNK: - case THUNK_1_0: case THUNK_0_1: - case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: - case THUNK_STATIC: - /* ToDo: will this work for THUNK_STATIC too? */ -#if defined(PROFILING) - printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); -#else - printThunkObject((StgThunk *)obj,"THUNK"); -#endif - break; + debugBelch("=========================\n"); +} - case THUNK_SELECTOR: - printStdObjHdr(obj, "THUNK_SELECTOR"); - debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); - break; +void printLargeAndPinnedObjects() +{ + debugBelch("====== PINNED OBJECTS ======\n"); - case BCO: - disassemble( (StgBCO*)obj ); - break; + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + Capability *cap = capabilities[cap_idx]; - case AP: - { - StgAP* ap = (StgAP*)obj; - StgWord i; - debugBelch("AP("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->n_args; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Capability %d: Current pinned object block: %p\n", + cap_idx, (void*)cap->pinned_object_block); + for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { + debugBelch("%p\n", (void*)bd); } + } - case PAP: - { - StgPAP* pap = (StgPAP*)obj; - StgWord i; - debugBelch("PAP/%d(",(int)pap->arity); - printPtr((StgPtr)pap->fun); - for (i = 0; i < pap->n_args; ++i) { - debugBelch(", "); - printPtr((StgPtr)pap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("====== LARGE OBJECTS =======\n"); + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current large objects:\n", gen_idx); + for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } - case AP_STACK: - { - StgAP_STACK* ap = (StgAP_STACK*)obj; - StgWord i; - debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->size; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Generation %d scavenged large objects:\n", gen_idx); + for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } + } - case IND: - debugBelch("IND("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; - - case IND_STATIC: - debugBelch("IND_STATIC("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; + debugBelch("============================\n"); +} - case BLACKHOLE: - debugBelch("BLACKHOLE("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; +/* -------------------------------------------------------------------------- + * Address printing code + * + * Uses symbol table in (unstripped executable) + * ------------------------------------------------------------------------*/ - /* Cannot happen -- use default case. - case RET_BCO: - case RET_SMALL: - case RET_BIG: - case RET_FUN: - */ +/* -------------------------------------------------------------------------- + * Simple lookup table + * address -> function name + * ------------------------------------------------------------------------*/ - case UPDATE_FRAME: - { - StgUpdateFrame* u = (StgUpdateFrame*)obj; - debugBelch("%s(", info_update_frame(obj)); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->updatee); - debugBelch(")\n"); - break; - } +static HashTable * add_to_fname_table = NULL; - case CATCH_FRAME: - { - StgCatchFrame* u = (StgCatchFrame*)obj; - debugBelch("CATCH_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->handler); - debugBelch(")\n"); - break; - } - - case UNDERFLOW_FRAME: - { - StgUnderflowFrame* u = (StgUnderflowFrame*)obj; - debugBelch("UNDERFLOW_FRAME("); - printPtr((StgPtr)u->next_chunk); - debugBelch(")\n"); - break; - } - - case STOP_FRAME: - { - StgStopFrame* u = (StgStopFrame*)obj; - debugBelch("STOP_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(")\n"); - break; - } - - case ARR_WORDS: - { - StgWord i; - debugBelch("ARR_WORDS(\""); - for (i=0; ipayload[i]); - debugBelch("\")\n"); - break; - } - - case MUT_ARR_PTRS_CLEAN: - debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; - - case MUT_ARR_PTRS_DIRTY: - debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; +const char *lookupGHCName( void *addr ) +{ + if (add_to_fname_table == NULL) + return NULL; - case MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; + return lookupHashTable(add_to_fname_table, (StgWord)addr); +} - case SMALL_MUT_ARR_PTRS_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* -------------------------------------------------------------------------- + * Symbol table loading + * ------------------------------------------------------------------------*/ - case SMALL_MUT_ARR_PTRS_DIRTY: - debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Causing linking trouble on Win32 plats, so I'm + disabling this for now. +*/ +#if defined(USING_LIBBFD) +# define PACKAGE 1 +# define PACKAGE_VERSION 1 +/* Those PACKAGE_* defines are workarounds for bfd: + * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 + * ghc's build system filter PACKAGE_* values out specifically to avoid clashes + * with user's autoconf-based Cabal packages. + * It's a shame checks for unrelated fields instead of actually used + * macros. + */ +# include - case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Fairly ad-hoc piece of code that seems to filter out a lot of + * rubbish like the obj-splitting symbols + */ - case MVAR_CLEAN: - case MVAR_DIRTY: - { - StgMVar* mv = (StgMVar*)obj; +static bool isReal( flagword flags STG_UNUSED, const char *name ) +{ +#if 0 + /* ToDo: make this work on BFD */ + int tp = type & N_TYPE; + if (tp == N_TEXT || tp == N_DATA) { + return (name[0] == '_' && name[1] != '_'); + } else { + return false; + } +#else + if (*name == '\0' || + (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || + (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { + return false; + } + return true; +#endif +} - debugBelch("MVAR(head="); - if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->head); - } +extern void DEBUG_LoadSymbols( const char *name ) +{ + bfd* abfd; + char **matching; - debugBelch(", tail="); - if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->tail); - } + bfd_init(); + abfd = bfd_openr(name, "default"); + if (abfd == NULL) { + barf("can't open executable %s to get symbol table", name); + } + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { + barf("mismatch"); + } - debugBelch(", value="); - if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->value); - } - debugBelch(")\n"); + { + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long num_real_syms = 0; + long i; - break; - } + storage_needed = bfd_get_symtab_upper_bound (abfd); - case TVAR: - { - StgTVar* tv = (StgTVar*)obj; - debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); - break; + if (storage_needed < 0) { + barf("can't read symbol table"); } + symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - case MUT_VAR_CLEAN: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); - break; - } + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - case MUT_VAR_DIRTY: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); - break; + if (number_of_symbols < 0) { + barf("can't canonicalise symbol table"); } - case WEAK: - debugBelch("WEAK("); - debugBelch("key=%p value=%p finalizer=%p", - (StgPtr)(((StgWeak*)obj)->key), - (StgPtr)(((StgWeak*)obj)->value), - (StgPtr)(((StgWeak*)obj)->finalizer)); - debugBelch(")\n"); - /* ToDo: chase 'link' ? */ - break; - - case TSO: - debugBelch("TSO("); - debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); - debugBelch(")\n"); - break; - - case STACK: - debugBelch("STACK\n"); - break; - -#if 0 - /* Symptomatic of a problem elsewhere, have it fall-through & fail */ - case EVACUATED: - debugBelch("EVACUATED("); - printClosure((StgEvacuated*)obj->evacuee); - debugBelch(")\n"); - break; -#endif + if (add_to_fname_table == NULL) + add_to_fname_table = allocHashTable(); - case COMPACT_NFDATA: - debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", - (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); - break; + for( i = 0; i != number_of_symbols; ++i ) { + symbol_info info; + bfd_get_symbol_info(abfd,symbol_table[i],&info); + if (isReal(info.type, info.name)) { + insertHashTable(add_to_fname_table, + info.value, (void*)info.name); + num_real_syms += 1; + } + } - case TREC_CHUNK: - debugBelch("TREC_CHUNK\n"); - break; + IF_DEBUG(interpreter, + debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", + number_of_symbols, num_real_syms) + ); - default: - //barf("printClosure %d",get_itbl(obj)->type); - debugBelch("*** printClosure: unknown type %d ****\n", - (int)get_itbl(obj)->type ); - barf("printClosure %d",get_itbl(obj)->type); - return; + stgFree(symbol_table); } } -void -printMutableList(bdescr *bd) +#else /* USING_LIBBFD */ + +extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { - StgPtr p; + /* nothing, yet */ +} - debugBelch("mutable list %p: ", bd); +#endif /* USING_LIBBFD */ - for (; bd != NULL; bd = bd->link) { - for (p = bd->start; p < bd->free; p++) { - debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); - } - } - debugBelch("\n"); -} +void findPtr(P_ p, int); /* keep gcc -Wall happy */ -// If you know you have an UPDATE_FRAME, but want to know exactly which. -const char *info_update_frame(const StgClosure *closure) +int searched = 0; + +static int +findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) { - // Note: We intentionally don't take the info table pointer as - // an argument. As it will be confusing whether one should pass - // it pointing to the code or struct members when compiling with - // TABLES_NEXT_TO_CODE. + StgPtr q, r, end; + for (; bd; bd = bd->link) { + searched++; + for (q = bd->start; q < bd->free; q++) { + if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { + if (i < arr_size) { + for (r = bd->start; r < bd->free; r = end) { + // skip over zeroed-out slop + while (*r == 0) r++; + if (!LOOKS_LIKE_CLOSURE_PTR(r)) { + debugBelch("%p found at %p, no closure at %p\n", + p, q, r); + break; + } + end = r + closure_sizeW((StgClosure*)r); + if (q < end) { + debugBelch("%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + break; + } + } + if (r >= bd->free) { + debugBelch("%p found at %p, closure?", p, q); + } + } else { + return i; + } + } + } + } + return i; +} + +void +findPtr(P_ p, int follow) +{ + uint32_t g, n; + bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; + searched = 0; + +#if 0 + // We can't search the nursery, because we don't know which blocks contain + // valid data, because the bd->free pointers in the nursery are only reset + // just before a block is used. + for (n = 0; n < n_capabilities; n++) { + bd = nurseries[i].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + } +#endif + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + bd = generations[g].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + bd = generations[g].large_objects; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + for (n = 0; n < n_capabilities; n++) { + i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, + arr, arr_size, i); + i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, + arr, arr_size, i); + } + if (i >= arr_size) return; + } + if (follow && i == 1) { + debugBelch("-->\n"); + findPtr(arr[0], 1); + } +} + +const char *what_next_strs[] = { + [0] = "(unknown)", + [ThreadRunGHC] = "ThreadRunGHC", + [ThreadInterpret] = "ThreadInterpret", + [ThreadKilled] = "ThreadKilled", + [ThreadComplete] = "ThreadComplete" +}; + +#else /* DEBUG */ +void printPtr( StgPtr p ) +{ + debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); +} + +void printObj( StgClosure *obj ) +{ + debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); +} + + +#endif /* DEBUG */ + +// If you know you have an UPDATE_FRAME, but want to know exactly which. +const char *info_update_frame(const StgClosure *closure) +{ + // Note: We intentionally don't take the info table pointer as + // an argument. As it will be confusing whether one should pass + // it pointing to the code or struct members when compiling with + // TABLES_NEXT_TO_CODE. const StgInfoTable *info = closure->header.info; if (info == &stg_upd_frame_info) { return "NORMAL_UPDATE_FRAME"; @@ -467,496 +403,561 @@ const char *info_update_frame(const StgClosure *closure) } static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, - uint32_t size ) +printThunkPayload( StgThunk *obj ) { - uint32_t i; + StgWord i, j; + const StgInfoTable* info; - for(i = 0; i < size; i++, bitmap >>= 1 ) { - debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch("\n"); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } + info = get_itbl((StgClosure *)obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); +} + +STATIC_INLINE void +printStdObjHdr( const StgClosure *obj, char* tag ) +{ + debugBelch("%s(",tag); + printPtr((StgPtr)obj->header.info); +#if defined(PROFILING) + debugBelch(", %s", obj->header.prof.ccs->cc->label); +#endif } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, - uint32_t size ) +printThunkObject( StgThunk *obj, char* tag ) { - StgWord bmp; - uint32_t i, j; + printStdObjHdr( (StgClosure *)obj, tag ); + printThunkPayload( obj ); +} - i = 0; - for (bmp=0; i < size; bmp++) { - StgWord bitmap = large_bitmap->bitmap[bmp]; - j = 0; - for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { - debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch("\n"); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } - } +static void +printStdObjPayload( const StgClosure *obj ) +{ + StgWord i, j; + const StgInfoTable* info; + + info = get_itbl(obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); } void -printStackChunk( StgPtr sp, StgPtr spBottom ) +printClosure( const StgClosure *obj ) { - StgWord bitmap; - const StgInfoTable *info; + debugBelch("%p: ", obj); + obj = UNTAG_CONST_CLOSURE(obj); + const StgInfoTable* info = get_itbl(obj); - ASSERT(sp <= spBottom); - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { + while (IS_FORWARDING_PTR(info)) { + obj = (StgClosure*)UN_FORWARDING_PTR(info); + debugBelch("(forwarding to %p) ", (void*)obj); + info = get_itbl(obj); + } - info = get_itbl((StgClosure *)sp); + switch ( info->type ) { + case INVALID_OBJECT: + barf("Invalid object"); - switch (info->type) { + case CONSTR: + case CONSTR_1_0: case CONSTR_0_1: + case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: + case CONSTR_NOCAF: + { + StgWord i, j; + const StgConInfoTable *con_info = get_con_itbl (obj); - case UPDATE_FRAME: - case CATCH_FRAME: - case UNDERFLOW_FRAME: - case STOP_FRAME: - printClosure((StgClosure*)sp); - continue; + debugBelch("%s(", GET_CON_DESC(con_info)); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + if (i != 0) debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + if (i != 0 || j != 0) debugBelch(", "); + debugBelch("%p#", obj->payload[i+j]); + } + debugBelch(")\n"); + break; + } - case RET_SMALL: { - StgWord c = *sp; - if (c == (StgWord)&stg_ctoi_R1p_info) { - debugBelch("tstg_ctoi_ret_R1p_info\n" ); - } else if (c == (StgWord)&stg_ctoi_R1n_info) { - debugBelch("stg_ctoi_ret_R1n_info\n" ); - } else if (c == (StgWord)&stg_ctoi_F1_info) { - debugBelch("stg_ctoi_ret_F1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_D1_info) { - debugBelch("stg_ctoi_ret_D1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_V_info) { - debugBelch("stg_ctoi_ret_V_info\n" ); - } else if (c == (StgWord)&stg_ap_v_info) { - debugBelch("stg_ap_v_info\n" ); - } else if (c == (StgWord)&stg_ap_f_info) { - debugBelch("stg_ap_f_info\n" ); - } else if (c == (StgWord)&stg_ap_d_info) { - debugBelch("stg_ap_d_info\n" ); - } else if (c == (StgWord)&stg_ap_l_info) { - debugBelch("stg_ap_l_info\n" ); - } else if (c == (StgWord)&stg_ap_n_info) { - debugBelch("stg_ap_n_info\n" ); - } else if (c == (StgWord)&stg_ap_p_info) { - debugBelch("stg_ap_p_info\n" ); - } else if (c == (StgWord)&stg_ap_pp_info) { - debugBelch("stg_ap_pp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppp_info) { - debugBelch("stg_ap_ppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppp_info) { - debugBelch("stg_ap_pppp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppppp_info) { - debugBelch("stg_ap_ppppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppppp_info) { - debugBelch("stg_ap_pppppp_info\n" ); - } else if (c == (StgWord)&stg_ret_v_info) { - debugBelch("stg_ret_v_info\n" ); - } else if (c == (StgWord)&stg_ret_p_info) { - debugBelch("stg_ret_p_info\n" ); - } else if (c == (StgWord)&stg_ret_n_info) { - debugBelch("stg_ret_n_info\n" ); - } else if (c == (StgWord)&stg_ret_f_info) { - debugBelch("stg_ret_f_info\n" ); - } else if (c == (StgWord)&stg_ret_d_info) { - debugBelch("stg_ret_d_info\n" ); - } else if (c == (StgWord)&stg_ret_l_info) { - debugBelch("stg_ret_l_info\n" ); + case FUN: + case FUN_1_0: case FUN_0_1: + case FUN_1_1: case FUN_0_2: case FUN_2_0: + case FUN_STATIC: + debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); + printPtr((StgPtr)obj->header.info); #if defined(PROFILING) - } else if (c == (StgWord)&stg_restore_cccs_info) { - debugBelch("stg_restore_cccs_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; - } else if (c == (StgWord)&stg_restore_cccs_eval_info) { - debugBelch("stg_restore_cccs_eval_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; + debugBelch(", %s", obj->header.prof.ccs->cc->label); #endif - } else { - debugBelch("RET_SMALL (%p)\n", info); - } - bitmap = info->layout.bitmap; - printSmallBitmap(spBottom, sp+1, - BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); - continue; - } + printStdObjPayload(obj); + break; - case RET_BCO: { - StgBCO *bco; + case PRIM: + debugBelch("PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - bco = ((StgBCO *)sp[1]); + case MUT_PRIM: + debugBelch("MUT_PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - debugBelch("RET_BCO (%p)\n", sp); - printLargeBitmap(spBottom, sp+2, - BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); - continue; - } + case THUNK: + case THUNK_1_0: case THUNK_0_1: + case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: + case THUNK_STATIC: + /* ToDo: will this work for THUNK_STATIC too? */ +#if defined(PROFILING) + printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); +#else + printThunkObject((StgThunk *)obj,"THUNK"); +#endif + break; - case RET_BIG: - barf("todo"); + case THUNK_SELECTOR: + printStdObjHdr(obj, "THUNK_SELECTOR"); + debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); + break; - case RET_FUN: + case BCO: + disassemble( (StgBCO*)obj ); + break; + + case AP: { - const StgFunInfoTable *fun_info; - StgRetFun *ret_fun; + StgAP* ap = (StgAP*)obj; + StgWord i; + debugBelch("AP("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->n_args; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; + } - ret_fun = (StgRetFun *)sp; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); - debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); - switch (fun_info->f.fun_type) { - case ARG_GEN: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(fun_info->f.b.bitmap), - BITMAP_SIZE(fun_info->f.b.bitmap)); - break; - case ARG_GEN_BIG: - printLargeBitmap(spBottom, sp+2, - GET_FUN_LARGE_BITMAP(fun_info), - GET_FUN_LARGE_BITMAP(fun_info)->size); - break; - default: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), - BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); - break; + case PAP: + { + StgPAP* pap = (StgPAP*)obj; + StgWord i; + debugBelch("PAP/%d(",(int)pap->arity); + printPtr((StgPtr)pap->fun); + for (i = 0; i < pap->n_args; ++i) { + debugBelch(", "); + printPtr((StgPtr)pap->payload[i]); } - continue; + debugBelch(")\n"); + break; } - default: - debugBelch("unknown object %d\n", (int)info->type); - barf("printStackChunk"); + case AP_STACK: + { + StgAP_STACK* ap = (StgAP_STACK*)obj; + StgWord i; + debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->size; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; } - } -} -// TODO: Do not merge. Only exported for debugging. -void printStack( StgStack *stack ) -{ - printStackChunk( stack->sp, stack->stack + stack->stack_size ); -} + case IND: + debugBelch("IND("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printTSO( StgTSO *tso ) -{ - printStack( tso->stackobj ); -} + case IND_STATIC: + debugBelch("IND_STATIC("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printStaticObjects( StgClosure *p ) -{ - while (p != END_OF_STATIC_OBJECT_LIST) { - p = UNTAG_STATIC_LIST_PTR(p); - printClosure(p); + case BLACKHOLE: + debugBelch("BLACKHOLE("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; - const StgInfoTable *info = get_itbl(p); - p = *STATIC_LINK(info, p); - } -} + /* Cannot happen -- use default case. + case RET_BCO: + case RET_SMALL: + case RET_BIG: + case RET_FUN: + */ -void printWeakLists() -{ - debugBelch("======= WEAK LISTS =======\n"); + case UPDATE_FRAME: + { + StgUpdateFrame* u = (StgUpdateFrame*)obj; + debugBelch("%s(", info_update_frame(obj)); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->updatee); + debugBelch(")\n"); + break; + } - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - debugBelch("Capability %d:\n", cap_idx); - Capability *cap = capabilities[cap_idx]; - for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case CATCH_FRAME: + { + StgCatchFrame* u = (StgCatchFrame*)obj; + debugBelch("CATCH_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->handler); + debugBelch(")\n"); + break; } - } - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current weaks:\n", gen_idx); - for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case UNDERFLOW_FRAME: + { + StgUnderflowFrame* u = (StgUnderflowFrame*)obj; + debugBelch("UNDERFLOW_FRAME("); + printPtr((StgPtr)u->next_chunk); + debugBelch(")\n"); + break; } - debugBelch("Generation %d old weaks:\n", gen_idx); - for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + + case STOP_FRAME: + { + StgStopFrame* u = (StgStopFrame*)obj; + debugBelch("STOP_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(")\n"); + break; } - } - debugBelch("=========================\n"); -} + case ARR_WORDS: + { + StgWord i; + debugBelch("ARR_WORDS(\""); + for (i=0; ipayload[i]); + debugBelch("\")\n"); + break; + } -void printLargeAndPinnedObjects() -{ - debugBelch("====== PINNED OBJECTS ======\n"); + case MUT_ARR_PTRS_CLEAN: + debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - Capability *cap = capabilities[cap_idx]; + case MUT_ARR_PTRS_DIRTY: + debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Capability %d: Current pinned object block: %p\n", - cap_idx, (void*)cap->pinned_object_block); - for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { - debugBelch("%p\n", (void*)bd); - } - } + case MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("====== LARGE OBJECTS =======\n"); - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current large objects:\n", gen_idx); - for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } + case SMALL_MUT_ARR_PTRS_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Generation %d scavenged large objects:\n", gen_idx); - for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } - } + case SMALL_MUT_ARR_PTRS_DIRTY: + debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("============================\n"); -} + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; -/* -------------------------------------------------------------------------- - * Address printing code - * - * Uses symbol table in (unstripped executable) - * ------------------------------------------------------------------------*/ + case MVAR_CLEAN: + case MVAR_DIRTY: + { + StgMVar* mv = (StgMVar*)obj; -/* -------------------------------------------------------------------------- - * Simple lookup table - * address -> function name - * ------------------------------------------------------------------------*/ + debugBelch("MVAR(head="); + if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->head); + } -static HashTable * add_to_fname_table = NULL; + debugBelch(", tail="); + if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->tail); + } -const char *lookupGHCName( void *addr ) -{ - if (add_to_fname_table == NULL) - return NULL; + debugBelch(", value="); + if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->value); + } + debugBelch(")\n"); - return lookupHashTable(add_to_fname_table, (StgWord)addr); -} + break; + } -/* -------------------------------------------------------------------------- - * Symbol table loading - * ------------------------------------------------------------------------*/ + case TVAR: + { + StgTVar* tv = (StgTVar*)obj; + debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); + break; + } -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame checks for unrelated fields instead of actually used - * macros. - */ -# include + case MUT_VAR_CLEAN: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); + break; + } -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ + case MUT_VAR_DIRTY: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); + break; + } -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} + case WEAK: + debugBelch("WEAK("); + debugBelch("key=%p value=%p finalizer=%p", + (StgPtr)(((StgWeak*)obj)->key), + (StgPtr)(((StgWeak*)obj)->value), + (StgPtr)(((StgWeak*)obj)->finalizer)); + debugBelch(")\n"); + /* ToDo: chase 'link' ? */ + break; -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; + case TSO: + debugBelch("TSO("); + debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); + debugBelch(")\n"); + break; - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } + case STACK: + debugBelch("STACK\n"); + break; - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; +#if 0 + /* Symptomatic of a problem elsewhere, have it fall-through & fail */ + case EVACUATED: + debugBelch("EVACUATED("); + printClosure((StgEvacuated*)obj->evacuee); + debugBelch(")\n"); + break; +#endif - storage_needed = bfd_get_symtab_upper_bound (abfd); + case COMPACT_NFDATA: + debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", + (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); + break; - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); + case TREC_CHUNK: + debugBelch("TREC_CHUNK\n"); + break; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + default: + //barf("printClosure %d",get_itbl(obj)->type); + debugBelch("*** printClosure: unknown type %d ****\n", + (int)get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); + return; + } +} - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); +static void +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) +{ + uint32_t i; + + for(i = 0; i < size; i++, bitmap >>= 1 ) { + debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch("\n"); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } + } +} - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); +static void +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) +{ + StgWord bmp; + uint32_t i, j; - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; + i = 0; + for (bmp=0; i < size; bmp++) { + StgWord bitmap = large_bitmap->bitmap[bmp]; + j = 0; + for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { + debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch("\n"); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); } } -#else /* USING_LIBBFD */ - -extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) +void +printStackChunk( StgPtr sp, StgPtr spBottom ) { - /* nothing, yet */ -} + StgWord bitmap; + const StgInfoTable *info; -#endif /* USING_LIBBFD */ + ASSERT(sp <= spBottom); + for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { -void findPtr(P_ p, int); /* keep gcc -Wall happy */ + info = get_itbl((StgClosure *)sp); -int searched = 0; + switch (info->type) { -static int -findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) -{ - StgPtr q, r, end; - for (; bd; bd = bd->link) { - searched++; - for (q = bd->start; q < bd->free; q++) { - if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { - if (i < arr_size) { - for (r = bd->start; r < bd->free; r = end) { - // skip over zeroed-out slop - while (*r == 0) r++; - if (!LOOKS_LIKE_CLOSURE_PTR(r)) { - debugBelch("%p found at %p, no closure at %p\n", - p, q, r); - break; - } - end = r + closure_sizeW((StgClosure*)r); - if (q < end) { - debugBelch("%p = ", r); - printClosure((StgClosure *)r); - arr[i++] = r; - break; - } - } - if (r >= bd->free) { - debugBelch("%p found at %p, closure?", p, q); - } - } else { - return i; - } + case UPDATE_FRAME: + case CATCH_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + printClosure((StgClosure*)sp); + continue; + + case RET_SMALL: { + StgWord c = *sp; + if (c == (StgWord)&stg_ctoi_R1p_info) { + debugBelch("tstg_ctoi_ret_R1p_info\n" ); + } else if (c == (StgWord)&stg_ctoi_R1n_info) { + debugBelch("stg_ctoi_ret_R1n_info\n" ); + } else if (c == (StgWord)&stg_ctoi_F1_info) { + debugBelch("stg_ctoi_ret_F1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_D1_info) { + debugBelch("stg_ctoi_ret_D1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_V_info) { + debugBelch("stg_ctoi_ret_V_info\n" ); + } else if (c == (StgWord)&stg_ap_v_info) { + debugBelch("stg_ap_v_info\n" ); + } else if (c == (StgWord)&stg_ap_f_info) { + debugBelch("stg_ap_f_info\n" ); + } else if (c == (StgWord)&stg_ap_d_info) { + debugBelch("stg_ap_d_info\n" ); + } else if (c == (StgWord)&stg_ap_l_info) { + debugBelch("stg_ap_l_info\n" ); + } else if (c == (StgWord)&stg_ap_n_info) { + debugBelch("stg_ap_n_info\n" ); + } else if (c == (StgWord)&stg_ap_p_info) { + debugBelch("stg_ap_p_info\n" ); + } else if (c == (StgWord)&stg_ap_pp_info) { + debugBelch("stg_ap_pp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppp_info) { + debugBelch("stg_ap_ppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppp_info) { + debugBelch("stg_ap_pppp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppppp_info) { + debugBelch("stg_ap_ppppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppppp_info) { + debugBelch("stg_ap_pppppp_info\n" ); + } else if (c == (StgWord)&stg_ret_v_info) { + debugBelch("stg_ret_v_info\n" ); + } else if (c == (StgWord)&stg_ret_p_info) { + debugBelch("stg_ret_p_info\n" ); + } else if (c == (StgWord)&stg_ret_n_info) { + debugBelch("stg_ret_n_info\n" ); + } else if (c == (StgWord)&stg_ret_f_info) { + debugBelch("stg_ret_f_info\n" ); + } else if (c == (StgWord)&stg_ret_d_info) { + debugBelch("stg_ret_d_info\n" ); + } else if (c == (StgWord)&stg_ret_l_info) { + debugBelch("stg_ret_l_info\n" ); +#if defined(PROFILING) + } else if (c == (StgWord)&stg_restore_cccs_info) { + debugBelch("stg_restore_cccs_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; + } else if (c == (StgWord)&stg_restore_cccs_eval_info) { + debugBelch("stg_restore_cccs_eval_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; +#endif + } else { + debugBelch("RET_SMALL (%p)\n", info); } + bitmap = info->layout.bitmap; + printSmallBitmap(spBottom, sp+1, + BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); + continue; } - } - return i; -} -void -findPtr(P_ p, int follow) -{ - uint32_t g, n; - bdescr *bd; - const int arr_size = 1024; - StgPtr arr[arr_size]; - int i = 0; - searched = 0; + case RET_BCO: { + StgBCO *bco; -#if 0 - // We can't search the nursery, because we don't know which blocks contain - // valid data, because the bd->free pointers in the nursery are only reset - // just before a block is used. - for (n = 0; n < n_capabilities; n++) { - bd = nurseries[i].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - } -#endif + bco = ((StgBCO *)sp[1]); - for (g = 0; g < RtsFlags.GcFlags.generations; g++) { - bd = generations[g].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - bd = generations[g].large_objects; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - for (n = 0; n < n_capabilities; n++) { - i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, - arr, arr_size, i); - i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, - arr, arr_size, i); - } - if (i >= arr_size) return; - } - if (follow && i == 1) { - debugBelch("-->\n"); - findPtr(arr[0], 1); - } -} + debugBelch("RET_BCO (%p)\n", sp); + printLargeBitmap(spBottom, sp+2, + BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); + continue; + } -const char *what_next_strs[] = { - [0] = "(unknown)", - [ThreadRunGHC] = "ThreadRunGHC", - [ThreadInterpret] = "ThreadInterpret", - [ThreadKilled] = "ThreadKilled", - [ThreadComplete] = "ThreadComplete" -}; + case RET_BIG: + barf("todo"); -#else /* DEBUG */ -void printPtr( StgPtr p ) -{ - debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); + case RET_FUN: + { + const StgFunInfoTable *fun_info; + StgRetFun *ret_fun; + + ret_fun = (StgRetFun *)sp; + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); + switch (fun_info->f.fun_type) { + case ARG_GEN: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(fun_info->f.b.bitmap), + BITMAP_SIZE(fun_info->f.b.bitmap)); + break; + case ARG_GEN_BIG: + printLargeBitmap(spBottom, sp+2, + GET_FUN_LARGE_BITMAP(fun_info), + GET_FUN_LARGE_BITMAP(fun_info)->size); + break; + default: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), + BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + break; + } + continue; + } + + default: + debugBelch("unknown object %d\n", (int)info->type); + barf("printStackChunk"); + } + } } -void printObj( StgClosure *obj ) +void printStack( StgStack *stack ) { - debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); + printStackChunk( stack->sp, stack->stack + stack->stack_size ); } -#endif /* DEBUG */ - /* ----------------------------------------------------------------------------- Closure types ===================================== rts/Printer.h ===================================== @@ -20,9 +20,9 @@ const char * info_type ( const StgClosure *closure ); const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); -#if defined(DEBUG) -extern void printStack( StgStack *stack ); extern void printClosure ( const StgClosure *obj ); + +#if defined(DEBUG) extern void printStackChunk ( StgPtr sp, StgPtr spLim ); extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/14599b016f8f71ac1207411f4cdecf5a442624ae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/14599b016f8f71ac1207411f4cdecf5a442624ae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 17:52:20 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 11 Oct 2020 13:52:20 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Rename assertion Message-ID: <5f834654ef9e6_80b3f83cccdb9e8182526c@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 8a0a2957 by Sven Tennie at 2020-10-11T19:52:00+02:00 Rename assertion - - - - - 2 changed files: - testsuite/tests/rts/cloneStackLib.c - testsuite/tests/rts/cloneThreadStack.hs Changes: ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -3,7 +3,7 @@ #include "rts/Messages.h" -void checkClonedStack(StgStack *clonedStack, StgTSO *tso) { +void expectStacksToBeEqual(StgStack *clonedStack, StgTSO *tso) { StgStack *liveStack = tso->stackobj; if(liveStack->header.info != clonedStack->header.info){ ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -8,7 +8,7 @@ import GHC.Stack.CloneStack import Control.Concurrent import GHC.Conc -foreign import ccall "checkClonedStack" checkClonedStack:: StackSnapshot# -> ThreadId# -> IO () +foreign import ccall "expectStacksToBeEqual" expectStacksToBeEqual:: StackSnapshot# -> ThreadId# -> IO () main :: IO () main = do @@ -21,7 +21,7 @@ main = do let (StackSnapshot stack) = stackSnapshot let (ThreadId tid#) = threadId - checkClonedStack stack tid# + expectStacksToBeEqual stack tid# immediatelyBlocking :: MVar Int -> IO () immediatelyBlocking mVarToBeBlockedOn = do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a0a2957fd8d18d89fb37871fe4cee4cae4d32de -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a0a2957fd8d18d89fb37871fe4cee4cae4d32de You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 19:21:13 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Sun, 11 Oct 2020 15:21:13 -0400 Subject: [Git][ghc/ghc][wip/ghc-18740-lookup-update] 2 commits: Remove the dependency on the ghc-linters stage Message-ID: <5f835b2986009_80b3f8469f368bc182604aa@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-18740-lookup-update at Glasgow Haskell Compiler / GHC Commits: 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 20 changed files: - .gitlab-ci.yml - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - + testsuite/tests/th/T18740d.hs - + testsuite/tests/th/T18740d.stderr - testsuite/tests/th/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2247,8 +2247,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] --------------- Expressions ----------------- repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp)) -repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str - | otherwise = repVar str +repVarOrCon vc str + | isVarNameSpace ns = repVar str -- Both type and term variables (#18740) + | otherwise = repCon str + where + ns = nameNameSpace vc repVar :: Core TH.Name -> MetaM (Core (M TH.Exp)) repVar (MkC s) = rep2 varEName [s] ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} {- (c) The GRASP/AQUA Project, Glasgow University, 1992-2006 @@ -1006,6 +1007,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName can be promoted to the type level and its promoted variant is in scope, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1041,6 +1053,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1055,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -755,6 +755,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -772,9 +773,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1144,4 +1167,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/T18740d.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T18740d where + +import Language.Haskell.TH + +-- If we used 'ConE' here, then we would expect this error message: +-- +-- Illegal term-level use of the type constructor ‘Bool’ +-- imported from ‘Prelude’ at T18740d.hs:3:8-14 +-- (and originally defined in ‘GHC.Types’) +-- +-- But we used 'VarE', so the error message should say: +-- +-- Illegal variable name: ‘Bool’ +-- +e1 = $(return (VarE ''Bool)) ===================================== testsuite/tests/th/T18740d.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740d.hs:17:7: error: + • Illegal variable name: ‘Bool’ + When splicing a TH expression: GHC.Types.Bool + • In the untyped splice: $(return (VarE ''Bool)) ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,5 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) +test('T18740d', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9262d499599dcc5c706911da8272515322c53b6...990ea991a1c35fdb894fcb91f919fb8f8fed33dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9262d499599dcc5c706911da8272515322c53b6...990ea991a1c35fdb894fcb91f919fb8f8fed33dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 20:42:53 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Sun, 11 Oct 2020 16:42:53 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Super skolems are really super. Message-ID: <5f836e4dc0514_80b3f8458c2551c18272716@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: cbdfe1b9 by Richard Eisenberg at 2020-10-11T16:42:36-04:00 Super skolems are really super. - - - - - 2 changed files: - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Unify.hs Changes: ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -27,7 +27,6 @@ import GHC.Types.Var.Env import GHC.Data.Pair import GHC.Data.List.SetOps ( getNth ) import GHC.Core.Unify -import GHC.Core.InstEnv import Control.Monad ( zipWithM ) import GHC.Utils.Outputable @@ -1002,7 +1001,7 @@ checkAxInstCo (AxiomInstCo ax ind cos) check_no_conflict _ [] = Nothing check_no_conflict flat (b at CoAxBranch { cab_lhs = lhs_incomp } : rest) -- See Note [Apartness] in GHC.Core.FamInstEnv - | SurelyApart <- tcUnifyTysFG instanceBindFun flat lhs_incomp + | SurelyApart <- tcUnifyTysFG (const BindMe) flat lhs_incomp = check_no_conflict flat rest | otherwise = Just b ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -366,9 +366,29 @@ indexed-types/should_compile/Overlap14. Note [Unification with skolems] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If we discover that two types unify if and only if a skolem variable is -substituted, we can't properly unify the types. But, that skolem variable -may later be instantiated with a unifyable type. So, we return maybeApart -in these cases. +substituted, we can't properly unify the types. Perhaps surprisingly, +we say that these types are SurelyApart. This is to allow an example +like the following: + + class C a b where + meth :: a -> b -> () + + instance C a a where ... + instance C a Int where + meth = meth -- a bit silly, but this is meant to be a small example + +NB: No -XOverlappingInstances or overlapp(ing|able|ed) pragmas. + +The recursive call within the definition of `meth` is actually ambiguous: +if the instance variable `a` becomes Int, then the first instance would +match. But this is silly, because if `a` were Int, then we would never +have ended up in the second instance in the first place. + +We thus say that an unbindable variable is SurelyApart from other +types. This allows us to accept the program above. + +See also Note [Binding when looking up instances] in GHC.Core.InstEnv. + -} -- | Simple unification of two types; all type variables are bindable @@ -1163,12 +1183,12 @@ uUnrefined env tv1' ty2 ty2' kco -- How could this happen? If we're only matching and if -- we're comparing forall-bound variables. - _ -> maybeApart -- See Note [Unification with skolems] + _ -> surelyApart -- See Note [Unification with skolems] }}}} uUnrefined env tv1' ty2 _ kco -- ty2 is not a type variable = case tvBindFlag env tv1' of - Skolem -> maybeApart -- See Note [Unification with skolems] + Skolem -> surelyApart -- See Note [Unification with skolems] BindMe -> bindTv env tv1' (ty2 `mkCastTy` mkSymCo kco) bindTv :: UMEnv -> OutTyVar -> Type -> UM () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cbdfe1b9957e3c1f83feaf10e344e21864c202f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cbdfe1b9957e3c1f83feaf10e344e21864c202f2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 22:59:17 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 11 Oct 2020 18:59:17 -0400 Subject: [Git][ghc/ghc][wip/T18599] add AnnDot annotation to getField calc Message-ID: <5f838e45c29af_80bead686818279580@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 47f0d165 by Shayne Fletcher at 2020-10-11T18:59:07-04:00 add AnnDot annotation to getField calc - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2619,19 +2619,17 @@ fexp :: { ECP } -- See Note [Whitespace-sensitive operator parsing] in Lexer.x | fexp TIGHT_INFIX_PROJ field {% do { ; $1 <- runPV (unECP $1) - -- Suppose lhs is an application term e.g. 'f a' and - -- rhs is '.b'. Usually we want the parse 'f - -- (a.b)' rather than '(f a).b.'. However, if lhs is - -- a projection 'r.a' (say) then we want the parse - -- '(r.a).b'. - ; return . ecpFromExp $ case $1 of - L _ (HsApp _ f arg) - | not $ isGetField f -> - let l = (comb2 arg $3) in - L (getLoc f `combineSrcSpans` l) - (HsApp noExtField f (mkGetField l arg $3)) - _ -> mkGetField (comb2 $1 $>) $1 $3 - }} + -- Suppose lhs is an application term e.g. 'f a' + -- and rhs is '.b'. Usually we want the parse 'f + -- (a.b)' rather than '(f a).b.'. However, if lhs + -- is a projection 'r.a' (say) then we want the + -- parse '(r.a).b'. + ; fmap ecpFromExp $ ams (case $1 of + L _ (HsApp _ f arg) | not $ isGetField f -> + let l = (comb2 arg $3) in + L (getLoc f `combineSrcSpans` l) + (HsApp noExtField f (mkGetField l arg $3)) + _ -> mkGetField (comb2 $1 $>) $1 $3) [mj AnnDot $2] }} | aexp { $1 } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47f0d165ffe4c0df16c10a8fbc5f7e9ba5c8dc19 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/47f0d165ffe4c0df16c10a8fbc5f7e9ba5c8dc19 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 11 23:01:13 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 11 Oct 2020 19:01:13 -0400 Subject: [Git][ghc/ghc][wip/T18599] add AnnDot annotation to getField calc Message-ID: <5f838eb942502_80b3f8468e17090182797ca@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 418578bc by Shayne Fletcher at 2020-10-11T19:01:00-04:00 add AnnDot annotation to getField calc - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2619,19 +2619,17 @@ fexp :: { ECP } -- See Note [Whitespace-sensitive operator parsing] in Lexer.x | fexp TIGHT_INFIX_PROJ field {% do { ; $1 <- runPV (unECP $1) - -- Suppose lhs is an application term e.g. 'f a' and - -- rhs is '.b'. Usually we want the parse 'f - -- (a.b)' rather than '(f a).b.'. However, if lhs is - -- a projection 'r.a' (say) then we want the parse - -- '(r.a).b'. - ; return . ecpFromExp $ case $1 of - L _ (HsApp _ f arg) - | not $ isGetField f -> - let l = (comb2 arg $3) in - L (getLoc f `combineSrcSpans` l) - (HsApp noExtField f (mkGetField l arg $3)) - _ -> mkGetField (comb2 $1 $>) $1 $3 - }} + -- Suppose lhs is an application term e.g. 'f a' + -- and rhs is '.b'. Usually we want the parse 'f + -- (a.b)' rather than '(f a).b.'. However, if lhs + -- is a projection 'r.a' (say) then we want the + -- parse '(r.a).b'. + ; fmap ecpFromExp $ ams (case $1 of + L _ (HsApp _ f arg) | not $ isGetField f -> + let l = comb2 arg $3 in + L (getLoc f `combineSrcSpans` l) + (HsApp noExtField f (mkGetField l arg $3)) + _ -> mkGetField (comb2 $1 $>) $1 $3) [mj AnnDot $2] }} | aexp { $1 } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/418578bc584967ff964d059b1e66a9ca3c4284b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/418578bc584967ff964d059b1e66a9ca3c4284b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 01:47:40 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 11 Oct 2020 21:47:40 -0400 Subject: [Git][ghc/ghc][wip/T18599] add AnnDot annotation to getField calc Message-ID: <5f83b5bcbc30f_80b3f8468f6b75c18281157@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 26b29eba by Shayne Fletcher at 2020-10-11T21:47:27-04:00 add AnnDot annotation to getField calc - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2618,20 +2618,18 @@ fexp :: { ECP } -- See Note [Whitespace-sensitive operator parsing] in Lexer.x | fexp TIGHT_INFIX_PROJ field - {% do { ; $1 <- runPV (unECP $1) - -- Suppose lhs is an application term e.g. 'f a' and - -- rhs is '.b'. Usually we want the parse 'f - -- (a.b)' rather than '(f a).b.'. However, if lhs is - -- a projection 'r.a' (say) then we want the parse - -- '(r.a).b'. - ; return . ecpFromExp $ case $1 of - L _ (HsApp _ f arg) - | not $ isGetField f -> - let l = (comb2 arg $3) in - L (getLoc f `combineSrcSpans` l) - (HsApp noExtField f (mkGetField l arg $3)) - _ -> mkGetField (comb2 $1 $>) $1 $3 - }} + {% runPV (unECP $1) >>= \ $1 -> + -- Suppose lhs is an application term e.g. 'f a' + -- and rhs is '.b'. Usually we want the parse 'f + -- (a.b)' rather than '(f a).b.'. However, if lhs + -- is a projection 'r.a' (say) then we want the + -- parse '(r.a).b'. + fmap ecpFromExp $ ams (case $1 of + L _ (HsApp _ f arg) | not $ isGetField f -> + let l = comb2 arg $3 in + L (getLoc f `combineSrcSpans` l) + (HsApp noExtField f (mkGetField l arg $3)) + _ -> mkGetField (comb2 $1 $>) $1 $3) [mj AnnDot $2] } | aexp { $1 } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26b29ebac6ba3da8caec77f73c0a1d2ec8dbe512 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/26b29ebac6ba3da8caec77f73c0a1d2ec8dbe512 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 08:36:36 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 04:36:36 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 123 commits: Refactor CLabel pretty-printing Message-ID: <5f841594e3212_80b3f846a1604a8182963c6@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 8ed64942 by Sven Tennie at 2020-10-11T20:13:21+02:00 Add cloneMyStack# and cloneThreadStack# primops (#18741) This includes adding a new primtype, StackSnapshot#. cloneThreadStack# is currently only a stub, cloneMyStack# is untested. - - - - - ca59fa89 by Sven Tennie at 2020-10-11T20:13:21+02:00 Add hie.yaml for deriveConstants This enables IDE support for this tool. - - - - - 919153d2 by Sven Tennie at 2020-10-11T20:13:21+02:00 Remove unneccesary primop cloneThreadStack# (#18741) - - - - - 47ae6461 by Sven Tennie at 2020-10-11T20:13:21+02:00 Add cloneThreadStack and cloneMyStack - - - - - 9452542a by Sven Tennie at 2020-10-11T20:13:21+02:00 Fix MVar putting and implement tests - - - - - 0d14c193 by Sven Tennie at 2020-10-11T20:34:14+02:00 Add printStack - - - - - 766dd486 by Sven Tennie at 2020-10-11T20:34:14+02:00 Rename assertion - - - - - b3ca79d3 by Sven Tennie at 2020-10-11T20:34:14+02:00 Delete TODO - - - - - cd42fb20 by Sven Tennie at 2020-10-11T20:34:15+02:00 Undo Printer.h include - - - - - 745f8d2e by Sven Tennie at 2020-10-12T10:28:47+02:00 Fix merge issue - - - - - c9c9e554 by Sven Tennie at 2020-10-12T10:35:28+02:00 Fix C compiler warnings - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PIC.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a0a2957fd8d18d89fb37871fe4cee4cae4d32de...c9c9e5547274f5e80fd886ad8bfb1f44e63866f4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a0a2957fd8d18d89fb37871fe4cee4cae4d32de...c9c9e5547274f5e80fd886ad8bfb1f44e63866f4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 08:55:00 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 12 Oct 2020 04:55:00 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] 74 commits: Make the parser module less dependent on DynFlags Message-ID: <5f8419e440b74_80b3f84583455b41829689a@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - b730e3f2 by Andreas Klebinger at 2020-10-12T04:54:56-04:00 Increase -A default to 4MB. This gives a small increase in performance under most circumstances. For single threaded GC the improvement is on the order of 1-2%. For multi threaded GC the results are quite noisy but seem to fall into the same ballpark. Fixes #16499 - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30714844f51fa26937057d639be3c392bdfc7c7b...b730e3f2da56597192c569b8b57e3589f30fb726 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30714844f51fa26937057d639be3c392bdfc7c7b...b730e3f2da56597192c569b8b57e3589f30fb726 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 09:13:56 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 05:13:56 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 2 commits: Free MVar pointer Message-ID: <5f841e5416372_80b3f849252e7ec183046dc@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 98014fc8 by Sven Tennie at 2020-10-12T10:52:08+02:00 Free MVar pointer - - - - - d762fb34 by Sven Tennie at 2020-10-12T11:13:36+02:00 Remove unnecessary constant deriving - - - - - 2 changed files: - rts/CloneStack.c - utils/deriveConstants/Main.hs Changes: ===================================== rts/CloneStack.c ===================================== @@ -16,7 +16,7 @@ void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); msg->tso = tso; msg->result = (StgMVar*)deRefStablePtr(mvar); - // TODO: Free? See RtsAPI.c: hs_try_putmvar() + freeStablePtr(mvar); SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); // Ensure that writes constructing Message are committed before sending. write_barrier(); ===================================== utils/deriveConstants/Main.hs ===================================== @@ -442,7 +442,6 @@ wanteds os = concat ,closureField_ Both "StgTSO_cccs" "StgTSO" "prof.cccs" ,closureField Both "StgTSO" "stackobj" - ,closureSize C "StgStack" ,closureField Both "StgStack" "sp" ,closureFieldOffset Both "StgStack" "stack" ,closureField C "StgStack" "stack_size" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9c9e5547274f5e80fd886ad8bfb1f44e63866f4...d762fb34a025010ec01f1ab2341594dd3b68a6ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c9c9e5547274f5e80fd886ad8bfb1f44e63866f4...d762fb34a025010ec01f1ab2341594dd3b68a6ab You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 09:31:41 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 05:31:41 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Add cloneThreadStack and cloneMyStack (#18741) Message-ID: <5f84227d3e6c5_80bb65311818309391@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: c24a9197 by Sven Tennie at 2020-10-12T11:30:13+02:00 Add cloneThreadStack and cloneMyStack (#18741) These functions clone the stack of either another thread (cloneThreadStack) or the currently active one (cloneMyStack). A cloned stack is offline/cold, i.e. it isn't evaluated any further. For technical details, please see note [Stack Cloning]. - - - - - 23 changed files: - compiler/GHC/Builtin/Types/Prim.hs - + includes/rts/PrinterAPI.h - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Disassembler.c - rts/Disassembler.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/StgMiscClosures.cmm - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneMyStack.hs - + testsuite/tests/rts/cloneStackLib.c - + testsuite/tests/rts/cloneThreadStack.hs - utils/deriveConstants/Main.hs Changes: ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -1097,8 +1097,6 @@ compactPrimTy = mkTyConTy compactPrimTyCon ************************************************************************ -} --- TODO: choose the right PrimRep - This is relevant for garbage collection behaviour --- https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/prim-ops#adding-a-new-primop stackSnapshotPrimTyCon :: TyCon stackSnapshotPrimTyCon = pcPrimTyCon0 stackSnapshotPrimTyConName UnliftedRep ===================================== includes/rts/PrinterAPI.h ===================================== @@ -0,0 +1,3 @@ +#pragma once + +extern void printStack (StgStack* stack); ===================================== includes/rts/storage/Closures.h ===================================== @@ -431,6 +431,14 @@ typedef struct MessageBlackHole_ { StgClosure *bh; } MessageBlackHole; +typedef struct MessageCloneStack_ { + StgHeader header; + Message *link; + StgMVar *result; + StgTSO *tso; +} MessageCloneStack; + + /* ---------------------------------------------------------------------------- Compact Regions ------------------------------------------------------------------------- */ ===================================== includes/stg/MiscClosures.h ===================================== @@ -129,6 +129,7 @@ RTS_ENTRY(stg_STM_AWOKEN); RTS_ENTRY(stg_MSG_TRY_WAKEUP); RTS_ENTRY(stg_MSG_THROWTO); RTS_ENTRY(stg_MSG_BLACKHOLE); +RTS_ENTRY(stg_MSG_CLONE_STACK); RTS_ENTRY(stg_MSG_NULL); RTS_ENTRY(stg_MVAR_TSO_QUEUE); RTS_ENTRY(stg_catch); ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -624,7 +624,7 @@ data PrimMVar -- @hs_try_putmvar()@. The RTS wants a 'StablePtr' to the underlying -- 'MVar#', but a 'StablePtr#' can only refer to lifted types, so we -- have to cheat by coercing. -newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar) +newStablePtrPrimMVar :: MVar a -> IO (StablePtr PrimMVar) newStablePtrPrimMVar (MVar m) = IO $ \s0 -> case makeStablePtr# (unsafeCoerce# m :: PrimMVar) s0 of -- Coerce unlifted m :: MVar# RealWorld () ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes#-} + + +module GHC.Stack.CloneStack ( + cloneThreadStack, + cloneMyStack, + printStack, + StackSnapshot(..) + ) where + +import GHC.Prim (StackSnapshot#, cloneMyStack#, ThreadId#) +import Control.Concurrent.MVar +import GHC.Conc.Sync +import GHC.Stable +import GHC.IO (IO(..)) + +foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () + +foreign import ccall "PrinterAPI.h printStack" printStack_c :: StackSnapshot# -> IO () + +data StackSnapshot = StackSnapshot StackSnapshot# + +{- Note [Stack Cloning] +"Cloning" a stack means that it's StgStack closure is copied including the +stack memory (stack[]). The stack pointer (sp) of the clone is adjusted to be +valid. +The clone is "offline"/"cold", i.e. it won't be evaluated any further. This is +useful for further analyses like stack unwinding or traversal. + +There are two different ways to clone a stack: +1. By the corresponding thread via a primop call (cloneMyStack#). +2. By sending a RTS message (Messages.c) with a MVar to the corresponding + thread and receiving the stack by taking it out of this MVar. +-} + +-- | Clone the stack of a thread identified by it's 'ThreadId' +cloneThreadStack :: ThreadId -> IO StackSnapshot +cloneThreadStack (ThreadId tid#) = do + resultVar <- newEmptyMVar @StackSnapshot + ptr <- newStablePtrPrimMVar resultVar + -- Use the RTS's "message" mechanism to request that + -- the thread captures its stack, saving the result + -- into resultVar. + sendCloneStackMessage tid# ptr + freeStablePtr ptr + takeMVar resultVar + +-- | Clone the stack of the executing thread +cloneMyStack :: IO StackSnapshot +cloneMyStack = IO $ \s -> + case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) + +-- | Print the stack +printStack :: StackSnapshot -> IO () +printStack (StackSnapshot stack) = printStack_c stack ===================================== libraries/base/base.cabal ===================================== @@ -264,6 +264,7 @@ Library GHC.ResponseFile GHC.RTS.Flags GHC.ST + GHC.Stack.CloneStack GHC.StaticPtr GHC.STRef GHC.Show ===================================== rts/CloneStack.c ===================================== @@ -0,0 +1,66 @@ +#include + +#include "Rts.h" +#include "rts/Messages.h" +#include "rts/storage/TSO.h" +#include "stg/Types.h" +#include "CloneStack.h" + +#if defined(THREADED_RTS) + +// ThreadId# in Haskell is a StgTSO* in RTS. +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + Capability *srcCapability = rts_unsafeGetMyCapability(); + + MessageCloneStack *msg; + msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); + msg->tso = tso; + msg->result = (StgMVar*)deRefStablePtr(mvar); + freeStablePtr(mvar); + SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); + // Ensure that writes constructing Message are committed before sending. + write_barrier(); + + sendMessage(srcCapability, tso->cap, (Message *)msg); +} + +void handleCloneStackMessage(MessageCloneStack *msg){ + StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); + + // Lift StackSnapshot# to StackSnapshot by applying it's constructor. + // This is necessary because performTryPutMVar() puts the closure onto the + // stack for evaluation and stacks can not be evaluated (entered). + HaskellObj result = rts_apply(msg->tso->cap, StackSnapshot_constructor_closure, (HaskellObj) newStackClosure); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, result); + + if(!putMVarWasSuccessful) { + barf("Can't put stack cloning result into MVar."); + } +} + +#else // !defined(THREADED_RTS) + +GNU_ATTRIBUTE(__noreturn__) +void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) { + barf("Sending CloneStackMessages is only available in threaded RTS!"); +} + +#endif // end !defined(THREADED_RTS) + +StgStack* cloneStack(Capability* capability, StgStack* stack){ + StgWord spOffset = stack->sp - stack->stack; + StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); + + StgStack* newStackClosure = (StgStack*) allocate(capability, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + + memcpy(newStackClosure, stack, closureSizeBytes); + + newStackClosure->sp = newStackClosure->stack + spOffset; + +#if defined(DEBUG) + checkClosure(newStackClosure); +#endif + + return newStackClosure; +} ===================================== rts/CloneStack.h ===================================== @@ -0,0 +1,12 @@ +#pragma once + +#if defined(THREADED_RTS) +void handleCloneStackMessage(MessageCloneStack *msg); +#endif + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); + +StgStack* cloneStack(Capability* capability, StgStack* stack); + +extern StgClosure DLL_IMPORT_DATA_VARNAME(base_GHCziStackziCloneStack_StackSnapshot_closure); +#define StackSnapshot_constructor_closure DLL_IMPORT_DATA_REF(base_GHCziStackziCloneStack_StackSnapshot_closure) ===================================== rts/Disassembler.c ===================================== @@ -8,8 +8,6 @@ * $Date: 2004/09/03 15:28:19 $ * ---------------------------------------------------------------------------*/ -#if defined(DEBUG) - #include "PosixSource.h" #include "Rts.h" #include "RtsAPI.h" @@ -358,5 +356,3 @@ void disassemble( StgBCO *bco ) debugBelch("\n"); } - -#endif /* DEBUG */ ===================================== rts/Disassembler.h ===================================== @@ -8,9 +8,5 @@ #pragma once -#if defined(DEBUG) - RTS_PRIVATE int disInstr ( StgBCO *bco, int pc ); RTS_PRIVATE void disassemble( StgBCO *bco ); - -#endif ===================================== rts/Messages.c ===================================== @@ -14,6 +14,7 @@ #include "Threads.h" #include "RaiseAsync.h" #include "sm/Storage.h" +#include "CloneStack.h" /* ---------------------------------------------------------------------------- Send a message to another Capability @@ -32,7 +33,8 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg) i != &stg_MSG_BLACKHOLE_info && i != &stg_MSG_TRY_WAKEUP_info && i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked - i != &stg_WHITEHOLE_info) { + i != &stg_WHITEHOLE_info && + i != &stg_MSG_CLONE_STACK_info) { barf("sendMessage: %p", i); } } @@ -131,6 +133,10 @@ loop: #endif goto loop; } + else if(i == &stg_MSG_CLONE_STACK_info){ + MessageCloneStack *cloneStackMessage = (MessageCloneStack*) m; + handleCloneStackMessage(cloneStackMessage); + } else { barf("executeMessage: %p", i); ===================================== rts/PrimOps.cmm ===================================== @@ -2843,19 +2843,11 @@ stg_setThreadAllocationCounterzh ( I64 counter ) stg_cloneMyStackzh () { W_ stgStack; - gcptr p; - W_ neededMemorySize; + W_ clonedStack; stgStack = StgTSO_stackobj(CurrentTSO); - neededMemorySize = BYTES_TO_WDS(SIZEOF_StgStack) + StgStack_stack_size(stgStack); + ("ptr" clonedStack) = ccall cloneStack(MyCapability() "ptr", stgStack "ptr"); - ("ptr" p) = ccall allocateMightFail(MyCapability() "ptr", neededMemorySize); - if (p == NULL) { - jump stg_raisezh(base_GHCziIOziException_heapOverflow_closure); - } - - prim %memcpy(p, stgStack, WDS(neededMemorySize), SIZEOF_W); - - return (p); + return (clonedStack); } ===================================== rts/Printer.c ===================================== @@ -25,9 +25,10 @@ #include +#include "Disassembler.h" + #if defined(DEBUG) -#include "Disassembler.h" #include "Apply.h" /* -------------------------------------------------------------------------- @@ -58,402 +59,337 @@ void printObj( StgClosure *obj ) printClosure(obj); } -STATIC_INLINE void -printStdObjHdr( const StgClosure *obj, char* tag ) +void +printMutableList(bdescr *bd) { - debugBelch("%s(",tag); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif -} + StgPtr p; -static void -printStdObjPayload( const StgClosure *obj ) -{ - StgWord i, j; - const StgInfoTable* info; + debugBelch("mutable list %p: ", bd); - info = get_itbl(obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); + for (; bd != NULL; bd = bd->link) { + for (p = bd->start; p < bd->free; p++) { + debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); + } } - debugBelch(")\n"); + debugBelch("\n"); } -static void -printThunkPayload( StgThunk *obj ) +void printTSO( StgTSO *tso ) { - StgWord i, j; - const StgInfoTable* info; - - info = get_itbl((StgClosure *)obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); - } - debugBelch(")\n"); + printStack( tso->stackobj ); } -static void -printThunkObject( StgThunk *obj, char* tag ) +void printStaticObjects( StgClosure *p ) { - printStdObjHdr( (StgClosure *)obj, tag ); - printThunkPayload( obj ); + while (p != END_OF_STATIC_OBJECT_LIST) { + p = UNTAG_STATIC_LIST_PTR(p); + printClosure(p); + + const StgInfoTable *info = get_itbl(p); + p = *STATIC_LINK(info, p); + } } -void -printClosure( const StgClosure *obj ) +void printWeakLists() { - debugBelch("%p: ", obj); - obj = UNTAG_CONST_CLOSURE(obj); - const StgInfoTable* info = get_itbl(obj); + debugBelch("======= WEAK LISTS =======\n"); - while (IS_FORWARDING_PTR(info)) { - obj = (StgClosure*)UN_FORWARDING_PTR(info); - debugBelch("(forwarding to %p) ", (void*)obj); - info = get_itbl(obj); + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + debugBelch("Capability %d:\n", cap_idx); + Capability *cap = capabilities[cap_idx]; + for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } } - switch ( info->type ) { - case INVALID_OBJECT: - barf("Invalid object"); - - case CONSTR: - case CONSTR_1_0: case CONSTR_0_1: - case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: - case CONSTR_NOCAF: - { - StgWord i, j; - const StgConInfoTable *con_info = get_con_itbl (obj); - - debugBelch("%s(", GET_CON_DESC(con_info)); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - if (i != 0) debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - if (i != 0 || j != 0) debugBelch(", "); - debugBelch("%p#", obj->payload[i+j]); - } - debugBelch(")\n"); - break; + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current weaks:\n", gen_idx); + for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); } + debugBelch("Generation %d old weaks:\n", gen_idx); + for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } + } - case FUN: - case FUN_1_0: case FUN_0_1: - case FUN_1_1: case FUN_0_2: case FUN_2_0: - case FUN_STATIC: - debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif - printStdObjPayload(obj); - break; - - case PRIM: - debugBelch("PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case MUT_PRIM: - debugBelch("MUT_PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case THUNK: - case THUNK_1_0: case THUNK_0_1: - case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: - case THUNK_STATIC: - /* ToDo: will this work for THUNK_STATIC too? */ -#if defined(PROFILING) - printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); -#else - printThunkObject((StgThunk *)obj,"THUNK"); -#endif - break; + debugBelch("=========================\n"); +} - case THUNK_SELECTOR: - printStdObjHdr(obj, "THUNK_SELECTOR"); - debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); - break; +void printLargeAndPinnedObjects() +{ + debugBelch("====== PINNED OBJECTS ======\n"); - case BCO: - disassemble( (StgBCO*)obj ); - break; + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + Capability *cap = capabilities[cap_idx]; - case AP: - { - StgAP* ap = (StgAP*)obj; - StgWord i; - debugBelch("AP("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->n_args; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Capability %d: Current pinned object block: %p\n", + cap_idx, (void*)cap->pinned_object_block); + for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { + debugBelch("%p\n", (void*)bd); } + } - case PAP: - { - StgPAP* pap = (StgPAP*)obj; - StgWord i; - debugBelch("PAP/%d(",(int)pap->arity); - printPtr((StgPtr)pap->fun); - for (i = 0; i < pap->n_args; ++i) { - debugBelch(", "); - printPtr((StgPtr)pap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("====== LARGE OBJECTS =======\n"); + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current large objects:\n", gen_idx); + for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } - case AP_STACK: - { - StgAP_STACK* ap = (StgAP_STACK*)obj; - StgWord i; - debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->size; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Generation %d scavenged large objects:\n", gen_idx); + for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } + } - case IND: - debugBelch("IND("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; - - case IND_STATIC: - debugBelch("IND_STATIC("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; + debugBelch("============================\n"); +} - case BLACKHOLE: - debugBelch("BLACKHOLE("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; +/* -------------------------------------------------------------------------- + * Address printing code + * + * Uses symbol table in (unstripped executable) + * ------------------------------------------------------------------------*/ - /* Cannot happen -- use default case. - case RET_BCO: - case RET_SMALL: - case RET_BIG: - case RET_FUN: - */ +/* -------------------------------------------------------------------------- + * Simple lookup table + * address -> function name + * ------------------------------------------------------------------------*/ - case UPDATE_FRAME: - { - StgUpdateFrame* u = (StgUpdateFrame*)obj; - debugBelch("%s(", info_update_frame(obj)); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->updatee); - debugBelch(")\n"); - break; - } +static HashTable * add_to_fname_table = NULL; - case CATCH_FRAME: - { - StgCatchFrame* u = (StgCatchFrame*)obj; - debugBelch("CATCH_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->handler); - debugBelch(")\n"); - break; - } - - case UNDERFLOW_FRAME: - { - StgUnderflowFrame* u = (StgUnderflowFrame*)obj; - debugBelch("UNDERFLOW_FRAME("); - printPtr((StgPtr)u->next_chunk); - debugBelch(")\n"); - break; - } - - case STOP_FRAME: - { - StgStopFrame* u = (StgStopFrame*)obj; - debugBelch("STOP_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(")\n"); - break; - } - - case ARR_WORDS: - { - StgWord i; - debugBelch("ARR_WORDS(\""); - for (i=0; ipayload[i]); - debugBelch("\")\n"); - break; - } - - case MUT_ARR_PTRS_CLEAN: - debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; - - case MUT_ARR_PTRS_DIRTY: - debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; +const char *lookupGHCName( void *addr ) +{ + if (add_to_fname_table == NULL) + return NULL; - case MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; + return lookupHashTable(add_to_fname_table, (StgWord)addr); +} - case SMALL_MUT_ARR_PTRS_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* -------------------------------------------------------------------------- + * Symbol table loading + * ------------------------------------------------------------------------*/ - case SMALL_MUT_ARR_PTRS_DIRTY: - debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Causing linking trouble on Win32 plats, so I'm + disabling this for now. +*/ +#if defined(USING_LIBBFD) +# define PACKAGE 1 +# define PACKAGE_VERSION 1 +/* Those PACKAGE_* defines are workarounds for bfd: + * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 + * ghc's build system filter PACKAGE_* values out specifically to avoid clashes + * with user's autoconf-based Cabal packages. + * It's a shame checks for unrelated fields instead of actually used + * macros. + */ +# include - case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Fairly ad-hoc piece of code that seems to filter out a lot of + * rubbish like the obj-splitting symbols + */ - case MVAR_CLEAN: - case MVAR_DIRTY: - { - StgMVar* mv = (StgMVar*)obj; +static bool isReal( flagword flags STG_UNUSED, const char *name ) +{ +#if 0 + /* ToDo: make this work on BFD */ + int tp = type & N_TYPE; + if (tp == N_TEXT || tp == N_DATA) { + return (name[0] == '_' && name[1] != '_'); + } else { + return false; + } +#else + if (*name == '\0' || + (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || + (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { + return false; + } + return true; +#endif +} - debugBelch("MVAR(head="); - if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->head); - } +extern void DEBUG_LoadSymbols( const char *name ) +{ + bfd* abfd; + char **matching; - debugBelch(", tail="); - if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->tail); - } + bfd_init(); + abfd = bfd_openr(name, "default"); + if (abfd == NULL) { + barf("can't open executable %s to get symbol table", name); + } + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { + barf("mismatch"); + } - debugBelch(", value="); - if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->value); - } - debugBelch(")\n"); + { + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long num_real_syms = 0; + long i; - break; - } + storage_needed = bfd_get_symtab_upper_bound (abfd); - case TVAR: - { - StgTVar* tv = (StgTVar*)obj; - debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); - break; + if (storage_needed < 0) { + barf("can't read symbol table"); } + symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - case MUT_VAR_CLEAN: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); - break; - } + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - case MUT_VAR_DIRTY: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); - break; + if (number_of_symbols < 0) { + barf("can't canonicalise symbol table"); } - case WEAK: - debugBelch("WEAK("); - debugBelch("key=%p value=%p finalizer=%p", - (StgPtr)(((StgWeak*)obj)->key), - (StgPtr)(((StgWeak*)obj)->value), - (StgPtr)(((StgWeak*)obj)->finalizer)); - debugBelch(")\n"); - /* ToDo: chase 'link' ? */ - break; - - case TSO: - debugBelch("TSO("); - debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); - debugBelch(")\n"); - break; - - case STACK: - debugBelch("STACK\n"); - break; - -#if 0 - /* Symptomatic of a problem elsewhere, have it fall-through & fail */ - case EVACUATED: - debugBelch("EVACUATED("); - printClosure((StgEvacuated*)obj->evacuee); - debugBelch(")\n"); - break; -#endif + if (add_to_fname_table == NULL) + add_to_fname_table = allocHashTable(); - case COMPACT_NFDATA: - debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", - (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); - break; + for( i = 0; i != number_of_symbols; ++i ) { + symbol_info info; + bfd_get_symbol_info(abfd,symbol_table[i],&info); + if (isReal(info.type, info.name)) { + insertHashTable(add_to_fname_table, + info.value, (void*)info.name); + num_real_syms += 1; + } + } - case TREC_CHUNK: - debugBelch("TREC_CHUNK\n"); - break; + IF_DEBUG(interpreter, + debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", + number_of_symbols, num_real_syms) + ); - default: - //barf("printClosure %d",get_itbl(obj)->type); - debugBelch("*** printClosure: unknown type %d ****\n", - (int)get_itbl(obj)->type ); - barf("printClosure %d",get_itbl(obj)->type); - return; + stgFree(symbol_table); } } -void -printMutableList(bdescr *bd) +#else /* USING_LIBBFD */ + +extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { - StgPtr p; + /* nothing, yet */ +} - debugBelch("mutable list %p: ", bd); +#endif /* USING_LIBBFD */ - for (; bd != NULL; bd = bd->link) { - for (p = bd->start; p < bd->free; p++) { - debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); - } - } - debugBelch("\n"); -} +void findPtr(P_ p, int); /* keep gcc -Wall happy */ -// If you know you have an UPDATE_FRAME, but want to know exactly which. -const char *info_update_frame(const StgClosure *closure) +int searched = 0; + +static int +findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) { - // Note: We intentionally don't take the info table pointer as - // an argument. As it will be confusing whether one should pass - // it pointing to the code or struct members when compiling with - // TABLES_NEXT_TO_CODE. + StgPtr q, r, end; + for (; bd; bd = bd->link) { + searched++; + for (q = bd->start; q < bd->free; q++) { + if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { + if (i < arr_size) { + for (r = bd->start; r < bd->free; r = end) { + // skip over zeroed-out slop + while (*r == 0) r++; + if (!LOOKS_LIKE_CLOSURE_PTR(r)) { + debugBelch("%p found at %p, no closure at %p\n", + p, q, r); + break; + } + end = r + closure_sizeW((StgClosure*)r); + if (q < end) { + debugBelch("%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + break; + } + } + if (r >= bd->free) { + debugBelch("%p found at %p, closure?", p, q); + } + } else { + return i; + } + } + } + } + return i; +} + +void +findPtr(P_ p, int follow) +{ + uint32_t g, n; + bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; + searched = 0; + +#if 0 + // We can't search the nursery, because we don't know which blocks contain + // valid data, because the bd->free pointers in the nursery are only reset + // just before a block is used. + for (n = 0; n < n_capabilities; n++) { + bd = nurseries[i].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + } +#endif + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + bd = generations[g].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + bd = generations[g].large_objects; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + for (n = 0; n < n_capabilities; n++) { + i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, + arr, arr_size, i); + i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, + arr, arr_size, i); + } + if (i >= arr_size) return; + } + if (follow && i == 1) { + debugBelch("-->\n"); + findPtr(arr[0], 1); + } +} + +const char *what_next_strs[] = { + [0] = "(unknown)", + [ThreadRunGHC] = "ThreadRunGHC", + [ThreadInterpret] = "ThreadInterpret", + [ThreadKilled] = "ThreadKilled", + [ThreadComplete] = "ThreadComplete" +}; + +#else /* DEBUG */ +void printPtr( StgPtr p ) +{ + debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); +} + +void printObj( StgClosure *obj ) +{ + debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); +} + + +#endif /* DEBUG */ + +// If you know you have an UPDATE_FRAME, but want to know exactly which. +const char *info_update_frame(const StgClosure *closure) +{ + // Note: We intentionally don't take the info table pointer as + // an argument. As it will be confusing whether one should pass + // it pointing to the code or struct members when compiling with + // TABLES_NEXT_TO_CODE. const StgInfoTable *info = closure->header.info; if (info == &stg_upd_frame_info) { return "NORMAL_UPDATE_FRAME"; @@ -467,501 +403,567 @@ const char *info_update_frame(const StgClosure *closure) } static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, - uint32_t size ) +printThunkPayload( StgThunk *obj ) { - uint32_t i; + StgWord i, j; + const StgInfoTable* info; - for(i = 0; i < size; i++, bitmap >>= 1 ) { - debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } + info = get_itbl((StgClosure *)obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); +} + +STATIC_INLINE void +printStdObjHdr( const StgClosure *obj, char* tag ) +{ + debugBelch("%s(",tag); + printPtr((StgPtr)obj->header.info); +#if defined(PROFILING) + debugBelch(", %s", obj->header.prof.ccs->cc->label); +#endif } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, - uint32_t size ) +printThunkObject( StgThunk *obj, char* tag ) { - StgWord bmp; - uint32_t i, j; + printStdObjHdr( (StgClosure *)obj, tag ); + printThunkPayload( obj ); +} - i = 0; - for (bmp=0; i < size; bmp++) { - StgWord bitmap = large_bitmap->bitmap[bmp]; - j = 0; - for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { - debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } - } +static void +printStdObjPayload( const StgClosure *obj ) +{ + StgWord i, j; + const StgInfoTable* info; + + info = get_itbl(obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); } void -printStackChunk( StgPtr sp, StgPtr spBottom ) +printClosure( const StgClosure *obj ) { - const StgInfoTable *info; + debugBelch("%p: ", obj); + obj = UNTAG_CONST_CLOSURE(obj); + const StgInfoTable* info = get_itbl(obj); - ASSERT(sp <= spBottom); - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { + while (IS_FORWARDING_PTR(info)) { + obj = (StgClosure*)UN_FORWARDING_PTR(info); + debugBelch("(forwarding to %p) ", (void*)obj); + info = get_itbl(obj); + } - info = get_itbl((StgClosure *)sp); + switch ( info->type ) { + case INVALID_OBJECT: + barf("Invalid object"); - switch (info->type) { + case CONSTR: + case CONSTR_1_0: case CONSTR_0_1: + case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: + case CONSTR_NOCAF: + { + StgWord i, j; + const StgConInfoTable *con_info = get_con_itbl (obj); - case UPDATE_FRAME: - case CATCH_FRAME: - case UNDERFLOW_FRAME: - case STOP_FRAME: - printClosure((StgClosure*)sp); - continue; + debugBelch("%s(", GET_CON_DESC(con_info)); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + if (i != 0) debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + if (i != 0 || j != 0) debugBelch(", "); + debugBelch("%p#", obj->payload[i+j]); + } + debugBelch(")\n"); + break; + } - case RET_SMALL: { - StgWord c = *sp; - if (c == (StgWord)&stg_ctoi_R1p_info) { - debugBelch("tstg_ctoi_ret_R1p_info\n" ); - } else if (c == (StgWord)&stg_ctoi_R1n_info) { - debugBelch("stg_ctoi_ret_R1n_info\n" ); - } else if (c == (StgWord)&stg_ctoi_F1_info) { - debugBelch("stg_ctoi_ret_F1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_D1_info) { - debugBelch("stg_ctoi_ret_D1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_V_info) { - debugBelch("stg_ctoi_ret_V_info\n" ); - } else if (c == (StgWord)&stg_ap_v_info) { - debugBelch("stg_ap_v_info\n" ); - } else if (c == (StgWord)&stg_ap_f_info) { - debugBelch("stg_ap_f_info\n" ); - } else if (c == (StgWord)&stg_ap_d_info) { - debugBelch("stg_ap_d_info\n" ); - } else if (c == (StgWord)&stg_ap_l_info) { - debugBelch("stg_ap_l_info\n" ); - } else if (c == (StgWord)&stg_ap_n_info) { - debugBelch("stg_ap_n_info\n" ); - } else if (c == (StgWord)&stg_ap_p_info) { - debugBelch("stg_ap_p_info\n" ); - } else if (c == (StgWord)&stg_ap_pp_info) { - debugBelch("stg_ap_pp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppp_info) { - debugBelch("stg_ap_ppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppp_info) { - debugBelch("stg_ap_pppp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppppp_info) { - debugBelch("stg_ap_ppppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppppp_info) { - debugBelch("stg_ap_pppppp_info\n" ); - } else if (c == (StgWord)&stg_ret_v_info) { - debugBelch("stg_ret_v_info\n" ); - } else if (c == (StgWord)&stg_ret_p_info) { - debugBelch("stg_ret_p_info\n" ); - } else if (c == (StgWord)&stg_ret_n_info) { - debugBelch("stg_ret_n_info\n" ); - } else if (c == (StgWord)&stg_ret_f_info) { - debugBelch("stg_ret_f_info\n" ); - } else if (c == (StgWord)&stg_ret_d_info) { - debugBelch("stg_ret_d_info\n" ); - } else if (c == (StgWord)&stg_ret_l_info) { - debugBelch("stg_ret_l_info\n" ); + case FUN: + case FUN_1_0: case FUN_0_1: + case FUN_1_1: case FUN_0_2: case FUN_2_0: + case FUN_STATIC: + debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); + printPtr((StgPtr)obj->header.info); #if defined(PROFILING) - } else if (c == (StgWord)&stg_restore_cccs_info) { - debugBelch("stg_restore_cccs_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; - } else if (c == (StgWord)&stg_restore_cccs_eval_info) { - debugBelch("stg_restore_cccs_eval_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; + debugBelch(", %s", obj->header.prof.ccs->cc->label); #endif - } else { - debugBelch("RET_SMALL (%p)\n", info); - } - StgWord bitmap = info->layout.bitmap; - printSmallBitmap(spBottom, sp+1, - BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); - continue; - } + printStdObjPayload(obj); + break; - case RET_BCO: { - StgBCO *bco; + case PRIM: + debugBelch("PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - bco = ((StgBCO *)sp[1]); + case MUT_PRIM: + debugBelch("MUT_PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - debugBelch("RET_BCO (%p)\n", sp); - printLargeBitmap(spBottom, sp+2, - BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); - continue; - } + case THUNK: + case THUNK_1_0: case THUNK_0_1: + case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: + case THUNK_STATIC: + /* ToDo: will this work for THUNK_STATIC too? */ +#if defined(PROFILING) + printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); +#else + printThunkObject((StgThunk *)obj,"THUNK"); +#endif + break; - case RET_BIG: - debugBelch("RET_BIG (%p)\n", sp); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); - printLargeBitmap(spBottom, - (StgPtr)((StgClosure *) sp)->payload, - bitmap, - bitmap->size); - continue; - case RET_FUN: + case THUNK_SELECTOR: + printStdObjHdr(obj, "THUNK_SELECTOR"); + debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); + break; + + case BCO: + disassemble( (StgBCO*)obj ); + break; + + case AP: { - const StgFunInfoTable *fun_info; - StgRetFun *ret_fun; + StgAP* ap = (StgAP*)obj; + StgWord i; + debugBelch("AP("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->n_args; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; + } - ret_fun = (StgRetFun *)sp; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); - debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); - switch (fun_info->f.fun_type) { - case ARG_GEN: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(fun_info->f.b.bitmap), - BITMAP_SIZE(fun_info->f.b.bitmap)); - break; - case ARG_GEN_BIG: - printLargeBitmap(spBottom, sp+2, - GET_FUN_LARGE_BITMAP(fun_info), - GET_FUN_LARGE_BITMAP(fun_info)->size); - break; - default: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), - BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); - break; + case PAP: + { + StgPAP* pap = (StgPAP*)obj; + StgWord i; + debugBelch("PAP/%d(",(int)pap->arity); + printPtr((StgPtr)pap->fun); + for (i = 0; i < pap->n_args; ++i) { + debugBelch(", "); + printPtr((StgPtr)pap->payload[i]); } - continue; + debugBelch(")\n"); + break; } - default: - debugBelch("unknown object %d\n", (int)info->type); - barf("printStackChunk"); + case AP_STACK: + { + StgAP_STACK* ap = (StgAP_STACK*)obj; + StgWord i; + debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->size; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; } - } -} -static void printStack( StgStack *stack ) -{ - printStackChunk( stack->sp, stack->stack + stack->stack_size ); -} + case IND: + debugBelch("IND("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printTSO( StgTSO *tso ) -{ - printStack( tso->stackobj ); -} + case IND_STATIC: + debugBelch("IND_STATIC("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printStaticObjects( StgClosure *p ) -{ - while (p != END_OF_STATIC_OBJECT_LIST) { - p = UNTAG_STATIC_LIST_PTR(p); - printClosure(p); + case BLACKHOLE: + debugBelch("BLACKHOLE("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; - const StgInfoTable *info = get_itbl(p); - p = *STATIC_LINK(info, p); - } -} + /* Cannot happen -- use default case. + case RET_BCO: + case RET_SMALL: + case RET_BIG: + case RET_FUN: + */ -void printWeakLists() -{ - debugBelch("======= WEAK LISTS =======\n"); + case UPDATE_FRAME: + { + StgUpdateFrame* u = (StgUpdateFrame*)obj; + debugBelch("%s(", info_update_frame(obj)); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->updatee); + debugBelch(")\n"); + break; + } - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - debugBelch("Capability %d:\n", cap_idx); - Capability *cap = capabilities[cap_idx]; - for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case CATCH_FRAME: + { + StgCatchFrame* u = (StgCatchFrame*)obj; + debugBelch("CATCH_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->handler); + debugBelch(")\n"); + break; } - } - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current weaks:\n", gen_idx); - for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case UNDERFLOW_FRAME: + { + StgUnderflowFrame* u = (StgUnderflowFrame*)obj; + debugBelch("UNDERFLOW_FRAME("); + printPtr((StgPtr)u->next_chunk); + debugBelch(")\n"); + break; } - debugBelch("Generation %d old weaks:\n", gen_idx); - for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + + case STOP_FRAME: + { + StgStopFrame* u = (StgStopFrame*)obj; + debugBelch("STOP_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(")\n"); + break; } - } - debugBelch("=========================\n"); -} + case ARR_WORDS: + { + StgWord i; + debugBelch("ARR_WORDS(\""); + for (i=0; ipayload[i]); + debugBelch("\")\n"); + break; + } -void printLargeAndPinnedObjects() -{ - debugBelch("====== PINNED OBJECTS ======\n"); + case MUT_ARR_PTRS_CLEAN: + debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - Capability *cap = capabilities[cap_idx]; + case MUT_ARR_PTRS_DIRTY: + debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Capability %d: Current pinned object block: %p\n", - cap_idx, (void*)cap->pinned_object_block); - for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { - debugBelch("%p\n", (void*)bd); - } - } + case MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("====== LARGE OBJECTS =======\n"); - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current large objects:\n", gen_idx); - for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } + case SMALL_MUT_ARR_PTRS_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Generation %d scavenged large objects:\n", gen_idx); - for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } - } + case SMALL_MUT_ARR_PTRS_DIRTY: + debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("============================\n"); -} + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; -/* -------------------------------------------------------------------------- - * Address printing code - * - * Uses symbol table in (unstripped executable) - * ------------------------------------------------------------------------*/ + case MVAR_CLEAN: + case MVAR_DIRTY: + { + StgMVar* mv = (StgMVar*)obj; -/* -------------------------------------------------------------------------- - * Simple lookup table - * address -> function name - * ------------------------------------------------------------------------*/ + debugBelch("MVAR(head="); + if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->head); + } -static HashTable * add_to_fname_table = NULL; + debugBelch(", tail="); + if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->tail); + } -const char *lookupGHCName( void *addr ) -{ - if (add_to_fname_table == NULL) - return NULL; + debugBelch(", value="); + if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->value); + } + debugBelch(")\n"); - return lookupHashTable(add_to_fname_table, (StgWord)addr); -} + break; + } -/* -------------------------------------------------------------------------- - * Symbol table loading - * ------------------------------------------------------------------------*/ + case TVAR: + { + StgTVar* tv = (StgTVar*)obj; + debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); + break; + } -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame checks for unrelated fields instead of actually used - * macros. - */ -# include + case MUT_VAR_CLEAN: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); + break; + } -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ + case MUT_VAR_DIRTY: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); + break; + } -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} + case WEAK: + debugBelch("WEAK("); + debugBelch("key=%p value=%p finalizer=%p", + (StgPtr)(((StgWeak*)obj)->key), + (StgPtr)(((StgWeak*)obj)->value), + (StgPtr)(((StgWeak*)obj)->finalizer)); + debugBelch(")\n"); + /* ToDo: chase 'link' ? */ + break; -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; + case TSO: + debugBelch("TSO("); + debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); + debugBelch(")\n"); + break; - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } + case STACK: + debugBelch("STACK\n"); + break; - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; +#if 0 + /* Symptomatic of a problem elsewhere, have it fall-through & fail */ + case EVACUATED: + debugBelch("EVACUATED("); + printClosure((StgEvacuated*)obj->evacuee); + debugBelch(")\n"); + break; +#endif - storage_needed = bfd_get_symtab_upper_bound (abfd); + case COMPACT_NFDATA: + debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", + (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); + break; - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); + case TREC_CHUNK: + debugBelch("TREC_CHUNK\n"); + break; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + default: + //barf("printClosure %d",get_itbl(obj)->type); + debugBelch("*** printClosure: unknown type %d ****\n", + (int)get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); + return; + } +} - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); +static void +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) +{ + uint32_t i; + + for(i = 0; i < size; i++, bitmap >>= 1 ) { + debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } + } +} - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); +static void +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) +{ + StgWord bmp; + uint32_t i, j; - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; + i = 0; + for (bmp=0; i < size; bmp++) { + StgWord bitmap = large_bitmap->bitmap[bmp]; + j = 0; + for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { + debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); } } -#else /* USING_LIBBFD */ - -extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) +void +printStackChunk( StgPtr sp, StgPtr spBottom ) { - /* nothing, yet */ -} + const StgInfoTable *info; -#endif /* USING_LIBBFD */ + ASSERT(sp <= spBottom); + for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { -void findPtr(P_ p, int); /* keep gcc -Wall happy */ + info = get_itbl((StgClosure *)sp); -int searched = 0; + switch (info->type) { -static int -findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) -{ - StgPtr q, r, end; - for (; bd; bd = bd->link) { - searched++; - for (q = bd->start; q < bd->free; q++) { - if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { - if (i < arr_size) { - for (r = bd->start; r < bd->free; r = end) { - // skip over zeroed-out slop - while (*r == 0) r++; - if (!LOOKS_LIKE_CLOSURE_PTR(r)) { - debugBelch("%p found at %p, no closure at %p\n", - p, q, r); - break; - } - end = r + closure_sizeW((StgClosure*)r); - if (q < end) { - debugBelch("%p = ", r); - printClosure((StgClosure *)r); - arr[i++] = r; - break; - } - } - if (r >= bd->free) { - debugBelch("%p found at %p, closure?", p, q); - } - } else { - return i; - } + case UPDATE_FRAME: + case CATCH_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + printClosure((StgClosure*)sp); + continue; + + case RET_SMALL: { + StgWord c = *sp; + if (c == (StgWord)&stg_ctoi_R1p_info) { + debugBelch("tstg_ctoi_ret_R1p_info\n" ); + } else if (c == (StgWord)&stg_ctoi_R1n_info) { + debugBelch("stg_ctoi_ret_R1n_info\n" ); + } else if (c == (StgWord)&stg_ctoi_F1_info) { + debugBelch("stg_ctoi_ret_F1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_D1_info) { + debugBelch("stg_ctoi_ret_D1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_V_info) { + debugBelch("stg_ctoi_ret_V_info\n" ); + } else if (c == (StgWord)&stg_ap_v_info) { + debugBelch("stg_ap_v_info\n" ); + } else if (c == (StgWord)&stg_ap_f_info) { + debugBelch("stg_ap_f_info\n" ); + } else if (c == (StgWord)&stg_ap_d_info) { + debugBelch("stg_ap_d_info\n" ); + } else if (c == (StgWord)&stg_ap_l_info) { + debugBelch("stg_ap_l_info\n" ); + } else if (c == (StgWord)&stg_ap_n_info) { + debugBelch("stg_ap_n_info\n" ); + } else if (c == (StgWord)&stg_ap_p_info) { + debugBelch("stg_ap_p_info\n" ); + } else if (c == (StgWord)&stg_ap_pp_info) { + debugBelch("stg_ap_pp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppp_info) { + debugBelch("stg_ap_ppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppp_info) { + debugBelch("stg_ap_pppp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppppp_info) { + debugBelch("stg_ap_ppppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppppp_info) { + debugBelch("stg_ap_pppppp_info\n" ); + } else if (c == (StgWord)&stg_ret_v_info) { + debugBelch("stg_ret_v_info\n" ); + } else if (c == (StgWord)&stg_ret_p_info) { + debugBelch("stg_ret_p_info\n" ); + } else if (c == (StgWord)&stg_ret_n_info) { + debugBelch("stg_ret_n_info\n" ); + } else if (c == (StgWord)&stg_ret_f_info) { + debugBelch("stg_ret_f_info\n" ); + } else if (c == (StgWord)&stg_ret_d_info) { + debugBelch("stg_ret_d_info\n" ); + } else if (c == (StgWord)&stg_ret_l_info) { + debugBelch("stg_ret_l_info\n" ); +#if defined(PROFILING) + } else if (c == (StgWord)&stg_restore_cccs_info) { + debugBelch("stg_restore_cccs_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; + } else if (c == (StgWord)&stg_restore_cccs_eval_info) { + debugBelch("stg_restore_cccs_eval_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; +#endif + } else { + debugBelch("RET_SMALL (%p)\n", info); } + StgWord bitmap = info->layout.bitmap; + printSmallBitmap(spBottom, sp+1, + BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); + continue; } - } - return i; -} -void -findPtr(P_ p, int follow) -{ - uint32_t g, n; - bdescr *bd; - const int arr_size = 1024; - StgPtr arr[arr_size]; - int i = 0; - searched = 0; + case RET_BCO: { + StgBCO *bco; -#if 0 - // We can't search the nursery, because we don't know which blocks contain - // valid data, because the bd->free pointers in the nursery are only reset - // just before a block is used. - for (n = 0; n < n_capabilities; n++) { - bd = nurseries[i].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - } -#endif + bco = ((StgBCO *)sp[1]); - for (g = 0; g < RtsFlags.GcFlags.generations; g++) { - bd = generations[g].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - bd = generations[g].large_objects; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - for (n = 0; n < n_capabilities; n++) { - i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, - arr, arr_size, i); - i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, - arr, arr_size, i); - } - if (i >= arr_size) return; - } - if (follow && i == 1) { - debugBelch("-->\n"); - findPtr(arr[0], 1); - } -} + debugBelch("RET_BCO (%p)\n", sp); + printLargeBitmap(spBottom, sp+2, + BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); + continue; + } -const char *what_next_strs[] = { - [0] = "(unknown)", - [ThreadRunGHC] = "ThreadRunGHC", - [ThreadInterpret] = "ThreadInterpret", - [ThreadKilled] = "ThreadKilled", - [ThreadComplete] = "ThreadComplete" -}; + case RET_BIG: + debugBelch("RET_BIG (%p)\n", sp); + StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + printLargeBitmap(spBottom, + (StgPtr)((StgClosure *) sp)->payload, + bitmap, + bitmap->size); + continue; + case RET_FUN: + { + const StgFunInfoTable *fun_info; + StgRetFun *ret_fun; -#else /* DEBUG */ -void printPtr( StgPtr p ) -{ - debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); + ret_fun = (StgRetFun *)sp; + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); + switch (fun_info->f.fun_type) { + case ARG_GEN: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(fun_info->f.b.bitmap), + BITMAP_SIZE(fun_info->f.b.bitmap)); + break; + case ARG_GEN_BIG: + printLargeBitmap(spBottom, sp+2, + GET_FUN_LARGE_BITMAP(fun_info), + GET_FUN_LARGE_BITMAP(fun_info)->size); + break; + default: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), + BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + break; + } + continue; + } + + default: + debugBelch("unknown object %d\n", (int)info->type); + barf("printStackChunk"); + } + } } -void printObj( StgClosure *obj ) +void printStack( StgStack *stack ) { - debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); + printStackChunk( stack->sp, stack->stack + stack->stack_size ); } -#endif /* DEBUG */ - /* ----------------------------------------------------------------------------- Closure types ===================================== rts/Printer.h ===================================== @@ -20,8 +20,9 @@ const char * info_type ( const StgClosure *closure ); const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); -#if defined(DEBUG) extern void printClosure ( const StgClosure *obj ); + +#if defined(DEBUG) extern void printStackChunk ( StgPtr sp, StgPtr spLim ); extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); ===================================== rts/StgMiscClosures.cmm ===================================== @@ -573,6 +573,9 @@ INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") { foreign "C" barf("MSG_NULL object (%p) entered!", R1) never returns; } +INFO_TABLE_CONSTR(stg_MSG_CLONE_STACK,3,0,0,PRIM,"MSG_CLONE_STACK","MSG_CLONE_STACK") +{ foreign "C" barf("stg_MSG_CLONE_STACK object (%p) entered!", R1) never returns; } + /* ---------------------------------------------------------------------------- END_TSO_QUEUE ===================================== rts/package.conf.in ===================================== @@ -194,6 +194,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,_findPtr" #endif + , "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" #else "-Wl,-u,base_GHCziTopHandler_runIO_closure" , "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" @@ -308,6 +309,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,findPtr" #endif + , "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" #endif /* Pick up static libraries in preference over dynamic if in earlier search ===================================== rts/rts.cabal.in ===================================== @@ -286,6 +286,7 @@ library "-Wl,-u,_hs_atomicwrite8" "-Wl,-u,_hs_atomicwrite16" "-Wl,-u,_hs_atomicwrite32" + "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -367,6 +368,7 @@ library "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" + "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -410,6 +412,7 @@ library Arena.c Capability.c CheckUnload.c + CloneStack.c ClosureFlags.c Disassembler.c FileLock.c ===================================== testsuite/tests/rts/all.T ===================================== @@ -418,3 +418,7 @@ test('T17088', compile_and_run, ['-rtsopts -O2']) test('T15427', normal, compile_and_run, ['']) + +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c']) + +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack +import Foreign +import Foreign.C.Types (CUInt) + +foreign import ccall "expectClosureTypes" expectClosureTypes:: StackSnapshot# -> Ptr CUInt -> Int -> IO () + +main :: IO () +main = do + stackSnapshot <- cloneMyStack + + let (StackSnapshot stack) = stackSnapshot + let expectedClosureTypes = [34 -- CATCH_FRAME + ,36 -- STOP_FRAME + ] + withArray expectedClosureTypes (\ptr -> expectClosureTypes stack ptr (length expectedClosureTypes)) ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -0,0 +1,53 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "rts/Messages.h" + + +void expectStacksToBeEqual(StgStack *clonedStack, StgTSO *tso) { + StgStack *liveStack = tso->stackobj; + + if(liveStack->header.info != clonedStack->header.info){ + barf("info table pointer not equal! Expected same pointer address, but got %p and %p", liveStack->header.info, clonedStack->header.info); + } + + StgInfoTable *info = INFO_PTR_TO_STRUCT(liveStack->header.info); + + if (info->type != STACK) { + barf("Expected a closure of type STACK!"); + } + + if(liveStack->stack_size != clonedStack->stack_size){ + barf("Expected same stack_size!"); + } + + if(liveStack->dirty != clonedStack->dirty){ + barf("Expected same dirty flags!"); + } + + if(liveStack->marking != clonedStack->marking){ + barf("Expected same marking flags!"); + } + + for(StgWord i = liveStack->stack_size - 1; (liveStack->stack + i) >= liveStack->sp; i--){ + if(liveStack->stack[i] != clonedStack->stack[i]){ + barf("Expected stack word %lu to be equal on both stacks.", i); + } + } +} + +void expectClosureTypes(StgStack *stack, unsigned int types[], size_t typesSize){ + StgPtr sp = stack->sp; + StgPtr spBottom = stack->stack + stack->stack_size; + + for (StgWord i = 0; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp), i++) { + const StgInfoTable *info = get_itbl((StgClosure *)sp); + + if(i >= typesSize) { + barf("Stack size exceeds expectation!"); + } + + if(info->type != types[i]) { + barf("Wrong closure type on stack! Expected %u but got %u", types[i], info->type); + } + } +} ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -0,0 +1,46 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#, ThreadId#) +import GHC.Conc.Sync (ThreadId(..)) +import GHC.Stack.CloneStack +import Control.Concurrent +import GHC.Conc + +foreign import ccall "expectStacksToBeEqual" expectStacksToBeEqual:: StackSnapshot# -> ThreadId# -> IO () + +main :: IO () +main = do + mVarToBeBlockedOn <- newEmptyMVar + threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + + waitUntilBlocked threadId + + stackSnapshot <- cloneThreadStack threadId + + let (StackSnapshot stack) = stackSnapshot + let (ThreadId tid#) = threadId + expectStacksToBeEqual stack tid# + +immediatelyBlocking :: MVar Int -> IO () +immediatelyBlocking mVarToBeBlockedOn = do + takeMVar mVarToBeBlockedOn + return () + +waitUntilBlocked :: ThreadId -> IO () +waitUntilBlocked tid = do + blocked <- isBlocked tid + if blocked then + return () + else + do + threadDelay 100000 + waitUntilBlocked tid + +isBlocked:: ThreadId -> IO Bool +isBlocked = fmap isThreadStatusBlocked . threadStatus + +isThreadStatusBlocked :: ThreadStatus -> Bool +isThreadStatusBlocked (ThreadBlocked _) = True +isThreadStatusBlocked _ = False ===================================== utils/deriveConstants/Main.hs ===================================== @@ -442,7 +442,6 @@ wanteds os = concat ,closureField_ Both "StgTSO_cccs" "StgTSO" "prof.cccs" ,closureField Both "StgTSO" "stackobj" - ,closureSize C "StgStack" ,closureField Both "StgStack" "sp" ,closureFieldOffset Both "StgStack" "stack" ,closureField C "StgStack" "stack_size" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24a9197c87573849199da43b22775a1a6af6631 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c24a9197c87573849199da43b22775a1a6af6631 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 09:31:44 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 12 Oct 2020 05:31:44 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 67 commits: Document profiling flags, warning flags, and no-pie Message-ID: <5f84228064c7a_80bb65311818309577@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 24cb85f2 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Nested CPR - - - - - bdcf72b4 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Move tests from stranal to cpranal - - - - - c426cac6 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Accept FacState - - - - - 498e2c5d by Sebastian Graf at 2020-10-12T11:31:25+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - 7b3d0659 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - a257ddb9 by Sebastian Graf at 2020-10-12T11:31:25+02:00 stuff - - - - - 38274602 by Sebastian Graf at 2020-10-12T11:31:25+02:00 A slew of testsuite changes - - - - - bdff7f5f by Sebastian Graf at 2020-10-12T11:31:25+02:00 Fix T1600 - - - - - 7ffaa2f7 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Fix primop termination - - - - - 78812c04 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Test for DataCon wrapper CPR - - - - - eb0825e6 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Fix CPR of bottoming functions/primops - - - - - 0c4eba89 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - 38524a86 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Accept two more changed test outputs - - - - - ded5e1d1 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Update CaseBinderCPR with a new function - - - - - 91e3a5ee by Sebastian Graf at 2020-10-12T11:31:25+02:00 Don't give the case binder the CPR property - - - - - 6442476b by Sebastian Graf at 2020-10-12T11:31:25+02:00 Prune CPR sigs to constant depth on all bindings - - - - - 67a6c915 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Use variable length coding for ConTags - - - - - 1ce97e48 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Accept testuite output - - - - - 4a5529dd by Sebastian Graf at 2020-10-12T11:31:25+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - 55e05e29 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 2a8f3523 by Sebastian Graf at 2020-10-12T11:31:25+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - bbf00ae6 by Sebastian Graf at 2020-10-12T11:31:25+02:00 Fix T9291 - - - - - ae2391be by Sebastian Graf at 2020-10-12T11:31:26+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - 3f1cda97 by Sebastian Graf at 2020-10-12T11:31:26+02:00 Testsuite changes - - - - - 05f052a8 by Sebastian Graf at 2020-10-12T11:31:26+02:00 Refactoring around cprAnalBind - - - - - a232e975 by Sebastian Graf at 2020-10-12T11:31:26+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - 5d6cbb4a by Sebastian Graf at 2020-10-12T11:31:26+02:00 Fix T16893 - - - - - 2dcfa20f by Sebastian Graf at 2020-10-12T11:31:26+02:00 Accept new test output for T17673 - - - - - f3c50c90 by Sebastian Graf at 2020-10-12T11:31:26+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6716c5fa3f566fcce2ac17c99bfc7c628c08e0f0...f3c50c901b6d6fedd4ad469aca743aff69f364f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6716c5fa3f566fcce2ac17c99bfc7c628c08e0f0...f3c50c901b6d6fedd4ad469aca743aff69f364f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 10:03:24 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 06:03:24 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Add cloneThreadStack and cloneMyStack (#18741) Message-ID: <5f8429eca8320_80b3f840f3a007018318858@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 9be8e25c by Sven Tennie at 2020-10-12T12:00:47+02:00 Add cloneThreadStack and cloneMyStack (#18741) These functions clone the stack of either another thread (cloneThreadStack) or the currently active one (cloneMyStack). A cloned stack is offline/cold, i.e. it isn't evaluated any further. The stack is represented by a new primtype (StackSnapshot#) in Haskell. For technical details, please see note [Stack Cloning]. - - - - - 28 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - + includes/rts/PrinterAPI.h - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Disassembler.c - rts/Disassembler.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/StgMiscClosures.cmm - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneMyStack.hs - + testsuite/tests/rts/cloneStackLib.c - + testsuite/tests/rts/cloneThreadStack.hs - utils/deriveConstants/Main.hs - + utils/deriveConstants/hie.yaml - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1770,7 +1770,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, typeConKey, threadIdPrimTyConKey, bcoPrimTyConKey, ptrTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, - compactPrimTyConKey :: Unique + compactPrimTyConKey, stackSnapshotPrimTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -1801,6 +1801,7 @@ ptrTyConKey = mkPreludeTyConUnique 77 funPtrTyConKey = mkPreludeTyConUnique 78 tVarPrimTyConKey = mkPreludeTyConUnique 79 compactPrimTyConKey = mkPreludeTyConUnique 80 +stackSnapshotPrimTyConKey = mkPreludeTyConUnique 81 eitherTyConKey :: Unique eitherTyConKey = mkPreludeTyConUnique 84 ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -69,6 +69,7 @@ module GHC.Builtin.Types.Prim( bcoPrimTyCon, bcoPrimTy, weakPrimTyCon, mkWeakPrimTy, threadIdPrimTyCon, threadIdPrimTy, + stackSnapshotPrimTyCon, stackSnapshotPrimTy, int8PrimTyCon, int8PrimTy, int8PrimTyConName, word8PrimTyCon, word8PrimTy, word8PrimTyConName, @@ -188,6 +189,7 @@ exposedPrimTyCons , word16PrimTyCon , word32PrimTyCon , word64PrimTyCon + , stackSnapshotPrimTyCon , tYPETyCon , funTyCon @@ -210,7 +212,7 @@ mkBuiltInPrimTc fs unique tycon BuiltInSyntax -charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName :: Name +charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, stackSnapshotPrimTyConName :: Name charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon @@ -246,6 +248,7 @@ tVarPrimTyConName = mkPrimTc (fsLit "TVar#") tVarPrimTyConKey tVarPr stablePtrPrimTyConName = mkPrimTc (fsLit "StablePtr#") stablePtrPrimTyConKey stablePtrPrimTyCon stableNamePrimTyConName = mkPrimTc (fsLit "StableName#") stableNamePrimTyConKey stableNamePrimTyCon compactPrimTyConName = mkPrimTc (fsLit "Compact#") compactPrimTyConKey compactPrimTyCon +stackSnapshotPrimTyConName = mkPrimTc (fsLit "StackSnapshot#") stackSnapshotPrimTyConKey stackSnapshotPrimTyCon bcoPrimTyConName = mkPrimTc (fsLit "BCO") bcoPrimTyConKey bcoPrimTyCon weakPrimTyConName = mkPrimTc (fsLit "Weak#") weakPrimTyConKey weakPrimTyCon threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKey threadIdPrimTyCon @@ -1086,6 +1089,21 @@ compactPrimTyCon = pcPrimTyCon0 compactPrimTyConName UnliftedRep compactPrimTy :: Type compactPrimTy = mkTyConTy compactPrimTyCon +{- +************************************************************************ +* * + The @StackSnapshot#@ type +* * +************************************************************************ +-} + +stackSnapshotPrimTyCon :: TyCon +stackSnapshotPrimTyCon = pcPrimTyCon0 stackSnapshotPrimTyConName UnliftedRep + +stackSnapshotPrimTy :: Type +stackSnapshotPrimTy = mkTyConTy stackSnapshotPrimTyCon + + {- ************************************************************************ * * ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3599,6 +3599,16 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp has_side_effects = True out_of_line = True +primtype StackSnapshot# + +primop CloneMyStack "cloneMyStack#" GenPrimOp + State# RealWorld -> (# State# RealWorld, StackSnapshot# #) + { Clones the stack of the current Haskell thread. } + with + has_side_effects = True + out_of_line = True + + ------------------------------------------------------------------------ section "Safe coercions" ------------------------------------------------------------------------ ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1521,6 +1521,7 @@ emitPrimOp dflags primop = case primop of TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + CloneMyStack -> alwaysExternal where profile = targetProfile dflags ===================================== includes/rts/PrinterAPI.h ===================================== @@ -0,0 +1,3 @@ +#pragma once + +extern void printStack (StgStack* stack); ===================================== includes/rts/storage/Closures.h ===================================== @@ -431,6 +431,14 @@ typedef struct MessageBlackHole_ { StgClosure *bh; } MessageBlackHole; +typedef struct MessageCloneStack_ { + StgHeader header; + Message *link; + StgMVar *result; + StgTSO *tso; +} MessageCloneStack; + + /* ---------------------------------------------------------------------------- Compact Regions ------------------------------------------------------------------------- */ ===================================== includes/stg/MiscClosures.h ===================================== @@ -129,6 +129,7 @@ RTS_ENTRY(stg_STM_AWOKEN); RTS_ENTRY(stg_MSG_TRY_WAKEUP); RTS_ENTRY(stg_MSG_THROWTO); RTS_ENTRY(stg_MSG_BLACKHOLE); +RTS_ENTRY(stg_MSG_CLONE_STACK); RTS_ENTRY(stg_MSG_NULL); RTS_ENTRY(stg_MVAR_TSO_QUEUE); RTS_ENTRY(stg_catch); ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -624,7 +624,7 @@ data PrimMVar -- @hs_try_putmvar()@. The RTS wants a 'StablePtr' to the underlying -- 'MVar#', but a 'StablePtr#' can only refer to lifted types, so we -- have to cheat by coercing. -newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar) +newStablePtrPrimMVar :: MVar a -> IO (StablePtr PrimMVar) newStablePtrPrimMVar (MVar m) = IO $ \s0 -> case makeStablePtr# (unsafeCoerce# m :: PrimMVar) s0 of -- Coerce unlifted m :: MVar# RealWorld () ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -0,0 +1,59 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes#-} + + +module GHC.Stack.CloneStack ( + cloneThreadStack, + cloneMyStack, + printStack, + StackSnapshot(..) + ) where + +import GHC.Prim (StackSnapshot#, cloneMyStack#, ThreadId#) +import Control.Concurrent.MVar +import GHC.Conc.Sync +import GHC.Stable +import GHC.IO (IO(..)) + +foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () + +foreign import ccall "PrinterAPI.h printStack" printStack_c :: StackSnapshot# -> IO () + +data StackSnapshot = StackSnapshot StackSnapshot# + +{- Note [Stack Cloning] +"Cloning" a stack means that it's StgStack closure is copied including the +stack memory (stack[]). The stack pointer (sp) of the clone is adjusted to be +valid. +The clone is "offline"/"cold", i.e. it won't be evaluated any further. This is +useful for further analyses like stack unwinding or traversal. + +There are two different ways to clone a stack: +1. By the corresponding thread via a primop call (cloneMyStack#). +2. By sending a RTS message (Messages.c) with a MVar to the corresponding + thread and receiving the stack by taking it out of this MVar. +-} + +-- | Clone the stack of a thread identified by it's 'ThreadId' +cloneThreadStack :: ThreadId -> IO StackSnapshot +cloneThreadStack (ThreadId tid#) = do + resultVar <- newEmptyMVar @StackSnapshot + ptr <- newStablePtrPrimMVar resultVar + -- Use the RTS's "message" mechanism to request that + -- the thread captures its stack, saving the result + -- into resultVar. + sendCloneStackMessage tid# ptr + freeStablePtr ptr + takeMVar resultVar + +-- | Clone the stack of the executing thread +cloneMyStack :: IO StackSnapshot +cloneMyStack = IO $ \s -> + case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) + +-- | Print the stack +printStack :: StackSnapshot -> IO () +printStack (StackSnapshot stack) = printStack_c stack ===================================== libraries/base/base.cabal ===================================== @@ -264,6 +264,7 @@ Library GHC.ResponseFile GHC.RTS.Flags GHC.ST + GHC.Stack.CloneStack GHC.StaticPtr GHC.STRef GHC.Show ===================================== rts/CloneStack.c ===================================== @@ -0,0 +1,66 @@ +#include + +#include "Rts.h" +#include "rts/Messages.h" +#include "rts/storage/TSO.h" +#include "stg/Types.h" +#include "CloneStack.h" + +#if defined(THREADED_RTS) + +// ThreadId# in Haskell is a StgTSO* in RTS. +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + Capability *srcCapability = rts_unsafeGetMyCapability(); + + MessageCloneStack *msg; + msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); + msg->tso = tso; + msg->result = (StgMVar*)deRefStablePtr(mvar); + freeStablePtr(mvar); + SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); + // Ensure that writes constructing Message are committed before sending. + write_barrier(); + + sendMessage(srcCapability, tso->cap, (Message *)msg); +} + +void handleCloneStackMessage(MessageCloneStack *msg){ + StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); + + // Lift StackSnapshot# to StackSnapshot by applying it's constructor. + // This is necessary because performTryPutMVar() puts the closure onto the + // stack for evaluation and stacks can not be evaluated (entered). + HaskellObj result = rts_apply(msg->tso->cap, StackSnapshot_constructor_closure, (HaskellObj) newStackClosure); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, result); + + if(!putMVarWasSuccessful) { + barf("Can't put stack cloning result into MVar."); + } +} + +#else // !defined(THREADED_RTS) + +GNU_ATTRIBUTE(__noreturn__) +void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) { + barf("Sending CloneStackMessages is only available in threaded RTS!"); +} + +#endif // end !defined(THREADED_RTS) + +StgStack* cloneStack(Capability* capability, StgStack* stack){ + StgWord spOffset = stack->sp - stack->stack; + StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); + + StgStack* newStackClosure = (StgStack*) allocate(capability, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + + memcpy(newStackClosure, stack, closureSizeBytes); + + newStackClosure->sp = newStackClosure->stack + spOffset; + +#if defined(DEBUG) + checkClosure(newStackClosure); +#endif + + return newStackClosure; +} ===================================== rts/CloneStack.h ===================================== @@ -0,0 +1,12 @@ +#pragma once + +#if defined(THREADED_RTS) +void handleCloneStackMessage(MessageCloneStack *msg); +#endif + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); + +StgStack* cloneStack(Capability* capability, StgStack* stack); + +extern StgClosure DLL_IMPORT_DATA_VARNAME(base_GHCziStackziCloneStack_StackSnapshot_closure); +#define StackSnapshot_constructor_closure DLL_IMPORT_DATA_REF(base_GHCziStackziCloneStack_StackSnapshot_closure) ===================================== rts/Disassembler.c ===================================== @@ -8,8 +8,6 @@ * $Date: 2004/09/03 15:28:19 $ * ---------------------------------------------------------------------------*/ -#if defined(DEBUG) - #include "PosixSource.h" #include "Rts.h" #include "RtsAPI.h" @@ -358,5 +356,3 @@ void disassemble( StgBCO *bco ) debugBelch("\n"); } - -#endif /* DEBUG */ ===================================== rts/Disassembler.h ===================================== @@ -8,9 +8,5 @@ #pragma once -#if defined(DEBUG) - RTS_PRIVATE int disInstr ( StgBCO *bco, int pc ); RTS_PRIVATE void disassemble( StgBCO *bco ); - -#endif ===================================== rts/Messages.c ===================================== @@ -14,6 +14,7 @@ #include "Threads.h" #include "RaiseAsync.h" #include "sm/Storage.h" +#include "CloneStack.h" /* ---------------------------------------------------------------------------- Send a message to another Capability @@ -32,7 +33,8 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg) i != &stg_MSG_BLACKHOLE_info && i != &stg_MSG_TRY_WAKEUP_info && i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked - i != &stg_WHITEHOLE_info) { + i != &stg_WHITEHOLE_info && + i != &stg_MSG_CLONE_STACK_info) { barf("sendMessage: %p", i); } } @@ -131,6 +133,10 @@ loop: #endif goto loop; } + else if(i == &stg_MSG_CLONE_STACK_info){ + MessageCloneStack *cloneStackMessage = (MessageCloneStack*) m; + handleCloneStackMessage(cloneStackMessage); + } else { barf("executeMessage: %p", i); ===================================== rts/PrimOps.cmm ===================================== @@ -2840,3 +2840,14 @@ stg_setThreadAllocationCounterzh ( I64 counter ) StgTSO_alloc_limit(CurrentTSO) = counter + TO_I64(offset); return (); } + +stg_cloneMyStackzh () { + W_ stgStack; + W_ clonedStack; + + stgStack = StgTSO_stackobj(CurrentTSO); + + ("ptr" clonedStack) = ccall cloneStack(MyCapability() "ptr", stgStack "ptr"); + + return (clonedStack); +} ===================================== rts/Printer.c ===================================== @@ -25,9 +25,10 @@ #include +#include "Disassembler.h" + #if defined(DEBUG) -#include "Disassembler.h" #include "Apply.h" /* -------------------------------------------------------------------------- @@ -58,402 +59,337 @@ void printObj( StgClosure *obj ) printClosure(obj); } -STATIC_INLINE void -printStdObjHdr( const StgClosure *obj, char* tag ) +void +printMutableList(bdescr *bd) { - debugBelch("%s(",tag); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif -} + StgPtr p; -static void -printStdObjPayload( const StgClosure *obj ) -{ - StgWord i, j; - const StgInfoTable* info; + debugBelch("mutable list %p: ", bd); - info = get_itbl(obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); + for (; bd != NULL; bd = bd->link) { + for (p = bd->start; p < bd->free; p++) { + debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); + } } - debugBelch(")\n"); + debugBelch("\n"); } -static void -printThunkPayload( StgThunk *obj ) +void printTSO( StgTSO *tso ) { - StgWord i, j; - const StgInfoTable* info; - - info = get_itbl((StgClosure *)obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); - } - debugBelch(")\n"); + printStack( tso->stackobj ); } -static void -printThunkObject( StgThunk *obj, char* tag ) +void printStaticObjects( StgClosure *p ) { - printStdObjHdr( (StgClosure *)obj, tag ); - printThunkPayload( obj ); + while (p != END_OF_STATIC_OBJECT_LIST) { + p = UNTAG_STATIC_LIST_PTR(p); + printClosure(p); + + const StgInfoTable *info = get_itbl(p); + p = *STATIC_LINK(info, p); + } } -void -printClosure( const StgClosure *obj ) +void printWeakLists() { - debugBelch("%p: ", obj); - obj = UNTAG_CONST_CLOSURE(obj); - const StgInfoTable* info = get_itbl(obj); + debugBelch("======= WEAK LISTS =======\n"); - while (IS_FORWARDING_PTR(info)) { - obj = (StgClosure*)UN_FORWARDING_PTR(info); - debugBelch("(forwarding to %p) ", (void*)obj); - info = get_itbl(obj); + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + debugBelch("Capability %d:\n", cap_idx); + Capability *cap = capabilities[cap_idx]; + for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } } - switch ( info->type ) { - case INVALID_OBJECT: - barf("Invalid object"); - - case CONSTR: - case CONSTR_1_0: case CONSTR_0_1: - case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: - case CONSTR_NOCAF: - { - StgWord i, j; - const StgConInfoTable *con_info = get_con_itbl (obj); - - debugBelch("%s(", GET_CON_DESC(con_info)); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - if (i != 0) debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - if (i != 0 || j != 0) debugBelch(", "); - debugBelch("%p#", obj->payload[i+j]); - } - debugBelch(")\n"); - break; + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current weaks:\n", gen_idx); + for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); } + debugBelch("Generation %d old weaks:\n", gen_idx); + for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } + } - case FUN: - case FUN_1_0: case FUN_0_1: - case FUN_1_1: case FUN_0_2: case FUN_2_0: - case FUN_STATIC: - debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif - printStdObjPayload(obj); - break; - - case PRIM: - debugBelch("PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case MUT_PRIM: - debugBelch("MUT_PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case THUNK: - case THUNK_1_0: case THUNK_0_1: - case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: - case THUNK_STATIC: - /* ToDo: will this work for THUNK_STATIC too? */ -#if defined(PROFILING) - printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); -#else - printThunkObject((StgThunk *)obj,"THUNK"); -#endif - break; + debugBelch("=========================\n"); +} - case THUNK_SELECTOR: - printStdObjHdr(obj, "THUNK_SELECTOR"); - debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); - break; +void printLargeAndPinnedObjects() +{ + debugBelch("====== PINNED OBJECTS ======\n"); - case BCO: - disassemble( (StgBCO*)obj ); - break; + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + Capability *cap = capabilities[cap_idx]; - case AP: - { - StgAP* ap = (StgAP*)obj; - StgWord i; - debugBelch("AP("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->n_args; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Capability %d: Current pinned object block: %p\n", + cap_idx, (void*)cap->pinned_object_block); + for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { + debugBelch("%p\n", (void*)bd); } + } - case PAP: - { - StgPAP* pap = (StgPAP*)obj; - StgWord i; - debugBelch("PAP/%d(",(int)pap->arity); - printPtr((StgPtr)pap->fun); - for (i = 0; i < pap->n_args; ++i) { - debugBelch(", "); - printPtr((StgPtr)pap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("====== LARGE OBJECTS =======\n"); + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current large objects:\n", gen_idx); + for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } - case AP_STACK: - { - StgAP_STACK* ap = (StgAP_STACK*)obj; - StgWord i; - debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->size; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Generation %d scavenged large objects:\n", gen_idx); + for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } + } - case IND: - debugBelch("IND("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; - - case IND_STATIC: - debugBelch("IND_STATIC("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; + debugBelch("============================\n"); +} - case BLACKHOLE: - debugBelch("BLACKHOLE("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; +/* -------------------------------------------------------------------------- + * Address printing code + * + * Uses symbol table in (unstripped executable) + * ------------------------------------------------------------------------*/ - /* Cannot happen -- use default case. - case RET_BCO: - case RET_SMALL: - case RET_BIG: - case RET_FUN: - */ +/* -------------------------------------------------------------------------- + * Simple lookup table + * address -> function name + * ------------------------------------------------------------------------*/ - case UPDATE_FRAME: - { - StgUpdateFrame* u = (StgUpdateFrame*)obj; - debugBelch("%s(", info_update_frame(obj)); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->updatee); - debugBelch(")\n"); - break; - } +static HashTable * add_to_fname_table = NULL; - case CATCH_FRAME: - { - StgCatchFrame* u = (StgCatchFrame*)obj; - debugBelch("CATCH_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->handler); - debugBelch(")\n"); - break; - } - - case UNDERFLOW_FRAME: - { - StgUnderflowFrame* u = (StgUnderflowFrame*)obj; - debugBelch("UNDERFLOW_FRAME("); - printPtr((StgPtr)u->next_chunk); - debugBelch(")\n"); - break; - } - - case STOP_FRAME: - { - StgStopFrame* u = (StgStopFrame*)obj; - debugBelch("STOP_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(")\n"); - break; - } - - case ARR_WORDS: - { - StgWord i; - debugBelch("ARR_WORDS(\""); - for (i=0; ipayload[i]); - debugBelch("\")\n"); - break; - } - - case MUT_ARR_PTRS_CLEAN: - debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; - - case MUT_ARR_PTRS_DIRTY: - debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; +const char *lookupGHCName( void *addr ) +{ + if (add_to_fname_table == NULL) + return NULL; - case MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; + return lookupHashTable(add_to_fname_table, (StgWord)addr); +} - case SMALL_MUT_ARR_PTRS_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* -------------------------------------------------------------------------- + * Symbol table loading + * ------------------------------------------------------------------------*/ - case SMALL_MUT_ARR_PTRS_DIRTY: - debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Causing linking trouble on Win32 plats, so I'm + disabling this for now. +*/ +#if defined(USING_LIBBFD) +# define PACKAGE 1 +# define PACKAGE_VERSION 1 +/* Those PACKAGE_* defines are workarounds for bfd: + * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 + * ghc's build system filter PACKAGE_* values out specifically to avoid clashes + * with user's autoconf-based Cabal packages. + * It's a shame checks for unrelated fields instead of actually used + * macros. + */ +# include - case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Fairly ad-hoc piece of code that seems to filter out a lot of + * rubbish like the obj-splitting symbols + */ - case MVAR_CLEAN: - case MVAR_DIRTY: - { - StgMVar* mv = (StgMVar*)obj; +static bool isReal( flagword flags STG_UNUSED, const char *name ) +{ +#if 0 + /* ToDo: make this work on BFD */ + int tp = type & N_TYPE; + if (tp == N_TEXT || tp == N_DATA) { + return (name[0] == '_' && name[1] != '_'); + } else { + return false; + } +#else + if (*name == '\0' || + (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || + (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { + return false; + } + return true; +#endif +} - debugBelch("MVAR(head="); - if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->head); - } +extern void DEBUG_LoadSymbols( const char *name ) +{ + bfd* abfd; + char **matching; - debugBelch(", tail="); - if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->tail); - } + bfd_init(); + abfd = bfd_openr(name, "default"); + if (abfd == NULL) { + barf("can't open executable %s to get symbol table", name); + } + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { + barf("mismatch"); + } - debugBelch(", value="); - if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->value); - } - debugBelch(")\n"); + { + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long num_real_syms = 0; + long i; - break; - } + storage_needed = bfd_get_symtab_upper_bound (abfd); - case TVAR: - { - StgTVar* tv = (StgTVar*)obj; - debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); - break; + if (storage_needed < 0) { + barf("can't read symbol table"); } + symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - case MUT_VAR_CLEAN: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); - break; - } + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - case MUT_VAR_DIRTY: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); - break; + if (number_of_symbols < 0) { + barf("can't canonicalise symbol table"); } - case WEAK: - debugBelch("WEAK("); - debugBelch("key=%p value=%p finalizer=%p", - (StgPtr)(((StgWeak*)obj)->key), - (StgPtr)(((StgWeak*)obj)->value), - (StgPtr)(((StgWeak*)obj)->finalizer)); - debugBelch(")\n"); - /* ToDo: chase 'link' ? */ - break; - - case TSO: - debugBelch("TSO("); - debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); - debugBelch(")\n"); - break; - - case STACK: - debugBelch("STACK\n"); - break; - -#if 0 - /* Symptomatic of a problem elsewhere, have it fall-through & fail */ - case EVACUATED: - debugBelch("EVACUATED("); - printClosure((StgEvacuated*)obj->evacuee); - debugBelch(")\n"); - break; -#endif + if (add_to_fname_table == NULL) + add_to_fname_table = allocHashTable(); - case COMPACT_NFDATA: - debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", - (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); - break; + for( i = 0; i != number_of_symbols; ++i ) { + symbol_info info; + bfd_get_symbol_info(abfd,symbol_table[i],&info); + if (isReal(info.type, info.name)) { + insertHashTable(add_to_fname_table, + info.value, (void*)info.name); + num_real_syms += 1; + } + } - case TREC_CHUNK: - debugBelch("TREC_CHUNK\n"); - break; + IF_DEBUG(interpreter, + debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", + number_of_symbols, num_real_syms) + ); - default: - //barf("printClosure %d",get_itbl(obj)->type); - debugBelch("*** printClosure: unknown type %d ****\n", - (int)get_itbl(obj)->type ); - barf("printClosure %d",get_itbl(obj)->type); - return; + stgFree(symbol_table); } } -void -printMutableList(bdescr *bd) +#else /* USING_LIBBFD */ + +extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { - StgPtr p; + /* nothing, yet */ +} - debugBelch("mutable list %p: ", bd); +#endif /* USING_LIBBFD */ - for (; bd != NULL; bd = bd->link) { - for (p = bd->start; p < bd->free; p++) { - debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); - } - } - debugBelch("\n"); -} +void findPtr(P_ p, int); /* keep gcc -Wall happy */ -// If you know you have an UPDATE_FRAME, but want to know exactly which. -const char *info_update_frame(const StgClosure *closure) +int searched = 0; + +static int +findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) { - // Note: We intentionally don't take the info table pointer as - // an argument. As it will be confusing whether one should pass - // it pointing to the code or struct members when compiling with - // TABLES_NEXT_TO_CODE. + StgPtr q, r, end; + for (; bd; bd = bd->link) { + searched++; + for (q = bd->start; q < bd->free; q++) { + if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { + if (i < arr_size) { + for (r = bd->start; r < bd->free; r = end) { + // skip over zeroed-out slop + while (*r == 0) r++; + if (!LOOKS_LIKE_CLOSURE_PTR(r)) { + debugBelch("%p found at %p, no closure at %p\n", + p, q, r); + break; + } + end = r + closure_sizeW((StgClosure*)r); + if (q < end) { + debugBelch("%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + break; + } + } + if (r >= bd->free) { + debugBelch("%p found at %p, closure?", p, q); + } + } else { + return i; + } + } + } + } + return i; +} + +void +findPtr(P_ p, int follow) +{ + uint32_t g, n; + bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; + searched = 0; + +#if 0 + // We can't search the nursery, because we don't know which blocks contain + // valid data, because the bd->free pointers in the nursery are only reset + // just before a block is used. + for (n = 0; n < n_capabilities; n++) { + bd = nurseries[i].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + } +#endif + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + bd = generations[g].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + bd = generations[g].large_objects; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + for (n = 0; n < n_capabilities; n++) { + i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, + arr, arr_size, i); + i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, + arr, arr_size, i); + } + if (i >= arr_size) return; + } + if (follow && i == 1) { + debugBelch("-->\n"); + findPtr(arr[0], 1); + } +} + +const char *what_next_strs[] = { + [0] = "(unknown)", + [ThreadRunGHC] = "ThreadRunGHC", + [ThreadInterpret] = "ThreadInterpret", + [ThreadKilled] = "ThreadKilled", + [ThreadComplete] = "ThreadComplete" +}; + +#else /* DEBUG */ +void printPtr( StgPtr p ) +{ + debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); +} + +void printObj( StgClosure *obj ) +{ + debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); +} + + +#endif /* DEBUG */ + +// If you know you have an UPDATE_FRAME, but want to know exactly which. +const char *info_update_frame(const StgClosure *closure) +{ + // Note: We intentionally don't take the info table pointer as + // an argument. As it will be confusing whether one should pass + // it pointing to the code or struct members when compiling with + // TABLES_NEXT_TO_CODE. const StgInfoTable *info = closure->header.info; if (info == &stg_upd_frame_info) { return "NORMAL_UPDATE_FRAME"; @@ -467,501 +403,567 @@ const char *info_update_frame(const StgClosure *closure) } static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, - uint32_t size ) +printThunkPayload( StgThunk *obj ) { - uint32_t i; + StgWord i, j; + const StgInfoTable* info; - for(i = 0; i < size; i++, bitmap >>= 1 ) { - debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } + info = get_itbl((StgClosure *)obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); +} + +STATIC_INLINE void +printStdObjHdr( const StgClosure *obj, char* tag ) +{ + debugBelch("%s(",tag); + printPtr((StgPtr)obj->header.info); +#if defined(PROFILING) + debugBelch(", %s", obj->header.prof.ccs->cc->label); +#endif } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, - uint32_t size ) +printThunkObject( StgThunk *obj, char* tag ) { - StgWord bmp; - uint32_t i, j; + printStdObjHdr( (StgClosure *)obj, tag ); + printThunkPayload( obj ); +} - i = 0; - for (bmp=0; i < size; bmp++) { - StgWord bitmap = large_bitmap->bitmap[bmp]; - j = 0; - for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { - debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } - } +static void +printStdObjPayload( const StgClosure *obj ) +{ + StgWord i, j; + const StgInfoTable* info; + + info = get_itbl(obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); } void -printStackChunk( StgPtr sp, StgPtr spBottom ) +printClosure( const StgClosure *obj ) { - const StgInfoTable *info; + debugBelch("%p: ", obj); + obj = UNTAG_CONST_CLOSURE(obj); + const StgInfoTable* info = get_itbl(obj); - ASSERT(sp <= spBottom); - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { + while (IS_FORWARDING_PTR(info)) { + obj = (StgClosure*)UN_FORWARDING_PTR(info); + debugBelch("(forwarding to %p) ", (void*)obj); + info = get_itbl(obj); + } - info = get_itbl((StgClosure *)sp); + switch ( info->type ) { + case INVALID_OBJECT: + barf("Invalid object"); - switch (info->type) { + case CONSTR: + case CONSTR_1_0: case CONSTR_0_1: + case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: + case CONSTR_NOCAF: + { + StgWord i, j; + const StgConInfoTable *con_info = get_con_itbl (obj); - case UPDATE_FRAME: - case CATCH_FRAME: - case UNDERFLOW_FRAME: - case STOP_FRAME: - printClosure((StgClosure*)sp); - continue; + debugBelch("%s(", GET_CON_DESC(con_info)); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + if (i != 0) debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + if (i != 0 || j != 0) debugBelch(", "); + debugBelch("%p#", obj->payload[i+j]); + } + debugBelch(")\n"); + break; + } - case RET_SMALL: { - StgWord c = *sp; - if (c == (StgWord)&stg_ctoi_R1p_info) { - debugBelch("tstg_ctoi_ret_R1p_info\n" ); - } else if (c == (StgWord)&stg_ctoi_R1n_info) { - debugBelch("stg_ctoi_ret_R1n_info\n" ); - } else if (c == (StgWord)&stg_ctoi_F1_info) { - debugBelch("stg_ctoi_ret_F1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_D1_info) { - debugBelch("stg_ctoi_ret_D1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_V_info) { - debugBelch("stg_ctoi_ret_V_info\n" ); - } else if (c == (StgWord)&stg_ap_v_info) { - debugBelch("stg_ap_v_info\n" ); - } else if (c == (StgWord)&stg_ap_f_info) { - debugBelch("stg_ap_f_info\n" ); - } else if (c == (StgWord)&stg_ap_d_info) { - debugBelch("stg_ap_d_info\n" ); - } else if (c == (StgWord)&stg_ap_l_info) { - debugBelch("stg_ap_l_info\n" ); - } else if (c == (StgWord)&stg_ap_n_info) { - debugBelch("stg_ap_n_info\n" ); - } else if (c == (StgWord)&stg_ap_p_info) { - debugBelch("stg_ap_p_info\n" ); - } else if (c == (StgWord)&stg_ap_pp_info) { - debugBelch("stg_ap_pp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppp_info) { - debugBelch("stg_ap_ppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppp_info) { - debugBelch("stg_ap_pppp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppppp_info) { - debugBelch("stg_ap_ppppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppppp_info) { - debugBelch("stg_ap_pppppp_info\n" ); - } else if (c == (StgWord)&stg_ret_v_info) { - debugBelch("stg_ret_v_info\n" ); - } else if (c == (StgWord)&stg_ret_p_info) { - debugBelch("stg_ret_p_info\n" ); - } else if (c == (StgWord)&stg_ret_n_info) { - debugBelch("stg_ret_n_info\n" ); - } else if (c == (StgWord)&stg_ret_f_info) { - debugBelch("stg_ret_f_info\n" ); - } else if (c == (StgWord)&stg_ret_d_info) { - debugBelch("stg_ret_d_info\n" ); - } else if (c == (StgWord)&stg_ret_l_info) { - debugBelch("stg_ret_l_info\n" ); + case FUN: + case FUN_1_0: case FUN_0_1: + case FUN_1_1: case FUN_0_2: case FUN_2_0: + case FUN_STATIC: + debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); + printPtr((StgPtr)obj->header.info); #if defined(PROFILING) - } else if (c == (StgWord)&stg_restore_cccs_info) { - debugBelch("stg_restore_cccs_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; - } else if (c == (StgWord)&stg_restore_cccs_eval_info) { - debugBelch("stg_restore_cccs_eval_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; + debugBelch(", %s", obj->header.prof.ccs->cc->label); #endif - } else { - debugBelch("RET_SMALL (%p)\n", info); - } - StgWord bitmap = info->layout.bitmap; - printSmallBitmap(spBottom, sp+1, - BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); - continue; - } + printStdObjPayload(obj); + break; - case RET_BCO: { - StgBCO *bco; + case PRIM: + debugBelch("PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - bco = ((StgBCO *)sp[1]); + case MUT_PRIM: + debugBelch("MUT_PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - debugBelch("RET_BCO (%p)\n", sp); - printLargeBitmap(spBottom, sp+2, - BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); - continue; - } + case THUNK: + case THUNK_1_0: case THUNK_0_1: + case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: + case THUNK_STATIC: + /* ToDo: will this work for THUNK_STATIC too? */ +#if defined(PROFILING) + printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); +#else + printThunkObject((StgThunk *)obj,"THUNK"); +#endif + break; - case RET_BIG: - debugBelch("RET_BIG (%p)\n", sp); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); - printLargeBitmap(spBottom, - (StgPtr)((StgClosure *) sp)->payload, - bitmap, - bitmap->size); - continue; - case RET_FUN: + case THUNK_SELECTOR: + printStdObjHdr(obj, "THUNK_SELECTOR"); + debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); + break; + + case BCO: + disassemble( (StgBCO*)obj ); + break; + + case AP: { - const StgFunInfoTable *fun_info; - StgRetFun *ret_fun; + StgAP* ap = (StgAP*)obj; + StgWord i; + debugBelch("AP("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->n_args; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; + } - ret_fun = (StgRetFun *)sp; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); - debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); - switch (fun_info->f.fun_type) { - case ARG_GEN: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(fun_info->f.b.bitmap), - BITMAP_SIZE(fun_info->f.b.bitmap)); - break; - case ARG_GEN_BIG: - printLargeBitmap(spBottom, sp+2, - GET_FUN_LARGE_BITMAP(fun_info), - GET_FUN_LARGE_BITMAP(fun_info)->size); - break; - default: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), - BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); - break; + case PAP: + { + StgPAP* pap = (StgPAP*)obj; + StgWord i; + debugBelch("PAP/%d(",(int)pap->arity); + printPtr((StgPtr)pap->fun); + for (i = 0; i < pap->n_args; ++i) { + debugBelch(", "); + printPtr((StgPtr)pap->payload[i]); } - continue; + debugBelch(")\n"); + break; } - default: - debugBelch("unknown object %d\n", (int)info->type); - barf("printStackChunk"); + case AP_STACK: + { + StgAP_STACK* ap = (StgAP_STACK*)obj; + StgWord i; + debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->size; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; } - } -} -static void printStack( StgStack *stack ) -{ - printStackChunk( stack->sp, stack->stack + stack->stack_size ); -} + case IND: + debugBelch("IND("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printTSO( StgTSO *tso ) -{ - printStack( tso->stackobj ); -} + case IND_STATIC: + debugBelch("IND_STATIC("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printStaticObjects( StgClosure *p ) -{ - while (p != END_OF_STATIC_OBJECT_LIST) { - p = UNTAG_STATIC_LIST_PTR(p); - printClosure(p); + case BLACKHOLE: + debugBelch("BLACKHOLE("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; - const StgInfoTable *info = get_itbl(p); - p = *STATIC_LINK(info, p); - } -} + /* Cannot happen -- use default case. + case RET_BCO: + case RET_SMALL: + case RET_BIG: + case RET_FUN: + */ -void printWeakLists() -{ - debugBelch("======= WEAK LISTS =======\n"); + case UPDATE_FRAME: + { + StgUpdateFrame* u = (StgUpdateFrame*)obj; + debugBelch("%s(", info_update_frame(obj)); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->updatee); + debugBelch(")\n"); + break; + } - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - debugBelch("Capability %d:\n", cap_idx); - Capability *cap = capabilities[cap_idx]; - for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case CATCH_FRAME: + { + StgCatchFrame* u = (StgCatchFrame*)obj; + debugBelch("CATCH_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->handler); + debugBelch(")\n"); + break; } - } - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current weaks:\n", gen_idx); - for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case UNDERFLOW_FRAME: + { + StgUnderflowFrame* u = (StgUnderflowFrame*)obj; + debugBelch("UNDERFLOW_FRAME("); + printPtr((StgPtr)u->next_chunk); + debugBelch(")\n"); + break; } - debugBelch("Generation %d old weaks:\n", gen_idx); - for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + + case STOP_FRAME: + { + StgStopFrame* u = (StgStopFrame*)obj; + debugBelch("STOP_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(")\n"); + break; } - } - debugBelch("=========================\n"); -} + case ARR_WORDS: + { + StgWord i; + debugBelch("ARR_WORDS(\""); + for (i=0; ipayload[i]); + debugBelch("\")\n"); + break; + } -void printLargeAndPinnedObjects() -{ - debugBelch("====== PINNED OBJECTS ======\n"); + case MUT_ARR_PTRS_CLEAN: + debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - Capability *cap = capabilities[cap_idx]; + case MUT_ARR_PTRS_DIRTY: + debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Capability %d: Current pinned object block: %p\n", - cap_idx, (void*)cap->pinned_object_block); - for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { - debugBelch("%p\n", (void*)bd); - } - } + case MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("====== LARGE OBJECTS =======\n"); - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current large objects:\n", gen_idx); - for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } + case SMALL_MUT_ARR_PTRS_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Generation %d scavenged large objects:\n", gen_idx); - for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } - } + case SMALL_MUT_ARR_PTRS_DIRTY: + debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("============================\n"); -} + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; -/* -------------------------------------------------------------------------- - * Address printing code - * - * Uses symbol table in (unstripped executable) - * ------------------------------------------------------------------------*/ + case MVAR_CLEAN: + case MVAR_DIRTY: + { + StgMVar* mv = (StgMVar*)obj; -/* -------------------------------------------------------------------------- - * Simple lookup table - * address -> function name - * ------------------------------------------------------------------------*/ + debugBelch("MVAR(head="); + if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->head); + } -static HashTable * add_to_fname_table = NULL; + debugBelch(", tail="); + if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->tail); + } -const char *lookupGHCName( void *addr ) -{ - if (add_to_fname_table == NULL) - return NULL; + debugBelch(", value="); + if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->value); + } + debugBelch(")\n"); - return lookupHashTable(add_to_fname_table, (StgWord)addr); -} + break; + } -/* -------------------------------------------------------------------------- - * Symbol table loading - * ------------------------------------------------------------------------*/ + case TVAR: + { + StgTVar* tv = (StgTVar*)obj; + debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); + break; + } -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame checks for unrelated fields instead of actually used - * macros. - */ -# include + case MUT_VAR_CLEAN: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); + break; + } -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ + case MUT_VAR_DIRTY: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); + break; + } -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} + case WEAK: + debugBelch("WEAK("); + debugBelch("key=%p value=%p finalizer=%p", + (StgPtr)(((StgWeak*)obj)->key), + (StgPtr)(((StgWeak*)obj)->value), + (StgPtr)(((StgWeak*)obj)->finalizer)); + debugBelch(")\n"); + /* ToDo: chase 'link' ? */ + break; -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; + case TSO: + debugBelch("TSO("); + debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); + debugBelch(")\n"); + break; - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } + case STACK: + debugBelch("STACK\n"); + break; - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; +#if 0 + /* Symptomatic of a problem elsewhere, have it fall-through & fail */ + case EVACUATED: + debugBelch("EVACUATED("); + printClosure((StgEvacuated*)obj->evacuee); + debugBelch(")\n"); + break; +#endif - storage_needed = bfd_get_symtab_upper_bound (abfd); + case COMPACT_NFDATA: + debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", + (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); + break; - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); + case TREC_CHUNK: + debugBelch("TREC_CHUNK\n"); + break; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + default: + //barf("printClosure %d",get_itbl(obj)->type); + debugBelch("*** printClosure: unknown type %d ****\n", + (int)get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); + return; + } +} - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); +static void +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) +{ + uint32_t i; + + for(i = 0; i < size; i++, bitmap >>= 1 ) { + debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } + } +} - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); +static void +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) +{ + StgWord bmp; + uint32_t i, j; - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; + i = 0; + for (bmp=0; i < size; bmp++) { + StgWord bitmap = large_bitmap->bitmap[bmp]; + j = 0; + for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { + debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); } } -#else /* USING_LIBBFD */ - -extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) +void +printStackChunk( StgPtr sp, StgPtr spBottom ) { - /* nothing, yet */ -} + const StgInfoTable *info; -#endif /* USING_LIBBFD */ + ASSERT(sp <= spBottom); + for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { -void findPtr(P_ p, int); /* keep gcc -Wall happy */ + info = get_itbl((StgClosure *)sp); -int searched = 0; + switch (info->type) { -static int -findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) -{ - StgPtr q, r, end; - for (; bd; bd = bd->link) { - searched++; - for (q = bd->start; q < bd->free; q++) { - if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { - if (i < arr_size) { - for (r = bd->start; r < bd->free; r = end) { - // skip over zeroed-out slop - while (*r == 0) r++; - if (!LOOKS_LIKE_CLOSURE_PTR(r)) { - debugBelch("%p found at %p, no closure at %p\n", - p, q, r); - break; - } - end = r + closure_sizeW((StgClosure*)r); - if (q < end) { - debugBelch("%p = ", r); - printClosure((StgClosure *)r); - arr[i++] = r; - break; - } - } - if (r >= bd->free) { - debugBelch("%p found at %p, closure?", p, q); - } - } else { - return i; - } + case UPDATE_FRAME: + case CATCH_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + printClosure((StgClosure*)sp); + continue; + + case RET_SMALL: { + StgWord c = *sp; + if (c == (StgWord)&stg_ctoi_R1p_info) { + debugBelch("tstg_ctoi_ret_R1p_info\n" ); + } else if (c == (StgWord)&stg_ctoi_R1n_info) { + debugBelch("stg_ctoi_ret_R1n_info\n" ); + } else if (c == (StgWord)&stg_ctoi_F1_info) { + debugBelch("stg_ctoi_ret_F1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_D1_info) { + debugBelch("stg_ctoi_ret_D1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_V_info) { + debugBelch("stg_ctoi_ret_V_info\n" ); + } else if (c == (StgWord)&stg_ap_v_info) { + debugBelch("stg_ap_v_info\n" ); + } else if (c == (StgWord)&stg_ap_f_info) { + debugBelch("stg_ap_f_info\n" ); + } else if (c == (StgWord)&stg_ap_d_info) { + debugBelch("stg_ap_d_info\n" ); + } else if (c == (StgWord)&stg_ap_l_info) { + debugBelch("stg_ap_l_info\n" ); + } else if (c == (StgWord)&stg_ap_n_info) { + debugBelch("stg_ap_n_info\n" ); + } else if (c == (StgWord)&stg_ap_p_info) { + debugBelch("stg_ap_p_info\n" ); + } else if (c == (StgWord)&stg_ap_pp_info) { + debugBelch("stg_ap_pp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppp_info) { + debugBelch("stg_ap_ppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppp_info) { + debugBelch("stg_ap_pppp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppppp_info) { + debugBelch("stg_ap_ppppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppppp_info) { + debugBelch("stg_ap_pppppp_info\n" ); + } else if (c == (StgWord)&stg_ret_v_info) { + debugBelch("stg_ret_v_info\n" ); + } else if (c == (StgWord)&stg_ret_p_info) { + debugBelch("stg_ret_p_info\n" ); + } else if (c == (StgWord)&stg_ret_n_info) { + debugBelch("stg_ret_n_info\n" ); + } else if (c == (StgWord)&stg_ret_f_info) { + debugBelch("stg_ret_f_info\n" ); + } else if (c == (StgWord)&stg_ret_d_info) { + debugBelch("stg_ret_d_info\n" ); + } else if (c == (StgWord)&stg_ret_l_info) { + debugBelch("stg_ret_l_info\n" ); +#if defined(PROFILING) + } else if (c == (StgWord)&stg_restore_cccs_info) { + debugBelch("stg_restore_cccs_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; + } else if (c == (StgWord)&stg_restore_cccs_eval_info) { + debugBelch("stg_restore_cccs_eval_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; +#endif + } else { + debugBelch("RET_SMALL (%p)\n", info); } + StgWord bitmap = info->layout.bitmap; + printSmallBitmap(spBottom, sp+1, + BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); + continue; } - } - return i; -} -void -findPtr(P_ p, int follow) -{ - uint32_t g, n; - bdescr *bd; - const int arr_size = 1024; - StgPtr arr[arr_size]; - int i = 0; - searched = 0; + case RET_BCO: { + StgBCO *bco; -#if 0 - // We can't search the nursery, because we don't know which blocks contain - // valid data, because the bd->free pointers in the nursery are only reset - // just before a block is used. - for (n = 0; n < n_capabilities; n++) { - bd = nurseries[i].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - } -#endif + bco = ((StgBCO *)sp[1]); - for (g = 0; g < RtsFlags.GcFlags.generations; g++) { - bd = generations[g].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - bd = generations[g].large_objects; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - for (n = 0; n < n_capabilities; n++) { - i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, - arr, arr_size, i); - i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, - arr, arr_size, i); - } - if (i >= arr_size) return; - } - if (follow && i == 1) { - debugBelch("-->\n"); - findPtr(arr[0], 1); - } -} + debugBelch("RET_BCO (%p)\n", sp); + printLargeBitmap(spBottom, sp+2, + BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); + continue; + } -const char *what_next_strs[] = { - [0] = "(unknown)", - [ThreadRunGHC] = "ThreadRunGHC", - [ThreadInterpret] = "ThreadInterpret", - [ThreadKilled] = "ThreadKilled", - [ThreadComplete] = "ThreadComplete" -}; + case RET_BIG: + debugBelch("RET_BIG (%p)\n", sp); + StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + printLargeBitmap(spBottom, + (StgPtr)((StgClosure *) sp)->payload, + bitmap, + bitmap->size); + continue; + case RET_FUN: + { + const StgFunInfoTable *fun_info; + StgRetFun *ret_fun; -#else /* DEBUG */ -void printPtr( StgPtr p ) -{ - debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); + ret_fun = (StgRetFun *)sp; + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); + switch (fun_info->f.fun_type) { + case ARG_GEN: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(fun_info->f.b.bitmap), + BITMAP_SIZE(fun_info->f.b.bitmap)); + break; + case ARG_GEN_BIG: + printLargeBitmap(spBottom, sp+2, + GET_FUN_LARGE_BITMAP(fun_info), + GET_FUN_LARGE_BITMAP(fun_info)->size); + break; + default: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), + BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + break; + } + continue; + } + + default: + debugBelch("unknown object %d\n", (int)info->type); + barf("printStackChunk"); + } + } } -void printObj( StgClosure *obj ) +void printStack( StgStack *stack ) { - debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); + printStackChunk( stack->sp, stack->stack + stack->stack_size ); } -#endif /* DEBUG */ - /* ----------------------------------------------------------------------------- Closure types ===================================== rts/Printer.h ===================================== @@ -20,8 +20,9 @@ const char * info_type ( const StgClosure *closure ); const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); -#if defined(DEBUG) extern void printClosure ( const StgClosure *obj ); + +#if defined(DEBUG) extern void printStackChunk ( StgPtr sp, StgPtr spLim ); extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); ===================================== rts/StgMiscClosures.cmm ===================================== @@ -573,6 +573,9 @@ INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") { foreign "C" barf("MSG_NULL object (%p) entered!", R1) never returns; } +INFO_TABLE_CONSTR(stg_MSG_CLONE_STACK,3,0,0,PRIM,"MSG_CLONE_STACK","MSG_CLONE_STACK") +{ foreign "C" barf("stg_MSG_CLONE_STACK object (%p) entered!", R1) never returns; } + /* ---------------------------------------------------------------------------- END_TSO_QUEUE ===================================== rts/package.conf.in ===================================== @@ -194,6 +194,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,_findPtr" #endif + , "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" #else "-Wl,-u,base_GHCziTopHandler_runIO_closure" , "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" @@ -308,6 +309,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,findPtr" #endif + , "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" #endif /* Pick up static libraries in preference over dynamic if in earlier search ===================================== rts/rts.cabal.in ===================================== @@ -286,6 +286,7 @@ library "-Wl,-u,_hs_atomicwrite8" "-Wl,-u,_hs_atomicwrite16" "-Wl,-u,_hs_atomicwrite32" + "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -367,6 +368,7 @@ library "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" + "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -410,6 +412,7 @@ library Arena.c Capability.c CheckUnload.c + CloneStack.c ClosureFlags.c Disassembler.c FileLock.c ===================================== testsuite/tests/rts/all.T ===================================== @@ -418,3 +418,7 @@ test('T17088', compile_and_run, ['-rtsopts -O2']) test('T15427', normal, compile_and_run, ['']) + +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c']) + +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack +import Foreign +import Foreign.C.Types (CUInt) + +foreign import ccall "expectClosureTypes" expectClosureTypes:: StackSnapshot# -> Ptr CUInt -> Int -> IO () + +main :: IO () +main = do + stackSnapshot <- cloneMyStack + + let (StackSnapshot stack) = stackSnapshot + let expectedClosureTypes = [34 -- CATCH_FRAME + ,36 -- STOP_FRAME + ] + withArray expectedClosureTypes (\ptr -> expectClosureTypes stack ptr (length expectedClosureTypes)) ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -0,0 +1,53 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "rts/Messages.h" + + +void expectStacksToBeEqual(StgStack *clonedStack, StgTSO *tso) { + StgStack *liveStack = tso->stackobj; + + if(liveStack->header.info != clonedStack->header.info){ + barf("info table pointer not equal! Expected same pointer address, but got %p and %p", liveStack->header.info, clonedStack->header.info); + } + + StgInfoTable *info = INFO_PTR_TO_STRUCT(liveStack->header.info); + + if (info->type != STACK) { + barf("Expected a closure of type STACK!"); + } + + if(liveStack->stack_size != clonedStack->stack_size){ + barf("Expected same stack_size!"); + } + + if(liveStack->dirty != clonedStack->dirty){ + barf("Expected same dirty flags!"); + } + + if(liveStack->marking != clonedStack->marking){ + barf("Expected same marking flags!"); + } + + for(StgWord i = liveStack->stack_size - 1; (liveStack->stack + i) >= liveStack->sp; i--){ + if(liveStack->stack[i] != clonedStack->stack[i]){ + barf("Expected stack word %lu to be equal on both stacks.", i); + } + } +} + +void expectClosureTypes(StgStack *stack, unsigned int types[], size_t typesSize){ + StgPtr sp = stack->sp; + StgPtr spBottom = stack->stack + stack->stack_size; + + for (StgWord i = 0; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp), i++) { + const StgInfoTable *info = get_itbl((StgClosure *)sp); + + if(i >= typesSize) { + barf("Stack size exceeds expectation!"); + } + + if(info->type != types[i]) { + barf("Wrong closure type on stack! Expected %u but got %u", types[i], info->type); + } + } +} ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -0,0 +1,46 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#, ThreadId#) +import GHC.Conc.Sync (ThreadId(..)) +import GHC.Stack.CloneStack +import Control.Concurrent +import GHC.Conc + +foreign import ccall "expectStacksToBeEqual" expectStacksToBeEqual:: StackSnapshot# -> ThreadId# -> IO () + +main :: IO () +main = do + mVarToBeBlockedOn <- newEmptyMVar + threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + + waitUntilBlocked threadId + + stackSnapshot <- cloneThreadStack threadId + + let (StackSnapshot stack) = stackSnapshot + let (ThreadId tid#) = threadId + expectStacksToBeEqual stack tid# + +immediatelyBlocking :: MVar Int -> IO () +immediatelyBlocking mVarToBeBlockedOn = do + takeMVar mVarToBeBlockedOn + return () + +waitUntilBlocked :: ThreadId -> IO () +waitUntilBlocked tid = do + blocked <- isBlocked tid + if blocked then + return () + else + do + threadDelay 100000 + waitUntilBlocked tid + +isBlocked:: ThreadId -> IO Bool +isBlocked = fmap isThreadStatusBlocked . threadStatus + +isThreadStatusBlocked :: ThreadStatus -> Bool +isThreadStatusBlocked (ThreadBlocked _) = True +isThreadStatusBlocked _ = False ===================================== utils/deriveConstants/Main.hs ===================================== @@ -924,4 +924,3 @@ execute verbose prog args ec <- rawSystem prog args unless (ec == ExitSuccess) $ die ("Executing " ++ show prog ++ " failed") - ===================================== utils/deriveConstants/hie.yaml ===================================== @@ -0,0 +1 @@ +cradle: {cabal: {component: "exe:deriveConstants"}} ===================================== utils/genprimopcode/Main.hs ===================================== @@ -878,6 +878,7 @@ ppType (TyApp (TyCon "ThreadId#") []) = "threadIdPrimTy" ppType (TyApp (TyCon "ForeignObj#") []) = "foreignObjPrimTy" ppType (TyApp (TyCon "BCO") []) = "bcoPrimTy" ppType (TyApp (TyCon "Compact#") []) = "compactPrimTy" +ppType (TyApp (TyCon "StackSnapshot#") []) = "stackSnapshotPrimTy" ppType (TyApp (TyCon "()") []) = "unitTy" -- unitTy is GHC.Builtin.Types's name for () ppType (TyVar "a") = "alphaTy" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9be8e25c847e3260b1b715209e0fe8f0e1d6a043 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9be8e25c847e3260b1b715209e0fe8f0e1d6a043 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 10:52:55 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 12 Oct 2020 06:52:55 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] Increase -A default to 4MB. Message-ID: <5f843587f3b5c_80bf3ff96c183333f4@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: 7e564eb5 by Andreas Klebinger at 2020-10-12T12:52:42+02:00 Increase -A default to 4MB. This gives a small increase in performance under most circumstances. For single threaded GC the improvement is on the order of 1-2%. For multi threaded GC the results are quite noisy but seem to fall into the same ballpark. Fixes #16499 - - - - - 3 changed files: - docs/users_guide/runtime_control.rst - rts/RtsFlags.c - testsuite/tests/rts/T9579/Makefile Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -418,7 +418,7 @@ performance. .. rts-flag:: -A ⟨size⟩ - :default: 1MB + :default: 4MB .. index:: single: allocation area, size @@ -427,15 +427,22 @@ performance. collector. The allocation area (actually generation 0 step 0) is fixed and is never resized (unless you use :rts-flag:`-H [⟨size⟩]`, below). - Increasing the allocation area size may or may not give better - performance (a bigger allocation area means worse cache behaviour - but fewer garbage collections and less promotion). + Optimal settings depend on the actual machine, program, and other RTS options. + Increasing the allocation area size means worse cache behaviour + but fewer garbage collections and less promotion. + + In general settings >= 4MB can reduce performance in some cases, in particular for single + threaded operation. However in a parallel setting increasing the allocation area + to ``16MB``, or even ``64MB`` can increase gc throughput significantly. With only 1 generation (e.g. ``-G1``, see :rts-flag:`-G ⟨generations⟩`) the ``-A`` option specifies the minimum allocation area, since the actual size of the allocation area will be resized according to the amount of data in the heap (see :rts-flag:`-F ⟨factor⟩`, below). + When heap profiling using a smaller allocation area can increase accuracy as more frequent + major garbage collections also results in more frequent heap snapshots + .. rts-flag:: -AL ⟨size⟩ :default: :rts-flag:`-A <-A ⟨size⟩>` value ===================================== rts/RtsFlags.c ===================================== @@ -153,10 +153,11 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.stkChunkSize = (32 * 1024) / sizeof(W_); RtsFlags.GcFlags.stkChunkBufferSize = (1 * 1024) / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (1024 * 1024) / BLOCK_SIZE; + /* -A default. See #16499 for a discussion about the tradeoffs */ + RtsFlags.GcFlags.minAllocAreaSize = (4 * 1024 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.largeAllocLim = 0; /* defaults to minAllocAreasize */ RtsFlags.GcFlags.nurseryChunkSize = 0; - RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; /* -O default */ RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ ===================================== testsuite/tests/rts/T9579/Makefile ===================================== @@ -3,43 +3,43 @@ include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk T9579_stackoverflow_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A1m -K1m \ -outputdir tmp_T9579_stackoverflow_rtsnone \ StackOverflow.hs -o T9579_stackoverflow_rtsnone T9579_stackoverflow_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A1m -K1m \ -outputdir tmp_T9579_stackoverflow_rtssome \ StackOverflow.hs -o T9579_stackoverflow_rtssome T9579_stackoverflow_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -K1m \ -outputdir tmp_T9579_stackoverflow_rtsall \ StackOverflow.hs -o T9579_stackoverflow_rtsall T9579_stackoverflow_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -K1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_stackoverflow_rtsall_no_suggestions \ StackOverflow.hs -o T9579_stackoverflow_rtsall_no_suggestions T9579_outofheap_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A1m -M1m \ -outputdir tmp_T9579_outofheap_rtsnone \ OutOfHeap.hs -o T9579_outofheap_rtsnone T9579_outofheap_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A1m -M1m \ -outputdir tmp_T9579_outofheap_rtssome \ OutOfHeap.hs -o T9579_outofheap_rtssome T9579_outofheap_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -M1m \ -outputdir tmp_T9579_outofheap_rtsall \ OutOfHeap.hs -o T9579_outofheap_rtsall T9579_outofheap_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -M1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_outofheap_rtsall_no_suggestions \ OutOfHeap.hs -o T9579_outofheap_rtsall_no_suggestions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7e564eb57bc7985f2996960ebf33ce38e1ae8845 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7e564eb57bc7985f2996960ebf33ce38e1ae8845 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 12:28:55 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 12 Oct 2020 08:28:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports-9.0 Message-ID: <5f844c0787db3_80b3f8468b8cf3c183582f8@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/backports-9.0 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports-9.0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 13:10:45 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 12 Oct 2020 09:10:45 -0400 Subject: [Git][ghc/ghc][wip/backports-9.0] 2 commits: Bignum: match on small Integer/Natural Message-ID: <5f8455d554ca0_80b3f8458305c5c183649d5@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed to branch wip/backports-9.0 at Glasgow Haskell Compiler / GHC Commits: a740aa0b by Sylvain Henry at 2020-10-12T15:10:13+02:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - d09e7e41 by Sylvain Henry at 2020-10-12T15:10:30+02:00 Bignum: fix bigNatCompareWord# bug (#18813) (cherry picked from commit 74ee1237bf243dd7d8b758a53695575c364c3088) - - - - - 7 changed files: - compiler/GHC/Core/SimpleOpt.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - + testsuite/tests/lib/integer/T18813.hs - + testsuite/tests/lib/integer/T18813.stdout - testsuite/tests/lib/integer/all.T - + testsuite/tests/lib/integer/bignumMatch.hs - + testsuite/tests/lib/integer/bignumMatch.stderr Changes: ===================================== compiler/GHC/Core/SimpleOpt.hs ===================================== @@ -1257,13 +1257,24 @@ exprIsLiteral_maybe env@(_, id_unf) e -> Just l Var v | Just rhs <- expandUnfolding_maybe (id_unf v) - , Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env rhs + , Just b <- matchBignum env rhs + -> Just b + e + | Just b <- matchBignum env e + -> Just b + + | otherwise + -> Nothing + where + matchBignum env e + | Just (_env,_fb,dc,_tys,[arg]) <- exprIsConApp_maybe env e , Just (LitNumber _ i) <- exprIsLiteral_maybe env arg - -> if + = if | dc == naturalNSDataCon -> Just (mkLitNatural i) | dc == integerISDataCon -> Just (mkLitInteger i) | otherwise -> Nothing - _ -> Nothing + | otherwise + = Nothing {- Note [exprIsLambda_maybe] ===================================== libraries/ghc-bignum/src/GHC/Num/BigNat.hs ===================================== @@ -339,7 +339,7 @@ bigNatCompareWord# a b | bigNatIsZero a = cmpW# 0## b | isTrue# (wordArraySize# a ># 1#) = GT | True - = cmpW# (indexWordArray# a 1#) b + = cmpW# (indexWordArray# a 0#) b -- | Compare a BigNat and a Word bigNatCompareWord :: BigNat# -> Word -> Ordering ===================================== testsuite/tests/lib/integer/T18813.hs ===================================== @@ -0,0 +1,22 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# OPTIONS_GHC -O0 #-} + +import GHC.Exts +import GHC.Num.BigNat (bigNatCompareWord#, bigNatFromWord#) +import GHC.Num.Integer (integerGcd) + +main :: IO () +main = do + let + x = noinline (14205695611797621937 :: Integer) + y = noinline (2 :: Word) + print (integerGcd x (toInteger y)) + print (toInteger (gcd (fromInteger x) y :: Word)) + + let + x@(W# x#) = 1 :: Word + !x' = bigNatFromWord# x# + print (bigNatCompareWord# x' x#) + print (compare x x) ===================================== testsuite/tests/lib/integer/T18813.stdout ===================================== @@ -0,0 +1,4 @@ +1 +1 +EQ +EQ ===================================== testsuite/tests/lib/integer/all.T ===================================== @@ -10,6 +10,8 @@ test('gcdeInteger', normal, compile_and_run, ['']) test('integerPowMod', [], compile_and_run, ['']) test('integerGcdExt', [], compile_and_run, ['']) test('integerRecipMod', [], compile_and_run, ['']) +test('bignumMatch', [], compile, ['']) +test('T18813', [], compile_and_run, ['']) # skip ghci as it doesn't support unboxed tuples test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, ['']) ===================================== testsuite/tests/lib/integer/bignumMatch.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE MagicHash #-} +{-# OPTIONS_GHC -ddump-rule-firings -O0 -v0 #-} + +module Test where + +import GHC.Num.Integer + +foo :: Integer +foo = IS 45# `integerAdd` (IS 0# `integerMul` IS 18#) ===================================== testsuite/tests/lib/integer/bignumMatch.stderr ===================================== @@ -0,0 +1,2 @@ +Rule fired: integerMul (BUILTIN) +Rule fired: integerAdd (BUILTIN) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15c4eb1f774c15d653358e9dcae1e55791c4bbfd...d09e7e41cf79fe981a61eae46a93d8881859ff1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/15c4eb1f774c15d653358e9dcae1e55791c4bbfd...d09e7e41cf79fe981a61eae46a93d8881859ff1f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 13:27:31 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 09:27:31 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] Fix Printer.c missing prototype warnings Message-ID: <5f8459c383843_80b3f8454cd0b8c18372174@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 18f27693 by Sven Tennie at 2020-10-12T15:27:17+02:00 Fix Printer.c missing prototype warnings - - - - - 2 changed files: - rts/Printer.c - rts/Printer.h Changes: ===================================== rts/Printer.c ===================================== @@ -17,6 +17,7 @@ #include "sm/GCThread.h" #include "Hash.h" #include "Printer.h" +#include "rts/PrinterAPI.h" #include "RtsUtils.h" #if defined(PROFILING) ===================================== rts/Printer.h ===================================== @@ -21,9 +21,9 @@ const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); extern void printClosure ( const StgClosure *obj ); +extern void printStackChunk ( StgPtr sp, StgPtr spLim ); #if defined(DEBUG) -extern void printStackChunk ( StgPtr sp, StgPtr spLim ); extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); extern void printStaticObjects ( StgClosure *obj ); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18f276934c09afcffd10146f8d219cc2bf428cc1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18f276934c09afcffd10146f8d219cc2bf428cc1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 14:02:20 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 10:02:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/riscv-revived Message-ID: <5f8461ecd9cec_80b3f8494254e4818378022@gitlab.haskell.org.mail> Sven Tennie pushed new branch wip/riscv-revived at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/riscv-revived You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 14:09:43 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 10:09:43 -0400 Subject: [Git][ghc/ghc][wip/riscv-revived] Fix linting issue Message-ID: <5f8463a79dcac_80b107f46d418383313@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/riscv-revived at Glasgow Haskell Compiler / GHC Commits: 2faf4e51 by Sven Tennie at 2020-10-12T16:09:30+02:00 Fix linting issue - - - - - 1 changed file: - rts/StgCRun.c Changes: ===================================== rts/StgCRun.c ===================================== @@ -970,7 +970,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { #endif -#ifdef riscv64_HOST_ARCH +#if defined(riscv64_HOST_ARCH) StgRegTable * StgRun(StgFunPtr f, StgRegTable *basereg) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2faf4e51a26829df522ef422483ed63976736b16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2faf4e51a26829df522ef422483ed63976736b16 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 14:11:12 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 12 Oct 2020 10:11:12 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Remove the dependency on the ghc-linters stage Message-ID: <5f8464006f15d_80b3f8477cd9d18183885dd@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 431aea3e by Sylvain Henry at 2020-10-12T10:11:02-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 22 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - + testsuite/tests/th/T18740d.hs - + testsuite/tests/th/T18740d.stderr - testsuite/tests/th/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -248,7 +248,7 @@ validate-x86_64-linux-deb9-unreg-hadrian: hadrian-ghc-in-ghci: stage: quick-build - needs: [ghc-linters, lint-linters, lint-submods] + needs: [lint-linters, lint-submods] image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" before_script: # workaround for docker permissions @@ -282,7 +282,7 @@ hadrian-ghc-in-ghci: .lint-params: stage: lint - needs: [ghc-linters, lint-submods] + needs: [lint-submods] tags: - lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -9,18 +9,20 @@ {-# LANGUAGE CPP #-} -module GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) where +module GHC.Core.Opt.DmdAnal + ( DmdAnalOpts(..) + , dmdAnalProgram + ) +where #include "HsVersions.h" import GHC.Prelude -import GHC.Driver.Session import GHC.Core.Opt.WorkWrap.Utils import GHC.Types.Demand -- All of it import GHC.Core import GHC.Core.Multiplicity ( scaledThing ) -import GHC.Core.Seq ( seqBinds ) import GHC.Utils.Outputable import GHC.Types.Var.Env import GHC.Types.Var.Set @@ -29,7 +31,6 @@ import Data.List ( mapAccumL ) import GHC.Core.DataCon import GHC.Types.ForeignCall ( isSafeForeignCall ) import GHC.Types.Id -import GHC.Types.Id.Info import GHC.Core.Utils import GHC.Core.TyCon import GHC.Core.Type @@ -41,7 +42,6 @@ import GHC.Utils.Panic import GHC.Data.Maybe ( isJust ) import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) -import GHC.Utils.Error ( dumpIfSet_dyn, DumpFormat (..) ) import GHC.Types.Unique.Set {- @@ -52,14 +52,21 @@ import GHC.Types.Unique.Set ************************************************************************ -} -dmdAnalProgram :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram -dmdAnalProgram dflags fam_envs binds = do - let env = emptyAnalEnv dflags fam_envs - let binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds - dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ - dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds - -- See Note [Stamp out space leaks in demand analysis] - seqBinds binds_plus_dmds `seq` return binds_plus_dmds +-- | Options for the demand analysis +data DmdAnalOpts = DmdAnalOpts + { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries + } + +-- | Outputs a new copy of the Core program in which binders have been annotated +-- with demand and strictness information. +-- +-- Note: use `seqBinds` on the result to avoid leaks due to lazyness (cf Note +-- [Stamp out space leaks in demand analysis]) +dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> CoreProgram -> CoreProgram +dmdAnalProgram opts fam_envs binds = binds_plus_dmds + where + env = emptyAnalEnv opts fam_envs + binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds -- Analyse a (group of) top-level binding(s) dmdAnalTopBind :: AnalEnv @@ -1235,31 +1242,13 @@ type DFunFlag = Bool -- indicates if the lambda being considered is in the notArgOfDfun :: DFunFlag notArgOfDfun = False -{- Note [dmdAnalEnv performance] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -It's tempting to think that removing the dynflags from AnalEnv would improve -performance. After all when analysing recursive groups we end up allocating -a lot of environments. However this is not the case. - -We do get some performance by making AnalEnv smaller. However very often we -defer computation which means we have to capture the dynflags in the thunks -we allocate. Doing this naively in practice causes more allocation than the -removal of DynFlags saves us. - -In theory it should be possible to make this better if we are stricter in -the analysis and therefore allocate fewer thunks. But I couldn't get there -in a few hours and overall the impact on GHC here is small, and there are -bigger fish to fry. So for new the env will keep a reference to the flags. --} - -data AnalEnv - = AE { ae_dflags :: DynFlags -- See Note [dmdAnalEnv performance] - , ae_sigs :: SigEnv - , ae_virgin :: Bool -- True on first iteration only +data AnalEnv = AE + { ae_strict_dicts :: !Bool -- ^ Enable strict dict + , ae_sigs :: !SigEnv + , ae_virgin :: !Bool -- ^ True on first iteration only -- See Note [Initialising strictness] - , ae_fam_envs :: FamInstEnvs - } + , ae_fam_envs :: !FamInstEnvs + } -- We use the se_env to tell us whether to -- record info about a variable in the DmdEnv @@ -1271,17 +1260,18 @@ data AnalEnv type SigEnv = VarEnv (StrictSig, TopLevelFlag) instance Outputable AnalEnv where - ppr (AE { ae_sigs = env, ae_virgin = virgin }) - = text "AE" <+> braces (vcat - [ text "ae_virgin =" <+> ppr virgin - , text "ae_sigs =" <+> ppr env ]) - -emptyAnalEnv :: DynFlags -> FamInstEnvs -> AnalEnv -emptyAnalEnv dflags fam_envs - = AE { ae_dflags = dflags - , ae_sigs = emptySigEnv - , ae_virgin = True - , ae_fam_envs = fam_envs + ppr env = text "AE" <+> braces (vcat + [ text "ae_virgin =" <+> ppr (ae_virgin env) + , text "ae_strict_dicts =" <+> ppr (ae_strict_dicts env) + , text "ae_sigs =" <+> ppr (ae_sigs env) + ]) + +emptyAnalEnv :: DmdAnalOpts -> FamInstEnvs -> AnalEnv +emptyAnalEnv opts fam_envs + = AE { ae_strict_dicts = dmd_strict_dicts opts + , ae_sigs = emptySigEnv + , ae_virgin = True + , ae_fam_envs = fam_envs } emptySigEnv :: SigEnv @@ -1334,7 +1324,7 @@ findBndrDmd env arg_of_dfun dmd_ty id id_ty = idType id strictify dmd - | gopt Opt_DictsStrict (ae_dflags env) + | ae_strict_dicts env -- We never want to strictify a recursive let. At the moment -- annotateBndr is only call for non-recursive lets; if that -- changes, we need a RecFlag parameter and another guard here. ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -24,7 +24,7 @@ import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Types.Id.Info import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) -import GHC.Core.Utils ( mkTicks, stripTicksTop ) +import GHC.Core.Utils ( mkTicks, stripTicksTop, dumpIdInfoOfProgram ) import GHC.Core.Lint ( endPass, lintPassResult, dumpPassResult, lintAnnots ) import GHC.Core.Opt.Simplify ( simplTopBinds, simplExpr, simplRules ) @@ -41,15 +41,17 @@ import GHC.Utils.Error ( withTiming, withTimingD, DumpFormat (..) ) import GHC.Types.Basic import GHC.Types.Var.Set import GHC.Types.Var.Env +import GHC.Types.Demand import GHC.Core.Opt.LiberateCase ( liberateCase ) import GHC.Core.Opt.StaticArgs ( doStaticArgs ) import GHC.Core.Opt.Specialise ( specProgram) import GHC.Core.Opt.SpecConstr ( specConstrProgram) -import GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) +import GHC.Core.Opt.DmdAnal import GHC.Core.Opt.CprAnal ( cprAnalProgram ) import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) +import GHC.Core.Seq (seqBinds) import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Unit.Module.Env @@ -484,7 +486,7 @@ doCorePass CoreDoExitify = {-# SCC "Exitify" #-} doPass exitifyProgram doCorePass CoreDoDemand = {-# SCC "DmdAnal" #-} - doPassDFM dmdAnalProgram + doPassDFM dmdAnal doCorePass CoreDoCpr = {-# SCC "CprAnal" #-} doPassDFM cprAnalProgram @@ -1074,3 +1076,16 @@ transferIdInfo exported_id local_id (ruleInfo local_info) -- Remember to set the function-name field of the -- rules as we transfer them from one function to another + + + +dmdAnal :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram +dmdAnal dflags fam_envs binds = do + let opts = DmdAnalOpts + { dmd_strict_dicts = gopt Opt_DictsStrict dflags + } + binds_plus_dmds = dmdAnalProgram opts fam_envs binds + Err.dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ + dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds + -- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal + seqBinds binds_plus_dmds `seq` return binds_plus_dmds ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2247,8 +2247,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] --------------- Expressions ----------------- repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp)) -repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str - | otherwise = repVar str +repVarOrCon vc str + | isVarNameSpace ns = repVar str -- Both type and term variables (#18740) + | otherwise = repCon str + where + ns = nameNameSpace vc repVar :: Core TH.Name -> MetaM (Core (M TH.Exp)) repVar (MkC s) = rep2 varEName [s] ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} {- (c) The GRASP/AQUA Project, Glasgow University, 1992-2006 @@ -1006,6 +1007,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName can be promoted to the type level and its promoted variant is in scope, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1041,6 +1053,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1055,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -755,6 +755,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -772,9 +773,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1144,4 +1167,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/T18740d.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T18740d where + +import Language.Haskell.TH + +-- If we used 'ConE' here, then we would expect this error message: +-- +-- Illegal term-level use of the type constructor ‘Bool’ +-- imported from ‘Prelude’ at T18740d.hs:3:8-14 +-- (and originally defined in ‘GHC.Types’) +-- +-- But we used 'VarE', so the error message should say: +-- +-- Illegal variable name: ‘Bool’ +-- +e1 = $(return (VarE ''Bool)) ===================================== testsuite/tests/th/T18740d.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740d.hs:17:7: error: + • Illegal variable name: ‘Bool’ + When splicing a TH expression: GHC.Types.Bool + • In the untyped splice: $(return (VarE ''Bool)) ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,5 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) +test('T18740d', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f283f889f27a50c195feed0d62127d067ec1c8a8...431aea3ecec5acafcdd71f24a48562d9f13121b9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f283f889f27a50c195feed0d62127d067ec1c8a8...431aea3ecec5acafcdd71f24a48562d9f13121b9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 14:36:42 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Mon, 12 Oct 2020 10:36:42 -0400 Subject: [Git][ghc/ghc][wip/riscv-revived] Fix linting issue: Incomplete pattern match Message-ID: <5f8469fabcd3_80b3f849627c5b818391539@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/riscv-revived at Glasgow Haskell Compiler / GHC Commits: 3b01b2b1 by Sven Tennie at 2020-10-12T16:36:30+02:00 Fix linting issue: Incomplete pattern match - - - - - 1 changed file: - compiler/GHC/CmmToAsm.hs Changes: ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -170,6 +170,7 @@ nativeCodeGen dflags this_mod modLoc h us cmms ArchAlpha -> panic "nativeCodeGen: No NCG for Alpha" ArchMipseb -> panic "nativeCodeGen: No NCG for mipseb" ArchMipsel -> panic "nativeCodeGen: No NCG for mipsel" + ArchRiscV64 -> panic "nativeCodeGen: No NCG for RiscV64" ArchUnknown -> panic "nativeCodeGen: No NCG for unknown arch" ArchJavaScript-> panic "nativeCodeGen: No NCG for JavaScript" @@ -1194,4 +1195,3 @@ initNCGConfig dflags = NCGConfig , ncgDwarfUnwindings = debugLevel dflags >= 1 , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. } - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b01b2b15a28558ec411561567ebe211eaa1e3a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b01b2b15a28558ec411561567ebe211eaa1e3a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 15:45:00 2020 From: gitlab at gitlab.haskell.org (davean) Date: Mon, 12 Oct 2020 11:45:00 -0400 Subject: [Git][ghc/ghc][wip/testing] Look in toolchain Message-ID: <5f8479fc2374_80b3f8463baf2f81839224a@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: 2e206947 by davean at 2020-10-12T11:44:58-04:00 Look in toolchain - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -285,6 +285,7 @@ hadrian-ghc-in-ghci: - "echo $PATH" - "echo $SHELL" - which autoreconf + - "ls toolchain" - .gitlab/ci.sh setup - .gitlab/ci.sh configure - .gitlab/ci.sh build_make View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e206947dca266210aecd0389aa07506fb9d29bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2e206947dca266210aecd0389aa07506fb9d29bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:07:12 2020 From: gitlab at gitlab.haskell.org (davean) Date: Mon, 12 Oct 2020 12:07:12 -0400 Subject: [Git][ghc/ghc][wip/testing] testing output Message-ID: <5f847f30924c5_80b3f83761c085c18396097@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: 76dbbf60 by davean at 2020-10-12T12:07:11-04:00 testing output - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -285,6 +285,8 @@ hadrian-ghc-in-ghci: - "echo $PATH" - "echo $SHELL" - which autoreconf + - pwd + - ls - "ls toolchain" - .gitlab/ci.sh setup - .gitlab/ci.sh configure View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76dbbf6092a0247f87961e76168d9bddc0fdb757 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76dbbf6092a0247f87961e76168d9bddc0fdb757 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:09:43 2020 From: gitlab at gitlab.haskell.org (davean) Date: Mon, 12 Oct 2020 12:09:43 -0400 Subject: [Git][ghc/ghc][wip/testing] Trying to debug why we can't see something that is actually there. Message-ID: <5f847fc775e56_80b84382281839684c@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: f78f6652 by davean at 2020-10-12T12:09:42-04:00 Trying to debug why we can't see something that is actually there. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -287,6 +287,8 @@ hadrian-ghc-in-ghci: - which autoreconf - pwd - ls + - sleep 5 + - ls - "ls toolchain" - .gitlab/ci.sh setup - .gitlab/ci.sh configure View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f78f66521c94839e8df4a6a4cd9199f5a6a65a4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f78f66521c94839e8df4a6a4cd9199f5a6a65a4b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:22:44 2020 From: gitlab at gitlab.haskell.org (davean) Date: Mon, 12 Oct 2020 12:22:44 -0400 Subject: [Git][ghc/ghc][wip/testing] Check things for carter Message-ID: <5f8482d45f1ab_80b3f837ac9ad641839905f@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: b15a8c77 by davean at 2020-10-12T12:22:43-04:00 Check things for carter - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -285,10 +285,11 @@ hadrian-ghc-in-ghci: - "echo $PATH" - "echo $SHELL" - which autoreconf + - whoami - pwd - - ls + - /bin/ls - sleep 5 - - ls + - /bin/ls - "ls toolchain" - .gitlab/ci.sh setup - .gitlab/ci.sh configure View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b15a8c77d72b6112ceed668fadbce1ceab0c97ef -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b15a8c77d72b6112ceed668fadbce1ceab0c97ef You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:39:57 2020 From: gitlab at gitlab.haskell.org (davean) Date: Mon, 12 Oct 2020 12:39:57 -0400 Subject: [Git][ghc/ghc][wip/testing] Just a pile of debug Message-ID: <5f8486dd5c4e2_80b3f84112b4e3418400243@gitlab.haskell.org.mail> davean pushed to branch wip/testing at Glasgow Haskell Compiler / GHC Commits: d0931658 by davean at 2020-10-12T12:39:56-04:00 Just a pile of debug - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -286,11 +286,14 @@ hadrian-ghc-in-ghci: - "echo $SHELL" - which autoreconf - whoami + - env - pwd - /bin/ls - sleep 5 - /bin/ls + - date - "ls toolchain" + - date - .gitlab/ci.sh setup - .gitlab/ci.sh configure - .gitlab/ci.sh build_make View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d093165802892e7bb24f9793788c9f4703233a2f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d093165802892e7bb24f9793788c9f4703233a2f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:40:08 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 12 Oct 2020 12:40:08 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/minor-comments Message-ID: <5f8486e869172_80b3f8468f7115c1840088a@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/minor-comments at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/minor-comments You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 16:48:36 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Mon, 12 Oct 2020 12:48:36 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] 38 commits: Use UnitId in the backend instead of Unit Message-ID: <5f8488e454e37_80b3f84902b47fc184026c3@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - b3a986d9 by John Ericson at 2020-10-12T18:46:14+02:00 Make fixed-size `Int32#` and `Int64#` The boxed Int64 uses Int64#, but Int32# still uses Int#. The 32-bit case is less pressing to change because it is not a source of brittle CPP---it is the same thing on all platforms. We need Int64/Word64 constant folding to avoid the let/app restriction on Core, so that is implemented now. 32-bit constant unfolding and 32-bit literals are left as follow-up. This is the bulk of #11953 ghc-bignum: add support for Word64#/Int64# on 64-bit arch Fix fingerprint Core generation Fix some tests Co-authored-by: Sylvain Henry <hsyl20 at gmail.com> - - - - - 21f19cd9 by John Ericson at 2020-10-12T18:46:14+02:00 Inline INT64 and WORD64 macros in primops.txt.pp The definition is now unconditional so there is no reason for that CPP. - - - - - 50808f04 by Sylvain Henry at 2020-10-12T18:46:14+02:00 Fix toArgRep - - - - - 555837ff by Sylvain Henry at 2020-10-12T18:46:14+02:00 Adapt rules from #16402 to Word64#/Int64# - - - - - 699ebd26 by John Ericson at 2020-10-12T18:46:14+02:00 Copy enumFrom* implementations from Int/Word for Int64/Word64 Without this, we don't get proper list fusion. I think this sort of copying is OK for now, but we absolutely need something better if we are going to make `IntN` use `IntN#` for all `N`. The degree to which proper metaprogramming has been punted upon by factoring everything through the native-sized types is disconcerting. - - - - - 0fe30e8a by John Ericson at 2020-10-12T18:46:14+02:00 `integerFromInt64#` can be inlined when the word size is >= 64 bits Maybe this will help with the renaming test failure? - - - - - 111f53ed by John Ericson at 2020-10-12T18:46:15+02:00 Add builtin rule for `divInt64#` and `modInt64#` - - - - - 37b9421d by John Ericson at 2020-10-12T18:46:15+02:00 WIP: Add missing floats <-> int/word 64 rule and primops - - - - - 1771b41b by Sylvain Henry at 2020-10-12T18:46:15+02:00 Fix Word64/Int64 constant-folding I've refactored literal narrow/coerce functions to make them more generic. Hence this patch incidentally implements basic support for Int8/16/32 and Word8/16/32 in Core. - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/CPrim.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e2ba78a1198e693eef8148e339dea5acc9c5e8e...1771b41b35114b63baaa412b76594354ee0981fb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e2ba78a1198e693eef8148e339dea5acc9c5e8e...1771b41b35114b63baaa412b76594354ee0981fb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 17:01:25 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 12 Oct 2020 13:01:25 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] Accepting metric changes to advance CI Message-ID: <5f848be56fa60_80bd778f5018406615@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 9d5d56a9 by Sebastian Graf at 2020-10-12T19:01:01+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 Metric Increase ['max_bytes_used']: T10370 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T7360.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -190,6 +190,7 @@ T7360.$tc'Foo2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo9 [InlPrag=NOUSERINLINE[~]] :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] T7360.$tc'Foo9 = GHC.Types.KindRepFun $krep T7360.$tc'Foo4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -219,3 +220,6 @@ T7360.$tc'Foo3 T7360.$tc'Foo10 0# T7360.$tc'Foo9 + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d5d56a9bf413bf3bf1cc84e874360d98c92772e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9d5d56a9bf413bf3bf1cc84e874360d98c92772e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 17:18:00 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Mon, 12 Oct 2020 13:18:00 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 6 commits: Support STACK closures in collect_pointers() Message-ID: <5f848fc81010d_80b3f8468e9f5e418414214@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: e15213d5 by David Eichmann at 2020-10-06T12:23:14+01:00 Support STACK closures in collect_pointers() - - - - - d2724ab5 by David Eichmann at 2020-10-06T12:23:30+01:00 Update documentation - - - - - 5d654ff0 by David Eichmann at 2020-10-06T13:18:29+01:00 Update documentation - - - - - 8e82553c by David Eichmann at 2020-10-06T13:47:06+01:00 Remove LiftedClosure. Use Any instead. - - - - - 773548ae by David Eichmann at 2020-10-08T17:51:30+01:00 Remove first argument to peekTSOFields. Always use peekStgTSOProfInfo. - - - - - 778961af by David Eichmann at 2020-10-12T18:15:45+01:00 Comobine prof_info tso_and_stack_closures test and test getClosureDataFromHeapRep - - - - - 18 changed files: - includes/RtsAPI.h - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc - libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc → libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc - libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - libraries/ghc-heap/ghc-heap.cabal.in - libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/all.T - libraries/ghc-heap/tests/create_tso.c - libraries/ghc-heap/tests/create_tso.h - libraries/ghc-heap/tests/list_threads_and_misc_roots.hs - − libraries/ghc-heap/tests/prof_info.hs - libraries/ghc-heap/tests/tso_and_stack_closures.hs - rts/Heap.c - rts/RtsAPI.c Changes: ===================================== includes/RtsAPI.h ===================================== @@ -487,16 +487,17 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); -// Halt execution of all Haskell threads by acquiring all capabilities (safe FFI -// calls may continue). rts_resume must later be called on the same thread to -// resume the RTS. Only one thread at a time can keep the rts paused. The -// rts_pause function will block until the current thread is given exclusive -// permission to pause the RTS. If the RTS is already paused by the current OS -// thread, then rts_pause will return immediately and have no effect. Returns a -// token which may be used to create new objects and evaluate them (like -// rts_lock) .This is different to rts_lock which only pauses a single -// capability. Calling rts_pause in between rts_lock/rts_unlock on the same -// thread will cause an error. +// Halt execution of all Haskell threads by acquiring all capabilities. Note +// that this does not pause threads running safe FFI calls. rts_resume must +// later be called on the same thread to resume the RTS. Only one thread at a +// time can keep the rts paused. The rts_pause function will block until the +// current thread is given exclusive permission to pause the RTS. If the RTS is +// already paused by the current OS thread, then rts_pause will return +// immediately and have no effect. Returns a token which may be used to create +// new objects and evaluate them (like rts_lock). This is different to rts_lock +// which only pauses a single capability. Calling rts_pause in between +// rts_lock/rts_unlock on the same thread will cause an error. Calling rts_pause +// from an unsafe FFI call will also cause an error (safe FFI calls are ok). Capability * rts_pause (void); // Counterpart of rts_pause: Continue from a pause. All capabilities are ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -24,7 +24,6 @@ values, i.e. to investigate sharing and lazy evaluation. module GHC.Exts.Heap ( -- * Closure types Closure - , LiftedClosure , GenClosure(..) , ClosureType(..) , PrimType(..) @@ -65,17 +64,8 @@ import GHC.Exts.Heap.ClosureTypes import GHC.Exts.Heap.Constants import GHC.Exts.Heap.ProfInfo.Types #if defined(PROFILING) -import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled import GHC.Exts.Heap.InfoTableProf #else --- This import makes PeekProfInfo_ProfilingEnabled available in make-based --- builds. See #15197 for details (even though the related patch didn't --- seem to fix the issue). --- GHC.Exts.Heap.Closures uses the same trick to include --- GHC.Exts.Heap.InfoTableProf into make-based builds. -import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled () - -import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled import GHC.Exts.Heap.InfoTable #endif import GHC.Exts.Heap.Utils @@ -91,12 +81,6 @@ import Foreign #include "ghcconfig.h" --- | Some closures (e.g.TSOs) don't have corresponding types to represent them in Haskell. --- So when we have a pointer to such closure that we want to inspect, we `unsafeCoerce` it --- into the following `LiftedClosure` lifted type (could be any lifted type) so that the --- appropriate `instance HasHeapRep (a :: TYPE 'LiftedRep)` is used to decode the closure. -data LiftedClosure - class HasHeapRep (a :: TYPE rep) where -- | Decode a closure to it's heap representation ('GenClosure'). @@ -191,9 +175,10 @@ getClosureDataFromHeapObject x = do getClosureDataFromHeapRep :: Maybe (Ptr a) -- ^ Pointer to the closure in the heap. This is only used for STACK - -- closures to properly calculate the `stack_spOffset`. If this argument is - -- Nothing and the closure is a STACK, then `UnsupportedClosure` is - -- returned. + -- closures to properly calculate the `stack_spOffset`. This pointer will + -- not be dereferenced; the object need not exist at the give address. If + -- this argument is Nothing and the closure is a STACK, then + -- `UnsupportedClosure` is returned. -> ByteArray# -- ^ Heap representation of the closure as returned by `unpackClosure#`. -- This includes all of the object including the header, info table @@ -205,16 +190,16 @@ getClosureDataFromHeapRep -- info table from this process's runtime or in pinned or off-heap memory. -> [b] -- ^ Pointers in the payload of the closure, extracted from the heap - -- representation. In the case of STACK objects, this does NOT contain - -- pointers in the stack space (i.e. in StgStack::stack). Note `b` is some - -- representation of a pointer. If for example `b ~ Any` then the referenced - -- objects will be managed by the runtime system and kept alive by the - -- garbage collector. That is not true if for example `b ~ Ptr Any`. + -- representation as defined by `collect_pointers()` in `Heap.c`. In the + -- case of STACK objects, this does NOT contain pointers in the stack space + -- (i.e. in StgStack::stack). Note `b` is some representation of a pointer. + -- If for example `b ~ Any` then the referenced objects will be managed by + -- the runtime system and kept alive by the garbage collector. That is not + -- true if for example `b ~ Ptr Any`. -> IO (GenClosure b) -- ^ Heap representation of the closure. getClosureDataFromHeapRep closureAddressMay heapRep infoTablePtr pts = do itbl <- peekItbl infoTablePtr - -- The remaining words after the header let -- heapRep as a list of words. rawHeapWords :: [Word] rawHeapWords = [W# (indexWordArray# heapRep i) | I# i <- [0.. end] ] @@ -368,7 +353,7 @@ getClosureDataFromHeapRep closureAddressMay heapRep infoTablePtr pts = do } TSO | [ u_lnk, u_gbl_lnk, tso_stack, u_trec, u_blk_ex, u_bq] <- pts -> withArray rawHeapWords (\ptr -> do - fields <- FFIClosures.peekTSOFields peekStgTSOProfInfo ptr + fields <- FFIClosures.peekTSOFields ptr pure $ TSOClosure { info = itbl , link = u_lnk ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -318,9 +318,10 @@ data GenClosure b #if __GLASGOW_HASKELL__ >= 810 , stack_marking :: !Word8 #endif - -- | Offset of the `StgStack::sp` pointer in bytes - -- x->sp == ((byte*)x)+stack_spOffset - -- The type of `stack_spOffset` reflects the type of `stack_size`. + -- | Offset of the `StgStack::sp` pointer in *bytes*: + -- + -- stgStack->sp == ((byte*)stgStack)+stack_spOffset + -- , stack_spOffset :: !Int } @@ -393,7 +394,7 @@ data WhatNext | ThreadInterpret | ThreadKilled | ThreadComplete - | WhatNextUnknownValue -- ^ Please report this as a bug + | WhatNextUnknownValue Word16 -- ^ Please report this as a bug deriving (Eq, Show, Generic) data WhyBlocked @@ -411,7 +412,7 @@ data WhyBlocked | BlockedOnMsgThrowTo | ThreadMigrating | BlockedOnIOCompletion - | WhyBlockedUnknownValue -- ^ Please report this as a bug + | WhyBlockedUnknownValue Word16 -- ^ Please report this as a bug deriving (Eq, Show, Generic) data TsoFlags @@ -422,7 +423,7 @@ data TsoFlags | TsoMarked | TsoSqueezed | TsoAllocLimit - | TsoFlagsUnknownValue -- ^ Please report this as a bug + | TsoFlagsUnknownValue Word32 -- ^ Please report this as a bug deriving (Eq, Show, Generic) -- | For generic code, this function returns all referenced closures. ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP #-} + +module GHC.Exts.Heap.FFIClosures (module Reexport) where + +#if defined(PROFILING) +import GHC.Exts.Heap.FFIClosures_ProfilingEnabled as Reexport +import GHC.Exts.Heap.FFIClosures_ProfilingDisabled () +#else +import GHC.Exts.Heap.FFIClosures_ProfilingDisabled as Reexport +import GHC.Exts.Heap.FFIClosures_ProfilingEnabled () +#endif ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc ===================================== @@ -0,0 +1,133 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} + +module GHC.Exts.Heap.FFIClosures_ProfilingDisabled where + +-- Manually undefining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.FFIClosures_ProfilingEnabled. +#undef PROFILING +#include "Rts.h" + +import Prelude +import Foreign +import GHC.Exts +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled +import GHC.Exts.Heap.ProfInfo.Types +import GHC.Exts.Heap.Closures(WhatNext(..), WhyBlocked(..), TsoFlags(..)) + +data TSOFields = TSOFields { + tso_what_next :: WhatNext, + tso_why_blocked :: WhyBlocked, + tso_flags :: [TsoFlags], +-- Unfortunately block_info is a union without clear discriminator. +-- block_info :: TDB, + tso_threadId :: Word64, + tso_saved_errno :: Word32, + tso_dirty:: Word32, + tso_alloc_limit :: Int64, + tso_tot_stack_size :: Word32, + tso_prof :: Maybe StgTSOProfInfo +} + +-- | Get non-pointer fields from @StgTSO_@ (@TSO.h@) +peekTSOFields :: Ptr tsoPtr -> IO TSOFields +peekTSOFields ptr = do + what_next' <- (#peek struct StgTSO_, what_next) ptr + why_blocked' <- (#peek struct StgTSO_, why_blocked) ptr + flags' <- (#peek struct StgTSO_, flags) ptr + threadId' <- (#peek struct StgTSO_, id) ptr + saved_errno' <- (#peek struct StgTSO_, saved_errno) ptr + dirty' <- (#peek struct StgTSO_, dirty) ptr + alloc_limit' <- (#peek struct StgTSO_, alloc_limit) ptr + tot_stack_size' <- (#peek struct StgTSO_, tot_stack_size) ptr + tso_prof' <- peekStgTSOProfInfo ptr + + return TSOFields { + tso_what_next = parseWhatNext what_next', + tso_why_blocked = parseWhyBlocked why_blocked', + tso_flags = parseTsoFlags flags', + tso_threadId = threadId', + tso_saved_errno = saved_errno', + tso_dirty = dirty', + tso_alloc_limit = alloc_limit', + tso_tot_stack_size = tot_stack_size', + tso_prof = tso_prof' + } + +parseWhatNext :: Word16 -> WhatNext +parseWhatNext w = case w of + (#const ThreadRunGHC) -> ThreadRunGHC + (#const ThreadInterpret) -> ThreadInterpret + (#const ThreadKilled) -> ThreadKilled + (#const ThreadComplete) -> ThreadComplete + _ -> WhatNextUnknownValue w + +parseWhyBlocked :: Word16 -> WhyBlocked +parseWhyBlocked w = case w of + (#const NotBlocked) -> NotBlocked + (#const BlockedOnMVar) -> BlockedOnMVar + (#const BlockedOnMVarRead) -> BlockedOnMVarRead + (#const BlockedOnBlackHole) -> BlockedOnBlackHole + (#const BlockedOnRead) -> BlockedOnRead + (#const BlockedOnWrite) -> BlockedOnWrite + (#const BlockedOnDelay) -> BlockedOnDelay + (#const BlockedOnSTM) -> BlockedOnSTM + (#const BlockedOnDoProc) -> BlockedOnDoProc + (#const BlockedOnCCall) -> BlockedOnCCall + (#const BlockedOnCCall_Interruptible) -> BlockedOnCCall_Interruptible + (#const BlockedOnMsgThrowTo) -> BlockedOnMsgThrowTo + (#const ThreadMigrating) -> ThreadMigrating +#if __GLASGOW_HASKELL__ >= 810 + (#const BlockedOnIOCompletion) -> BlockedOnIOCompletion +#endif + _ -> WhyBlockedUnknownValue w + +parseTsoFlags :: Word32 -> [TsoFlags] +parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset (#const TSO_LOCKED) w) + | isSet (#const TSO_BLOCKEX) w = TsoBlockx : parseTsoFlags (unset (#const TSO_BLOCKEX) w) + | isSet (#const TSO_INTERRUPTIBLE) w = TsoInterruptible : parseTsoFlags (unset (#const TSO_INTERRUPTIBLE) w) + | isSet (#const TSO_STOPPED_ON_BREAKPOINT) w = TsoStoppedOnBreakpoint : parseTsoFlags (unset (#const TSO_STOPPED_ON_BREAKPOINT) w) + | isSet (#const TSO_MARKED) w = TsoMarked : parseTsoFlags (unset (#const TSO_MARKED) w) + | isSet (#const TSO_SQUEEZED) w = TsoSqueezed : parseTsoFlags (unset (#const TSO_SQUEEZED) w) + | isSet (#const TSO_ALLOC_LIMIT) w = TsoAllocLimit : parseTsoFlags (unset (#const TSO_ALLOC_LIMIT) w) +parseTsoFlags 0 = [] +parseTsoFlags w = [TsoFlagsUnknownValue w] + +isSet :: Word32 -> Word32 -> Bool +isSet bitMask w = w .&. bitMask /= 0 + +unset :: Word32 -> Word32 -> Word32 +unset bitMask w = w `xor` bitMask + +data StackFields = StackFields { + stack_size :: Word32, + stack_dirty :: Word8, +#if __GLASGOW_HASKELL__ >= 810 + stack_marking :: Word8, +#endif + stack_sp :: Addr## +} + +-- | Get non-closure fields from @StgStack_@ (@TSO.h@) +peekStackFields :: Ptr a -> IO StackFields +peekStackFields ptr = do + stack_size' <- (#peek struct StgStack_, stack_size) ptr ::IO Word32 + dirty' <- (#peek struct StgStack_, dirty) ptr +#if __GLASGOW_HASKELL__ >= 810 + marking' <- (#peek struct StgStack_, marking) ptr +#endif + Ptr sp' <- (#peek struct StgStack_, sp) ptr + + -- TODO decode the stack. + + return StackFields { + stack_size = stack_size', + stack_dirty = dirty', +#if __GLASGOW_HASKELL__ >= 810 + stack_marking = marking', +#endif + stack_sp = sp' + } + ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hsc → libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc ===================================== @@ -1,13 +1,19 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} -module GHC.Exts.Heap.FFIClosures where +module GHC.Exts.Heap.FFIClosures_ProfilingEnabled where +-- Manually defining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.FFIClosures_ProfilingDisabled. +#define PROFILING #include "Rts.h" import Prelude import Foreign import GHC.Exts +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled import GHC.Exts.Heap.ProfInfo.Types import GHC.Exts.Heap.Closures(WhatNext(..), WhyBlocked(..), TsoFlags(..)) @@ -26,10 +32,8 @@ data TSOFields = TSOFields { } -- | Get non-pointer fields from @StgTSO_@ (@TSO.h@) -peekTSOFields :: (Ptr tsoPtr -> IO (Maybe StgTSOProfInfo)) - -> Ptr tsoPtr - -> IO TSOFields -peekTSOFields peekProfInfo ptr = do +peekTSOFields :: Ptr tsoPtr -> IO TSOFields +peekTSOFields ptr = do what_next' <- (#peek struct StgTSO_, what_next) ptr why_blocked' <- (#peek struct StgTSO_, why_blocked) ptr flags' <- (#peek struct StgTSO_, flags) ptr @@ -38,7 +42,7 @@ peekTSOFields peekProfInfo ptr = do dirty' <- (#peek struct StgTSO_, dirty) ptr alloc_limit' <- (#peek struct StgTSO_, alloc_limit) ptr tot_stack_size' <- (#peek struct StgTSO_, tot_stack_size) ptr - tso_prof' <- peekProfInfo ptr + tso_prof' <- peekStgTSOProfInfo ptr return TSOFields { tso_what_next = parseWhatNext what_next', @@ -58,7 +62,7 @@ parseWhatNext w = case w of (#const ThreadInterpret) -> ThreadInterpret (#const ThreadKilled) -> ThreadKilled (#const ThreadComplete) -> ThreadComplete - _ -> WhatNextUnknownValue + _ -> WhatNextUnknownValue w parseWhyBlocked :: Word16 -> WhyBlocked parseWhyBlocked w = case w of @@ -78,7 +82,7 @@ parseWhyBlocked w = case w of #if __GLASGOW_HASKELL__ >= 810 (#const BlockedOnIOCompletion) -> BlockedOnIOCompletion #endif - _ -> WhyBlockedUnknownValue + _ -> WhyBlockedUnknownValue w parseTsoFlags :: Word32 -> [TsoFlags] parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset (#const TSO_LOCKED) w) @@ -89,7 +93,7 @@ parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset | isSet (#const TSO_SQUEEZED) w = TsoSqueezed : parseTsoFlags (unset (#const TSO_SQUEEZED) w) | isSet (#const TSO_ALLOC_LIMIT) w = TsoAllocLimit : parseTsoFlags (unset (#const TSO_ALLOC_LIMIT) w) parseTsoFlags 0 = [] -parseTsoFlags _ = [TsoFlagsUnknownValue] +parseTsoFlags w = [TsoFlagsUnknownValue w] isSet :: Word32 -> Word32 -> Bool isSet bitMask w = w .&. bitMask /= 0 ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc ===================================== @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP, DeriveGeneric #-} module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled( peekStgTSOProfInfo ) where ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE MagicHash #-} @@ -49,7 +48,11 @@ peekStgTSOProfInfo tsoPtr = do cccsOffset :: Int cccsOffset = (#const OFFSET_StgTSO_cccs) + (#size StgHeader) -peekCostCentreStack :: AddressSet -> IORef (AddressMap CostCentre) -> Ptr costCentreStack -> IO (Maybe CostCentreStack) +peekCostCentreStack + :: AddressSet + -> IORef (AddressMap CostCentre) + -> Ptr costCentreStack + -> IO (Maybe CostCentreStack) peekCostCentreStack _ _ ptr | ptr == nullPtr = return Nothing peekCostCentreStack loopBreakers _ ptr | IntSet.member (ptrToInt ptr) loopBreakers = return Nothing peekCostCentreStack loopBreakers costCenterCacheRef ptr = do ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -41,6 +41,8 @@ library GHC.Exts.Heap.InfoTableProf GHC.Exts.Heap.Utils GHC.Exts.Heap.FFIClosures + GHC.Exts.Heap.FFIClosures_ProfilingEnabled + GHC.Exts.Heap.FFIClosures_ProfilingDisabled GHC.Exts.Heap.ProfInfo.Types GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled ===================================== libraries/ghc-heap/tests/TestUtils.hs ===================================== @@ -1,9 +1,8 @@ {-# LANGUAGE MagicHash #-} module TestUtils where -import GHC.Exts.Heap (getClosureData, LiftedClosure, Box, GenClosure) import Foreign (Ptr) -import GHC.Exts (Ptr, Addr#, unsafeCoerce#) +import GHC.Exts (Addr#) import GHC.Ptr (Ptr(Ptr)) assertEqual :: (Show a, Eq a) => a -> a -> IO () @@ -11,10 +10,5 @@ assertEqual a b | a /= b = error (show a ++ " /= " ++ show b) | otherwise = return () -createClosure :: Ptr () -> IO (GenClosure Box) -createClosure tsoPtr = do - let addr = unpackAddr# tsoPtr - getClosureData ((unsafeCoerce# addr) :: LiftedClosure) - unpackAddr# :: Ptr () -> Addr# unpackAddr# (Ptr addr) = addr ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -37,12 +37,23 @@ test('closure_size_noopt', compile_and_run, ['']) test('tso_and_stack_closures', - [extra_files(['create_tso.c','create_tso.h', 'TestUtils.hs']), + [extra_files(['create_tso.c','create_tso.h','TestUtils.hs']), + only_ways(['profthreaded']), + extra_ways(['profthreaded']), ignore_stdout, ignore_stderr ], multi_compile_and_run, ['tso_and_stack_closures', [('create_tso.c','')], '']) +# test('tso_and_stack_closures (prof)', +# [extra_files(['create_tso.c','create_tso.h','TestUtils.hs']), +# only_ways(prof_ways), +# extra_ways(prof_ways), +# ignore_stdout, +# ignore_stderr, +# ], +# multi_compile_and_run, ['tso_and_stack_closures', [('create_tso.c','')], '-prof']) + test('list_threads_and_misc_roots', [extra_files(['list_threads_and_misc_roots_c.c','list_threads_and_misc_roots_c.h','TestUtils.hs']), ignore_stdout, @@ -50,15 +61,6 @@ test('list_threads_and_misc_roots', ], multi_compile_and_run, ['list_threads_and_misc_roots', [('list_threads_and_misc_roots_c.c','')], '-threaded']) -test('prof_info', - [extra_files(['create_tso.c','create_tso.h','TestUtils.hs']), - ignore_stdout, - ignore_stderr, - when(have_profiling(), extra_ways(['prof'])), - only_ways(prof_ways) - ], - multi_compile_and_run, ['prof_info', [('create_tso.c','')], '-prof']) - test('parse_tso_flags', [extra_files(['TestUtils.hs']), only_ways(['normal']), ===================================== libraries/ghc-heap/tests/create_tso.c ===================================== @@ -1,10 +1,80 @@ #include "Rts.h" #include "RtsAPI.h" -StgTSO* create_tso(){ - HaskellObj trueClosure = rts_mkBool(&MainCapability, 1); +// Must be called from a safe FFI call. +void create_and_unpack_tso_and_stack + // TSO + ( StgTSO ** outTso + , StgInfoTable ** outTsoInfoTablePtr + , int * outTsoHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outTsoHeapRep // Array of words + , int * outTsoPointersSize // Size of outPointers (in words) + , StgClosure *** outTsoPointers // Array of all pointers of the TSO + // Stack + , StgTSO ** outStack + , StgInfoTable ** outStackInfoTablePtr + , int * outStackHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outStackHeapRep // Array of words + , int * outStackPointersSize // Size of outPointers (in words) + , StgClosure *** outStackPointers // Array of all pointers of the TSO + ) +{ + // Pause RTS + Capability * cap = rts_pause(); - StgTSO * tso = createGenThread(&MainCapability, 500U, trueClosure); + // Create TSO/Stack + HaskellObj trueClosure = rts_mkBool(cap, 1); + *outTso = createGenThread(cap, 500U, trueClosure); - return tso; + // Unpack TSO + unpack_closure( + (StgClosure*)(*outTso), + outTsoInfoTablePtr, + outTsoHeapRepSize, + outTsoHeapRep, + outTsoPointersSize, + outTsoPointers); + + // Unpack STACK + *outStack = (*outTsoPointers)[2]; + unpack_closure( + (StgClosure*)(*outStack), + outStackInfoTablePtr, + outStackHeapRepSize, + outStackHeapRep, + outStackPointersSize, + outStackPointers); + + // Resume RTS + rts_resume(cap); +} + +// Assumed the rts is paused +void unpack_closure + ( StgClosure * inClosure + , StgInfoTable ** outInfoTablePtr + , int * outHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outHeapRep // Array of words + , int * outPointersSize // Size of outPointers (in words) + , StgClosure *** outPointers // Array of all pointers of the TSO + ) +{ + *outInfoTablePtr = get_itbl(inClosure); + + // Copy TSO pointers. + StgWord closureSizeW = heap_view_closureSize(inClosure); + int closureSizeB = sizeof(StgWord) * closureSizeW; + StgClosure ** pointers = malloc(closureSizeB); + *outPointersSize = collect_pointers(inClosure, closureSizeW, pointers); + *outPointers = pointers; + + // Copy the heap rep. + StgWord * heapRep = malloc(closureSizeB); + for (int i = 0; i < closureSizeW; i++) + { + heapRep[i] = ((StgWord*)inClosure)[i]; + } + + *outHeapRepSize = closureSizeB; + *outHeapRep = heapRep; } ===================================== libraries/ghc-heap/tests/create_tso.h ===================================== @@ -1,3 +1,19 @@ +#include "Rts.h" #include "RtsAPI.h" -StgTSO* create_tso(); +void create_and_unpack_tso_and_stack + // TSO + ( StgTSO ** outTso + , StgInfoTable ** outTsoInfoTablePtr + , int * outTsoHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outTsoHeapRep // Array of words + , int * outTsoPointersSize // Size of outPointers (in words) + , StgClosure *** outTsoPointers // Array of all pointers of the TSO + // Stack + , StgTSO ** outStack + , StgInfoTable ** outStackInfoTablePtr + , int * outStackHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outStackHeapRep // Array of words + , int * outStackPointersSize // Size of outPointers (in words) + , StgClosure *** outStackPointers // Array of all pointers of the TSO + ); \ No newline at end of file ===================================== libraries/ghc-heap/tests/list_threads_and_misc_roots.hs ===================================== @@ -31,14 +31,14 @@ main = do tsoCount <- getTSOCount_c tsos <- getTSOs_c tsoList <- peekArray tsoCount tsos - tsoClosures <- mapM createClosure tsoList + tsoClosures <- mapM createAndUnpackTSOClosure tsoList assertEqual tsoCount $ length tsoClosures mapM (assertEqual TSO) $ map (tipe . info) tsoClosures miscRootsCount <- getMiscRootsCount_c miscRoots <- getMiscRoots_c miscRootsList <- peekArray miscRootsCount miscRoots - heapClosures <- mapM createClosure miscRootsList + heapClosures <- mapM _ miscRootsList assertEqual miscRootsCount $ length heapClosures -- Regarding the type system, this always has to be True, but we want to -- force evaluation / de-serialization with a simple check. ===================================== libraries/ghc-heap/tests/prof_info.hs deleted ===================================== @@ -1,53 +0,0 @@ -{-# LANGUAGE ForeignFunctionInterface, MagicHash, CPP, BangPatterns #-} - -import Prelude -import Foreign -import Foreign.C.Types -import GHC.Exts.Heap -import GHC.Exts -import Data.Functor - -import GHC.Word -import Data.List (find) - -import TestUtils - -#include "ghcconfig.h" -#include "rts/Constants.h" - -foreign import ccall unsafe "create_tso.h create_tso" - c_create_tso:: IO (Ptr ()) - -createTSOClosure :: IO (GenClosure Box) -createTSOClosure = do - ptr <- {-# SCC "MyCostCentre" #-} c_create_tso - let addr = unpackAddr# ptr - getClosureData ((unsafeCoerce# addr) :: LiftedClosure) - --- We can make some assumptions about the - otherwise dynamic - properties of --- StgTSO and StgStack, because a new, non-running TSO is created with --- create_tso() (create_tso.c).create_tso -main :: IO () -main = do - tso <- createTSOClosure - - let costCentre = prof tso >>= cccs <&> ccs_cc - - case costCentre of - Nothing -> error $ "No CostCentre found in TSO: " ++ show tso - Just _ -> case findMyCostCentre (linkedCostCentres costCentre) of - Just myCostCentre -> do - assertEqual (cc_label myCostCentre) "MyCostCentre" - assertEqual (cc_module myCostCentre) "Main" - assertEqual (cc_srcloc myCostCentre) (Just "prof_info.hs:23:39-50") - assertEqual (cc_mem_alloc myCostCentre) 0 - assertEqual (cc_time_ticks myCostCentre) 0 - assertEqual (cc_is_caf myCostCentre) False - Nothing -> error "MyCostCentre not found!" - -linkedCostCentres :: Maybe CostCentre -> [CostCentre] -linkedCostCentres Nothing = [] -linkedCostCentres (Just cc) = cc : linkedCostCentres (cc_link cc) - -findMyCostCentre:: [CostCentre] -> Maybe CostCentre -findMyCostCentre ccs = find (\cc -> cc_label cc == "MyCostCentre") ccs ===================================== libraries/ghc-heap/tests/tso_and_stack_closures.hs ===================================== @@ -1,61 +1,159 @@ -{-# LANGUAGE ForeignFunctionInterface, MagicHash, BangPatterns #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +import Control.Monad (forM_, unless) +import Data.List (find) +import Data.Word import Foreign import Foreign.C.Types -import GHC.Exts.Heap +import GHC.IO ( IO(..) ) import GHC.Exts - +import GHC.Exts.Heap +import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import GHC.Word import TestUtils -foreign import ccall unsafe "create_tso.h create_tso" - c_create_tso:: IO (Ptr ()) - --- We can make some assumptions about the - otherwise dynamic - properties of --- StgTSO and StgStack, because a new, non-running TSO is created with --- create_tso() (create_tso.c).create_tso main :: IO () main = do - tso <- createTSOClosure + (tso, stack) <- {-# SCC "MyCostCentre" #-} createAndUnpackTSOAndSTACKClosure + assertEqual (getClosureType tso) TSO + assertEqual (getClosureType stack) STACK assertEqual (what_next tso) ThreadRunGHC assertEqual (why_blocked tso) NotBlocked assertEqual (saved_errno tso) 0 - -- The newly created TSO should be on the end of the run queue. - let !_linkBox = unsafe_link tso - _linkClosure <- getBoxedClosureData _linkBox - assertEqual (name _linkClosure) "END_TSO_QUEUE" - assertEqual (getClosureType _linkClosure) CONSTR_NOCAF +#if defined(PROFILING) + let costCentre = ccs_cc <$> (cccs =<< prof tso) + case costCentre of + Nothing -> error $ "No CostCentre found in TSO: " ++ show tso + Just _ -> case findMyCostCentre (linkedCostCentres costCentre) of + Just myCostCentre -> do + assertEqual (cc_label myCostCentre) "MyCostCentre" + assertEqual (cc_module myCostCentre) "Main" + assertEqual (cc_srcloc myCostCentre) (Just "tso_and_stack_closures.hs:23:48-80") + assertEqual (cc_is_caf myCostCentre) False + Nothing -> error $ "MyCostCentre not found in:\n" ++ unlines (cc_label <$> linkedCostCentres costCentre) +#endif - let !global_linkBox = unsafe_global_link tso - globalLinkClosure <- getBoxedClosureData global_linkBox - assertEqual (getClosureType globalLinkClosure) TSO +linkedCostCentres :: Maybe CostCentre -> [CostCentre] +linkedCostCentres Nothing = [] +linkedCostCentres (Just cc) = cc : linkedCostCentres (cc_link cc) - let !stackBox = tsoStack tso - stackClosure <- getBoxedClosureData stackBox - assertEqual (getClosureType stackClosure) STACK +findMyCostCentre:: [CostCentre] -> Maybe CostCentre +findMyCostCentre ccs = find (\cc -> cc_label cc == "MyCostCentre") ccs - let !stackPointerBox = unsafeStackPointer stackClosure - stackPointerClosure <- getBoxedClosureData stackPointerBox - assertEqual (getClosureType stackPointerClosure) RET_SMALL +getClosureType :: GenClosure b -> ClosureType +getClosureType = tipe . info - let !trecBox = unsafe_trec tso - trecClosure <- getBoxedClosureData trecBox - assertEqual (name trecClosure) "NO_TREC" +type StgTso = Any +type StgStack = Any +data MBA a = MBA (MutableByteArray# a) +data BA = BA ByteArray# - let !blockedExceptionsBox = unsafe_blocked_exceptions tso - blockedExceptionsClosure <- getBoxedClosureData blockedExceptionsBox - assertEqual (name blockedExceptionsClosure) "END_TSO_QUEUE" +foreign import ccall safe "create_tso.h create_and_unpack_tso_and_stack" + c_create_and_unpack_tso_and_stack + :: Ptr (Ptr StgTso) + -> Ptr (Ptr StgInfoTable) + -> Ptr CInt + -> Ptr (Ptr Word8) + -> Ptr CInt + -> Ptr (Ptr (Ptr Any)) + -> Ptr (Ptr StgStack) + -> Ptr (Ptr StgInfoTable) + -> Ptr CInt + -> Ptr (Ptr Word8) + -> Ptr CInt + -> Ptr (Ptr (Ptr Any)) + -> IO () - let !bqBox = unsafe_bq tso - bqClosure <- getBoxedClosureData bqBox - assertEqual (name bqClosure) "END_TSO_QUEUE" +createAndUnpackTSOAndSTACKClosure :: IO (GenClosure (Ptr Any), GenClosure (Ptr Any)) +createAndUnpackTSOAndSTACKClosure = do -createTSOClosure :: IO (GenClosure Box) -createTSOClosure = do - ptr <- c_create_tso - createClosure ptr + alloca $ \ptrPtrTso -> do + alloca $ \ptrPtrTsoInfoTable -> do + alloca $ \ptrTsoHeapRepSize -> do + alloca $ \ptrPtrTsoHeapRep -> do + alloca $ \ptrTsoPointersSize -> do + alloca $ \ptrPtrPtrTsoPointers -> do -getClosureType :: GenClosure b -> ClosureType -getClosureType = tipe . info + alloca $ \ptrPtrStack -> do + alloca $ \ptrPtrStackInfoTable -> do + alloca $ \ptrStackHeapRepSize -> do + alloca $ \ptrPtrStackHeapRep -> do + alloca $ \ptrStackPointersSize -> do + alloca $ \ptrPtrPtrStackPointers -> do + + c_create_and_unpack_tso_and_stack + + ptrPtrTso + ptrPtrTsoInfoTable + ptrTsoHeapRepSize + ptrPtrTsoHeapRep + ptrTsoPointersSize + ptrPtrPtrTsoPointers + + ptrPtrStack + ptrPtrStackInfoTable + ptrStackHeapRepSize + ptrPtrStackHeapRep + ptrStackPointersSize + ptrPtrPtrStackPointers + + let fromHeapRep + ptrPtrClosure + ptrPtrClosureInfoTable + ptrClosureHeapRepSize + ptrPtrClosureHeapRep + ptrClosurePointersSize + ptrPtrPtrClosurePointers = do + ptrClosure :: Ptr Any <- peek ptrPtrClosure + ptrInfoTable :: Ptr StgInfoTable <- peek ptrPtrClosureInfoTable + + heapRepSize :: Int <- fromIntegral <$> peek ptrClosureHeapRepSize + let I# heapRepSize# = heapRepSize + ptrHeapRep :: Ptr Word8 <- peek ptrPtrClosureHeapRep + MBA mutHeapRepBA <- IO $ \s -> let + (# s', mba# #) = newByteArray# heapRepSize# s + in (# s', MBA mba# #) + forM_ [0..heapRepSize-1] $ \i@(I# i#) -> do + W8# w <- peekElemOff ptrHeapRep i + IO (\s -> (# writeWord8Array# mutHeapRepBA i# w s, () #)) + BA heapRep <- IO $ \s -> let + (# s', ba# #) = unsafeFreezeByteArray# mutHeapRepBA s + in (# s', BA ba# #) + + pointersSize :: Int <- fromIntegral <$> peek ptrClosurePointersSize + ptrPtrPointers :: Ptr (Ptr Any) <- peek ptrPtrPtrClosurePointers + ptrPtrPointers :: [Ptr Any] <- sequence + [ peekElemOff ptrPtrPointers i + | i <- [0..pointersSize-1] + ] + + getClosureDataFromHeapRep + (Just ptrClosure) + heapRep + ptrInfoTable + ptrPtrPointers + + tso <- fromHeapRep + ptrPtrTso + ptrPtrTsoInfoTable + ptrTsoHeapRepSize + ptrPtrTsoHeapRep + ptrTsoPointersSize + ptrPtrPtrTsoPointers + + stack <- fromHeapRep + ptrPtrStack + ptrPtrStackInfoTable + ptrStackHeapRepSize + ptrPtrStackHeapRep + ptrStackPointersSize + ptrPtrPtrStackPointers + + return (tso, stack) ===================================== rts/Heap.c ===================================== @@ -93,6 +93,7 @@ StgWord collect_pointers(StgClosure *closure, StgWord size, StgClosure *ptrs[siz // No pointers case ARR_WORDS: + case STACK: break; // Default layout ===================================== rts/RtsAPI.c ===================================== @@ -670,7 +670,7 @@ rts_unlock (Capability *cap) * This is achieved almost entirely by the mechanism of acquiring and releasing * Capabilities, resulting in a sort of mutex / critical section pattern. * Correct usage of this API requires that you surround API calls in - * rts_lock/rts_unlock or rts_pause/rts_resume. These ensure that the thread + * rts_lock/rts_unlock or rts_pause/rts_resume. This ensures that the thread * owns a capability while calling other RtsAPI functions (in the case of * rts_pause/rts_resume the thread owns *all* capabilities). * @@ -678,7 +678,7 @@ rts_unlock (Capability *cap) * without objects unexpectedly moving, which is important for many of the * functions in RtsAPI. * - * Another important consequence is: + * Other important consequences are: * * * There are at most `n_capabilities` threads currently in a * rts_lock/rts_unlock section. @@ -686,11 +686,6 @@ rts_unlock (Capability *cap) * there will be no threads in a rts_lock/rts_unlock section. * * rts_pause and rts_lock may block in order to enforce the above 2 * invariants. - * - * In particular, by ensuring that that code does not block indefinitely in a - * rts_lock/rts_unlock or rts_pause/rts_resume section, we can be confident that - * the RtsAPI functions will not cause a deadlock even when many threads are - * attempting to use the RtsAPI concurrently. */ // See RtsAPI.h View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e8e08bdc063d86fcd5c4f5ac11bd35407c103fd...778961af6f5ac608cc1269ea21720cf9b08a9289 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e8e08bdc063d86fcd5c4f5ac11bd35407c103fd...778961af6f5ac608cc1269ea21720cf9b08a9289 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 17:36:45 2020 From: gitlab at gitlab.haskell.org (Sylvain Henry) Date: Mon, 12 Oct 2020 13:36:45 -0400 Subject: [Git][ghc/ghc][wip/int64-everywhere] Fix Word64/Int64 constant-folding Message-ID: <5f84942d62acd_80b3f84963c2ff81841746@gitlab.haskell.org.mail> Sylvain Henry pushed to branch wip/int64-everywhere at Glasgow Haskell Compiler / GHC Commits: c6b4bbc2 by Sylvain Henry at 2020-10-12T19:36:30+02:00 Fix Word64/Int64 constant-folding I've refactored literal narrow/coerce functions to make them more generic. Hence this patch incidentally implements basic support for Int8/16/32 and Word8/16/32 in Core. - - - - - 7 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Utils/Outputable.hs - testsuite/driver/testlib.py - testsuite/tests/simplCore/should_compile/T8832.stdout Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -458,8 +458,14 @@ assembleI platform i = case i of -- LitString requires a zero-terminator when emitted literal (LitNumber nt i) = case nt of LitNumInt -> int (fromIntegral i) - LitNumWord -> int (fromIntegral i) + LitNumInt8 -> int (fromIntegral i) + LitNumInt16 -> int (fromIntegral i) + LitNumInt32 -> int (fromIntegral i) LitNumInt64 -> int64 (fromIntegral i) + LitNumWord -> int (fromIntegral i) + LitNumWord8 -> int (fromIntegral i) + LitNumWord16 -> int (fromIntegral i) + LitNumWord32 -> int (fromIntegral i) LitNumWord64 -> int64 (fromIntegral i) LitNumInteger -> panic "GHC.ByteCode.Asm.literal: LitNumInteger" LitNumNatural -> panic "GHC.ByteCode.Asm.literal: LitNumNatural" ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -71,7 +71,6 @@ import Control.Monad import Data.Functor (($>)) import Data.Bits as Bits import qualified Data.ByteString as BS -import Data.Int import Data.Ratio import Data.Word import Data.Maybe (fromMaybe) @@ -264,41 +263,50 @@ primOpRules nm = \case WordSrlOp -> mkPrimOpRule nm 2 [ shiftRule LitNumWord shiftRightLogical ] -- coercions - Word64ToInt64Op-> mkPrimOpRule nm 1 [ liftLitPlatform $ const word64ToInt64Lit + Word64ToInt64Op-> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumInt64) , inversePrimOp Int64ToWord64Op ] - Int64ToWord64Op-> mkPrimOpRule nm 1 [ liftLitPlatform $ const int64ToWord64Lit + Int64ToWord64Op-> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumWord64) , inversePrimOp Word64ToInt64Op ] - WordToIntOp -> mkPrimOpRule nm 1 [ liftLitPlatform wordToIntLit - , inversePrimOp IntToWordOp ] - IntToWordOp -> mkPrimOpRule nm 1 [ liftLitPlatform intToWordLit - , inversePrimOp WordToIntOp ] - Narrow8IntOp -> mkPrimOpRule nm 1 [ liftLit narrow8IntLit + Int64ToInt -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumInt) + , inversePrimOp IntToInt64 ] + Word64ToWord -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumWord) + , inversePrimOp WordToWord64 ] + IntToInt64 -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumInt64) + , inversePrimOp Int64ToInt ] + WordToWord64 -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumWord64) + , inversePrimOp Word64ToWord ] + WordToIntOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumInt) + , inversePrimOp IntToWordOp ] + IntToWordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumCoerce LitNumWord) + , inversePrimOp WordToIntOp ] + + Narrow8IntOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt8) , subsumedByPrimOp Narrow8IntOp , Narrow8IntOp `subsumesPrimOp` Narrow16IntOp , Narrow8IntOp `subsumesPrimOp` Narrow32IntOp , narrowSubsumesAnd IntAndOp Narrow8IntOp 8 ] - Narrow16IntOp -> mkPrimOpRule nm 1 [ liftLit narrow16IntLit + Narrow16IntOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt16) , subsumedByPrimOp Narrow8IntOp , subsumedByPrimOp Narrow16IntOp , Narrow16IntOp `subsumesPrimOp` Narrow32IntOp , narrowSubsumesAnd IntAndOp Narrow16IntOp 16 ] - Narrow32IntOp -> mkPrimOpRule nm 1 [ liftLit narrow32IntLit + Narrow32IntOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumInt32) , subsumedByPrimOp Narrow8IntOp , subsumedByPrimOp Narrow16IntOp , subsumedByPrimOp Narrow32IntOp , removeOp32 , narrowSubsumesAnd IntAndOp Narrow32IntOp 32 ] - Narrow8WordOp -> mkPrimOpRule nm 1 [ liftLit narrow8WordLit + Narrow8WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord8) , subsumedByPrimOp Narrow8WordOp , Narrow8WordOp `subsumesPrimOp` Narrow16WordOp , Narrow8WordOp `subsumesPrimOp` Narrow32WordOp , narrowSubsumesAnd WordAndOp Narrow8WordOp 8 ] - Narrow16WordOp -> mkPrimOpRule nm 1 [ liftLit narrow16WordLit + Narrow16WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord16) , subsumedByPrimOp Narrow8WordOp , subsumedByPrimOp Narrow16WordOp , Narrow16WordOp `subsumesPrimOp` Narrow32WordOp , narrowSubsumesAnd WordAndOp Narrow16WordOp 16 ] - Narrow32WordOp -> mkPrimOpRule nm 1 [ liftLit narrow32WordLit + Narrow32WordOp -> mkPrimOpRule nm 1 [ liftLitPlatform (litNumNarrow LitNumWord32) , subsumedByPrimOp Narrow8WordOp , subsumedByPrimOp Narrow16WordOp , subsumedByPrimOp Narrow32WordOp @@ -710,28 +718,6 @@ mkRuleFn platform Gt _ (Lit lit) | isMaxBound platform lit = Just $ falseValInt mkRuleFn platform Le _ (Lit lit) | isMaxBound platform lit = Just $ trueValInt platform mkRuleFn _ _ _ _ = Nothing -isMinBound :: Platform -> Literal -> Bool -isMinBound _ (LitChar c) = c == minBound -isMinBound platform (LitNumber nt i) = case nt of - LitNumInt -> i == platformMinInt platform - LitNumInt64 -> i == toInteger (minBound :: Int64) - LitNumWord -> i == 0 - LitNumWord64 -> i == 0 - LitNumNatural -> i == 0 - LitNumInteger -> False -isMinBound _ _ = False - -isMaxBound :: Platform -> Literal -> Bool -isMaxBound _ (LitChar c) = c == maxBound -isMaxBound platform (LitNumber nt i) = case nt of - LitNumInt -> i == platformMaxInt platform - LitNumInt64 -> i == toInteger (maxBound :: Int64) - LitNumWord -> i == platformMaxWord platform - LitNumWord64 -> i == toInteger (maxBound :: Word64) - LitNumNatural -> False - LitNumInteger -> False -isMaxBound _ _ = False - -- | Create an Int literal expression while ensuring the given Integer is in the -- target Int range int64Result :: Integer -> Maybe CoreExpr ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1641,8 +1641,14 @@ pushAtom _ _ (AnnLit lit) = do LitRubbish -> code N LitNumber nt _ -> case nt of LitNumInt -> code N - LitNumWord -> code N + LitNumInt8 -> code N + LitNumInt16 -> code N + LitNumInt32 -> code N LitNumInt64 -> code L + LitNumWord -> code N + LitNumWord8 -> code N + LitNumWord16 -> code N + LitNumWord32 -> code N LitNumWord64 -> code L -- No LitInteger's or LitNatural's should be left by the time this is -- called. CorePrep should have converted them all to a real core ===================================== compiler/GHC/Types/Literal.hs ===================================== @@ -2,12 +2,15 @@ (c) The University of Glasgow 2006 (c) The GRASP/AQUA Project, Glasgow University, 1998 -\section[Literal]{@Literal@: literals} -} {-# LANGUAGE CPP, DeriveDataTypeable, ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE AllowAmbiguousTypes #-} + {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} +-- | Core literals module GHC.Types.Literal ( -- * Main data type @@ -30,6 +33,11 @@ module GHC.Types.Literal , pprLiteral , litNumIsSigned , litNumCheckRange + , litNumWrap + , litNumCoerce + , litNumNarrow + , isMinBound + , isMaxBound -- ** Predicates on Literals and their contents , litIsDupable, litIsTrivial, litIsLifted @@ -39,11 +47,6 @@ module GHC.Types.Literal , litValue, isLitValue, isLitValue_maybe, mapLitValue -- ** Coercions - , word64ToInt64Lit, int64ToWord64Lit - , wordToIntLit, intToWordLit - , narrowLit - , narrow8IntLit, narrow16IntLit, narrow32IntLit - , narrow8WordLit, narrow16WordLit, narrow32WordLit , charToIntLit, intToCharLit , floatToIntLit, intToFloatLit , floatToInt64Lit, int64ToFloatLit @@ -78,7 +81,6 @@ import Data.Word import Data.Char import Data.Maybe ( isJust ) import Data.Data ( Data ) -import Data.Proxy import Numeric ( fromRat ) {- @@ -158,8 +160,14 @@ data LitNumType = LitNumInteger -- ^ @Integer@ (see Note [BigNum literals]) | LitNumNatural -- ^ @Natural@ (see Note [BigNum literals]) | LitNumInt -- ^ @Int#@ - according to target machine + | LitNumInt8 -- ^ @Int8#@ - exactly 8 bits + | LitNumInt16 -- ^ @Int16#@ - exactly 16 bits + | LitNumInt32 -- ^ @Int32#@ - exactly 32 bits | LitNumInt64 -- ^ @Int64#@ - exactly 64 bits | LitNumWord -- ^ @Word#@ - according to target machine + | LitNumWord8 -- ^ @Word8#@ - exactly 8 bits + | LitNumWord16 -- ^ @Word16#@ - exactly 16 bits + | LitNumWord32 -- ^ @Word32#@ - exactly 32 bits | LitNumWord64 -- ^ @Word64#@ - exactly 64 bits deriving (Data,Enum,Eq,Ord) @@ -169,8 +177,14 @@ litNumIsSigned nt = case nt of LitNumInteger -> True LitNumNatural -> False LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> False + LitNumWord8 -> False + LitNumWord16 -> False + LitNumWord32 -> False LitNumWord64 -> False {- @@ -289,43 +303,65 @@ doesn't yield a warning. Instead we simply squash the value into the *target* Int/Word range. -} --- | Wrap a literal number according to its type -wrapLitNumber :: Platform -> Literal -> Literal -wrapLitNumber platform v@(LitNumber nt i) = case nt of +-- | Make a literal number using wrapping semantics if the value is out of +-- bound. +mkLitNumberWrap :: Platform -> LitNumType -> Integer -> Literal +mkLitNumberWrap platform nt i = case nt of LitNumInt -> case platformWordSize platform of - PW4 -> int32 - PW8 -> int64 + PW4 -> wrap @Int32 + PW8 -> wrap @Int64 LitNumWord -> case platformWordSize platform of - PW4 -> word32 - PW8 -> word64 - LitNumInt64 -> int64 - LitNumWord64 -> word64 - LitNumInteger -> v - LitNumNatural -> v + PW4 -> wrap @Word32 + PW8 -> wrap @Word64 + LitNumInt8 -> wrap @Int8 + LitNumInt16 -> wrap @Int16 + LitNumInt32 -> wrap @Int32 + LitNumInt64 -> wrap @Int64 + LitNumWord8 -> wrap @Word8 + LitNumWord16 -> wrap @Word16 + LitNumWord32 -> wrap @Word32 + LitNumWord64 -> wrap @Word64 + LitNumInteger -> LitNumber nt i + LitNumNatural + | i < 0 -> panic "mkLitNumberWrap: trying to create a negative Natural" + | otherwise -> LitNumber nt i where - int32 = LitNumber nt $ wrapInt32 i - word32 = LitNumber nt $ wrapWord32 i - int64 = LitNumber nt $ wrapInt64 i - word64 = LitNumber nt $ wrapWord64 i -wrapLitNumber _ x = x - -wrapInt32, wrapWord32, wrapInt64, wrapWord64 :: Integer -> Integer -wrapInt32 i = toInteger (fromIntegral i :: Int32) -wrapWord32 i = toInteger (fromIntegral i :: Word32) -wrapInt64 i = toInteger (fromIntegral i :: Int64) -wrapWord64 i = toInteger (fromIntegral i :: Word64) + wrap :: forall a. (Integral a, Num a) => Literal + wrap = LitNumber nt (toInteger (fromIntegral i :: a)) + +-- | Wrap a literal number according to its type using wrapping semantics. +litNumWrap :: Platform -> Literal -> Literal +litNumWrap platform (LitNumber nt i) = mkLitNumberWrap platform nt i +litNumWrap _ l = pprPanic "litNumWrap" (ppr l) + +-- | Coerce a literal number into another using wrapping semantics. +litNumCoerce :: LitNumType -> Platform -> Literal -> Literal +litNumCoerce pt platform (LitNumber _nt i) = mkLitNumberWrap platform pt i +litNumCoerce _ _ l = pprPanic "litNumWrapCoerce: not a number" (ppr l) + +-- | Narrow a literal number by converting it into another number type and then +-- converting it back to its original type. +litNumNarrow :: LitNumType -> Platform -> Literal -> Literal +litNumNarrow pt platform (LitNumber nt i) + = case mkLitNumberWrap platform pt i of + LitNumber _ j -> mkLitNumberWrap platform nt j + l -> pprPanic "litNumNarrow: got invalid literal" (ppr l) +litNumNarrow _ _ l = pprPanic "litNumNarrow: invalid literal" (ppr l) --- | Create a numeric 'Literal' of the given type -mkLitNumberWrap :: Platform -> LitNumType -> Integer -> Literal -mkLitNumberWrap platform nt i = wrapLitNumber platform (LitNumber nt i) -- | Check that a given number is in the range of a numeric literal litNumCheckRange :: Platform -> LitNumType -> Integer -> Bool litNumCheckRange platform nt i = case nt of LitNumInt -> platformInIntRange platform i LitNumWord -> platformInWordRange platform i - LitNumInt64 -> inInt64Range i - LitNumWord64 -> inWord64Range i + LitNumInt8 -> inBoundedRange @Int8 i + LitNumInt16 -> inBoundedRange @Int16 i + LitNumInt32 -> inBoundedRange @Int32 i + LitNumInt64 -> inBoundedRange @Int64 i + LitNumWord8 -> inBoundedRange @Word8 i + LitNumWord16 -> inBoundedRange @Word16 i + LitNumWord32 -> inBoundedRange @Word32 i + LitNumWord64 -> inBoundedRange @Word64 i LitNumNatural -> i >= 0 LitNumInteger -> True @@ -344,7 +380,7 @@ mkLitInt platform x = ASSERT2( platformInIntRange platform x, integer x ) -- If the argument is out of the (target-dependent) range, it is wrapped. -- See Note [Word/Int underflow/overflow] mkLitIntWrap :: Platform -> Integer -> Literal -mkLitIntWrap platform i = wrapLitNumber platform $ mkLitIntUnchecked i +mkLitIntWrap platform i = mkLitNumberWrap platform LitNumInt i -- | Creates a 'Literal' of type @Int#@ without checking its range. mkLitIntUnchecked :: Integer -> Literal @@ -368,7 +404,7 @@ mkLitWord platform x = ASSERT2( platformInWordRange platform x, integer x ) -- If the argument is out of the (target-dependent) range, it is wrapped. -- See Note [Word/Int underflow/overflow] mkLitWordWrap :: Platform -> Integer -> Literal -mkLitWordWrap platform i = wrapLitNumber platform $ mkLitWordUnchecked i +mkLitWordWrap platform i = mkLitNumberWrap platform LitNumWord i -- | Creates a 'Literal' of type @Word#@ without checking its range. mkLitWordUnchecked :: Integer -> Literal @@ -385,12 +421,12 @@ mkLitWordWrapC platform i = (n, i /= i') -- | Creates a 'Literal' of type @Int64#@ mkLitInt64 :: Integer -> Literal -mkLitInt64 x = ASSERT2( inInt64Range x, integer x ) (mkLitInt64Unchecked x) +mkLitInt64 x = ASSERT2( inBoundedRange @Int64 x, integer x ) (mkLitInt64Unchecked x) -- | Creates a 'Literal' of type @Int64#@. -- If the argument is out of the range, it is wrapped. mkLitInt64Wrap :: Integer -> Literal -mkLitInt64Wrap = mkLitInt64Unchecked . wrapInt64 +mkLitInt64Wrap i = LitNumber LitNumInt64 (toInteger (fromIntegral i :: Int64)) -- | Creates a 'Literal' of type @Int64#@ without checking its range. mkLitInt64Unchecked :: Integer -> Literal @@ -398,12 +434,12 @@ mkLitInt64Unchecked i = LitNumber LitNumInt64 i -- | Creates a 'Literal' of type @Word64#@ mkLitWord64 :: Integer -> Literal -mkLitWord64 x = ASSERT2( inWord64Range x, integer x ) (mkLitWord64Unchecked x) +mkLitWord64 x = ASSERT2( inBoundedRange @Word64 x, integer x ) (mkLitWord64Unchecked x) -- | Creates a 'Literal' of type @Word64#@. -- If the argument is out of the range, it is wrapped. mkLitWord64Wrap :: Integer -> Literal -mkLitWord64Wrap = mkLitWord64Unchecked . wrapWord64 +mkLitWord64Wrap i = LitNumber LitNumWord64 (toInteger (fromIntegral i :: Word64)) -- | Creates a 'Literal' of type @Word64#@ without checking its range. mkLitWord64Unchecked :: Integer -> Literal @@ -437,11 +473,43 @@ mkLitNatural x = ASSERT2( inNaturalRange x, integer x ) inNaturalRange :: Integer -> Bool inNaturalRange x = x >= 0 -inInt64Range, inWord64Range :: Integer -> Bool -inInt64Range x = x >= toInteger (minBound :: Int64) && - x <= toInteger (maxBound :: Int64) -inWord64Range x = x >= toInteger (minBound :: Word64) && - x <= toInteger (maxBound :: Word64) +inBoundedRange :: forall a. (Bounded a, Integral a) => Integer -> Bool +inBoundedRange x = x >= toInteger (minBound :: a) && + x <= toInteger (maxBound :: a) + +isMinBound :: Platform -> Literal -> Bool +isMinBound _ (LitChar c) = c == minBound +isMinBound platform (LitNumber nt i) = case nt of + LitNumInt -> i == platformMinInt platform + LitNumInt8 -> i == toInteger (minBound :: Int8) + LitNumInt16 -> i == toInteger (minBound :: Int16) + LitNumInt32 -> i == toInteger (minBound :: Int32) + LitNumInt64 -> i == toInteger (minBound :: Int64) + LitNumWord -> i == 0 + LitNumWord8 -> i == 0 + LitNumWord16 -> i == 0 + LitNumWord32 -> i == 0 + LitNumWord64 -> i == 0 + LitNumNatural -> i == 0 + LitNumInteger -> False +isMinBound _ _ = False + +isMaxBound :: Platform -> Literal -> Bool +isMaxBound _ (LitChar c) = c == maxBound +isMaxBound platform (LitNumber nt i) = case nt of + LitNumInt -> i == platformMaxInt platform + LitNumInt8 -> i == toInteger (maxBound :: Int8) + LitNumInt16 -> i == toInteger (maxBound :: Int16) + LitNumInt32 -> i == toInteger (maxBound :: Int32) + LitNumInt64 -> i == toInteger (maxBound :: Int64) + LitNumWord -> i == platformMaxWord platform + LitNumWord8 -> i == toInteger (maxBound :: Word8) + LitNumWord16 -> i == toInteger (maxBound :: Word16) + LitNumWord32 -> i == toInteger (maxBound :: Word32) + LitNumWord64 -> i == toInteger (maxBound :: Word64) + LitNumNatural -> False + LitNumInteger -> False +isMaxBound _ _ = False inCharRange :: Char -> Bool inCharRange c = c >= '\0' && c <= chr tARGET_MAX_CHAR @@ -475,7 +543,7 @@ isLitValue_maybe _ = Nothing mapLitValue :: Platform -> (Integer -> Integer) -> Literal -> Literal mapLitValue _ f (LitChar c) = mkLitChar (fchar c) where fchar = chr . fromInteger . f . toInteger . ord -mapLitValue platform f (LitNumber nt i) = wrapLitNumber platform (LitNumber nt (f i)) +mapLitValue platform f (LitNumber nt i) = mkLitNumberWrap platform nt (f i) mapLitValue _ _ l = pprPanic "mapLitValue" (ppr l) -- | Indicate if the `Literal` contains an 'Integer' value, e.g. 'Char', @@ -488,9 +556,7 @@ isLitValue = isJust . isLitValue_maybe ~~~~~~~~~ -} -narrow8IntLit, narrow16IntLit, narrow32IntLit, - narrow8WordLit, narrow16WordLit, narrow32WordLit, - charToIntLit, intToCharLit, +charToIntLit, intToCharLit, floatToIntLit, intToFloatLit, floatToInt64Lit, int64ToFloatLit, doubleToIntLit, intToDoubleLit, @@ -498,58 +564,6 @@ narrow8IntLit, narrow16IntLit, narrow32IntLit, floatToDoubleLit, doubleToFloatLit :: Literal -> Literal -maxBoundInt64, maxBoundWord64 :: Integer -maxBoundInt64 = toInteger (maxBound :: Int64) -maxBoundWord64 = toInteger (maxBound :: Word64) - -word64ToInt64Lit, int64ToWord64Lit :: Literal -> Literal - -word64ToInt64Lit (LitNumber LitNumWord64 w) - -- Map Word64 range [max_int64+1, max_word64] - -- to Int64 range [min_int64 , -1] - -- Range [0,max_int64] has the same representation with both Int64 and Word64 - | w > maxBoundInt64 = mkLitInt64 $ w - maxBoundWord64 - 1 - | otherwise = mkLitInt64 w -word64ToInt64Lit l = pprPanic "word64ToInt64Lit" (ppr l) - -int64ToWord64Lit (LitNumber LitNumInt64 i) - -- Map Int64 range [min_int64 , -1] - -- to Word64 range [max_int64+1, max_word64] - -- Range [0,max_int64] has the same representation with both Int64 and Word64 - | i < 0 = mkLitWord64 $ 1 + maxBoundWord64 + i - | otherwise = mkLitWord64 i -int64ToWord64Lit l = pprPanic "int64ToWord64Lit" (ppr l) - -wordToIntLit, intToWordLit :: Platform -> Literal -> Literal - -wordToIntLit platform (LitNumber LitNumWord w) - -- Map Word range [max_int+1, max_word] - -- to Int range [min_int , -1] - -- Range [0,max_int] has the same representation with both Int and Word - | w > platformMaxInt platform = mkLitInt platform (w - platformMaxWord platform - 1) - | otherwise = mkLitInt platform w -wordToIntLit _ l = pprPanic "wordToIntLit" (ppr l) - -intToWordLit platform (LitNumber LitNumInt i) - -- Map Int range [min_int , -1] - -- to Word range [max_int+1, max_word] - -- Range [0,max_int] has the same representation with both Int and Word - | i < 0 = mkLitWord platform (1 + platformMaxWord platform + i) - | otherwise = mkLitWord platform i -intToWordLit _ l = pprPanic "intToWordLit" (ppr l) - --- | Narrow a literal number (unchecked result range) -narrowLit :: forall a. Integral a => Proxy a -> Literal -> Literal -narrowLit _ (LitNumber nt i) = LitNumber nt (toInteger (fromInteger i :: a)) -narrowLit _ l = pprPanic "narrowLit" (ppr l) - -narrow8IntLit = narrowLit (Proxy :: Proxy Int8) -narrow16IntLit = narrowLit (Proxy :: Proxy Int16) -narrow32IntLit = narrowLit (Proxy :: Proxy Int32) -narrow8WordLit = narrowLit (Proxy :: Proxy Word8) -narrow16WordLit = narrowLit (Proxy :: Proxy Word16) -narrow32WordLit = narrowLit (Proxy :: Proxy Word32) - charToIntLit (LitChar c) = mkLitIntUnchecked (toInteger (ord c)) charToIntLit l = pprPanic "charToIntLit" (ppr l) intToCharLit (LitNumber _ i) = LitChar (chr (fromInteger i)) @@ -632,8 +646,14 @@ litIsTrivial (LitNumber nt _) = case nt of LitNumInteger -> False LitNumNatural -> False LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> True + LitNumWord8 -> True + LitNumWord16 -> True + LitNumWord32 -> True LitNumWord64 -> True litIsTrivial _ = True @@ -645,8 +665,14 @@ litIsDupable platform x = case x of LitNumInteger -> platformInIntRange platform i LitNumNatural -> platformInWordRange platform i LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> True + LitNumWord8 -> True + LitNumWord16 -> True + LitNumWord32 -> True LitNumWord64 -> True (LitString _) -> False _ -> True @@ -661,8 +687,14 @@ litIsLifted (LitNumber nt _) = case nt of LitNumInteger -> True LitNumNatural -> True LitNumInt -> False + LitNumInt8 -> False + LitNumInt16 -> False + LitNumInt32 -> False LitNumInt64 -> False LitNumWord -> False + LitNumWord8 -> False + LitNumWord16 -> False + LitNumWord32 -> False LitNumWord64 -> False litIsLifted _ = False @@ -683,8 +715,14 @@ literalType (LitNumber lt _) = case lt of LitNumInteger -> integerTy LitNumNatural -> naturalTy LitNumInt -> intPrimTy + LitNumInt8 -> int8PrimTy + LitNumInt16 -> int16PrimTy + LitNumInt32 -> int32PrimTy LitNumInt64 -> int64PrimTy LitNumWord -> wordPrimTy + LitNumWord8 -> word8PrimTy + LitNumWord16 -> word16PrimTy + LitNumWord32 -> word32PrimTy LitNumWord64 -> word64PrimTy literalType (LitRubbish) = mkForAllTy a Inferred (mkTyVarTy a) where @@ -760,8 +798,14 @@ pprLiteral add_par (LitNumber nt i) LitNumInteger -> pprIntegerVal add_par i LitNumNatural -> pprIntegerVal add_par i LitNumInt -> pprPrimInt i + LitNumInt8 -> pprPrimInt8 i + LitNumInt16 -> pprPrimInt16 i + LitNumInt32 -> pprPrimInt32 i LitNumInt64 -> pprPrimInt64 i LitNumWord -> pprPrimWord i + LitNumWord8 -> pprPrimWord8 i + LitNumWord16 -> pprPrimWord16 i + LitNumWord32 -> pprPrimWord32 i LitNumWord64 -> pprPrimWord64 i pprLiteral add_par (LitLabel l mb fod) = add_par (text "__label" <+> b <+> ppr fod) @@ -803,9 +847,9 @@ LitChar 'a'# LitString "aaa"# LitNullAddr "__NULL" LitInt -1# -LitInt64 -1L# +LitIntN -1#N LitWord 1## -LitWord64 1L## +LitWordN 1##N LitFloat -1.0# LitDouble -1.0## LitInteger -1 (-1) ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -59,10 +59,16 @@ module GHC.Utils.Outputable ( pprHsChar, pprHsString, pprHsBytes, primFloatSuffix, primCharSuffix, primDoubleSuffix, + primInt8Suffix, primWord8Suffix, + primInt16Suffix, primWord16Suffix, + primInt32Suffix, primWord32Suffix, primInt64Suffix, primWord64Suffix, primIntSuffix, primWordSuffix, pprPrimChar, pprPrimInt, pprPrimWord, + pprPrimInt8, pprPrimWord8, + pprPrimInt16, pprPrimWord16, + pprPrimInt32, pprPrimWord32, pprPrimInt64, pprPrimWord64, pprFastFilePath, pprFilePathString, @@ -1156,22 +1162,42 @@ pprHsBytes bs = let escaped = concatMap escape $ BS.unpack bs -- See Note [Printing of literals in Core] in "GHC.Types.Literal". primCharSuffix, primFloatSuffix, primDoubleSuffix, primIntSuffix, primWordSuffix, - primInt64Suffix, primWord64Suffix :: SDoc + primInt8Suffix, primWord8Suffix, + primInt16Suffix, primWord16Suffix, + primInt32Suffix, primWord32Suffix, + primInt64Suffix, primWord64Suffix + :: SDoc primCharSuffix = char '#' primFloatSuffix = char '#' primIntSuffix = char '#' primDoubleSuffix = text "##" primWordSuffix = text "##" -primInt64Suffix = text "L#" -primWord64Suffix = text "L##" +primInt8Suffix = text "#8" +primWord8Suffix = text "##8" +primInt16Suffix = text "#16" +primWord16Suffix = text "##16" +primInt32Suffix = text "#32" +primWord32Suffix = text "##32" +primInt64Suffix = text "#64" +primWord64Suffix = text "##64" -- | Special combinator for showing unboxed literals. pprPrimChar :: Char -> SDoc pprPrimInt, pprPrimWord, - pprPrimInt64, pprPrimWord64 :: Integer -> SDoc + pprPrimInt8, pprPrimWord8, + pprPrimInt16, pprPrimWord16, + pprPrimInt32, pprPrimWord32, + pprPrimInt64, pprPrimWord64 + :: Integer -> SDoc pprPrimChar c = pprHsChar c <> primCharSuffix pprPrimInt i = integer i <> primIntSuffix pprPrimWord w = word w <> primWordSuffix +pprPrimInt8 i = integer i <> primInt8Suffix +pprPrimWord8 w = word w <> primWord8Suffix +pprPrimInt16 i = integer i <> primInt16Suffix +pprPrimWord16 w = word w <> primWord16Suffix +pprPrimInt32 i = integer i <> primInt32Suffix +pprPrimWord32 w = word w <> primWord32Suffix pprPrimInt64 i = integer i <> primInt64Suffix pprPrimWord64 w = word w <> primWord64Suffix ===================================== testsuite/driver/testlib.py ===================================== @@ -2143,7 +2143,7 @@ def normalise_callstacks(s: str) -> str: s = re.sub(r'CallStack \(from -prof\):(\n .*)*\n?', '', s) return s -tyCon_re = re.compile(r'TyCon\s*\d+L?\#\#\s*\d+L?\#\#\s*', flags=re.MULTILINE) +tyCon_re = re.compile(r'TyCon\s*\d+\#\#\d?\d?\s*\d+\#\#\d?\d?\s*', flags=re.MULTILINE) def normalise_type_reps(s: str) -> str: """ Normalise out fingerprints from Typeable TyCon representations """ ===================================== testsuite/tests/simplCore/should_compile/T8832.stdout ===================================== @@ -2,10 +2,10 @@ i = GHC.Types.I# 0# i8 = GHC.Int.I8# 0# i16 = GHC.Int.I16# 0# i32 = GHC.Int.I32# 0# -i64 = GHC.Int.I64# 0L# +i64 = GHC.Int.I64# 0#64 w = GHC.Types.W# 0## w8 = GHC.Word.W8# 0## w16 = GHC.Word.W16# 0## w32 = GHC.Word.W32# 0## -w64 = GHC.Word.W64# 0L## +w64 = GHC.Word.W64# 0##64 z = 0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6b4bbc2867076310bdaabea03905901697d32c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6b4bbc2867076310bdaabea03905901697d32c7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:00:45 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Mon, 12 Oct 2020 18:00:45 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] 30 commits: Use UnitId in the backend instead of Unit Message-ID: <5f84d20db0113_80baecd81c1845247d@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 020b027b by Alan Zimmerman at 2020-10-12T22:59:39+01:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations Remove LHsLocalBinds Fix up after rebasing to bring in XRec Main thing is to make type instance XRec (GhcPass p) a = GenLocated (Anno a) a type family Anno a = b But this has massive implications. - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/OccurAnal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ccd9aa3ba98a6a376492852e77911243a470b224...020b027bc2c6995bd523ec9d8998513bad21f60b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ccd9aa3ba98a6a376492852e77911243a470b224...020b027bc2c6995bd523ec9d8998513bad21f60b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:06:46 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 12 Oct 2020 18:06:46 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-9.0 Message-ID: <5f84d3765aad5_80b3f84289b797c18455671@gitlab.haskell.org.mail> Krzysztof Gogolewski deleted branch wip/backports-9.0 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:06:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 12 Oct 2020 18:06:46 -0400 Subject: [Git][ghc/ghc][ghc-9.0] 12 commits: Document -Wderiving-typeable Message-ID: <5f84d376dc443_80b87fc4181845584a@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: b936c542 by MaxGabriel at 2020-10-12T14:19:41+02:00 Document -Wderiving-typeable Tracking: #18641 (cherry picked from commit 73d2521688bd1da4b6bd1202e5325a00cb410a44) - - - - - c073a4ab by Hécate at 2020-10-12T14:20:47+02:00 Remove the list of loaded modules from the ghci prompt (cherry picked from commit 086ef01813069fad84cafe81cab37527d41c8568) - - - - - aff164bc by Benjamin Maurer at 2020-10-12T14:21:51+02:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. (cherry picked from commit 74c797f6b72c4d01f5e0092dfac1461f3f3dd7a2) - - - - - 44779899 by Krzysztof Gogolewski at 2020-10-12T14:22:35+02:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. (cherry picked from commit e48cab2a57f2342891f985bcb44817e17e985275) - - - - - ba446875 by Krzysztof Gogolewski at 2020-10-12T14:23:25+02:00 Fix linear types in TH splices (#18465) (cherry picked from commit 802b5e6fdd6dfc58396a9dca1903dc5a1d6634ca) - - - - - b10154d6 by Icelandjack at 2020-10-12T14:25:47+02:00 Replaced MkT1 with T1 in type signatures. (cherry picked from commit b81350bb925f8cb309355ee46238dbc11b796faf) - - - - - baa55369 by Krzysztof Gogolewski at 2020-10-12T14:26:12+02:00 Linear types: fix quantification in GADTs (#18790) (cherry picked from commit 22f218b729a751bc5e5965624a716fc542f502a5) - - - - - 146cff70 by Alan Zimmerman at 2020-10-12T14:27:02+02:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 (cherry picked from commit d6dff830754a97220eacf032c32cd54b18654917) - - - - - 8c370e11 by Alan Zimmerman at 2020-10-12T14:27:30+02:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. (cherry picked from commit 36787bba78ae5acbb857c84b85b8feb7c83e54a5) - - - - - 15c4eb1f by Krzysztof Gogolewski at 2020-10-12T14:28:15+02:00 Linear types: fix roles in GADTs (#18799) (cherry picked from commit 8fafb304cacae69f8dbbdcf22ab858a5b28b6818) - - - - - a740aa0b by Sylvain Henry at 2020-10-12T15:10:13+02:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - d09e7e41 by Sylvain Henry at 2020-10-12T15:10:30+02:00 Bignum: fix bigNatCompareWord# bug (#18813) (cherry picked from commit 74ee1237bf243dd7d8b758a53695575c364c3088) - - - - - 30 changed files: - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Utils.hs - docs/users_guide/expected-undocumented-flags.txt - docs/users_guide/exts/linear_types.rst - docs/users_guide/ghci.rst - docs/users_guide/phases.rst - docs/users_guide/using-warnings.rst - ghc/GHCi/UI.hs - libraries/ghc-bignum/src/GHC/Num/BigNat.hs - rts/posix/OSMem.c - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - + testsuite/tests/lib/integer/T18813.hs - + testsuite/tests/lib/integer/T18813.stdout - testsuite/tests/lib/integer/all.T - + testsuite/tests/lib/integer/bignumMatch.hs - + testsuite/tests/lib/integer/bignumMatch.stderr - testsuite/tests/linear/should_compile/MultConstructor.hs - + testsuite/tests/linear/should_fail/LinearRole.hs - + testsuite/tests/linear/should_fail/LinearRole.stderr - + testsuite/tests/linear/should_fail/LinearTHFail.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5d414fdc01a370db6d7e1b3526d80ca53345ca8a...d09e7e41cf79fe981a61eae46a93d8881859ff1f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5d414fdc01a370db6d7e1b3526d80ca53345ca8a...d09e7e41cf79fe981a61eae46a93d8881859ff1f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:21:19 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 12 Oct 2020 18:21:19 -0400 Subject: [Git][ghc/ghc][master] Fall back to types when looking up data constructors (#18740) Message-ID: <5f84d6dfcc2dc_80b3f84663b0fb818464184@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 19 changed files: - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/module/mod132.stderr - testsuite/tests/module/mod147.stderr - testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr - + testsuite/tests/rename/should_fail/T18740a.hs - + testsuite/tests/rename/should_fail/T18740a.stderr - + testsuite/tests/rename/should_fail/T18740b.hs - + testsuite/tests/rename/should_fail/T18740b.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/th/T14627.stderr - + testsuite/tests/th/T18740c.hs - + testsuite/tests/th/T18740c.stderr - + testsuite/tests/th/T18740d.hs - + testsuite/tests/th/T18740d.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -2247,8 +2247,11 @@ repPsig (MkC p) (MkC t) = rep2 sigPName [p, t] --------------- Expressions ----------------- repVarOrCon :: Name -> Core TH.Name -> MetaM (Core (M TH.Exp)) -repVarOrCon vc str | isDataOcc (nameOccName vc) = repCon str - | otherwise = repVar str +repVarOrCon vc str + | isVarNameSpace ns = repVar str -- Both type and term variables (#18740) + | otherwise = repCon str + where + ns = nameNameSpace vc repVar :: Core TH.Name -> MetaM (Core (M TH.Exp)) repVar (MkC s) = rep2 varEName [s] ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE TypeApplications #-} {- (c) The GRASP/AQUA Project, Glasgow University, 1992-2006 @@ -1006,6 +1007,17 @@ lookup_demoted rdr_name , text "instead of" , quotes (ppr name) <> dot ] +-- If the given RdrName can be promoted to the type level and its promoted variant is in scope, +-- lookup_promoted returns the corresponding type-level Name. +-- Otherwise, the function returns Nothing. +-- See Note [Promotion] below. +lookup_promoted :: RdrName -> RnM (Maybe Name) +lookup_promoted rdr_name + | Just promoted_rdr <- promoteRdrName rdr_name + = lookupOccRn_maybe promoted_rdr + | otherwise + = return Nothing + badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" @@ -1041,6 +1053,26 @@ its namespace to DataName and do a second lookup. The final result (after the renamer) will be: HsTyVar ("Zero", DataName) + +Note [Promotion] +~~~~~~~~~~~~~~~ +When the user mentions a type constructor or a type variable in a +term-level context, then we report that a value identifier was expected +instead of a type-level one. That makes error messages more precise. +Previously, such errors contained only the info that a given value was out of scope (#18740). +We promote the namespace of RdrName and look up after that +(see the functions promotedRdrName and lookup_promoted). + +In particular, we have the following error message + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) + • In the first argument of ‘id’, namely ‘Int’ + In the expression: id Int + In an equation for ‘x’: x = id Int + +when the user writes the following declaration + + x = id Int -} lookupOccRnX_maybe :: (RdrName -> RnM (Maybe r)) -> (Name -> r) -> RdrName @@ -1055,14 +1087,22 @@ lookupOccRn_maybe = lookupOccRnX_maybe lookupGlobalOccRn_maybe id lookupOccRn_overloaded :: Bool -> RdrName -> RnM (Maybe (Either Name [Name])) -lookupOccRn_overloaded overload_ok - = lookupOccRnX_maybe global_lookup Left - where - global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) - global_lookup n = - runMaybeT . msum . map MaybeT $ - [ lookupGlobalOccRn_overloaded overload_ok n - , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] +lookupOccRn_overloaded overload_ok rdr_name + = do { mb_name <- lookupOccRnX_maybe global_lookup Left rdr_name + ; case mb_name of + Nothing -> fmap @Maybe Left <$> lookup_promoted rdr_name + -- See Note [Promotion]. + -- We try looking up the name as a + -- type constructor or type variable, if + -- we failed to look up the name at the term level. + p -> return p } + + where + global_lookup :: RdrName -> RnM (Maybe (Either Name [Name])) + global_lookup n = + runMaybeT . msum . map MaybeT $ + [ lookupGlobalOccRn_overloaded overload_ok n + , fmap Left . listToMaybe <$> lookupQualifiedNameGHCi n ] ===================================== compiler/GHC/Tc/Gen/Head.hs ===================================== @@ -755,6 +755,7 @@ tc_infer_assert assert_name tc_infer_id :: Name -> TcM (HsExpr GhcTc, TcSigmaType) tc_infer_id id_name = do { thing <- tcLookup id_name + ; global_env <- getGlobalRdrEnv ; case thing of ATcId { tct_id = id } -> do { check_local_id occ id @@ -772,9 +773,31 @@ tc_infer_id id_name | otherwise -> nonBidirectionalErr id_name + AGlobal (ATyCon ty_con) + -> fail_tycon global_env ty_con + + ATyVar name _ + -> failWithTc $ + text "Illegal term-level use of the type variable" + <+> quotes (ppr name) + $$ nest 2 (text "bound at" <+> ppr (getSrcLoc name)) + + ATcTyCon ty_con + -> fail_tycon global_env ty_con + _ -> failWithTc $ ppr thing <+> text "used where a value identifier was expected" } where + fail_tycon global_env ty_con = + let pprov = case lookupGRE_Name global_env (tyConName ty_con) of + Just gre -> nest 2 (pprNameProvenance gre) + Nothing -> empty + in failWithTc (term_level_tycons ty_con $$ pprov) + + term_level_tycons ty_con + = text "Illegal term-level use of the type constructor" + <+> quotes (ppr (tyConName ty_con)) + occ = nameOccName id_name return_id id = return (HsVar noExtField (noLoc id), idType id) @@ -1144,4 +1167,3 @@ addExprCtxt e thing_inside exprCtxt :: HsExpr GhcRn -> SDoc exprCtxt expr = hang (text "In the expression:") 2 (ppr (stripParensHsExpr expr)) - ===================================== compiler/GHC/Types/Name/Occurrence.hs ===================================== @@ -52,6 +52,7 @@ module GHC.Types.Name.Occurrence ( mkDFunOcc, setOccNameSpace, demoteOccName, + promoteOccName, HasOccName(..), -- ** Derived 'OccName's @@ -208,13 +209,21 @@ pprNameSpaceBrief TcClsName = text "tc" -- demoteNameSpace lowers the NameSpace if possible. We can not know -- in advance, since a TvName can appear in an HsTyVar. --- See Note [Demotion] in GHC.Rename.Env +-- See Note [Demotion] in GHC.Rename.Env. demoteNameSpace :: NameSpace -> Maybe NameSpace demoteNameSpace VarName = Nothing demoteNameSpace DataName = Nothing demoteNameSpace TvName = Nothing demoteNameSpace TcClsName = Just DataName +-- promoteNameSpace promotes the NameSpace as follows. +-- See Note [Promotion] in GHC.Rename.Env. +promoteNameSpace :: NameSpace -> Maybe NameSpace +promoteNameSpace DataName = Just TcClsName +promoteNameSpace VarName = Just TvName +promoteNameSpace TcClsName = Nothing +promoteNameSpace TvName = Nothing + {- ************************************************************************ * * @@ -336,12 +345,19 @@ mkClsOccFS :: FastString -> OccName mkClsOccFS = mkOccNameFS clsName -- demoteOccName lowers the Namespace of OccName. --- see Note [Demotion] +-- See Note [Demotion] in GHC.Rename.Env. demoteOccName :: OccName -> Maybe OccName demoteOccName (OccName space name) = do space' <- demoteNameSpace space return $ OccName space' name +-- promoteOccName promotes the NameSpace of OccName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteOccName :: OccName -> Maybe OccName +promoteOccName (OccName space name) = do + space' <- promoteNameSpace space + return $ OccName space' name + -- Name spaces are related if there is a chance to mean the one when one writes -- the other, i.e. variables <-> data constructors and type variables <-> type constructors nameSpacesRelated :: NameSpace -> NameSpace -> Bool ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types.Name.Reader ( nameRdrName, getRdrName, -- ** Destruction - rdrNameOcc, rdrNameSpace, demoteRdrName, + rdrNameOcc, rdrNameSpace, demoteRdrName, promoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, @@ -182,13 +182,21 @@ rdrNameSpace :: RdrName -> NameSpace rdrNameSpace = occNameSpace . rdrNameOcc -- demoteRdrName lowers the NameSpace of RdrName. --- see Note [Demotion] in GHC.Types.Name.Occurrence +-- See Note [Demotion] in GHC.Rename.Env demoteRdrName :: RdrName -> Maybe RdrName demoteRdrName (Unqual occ) = fmap Unqual (demoteOccName occ) demoteRdrName (Qual m occ) = fmap (Qual m) (demoteOccName occ) demoteRdrName (Orig _ _) = Nothing demoteRdrName (Exact _) = Nothing +-- promoteRdrName promotes the NameSpace of RdrName. +-- See Note [Promotion] in GHC.Rename.Env. +promoteRdrName :: RdrName -> Maybe RdrName +promoteRdrName (Unqual occ) = fmap Unqual (promoteOccName occ) +promoteRdrName (Qual m occ) = fmap (Qual m) (promoteOccName occ) +promoteRdrName (Orig _ _) = Nothing +promoteRdrName (Exact _) = Nothing + -- These two are the basic constructors mkRdrUnqual :: OccName -> RdrName mkRdrUnqual occ = Unqual occ ===================================== testsuite/tests/module/mod132.stderr ===================================== @@ -1,4 +1,7 @@ mod132.hs:6:7: error: - • Data constructor not in scope: Foo - • Perhaps you meant variable ‘foo’ (line 6) + Illegal term-level use of the type constructor ‘Foo’ + imported from ‘Mod132_B’ at mod132.hs:4:1-15 + (and originally defined in ‘Mod132_A’ at Mod132_A.hs:3:1-14) + In the expression: Foo + In an equation for ‘foo’: foo = Foo ===================================== testsuite/tests/module/mod147.stderr ===================================== @@ -1,2 +1,7 @@ -mod147.hs:6:5: error: Data constructor not in scope: D :: t0 -> t +mod147.hs:6:5: + Illegal term-level use of the type constructor ‘D’ + imported from ‘Mod147_A’ at mod147.hs:4:1-15 + (and originally defined at Mod147_A.hs:3:1-14) + In the expression: D 4 + In an equation for ‘x’: x = D 4 ===================================== testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr ===================================== @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T ===================================== testsuite/tests/rename/should_fail/T18740a.hs ===================================== @@ -0,0 +1,3 @@ +module T18740a where + +x = Int ===================================== testsuite/tests/rename/should_fail/T18740a.stderr ===================================== @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int ===================================== testsuite/tests/rename/should_fail/T18740b.hs ===================================== @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/T18740b.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) ===================================== testsuite/tests/th/T14627.stderr ===================================== @@ -1,2 +1,7 @@ -T14627.hs:4:1: error: Data constructor not in scope: Bool +T14627.hs:4:1: +Illegal term-level use of the type constructor ‘Bool’ + imported from ‘Prelude’ at T14627.hs:1:1 + (and originally defined in ‘GHC.Types’) +In the expression: Bool + In an equation for ‘f’: f = Bool ===================================== testsuite/tests/th/T18740c.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module T18740c where + +import Data.Proxy +import Language.Haskell.TH.Syntax + +[d| f (Proxy :: Proxy a) = a |] >>= addTopDecls >> return [] ===================================== testsuite/tests/th/T18740c.stderr ===================================== @@ -0,0 +1,6 @@ + +T18740c.hs:9:1: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740c.hs:9:1 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a ===================================== testsuite/tests/th/T18740d.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +module T18740d where + +import Language.Haskell.TH + +-- If we used 'ConE' here, then we would expect this error message: +-- +-- Illegal term-level use of the type constructor ‘Bool’ +-- imported from ‘Prelude’ at T18740d.hs:3:8-14 +-- (and originally defined in ‘GHC.Types’) +-- +-- But we used 'VarE', so the error message should say: +-- +-- Illegal variable name: ‘Bool’ +-- +e1 = $(return (VarE ''Bool)) ===================================== testsuite/tests/th/T18740d.stderr ===================================== @@ -0,0 +1,5 @@ + +T18740d.hs:17:7: error: + • Illegal variable name: ‘Bool’ + When splicing a TH expression: GHC.Types.Bool + • In the untyped splice: $(return (VarE ''Bool)) ===================================== testsuite/tests/th/all.T ===================================== @@ -515,3 +515,5 @@ test('T18121', normal, compile, ['']) test('T18123', normal, compile, ['']) test('T18388', normal, compile, ['']) test('T18612', normal, compile, ['']) +test('T18740c', normal, compile_fail, ['']) +test('T18740d', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/990ea991a1c35fdb894fcb91f919fb8f8fed33dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/990ea991a1c35fdb894fcb91f919fb8f8fed33dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:22:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 12 Oct 2020 18:22:03 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18835 Message-ID: <5f84d70b7858a_80b3f84663b0fb8184668f8@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18835 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18835 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:22:00 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 12 Oct 2020 18:22:00 -0400 Subject: [Git][ghc/ghc][master] DynFlags: refactor DmdAnal Message-ID: <5f84d708dc9d7_80b87fc418184666f0@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -9,18 +9,20 @@ {-# LANGUAGE CPP #-} -module GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) where +module GHC.Core.Opt.DmdAnal + ( DmdAnalOpts(..) + , dmdAnalProgram + ) +where #include "HsVersions.h" import GHC.Prelude -import GHC.Driver.Session import GHC.Core.Opt.WorkWrap.Utils import GHC.Types.Demand -- All of it import GHC.Core import GHC.Core.Multiplicity ( scaledThing ) -import GHC.Core.Seq ( seqBinds ) import GHC.Utils.Outputable import GHC.Types.Var.Env import GHC.Types.Var.Set @@ -29,7 +31,6 @@ import Data.List ( mapAccumL ) import GHC.Core.DataCon import GHC.Types.ForeignCall ( isSafeForeignCall ) import GHC.Types.Id -import GHC.Types.Id.Info import GHC.Core.Utils import GHC.Core.TyCon import GHC.Core.Type @@ -41,7 +42,6 @@ import GHC.Utils.Panic import GHC.Data.Maybe ( isJust ) import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) -import GHC.Utils.Error ( dumpIfSet_dyn, DumpFormat (..) ) import GHC.Types.Unique.Set {- @@ -52,14 +52,21 @@ import GHC.Types.Unique.Set ************************************************************************ -} -dmdAnalProgram :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram -dmdAnalProgram dflags fam_envs binds = do - let env = emptyAnalEnv dflags fam_envs - let binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds - dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ - dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds - -- See Note [Stamp out space leaks in demand analysis] - seqBinds binds_plus_dmds `seq` return binds_plus_dmds +-- | Options for the demand analysis +data DmdAnalOpts = DmdAnalOpts + { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries + } + +-- | Outputs a new copy of the Core program in which binders have been annotated +-- with demand and strictness information. +-- +-- Note: use `seqBinds` on the result to avoid leaks due to lazyness (cf Note +-- [Stamp out space leaks in demand analysis]) +dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> CoreProgram -> CoreProgram +dmdAnalProgram opts fam_envs binds = binds_plus_dmds + where + env = emptyAnalEnv opts fam_envs + binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds -- Analyse a (group of) top-level binding(s) dmdAnalTopBind :: AnalEnv @@ -1235,31 +1242,13 @@ type DFunFlag = Bool -- indicates if the lambda being considered is in the notArgOfDfun :: DFunFlag notArgOfDfun = False -{- Note [dmdAnalEnv performance] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -It's tempting to think that removing the dynflags from AnalEnv would improve -performance. After all when analysing recursive groups we end up allocating -a lot of environments. However this is not the case. - -We do get some performance by making AnalEnv smaller. However very often we -defer computation which means we have to capture the dynflags in the thunks -we allocate. Doing this naively in practice causes more allocation than the -removal of DynFlags saves us. - -In theory it should be possible to make this better if we are stricter in -the analysis and therefore allocate fewer thunks. But I couldn't get there -in a few hours and overall the impact on GHC here is small, and there are -bigger fish to fry. So for new the env will keep a reference to the flags. --} - -data AnalEnv - = AE { ae_dflags :: DynFlags -- See Note [dmdAnalEnv performance] - , ae_sigs :: SigEnv - , ae_virgin :: Bool -- True on first iteration only +data AnalEnv = AE + { ae_strict_dicts :: !Bool -- ^ Enable strict dict + , ae_sigs :: !SigEnv + , ae_virgin :: !Bool -- ^ True on first iteration only -- See Note [Initialising strictness] - , ae_fam_envs :: FamInstEnvs - } + , ae_fam_envs :: !FamInstEnvs + } -- We use the se_env to tell us whether to -- record info about a variable in the DmdEnv @@ -1271,17 +1260,18 @@ data AnalEnv type SigEnv = VarEnv (StrictSig, TopLevelFlag) instance Outputable AnalEnv where - ppr (AE { ae_sigs = env, ae_virgin = virgin }) - = text "AE" <+> braces (vcat - [ text "ae_virgin =" <+> ppr virgin - , text "ae_sigs =" <+> ppr env ]) - -emptyAnalEnv :: DynFlags -> FamInstEnvs -> AnalEnv -emptyAnalEnv dflags fam_envs - = AE { ae_dflags = dflags - , ae_sigs = emptySigEnv - , ae_virgin = True - , ae_fam_envs = fam_envs + ppr env = text "AE" <+> braces (vcat + [ text "ae_virgin =" <+> ppr (ae_virgin env) + , text "ae_strict_dicts =" <+> ppr (ae_strict_dicts env) + , text "ae_sigs =" <+> ppr (ae_sigs env) + ]) + +emptyAnalEnv :: DmdAnalOpts -> FamInstEnvs -> AnalEnv +emptyAnalEnv opts fam_envs + = AE { ae_strict_dicts = dmd_strict_dicts opts + , ae_sigs = emptySigEnv + , ae_virgin = True + , ae_fam_envs = fam_envs } emptySigEnv :: SigEnv @@ -1334,7 +1324,7 @@ findBndrDmd env arg_of_dfun dmd_ty id id_ty = idType id strictify dmd - | gopt Opt_DictsStrict (ae_dflags env) + | ae_strict_dicts env -- We never want to strictify a recursive let. At the moment -- annotateBndr is only call for non-recursive lets; if that -- changes, we need a RecFlag parameter and another guard here. ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -24,7 +24,7 @@ import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Types.Id.Info import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) -import GHC.Core.Utils ( mkTicks, stripTicksTop ) +import GHC.Core.Utils ( mkTicks, stripTicksTop, dumpIdInfoOfProgram ) import GHC.Core.Lint ( endPass, lintPassResult, dumpPassResult, lintAnnots ) import GHC.Core.Opt.Simplify ( simplTopBinds, simplExpr, simplRules ) @@ -41,15 +41,17 @@ import GHC.Utils.Error ( withTiming, withTimingD, DumpFormat (..) ) import GHC.Types.Basic import GHC.Types.Var.Set import GHC.Types.Var.Env +import GHC.Types.Demand import GHC.Core.Opt.LiberateCase ( liberateCase ) import GHC.Core.Opt.StaticArgs ( doStaticArgs ) import GHC.Core.Opt.Specialise ( specProgram) import GHC.Core.Opt.SpecConstr ( specConstrProgram) -import GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) +import GHC.Core.Opt.DmdAnal import GHC.Core.Opt.CprAnal ( cprAnalProgram ) import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) +import GHC.Core.Seq (seqBinds) import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Unit.Module.Env @@ -484,7 +486,7 @@ doCorePass CoreDoExitify = {-# SCC "Exitify" #-} doPass exitifyProgram doCorePass CoreDoDemand = {-# SCC "DmdAnal" #-} - doPassDFM dmdAnalProgram + doPassDFM dmdAnal doCorePass CoreDoCpr = {-# SCC "CprAnal" #-} doPassDFM cprAnalProgram @@ -1074,3 +1076,16 @@ transferIdInfo exported_id local_id (ruleInfo local_info) -- Remember to set the function-name field of the -- rules as we transfer them from one function to another + + + +dmdAnal :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram +dmdAnal dflags fam_envs binds = do + let opts = DmdAnalOpts + { dmd_strict_dicts = gopt Opt_DictsStrict dflags + } + binds_plus_dmds = dmdAnalProgram opts fam_envs binds + Err.dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ + dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds + -- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal + seqBinds binds_plus_dmds `seq` return binds_plus_dmds View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bbc84d20d0f50901351246cbe97c45234ca7d95 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9bbc84d20d0f50901351246cbe97c45234ca7d95 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:22:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 12 Oct 2020 18:22:46 -0400 Subject: [Git][ghc/ghc][wip/T18835] hadrian: Suppress xelatex output unless it fails Message-ID: <5f84d7368f8d2_80bd88f420184670ad@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18835 at Glasgow Haskell Compiler / GHC Commits: 37e1df61 by Ben Gamari at 2020-10-12T18:22:11-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 1 changed file: - hadrian/src/Builder.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -286,7 +286,19 @@ instance H.Builder Builder where Makeinfo -> do cmd' echo [path] "--no-split" [ "-o", output] [input] - Xelatex -> unit $ cmd' [Cwd output] [path] buildArgs + Xelatex -> + -- xelatex produces an incredible amount of output, almost + -- all of which is useless. Suppress it unless user + -- requests a loud build. + if verbosity >= Loud + then cmd' [Cwd output] [path] buildArgs + else do + (stdouterr out, Exit code) <- cmd' [Cwd output] [path] buildArgs + when (code /= ExitSuccess) $ + BSL.hPutStrLn stderr out + putFailure "xelatex failed!" + fail "xelatex failed" + Makeindex -> unit $ cmd' [Cwd output] [path] (buildArgs ++ [input]) Tar _ -> cmd' buildOptions echo [path] buildArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37e1df612540b2b26b7d2d5d810179f2218681ef -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37e1df612540b2b26b7d2d5d810179f2218681ef You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 22:52:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 12 Oct 2020 18:52:51 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: DynFlags: refactor DmdAnal Message-ID: <5f84de4365657_80b3f8434f889a8185013cf@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 824988ab by Wander Hillen at 2020-10-12T18:52:36-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - d8a9cdb6 by Sylvain Henry at 2020-10-12T18:52:40-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 21 changed files: - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools/ExtraObj.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - + libraries/ghc-boot/GHC/Data/ShortText.hs - libraries/ghc-boot/GHC/Unit/Database.hs - compiler/GHC/Utils/Encoding.hs → libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-boot/ghc-boot.cabal.in - utils/ghc-pkg/Main.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -20,7 +20,7 @@ import GHC.Prelude import GHC.Cmm.Expr import GHC.Parser.Lexer -import GHC.Cmm.Monad +import GHC.Cmm.Parser.Monad import GHC.Types.SrcLoc import GHC.Types.Unique.FM import GHC.Data.StringBuffer ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -234,8 +234,8 @@ import GHC.Cmm.Info import GHC.Cmm.BlockId import GHC.Cmm.Lexer import GHC.Cmm.CLabel -import GHC.Cmm.Monad hiding (getPlatform, getProfile, getPtrOpts) -import qualified GHC.Cmm.Monad as PD +import GHC.Cmm.Parser.Monad hiding (getPlatform, getProfile, getPtrOpts) +import qualified GHC.Cmm.Parser.Monad as PD import GHC.Cmm.CallConv import GHC.Runtime.Heap.Layout import GHC.Parser.Lexer @@ -385,9 +385,11 @@ cmmtop :: { CmmParse () } | cmmdata { $1 } | decl { $1 } | 'CLOSURE' '(' NAME ',' NAME lits ')' ';' - {% liftP . withHomeUnitId $ \pkg -> - do lits <- sequence $6; - staticClosure pkg $3 $5 (map getLit lits) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + lits <- sequence $6; + staticClosure home_unit_id $3 $5 (map getLit lits) } -- The only static closures in the RTS are dummy closures like -- stg_END_TSO_QUEUE_closure and stg_dummy_ret. We don't need @@ -406,8 +408,10 @@ cmmdata :: { CmmParse () } data_label :: { CmmParse CLabel } : NAME ':' - {% liftP . withHomeUnitId $ \pkg -> - return (mkCmmDataLabel pkg (NeedExternDecl False) $1) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + pure (mkCmmDataLabel home_unit_id (NeedExternDecl False) $1) } statics :: { [CmmParse [CmmStatic]] } : {- empty -} { [] } @@ -464,103 +468,117 @@ maybe_body :: { CmmParse () } info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) } : NAME - {% liftP . withHomeUnitId $ \pkg -> - do newFunctionName $1 pkg - return (mkCmmCodeLabel pkg $1, Nothing, []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + newFunctionName $1 home_unit_id + return (mkCmmCodeLabel home_unit_id $1, Nothing, []) } | 'INFO_TABLE' '(' NAME ',' INT ',' INT ',' INT ',' STRING ',' STRING ')' -- ptrs, nptrs, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $11 $13 - rep = mkRTSRep (fromIntegral $9) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) Thunk - -- not really Thunk, but that makes the info table - -- we want. - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $11 $13 + rep = mkRTSRep (fromIntegral $9) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) Thunk + -- not really Thunk, but that makes the info table + -- we want. + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_FUN' '(' NAME ',' INT ',' INT ',' INT ',' STRING ',' STRING ',' INT ')' -- ptrs, nptrs, closure type, description, type, fun type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $11 $13 - ty = Fun 0 (ArgSpec (fromIntegral $15)) - -- Arity zero, arg_type $15 - rep = mkRTSRep (fromIntegral $9) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $11 $13 + ty = Fun 0 (ArgSpec (fromIntegral $15)) + -- Arity zero, arg_type $15 + rep = mkRTSRep (fromIntegral $9) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } -- we leave most of the fields zero here. This is only used -- to generate the BCO info table in the RTS at the moment. | 'INFO_TABLE_CONSTR' '(' NAME ',' INT ',' INT ',' INT ',' INT ',' STRING ',' STRING ')' -- ptrs, nptrs, tag, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $13 $15 - ty = Constr (fromIntegral $9) -- Tag - (BS8.pack $13) - rep = mkRTSRep (fromIntegral $11) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing,cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $13 $15 + ty = Constr (fromIntegral $9) -- Tag + (BS8.pack $13) + rep = mkRTSRep (fromIntegral $11) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing,cit_clo = Nothing }, + []) } -- If profiling is on, this string gets duplicated, -- but that's the way the old code did it we can fix it some other time. | 'INFO_TABLE_SELECTOR' '(' NAME ',' INT ',' INT ',' STRING ',' STRING ')' -- selector, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $9 $11 - ty = ThunkSelector (fromIntegral $5) - rep = mkRTSRep (fromIntegral $7) $ - mkHeapRep profile False 0 0 ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $9 $11 + ty = ThunkSelector (fromIntegral $5) + rep = mkRTSRep (fromIntegral $7) $ + mkHeapRep profile False 0 0 ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_RET' '(' NAME ',' INT ')' -- closure type (no live regs) - {% liftP . withHomeUnitId $ \pkg -> - do let prof = NoProfilingInfo - rep = mkRTSRep (fromIntegral $5) $ mkStackRep [] - return (mkCmmRetLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + let prof = NoProfilingInfo + rep = mkRTSRep (fromIntegral $5) $ mkStackRep [] + return (mkCmmRetLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_RET' '(' NAME ',' INT ',' formals0 ')' -- closure type, live regs - {% liftP . withHomeUnitId $ \pkg -> - do platform <- getPlatform - live <- sequence $7 - let prof = NoProfilingInfo - -- drop one for the info pointer - bitmap = mkLiveness platform (drop 1 live) - rep = mkRTSRep (fromIntegral $5) $ mkStackRep bitmap - return (mkCmmRetLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - live) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + platform <- getPlatform + live <- sequence $7 + let prof = NoProfilingInfo + -- drop one for the info pointer + bitmap = mkLiveness platform (drop 1 live) + rep = mkRTSRep (fromIntegral $5) $ mkStackRep bitmap + return (mkCmmRetLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + live) } body :: { CmmParse () } : {- empty -} { return () } ===================================== compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs ===================================== @@ -7,13 +7,14 @@ -- The parser for C-- requires access to a lot more of the 'DynFlags', -- so 'PD' provides access to 'DynFlags' via a 'HasDynFlags' instance. ----------------------------------------------------------------------------- -module GHC.Cmm.Monad ( +module GHC.Cmm.Parser.Monad ( PD(..) , liftP , failMsgPD , getProfile , getPlatform , getPtrOpts + , getHomeUnitId ) where import GHC.Prelude @@ -28,6 +29,8 @@ import GHC.Driver.Session import GHC.Parser.Lexer import GHC.Parser.Errors import GHC.Types.SrcLoc +import GHC.Unit.Types +import GHC.Unit.Home newtype PD a = PD { unPD :: DynFlags -> PState -> ParseResult a } @@ -73,3 +76,9 @@ getPtrOpts = do { po_profile = profile , po_align_check = gopt Opt_AlignmentSanitisation dflags } + +-- | Return the UnitId of the home-unit. This is used to create labels. +getHomeUnitId :: PD UnitId +getHomeUnitId = do + dflags <- getDynFlags + pure (homeUnitId (mkHomeUnitFromFlags dflags)) ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -9,18 +9,20 @@ {-# LANGUAGE CPP #-} -module GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) where +module GHC.Core.Opt.DmdAnal + ( DmdAnalOpts(..) + , dmdAnalProgram + ) +where #include "HsVersions.h" import GHC.Prelude -import GHC.Driver.Session import GHC.Core.Opt.WorkWrap.Utils import GHC.Types.Demand -- All of it import GHC.Core import GHC.Core.Multiplicity ( scaledThing ) -import GHC.Core.Seq ( seqBinds ) import GHC.Utils.Outputable import GHC.Types.Var.Env import GHC.Types.Var.Set @@ -29,7 +31,6 @@ import Data.List ( mapAccumL ) import GHC.Core.DataCon import GHC.Types.ForeignCall ( isSafeForeignCall ) import GHC.Types.Id -import GHC.Types.Id.Info import GHC.Core.Utils import GHC.Core.TyCon import GHC.Core.Type @@ -41,7 +42,6 @@ import GHC.Utils.Panic import GHC.Data.Maybe ( isJust ) import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) -import GHC.Utils.Error ( dumpIfSet_dyn, DumpFormat (..) ) import GHC.Types.Unique.Set {- @@ -52,14 +52,21 @@ import GHC.Types.Unique.Set ************************************************************************ -} -dmdAnalProgram :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram -dmdAnalProgram dflags fam_envs binds = do - let env = emptyAnalEnv dflags fam_envs - let binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds - dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ - dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds - -- See Note [Stamp out space leaks in demand analysis] - seqBinds binds_plus_dmds `seq` return binds_plus_dmds +-- | Options for the demand analysis +data DmdAnalOpts = DmdAnalOpts + { dmd_strict_dicts :: !Bool -- ^ Use strict dictionaries + } + +-- | Outputs a new copy of the Core program in which binders have been annotated +-- with demand and strictness information. +-- +-- Note: use `seqBinds` on the result to avoid leaks due to lazyness (cf Note +-- [Stamp out space leaks in demand analysis]) +dmdAnalProgram :: DmdAnalOpts -> FamInstEnvs -> CoreProgram -> CoreProgram +dmdAnalProgram opts fam_envs binds = binds_plus_dmds + where + env = emptyAnalEnv opts fam_envs + binds_plus_dmds = snd $ mapAccumL dmdAnalTopBind env binds -- Analyse a (group of) top-level binding(s) dmdAnalTopBind :: AnalEnv @@ -1235,31 +1242,13 @@ type DFunFlag = Bool -- indicates if the lambda being considered is in the notArgOfDfun :: DFunFlag notArgOfDfun = False -{- Note [dmdAnalEnv performance] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -It's tempting to think that removing the dynflags from AnalEnv would improve -performance. After all when analysing recursive groups we end up allocating -a lot of environments. However this is not the case. - -We do get some performance by making AnalEnv smaller. However very often we -defer computation which means we have to capture the dynflags in the thunks -we allocate. Doing this naively in practice causes more allocation than the -removal of DynFlags saves us. - -In theory it should be possible to make this better if we are stricter in -the analysis and therefore allocate fewer thunks. But I couldn't get there -in a few hours and overall the impact on GHC here is small, and there are -bigger fish to fry. So for new the env will keep a reference to the flags. --} - -data AnalEnv - = AE { ae_dflags :: DynFlags -- See Note [dmdAnalEnv performance] - , ae_sigs :: SigEnv - , ae_virgin :: Bool -- True on first iteration only +data AnalEnv = AE + { ae_strict_dicts :: !Bool -- ^ Enable strict dict + , ae_sigs :: !SigEnv + , ae_virgin :: !Bool -- ^ True on first iteration only -- See Note [Initialising strictness] - , ae_fam_envs :: FamInstEnvs - } + , ae_fam_envs :: !FamInstEnvs + } -- We use the se_env to tell us whether to -- record info about a variable in the DmdEnv @@ -1271,17 +1260,18 @@ data AnalEnv type SigEnv = VarEnv (StrictSig, TopLevelFlag) instance Outputable AnalEnv where - ppr (AE { ae_sigs = env, ae_virgin = virgin }) - = text "AE" <+> braces (vcat - [ text "ae_virgin =" <+> ppr virgin - , text "ae_sigs =" <+> ppr env ]) - -emptyAnalEnv :: DynFlags -> FamInstEnvs -> AnalEnv -emptyAnalEnv dflags fam_envs - = AE { ae_dflags = dflags - , ae_sigs = emptySigEnv - , ae_virgin = True - , ae_fam_envs = fam_envs + ppr env = text "AE" <+> braces (vcat + [ text "ae_virgin =" <+> ppr (ae_virgin env) + , text "ae_strict_dicts =" <+> ppr (ae_strict_dicts env) + , text "ae_sigs =" <+> ppr (ae_sigs env) + ]) + +emptyAnalEnv :: DmdAnalOpts -> FamInstEnvs -> AnalEnv +emptyAnalEnv opts fam_envs + = AE { ae_strict_dicts = dmd_strict_dicts opts + , ae_sigs = emptySigEnv + , ae_virgin = True + , ae_fam_envs = fam_envs } emptySigEnv :: SigEnv @@ -1334,7 +1324,7 @@ findBndrDmd env arg_of_dfun dmd_ty id id_ty = idType id strictify dmd - | gopt Opt_DictsStrict (ae_dflags env) + | ae_strict_dicts env -- We never want to strictify a recursive let. At the moment -- annotateBndr is only call for non-recursive lets; if that -- changes, we need a RecFlag parameter and another guard here. ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -24,7 +24,7 @@ import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Types.Id.Info import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) -import GHC.Core.Utils ( mkTicks, stripTicksTop ) +import GHC.Core.Utils ( mkTicks, stripTicksTop, dumpIdInfoOfProgram ) import GHC.Core.Lint ( endPass, lintPassResult, dumpPassResult, lintAnnots ) import GHC.Core.Opt.Simplify ( simplTopBinds, simplExpr, simplRules ) @@ -41,15 +41,17 @@ import GHC.Utils.Error ( withTiming, withTimingD, DumpFormat (..) ) import GHC.Types.Basic import GHC.Types.Var.Set import GHC.Types.Var.Env +import GHC.Types.Demand import GHC.Core.Opt.LiberateCase ( liberateCase ) import GHC.Core.Opt.StaticArgs ( doStaticArgs ) import GHC.Core.Opt.Specialise ( specProgram) import GHC.Core.Opt.SpecConstr ( specConstrProgram) -import GHC.Core.Opt.DmdAnal ( dmdAnalProgram ) +import GHC.Core.Opt.DmdAnal import GHC.Core.Opt.CprAnal ( cprAnalProgram ) import GHC.Core.Opt.CallArity ( callArityAnalProgram ) import GHC.Core.Opt.Exitify ( exitifyProgram ) import GHC.Core.Opt.WorkWrap ( wwTopBinds ) +import GHC.Core.Seq (seqBinds) import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Unit.Module.Env @@ -484,7 +486,7 @@ doCorePass CoreDoExitify = {-# SCC "Exitify" #-} doPass exitifyProgram doCorePass CoreDoDemand = {-# SCC "DmdAnal" #-} - doPassDFM dmdAnalProgram + doPassDFM dmdAnal doCorePass CoreDoCpr = {-# SCC "CprAnal" #-} doPassDFM cprAnalProgram @@ -1074,3 +1076,16 @@ transferIdInfo exported_id local_id (ruleInfo local_info) -- Remember to set the function-name field of the -- rules as we transfer them from one function to another + + + +dmdAnal :: DynFlags -> FamInstEnvs -> CoreProgram -> IO CoreProgram +dmdAnal dflags fam_envs binds = do + let opts = DmdAnalOpts + { dmd_strict_dicts = gopt Opt_DictsStrict dflags + } + binds_plus_dmds = dmdAnalProgram opts fam_envs binds + Err.dumpIfSet_dyn dflags Opt_D_dump_str_signatures "Strictness signatures" FormatText $ + dumpIdInfoOfProgram (pprIfaceStrictSig . strictnessInfo) binds_plus_dmds + -- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal + seqBinds binds_plus_dmds `seq` return binds_plus_dmds ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NondecreasingIndentation #-} +{-# LANGUAGE OverloadedStrings #-} + -- | This is the driver for the 'ghc --backpack' mode, which -- is a reimplementation of the "package manager" bits of @@ -38,6 +40,7 @@ import GHC.Unit.State import GHC.Driver.Types import GHC.Data.StringBuffer import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Error import GHC.Types.SrcLoc import GHC.Driver.Main @@ -340,8 +343,8 @@ buildUnit session cid insts lunit = do unitAbiDepends = [], unitLinkerOptions = case session of TcSession -> [] - _ -> obj_files, - unitImportDirs = [ hi_dir ], + _ -> map ST.pack $ obj_files, + unitImportDirs = [ ST.pack $ hi_dir ], unitIsExposed = False, unitIsIndefinite = case session of TcSession -> True ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Cmm.CLabel import GHC.Driver.Types import GHC.Driver.Session import GHC.Driver.Ppr +import qualified GHC.Data.ShortText as ST import GHC.Data.Stream ( Stream ) import qualified GHC.Data.Stream as Stream import GHC.SysTools.FileCleanup @@ -211,7 +212,7 @@ outputForeignStubs dflags mod location stubs let rts_includes = let rts_pkg = unsafeLookupUnitId (unitState dflags) rtsUnitId in concatMap mk_include (unitIncludes rts_pkg) - mk_include i = "#include \"" ++ i ++ "\"\n" + mk_include i = "#include \"" ++ ST.unpack i ++ "\"\n" -- wrapper code mentions the ffi_arg type, which comes from ffi.h ffi_includes ===================================== compiler/GHC/Driver/Config.hs ===================================== @@ -32,7 +32,6 @@ initParserOpts = mkParserOpts <$> warningFlags <*> extensionFlags - <*> homeUnitId_ <*> safeImportsOn <*> gopt Opt_Haddock <*> gopt Opt_KeepRawTokenStream ===================================== compiler/GHC/Driver/Finder.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Unit.State import GHC.Driver.Types import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Misc import GHC.Builtin.Names ( gHC_PRIM ) import GHC.Driver.Session @@ -380,7 +381,7 @@ findPackageModule_ hsc_env mod pkg_conf = mk_hi_loc = mkHiOnlyModLocation dflags package_hisuf - import_dirs = unitImportDirs pkg_conf + import_dirs = map ST.unpack $ unitImportDirs pkg_conf -- we never look for a .hi-boot file in an external package; -- .hi-boot files only make sense for the home package. in ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -55,7 +55,7 @@ module GHC.Parser.Lexer ( P(..), ParseResult(..), allocateComments, MonadP(..), - getRealSrcLoc, getPState, withHomeUnitId, + getRealSrcLoc, getPState, failMsgP, failLocMsgP, srcParseFail, getErrorMessages, getMessages, popContext, pushModuleContext, setLastToken, setSrcLoc, @@ -104,7 +104,6 @@ import GHC.Data.OrdList import GHC.Utils.Misc ( readRational, readHexRational ) import GHC.Types.SrcLoc -import GHC.Unit.Types import GHC.Types.Basic ( InlineSpec(..), RuleMatchInfo(..), IntegralLit(..), FractionalLit(..), SourceText(..) ) @@ -2210,10 +2209,8 @@ warnopt f options = f `EnumSet.member` pWarningFlags options -- | Parser options. -- -- See 'mkParserOpts' to construct this. -data ParserOpts = ParserOpts { - pWarningFlags :: EnumSet WarningFlag - , pHomeUnitId :: UnitId -- ^ id of the unit currently being compiled - -- (only used in Cmm parser) +data ParserOpts = ParserOpts + { pWarningFlags :: EnumSet WarningFlag -- ^ enabled warning flags , pExtsBitmap :: !ExtsBitmap -- ^ bitmap of permitted extensions } @@ -2322,9 +2319,6 @@ failLocMsgP loc1 loc2 f = getPState :: P PState getPState = P $ \s -> POk s s -withHomeUnitId :: (UnitId -> a) -> P a -withHomeUnitId f = P $ \s@(PState{options = o}) -> POk s (f (pHomeUnitId o)) - getExts :: P ExtsBitmap getExts = P $ \s -> POk s (pExtsBitmap . options $ s) @@ -2637,8 +2631,6 @@ data ExtBits mkParserOpts :: EnumSet WarningFlag -- ^ warnings flags enabled -> EnumSet LangExt.Extension -- ^ permitted language extensions enabled - -> UnitId -- ^ id of the unit currently being compiled - -- (used in Cmm parser) -> Bool -- ^ are safe imports on? -> Bool -- ^ keeping Haddock comment tokens -> Bool -- ^ keep regular comment tokens @@ -2650,11 +2642,10 @@ mkParserOpts -> ParserOpts -- ^ Given exactly the information needed, set up the 'ParserOpts' -mkParserOpts warningFlags extensionFlags homeUnitId +mkParserOpts warningFlags extensionFlags safeImports isHaddock rawTokStream usePosPrags = ParserOpts { pWarningFlags = warningFlags - , pHomeUnitId = homeUnitId , pExtsBitmap = safeHaskellBit .|. langExtBits .|. optBits } where ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -61,6 +61,7 @@ import GHC.Types.SrcLoc import qualified GHC.Data.Maybe as Maybes import GHC.Types.Unique.DSet import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Platform import GHC.SysTools import GHC.SysTools.FileCleanup @@ -1282,10 +1283,10 @@ linkPackage hsc_env pkg let dflags = hsc_dflags hsc_env platform = targetPlatform dflags is_dyn = interpreterDynamic (hscInterp hsc_env) - dirs | is_dyn = Packages.unitLibraryDynDirs pkg - | otherwise = Packages.unitLibraryDirs pkg + dirs | is_dyn = map ST.unpack $ Packages.unitLibraryDynDirs pkg + | otherwise = map ST.unpack $ Packages.unitLibraryDirs pkg - let hs_libs = Packages.unitLibraries pkg + let hs_libs = map ST.unpack $ Packages.unitLibraries pkg -- The FFI GHCi import lib isn't needed as -- GHC.Runtime.Linker + rts/Linker.c link the -- interpreted references to FFI to the compiled FFI. @@ -1300,11 +1301,12 @@ linkPackage hsc_env pkg -- libs do not exactly match the .so/.dll equivalents. So if the -- package file provides an "extra-ghci-libraries" field then we use -- that instead of the "extra-libraries" field. - extra_libs = - (if null (Packages.unitExtDepLibsGhc pkg) - then Packages.unitExtDepLibsSys pkg - else Packages.unitExtDepLibsGhc pkg) - ++ [ lib | '-':'l':lib <- Packages.unitLinkerOptions pkg ] + extdeplibs = map ST.unpack (if null (Packages.unitExtDepLibsGhc pkg) + then Packages.unitExtDepLibsSys pkg + else Packages.unitExtDepLibsGhc pkg) + linkerlibs = [ lib | '-':'l':lib <- (map ST.unpack $ Packages.unitLinkerOptions pkg) ] + extra_libs = extdeplibs ++ linkerlibs + -- See Note [Fork/Exec Windows] gcc_paths <- getGCCPaths dflags (platformOS platform) dirs_env <- addEnvPaths "LIBRARY_PATH" dirs @@ -1434,8 +1436,8 @@ loadFrameworks :: HscEnv -> Platform -> UnitInfo -> IO () loadFrameworks hsc_env platform pkg = when (platformUsesFrameworks platform) $ mapM_ load frameworks where - fw_dirs = Packages.unitExtDepFrameworkDirs pkg - frameworks = Packages.unitExtDepFrameworks pkg + fw_dirs = map ST.unpack $ Packages.unitExtDepFrameworkDirs pkg + frameworks = map ST.unpack $ Packages.unitExtDepFrameworks pkg load fw = do r <- loadFramework hsc_env fw_dirs fw case r of ===================================== compiler/GHC/SysTools/ExtraObj.hs ===================================== @@ -25,6 +25,7 @@ import GHC.Unit import GHC.SysTools.Elf import GHC.Utils.Misc import GHC.Prelude +import qualified GHC.Data.ShortText as ST import Control.Monad import Data.Maybe @@ -57,7 +58,7 @@ mkExtraObj dflags extn xs -- we're compiling C or assembler. When compiling C, we pass the usual -- set of include directories and PIC flags. cOpts = map Option (picCCOpts dflags) - ++ map (FileOption "-I") + ++ map (FileOption "-I" . ST.unpack) (unitIncludeDirs $ unsafeLookupUnit pkgs rtsUnit) -- When compiling assembler code, we drop the usual C options, and if the ===================================== compiler/GHC/Unit/Info.hs ===================================== @@ -31,6 +31,7 @@ import Data.Version import Data.Bifunctor import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Outputable import GHC.Unit.Module as Module import GHC.Types.Unique @@ -124,21 +125,21 @@ pprUnitInfo GenericUnitInfo {..} = field "exposed-modules" (ppr unitExposedModules), field "hidden-modules" (fsep (map ppr unitHiddenModules)), field "trusted" (ppr unitIsTrusted), - field "import-dirs" (fsep (map text unitImportDirs)), - field "library-dirs" (fsep (map text unitLibraryDirs)), - field "dynamic-library-dirs" (fsep (map text unitLibraryDynDirs)), - field "hs-libraries" (fsep (map text unitLibraries)), - field "extra-libraries" (fsep (map text unitExtDepLibsSys)), - field "extra-ghci-libraries" (fsep (map text unitExtDepLibsGhc)), - field "include-dirs" (fsep (map text unitIncludeDirs)), - field "includes" (fsep (map text unitIncludes)), + field "import-dirs" (fsep (map (text . ST.unpack) unitImportDirs)), + field "library-dirs" (fsep (map (text . ST.unpack) unitLibraryDirs)), + field "dynamic-library-dirs" (fsep (map (text . ST.unpack) unitLibraryDynDirs)), + field "hs-libraries" (fsep (map (text . ST.unpack) unitLibraries)), + field "extra-libraries" (fsep (map (text . ST.unpack) unitExtDepLibsSys)), + field "extra-ghci-libraries" (fsep (map (text . ST.unpack) unitExtDepLibsGhc)), + field "include-dirs" (fsep (map (text . ST.unpack) unitIncludeDirs)), + field "includes" (fsep (map (text . ST.unpack) unitIncludes)), field "depends" (fsep (map ppr unitDepends)), - field "cc-options" (fsep (map text unitCcOptions)), - field "ld-options" (fsep (map text unitLinkerOptions)), - field "framework-dirs" (fsep (map text unitExtDepFrameworkDirs)), - field "frameworks" (fsep (map text unitExtDepFrameworks)), - field "haddock-interfaces" (fsep (map text unitHaddockInterfaces)), - field "haddock-html" (fsep (map text unitHaddockHTMLs)) + field "cc-options" (fsep (map (text . ST.unpack) unitCcOptions)), + field "ld-options" (fsep (map (text . ST.unpack) unitLinkerOptions)), + field "framework-dirs" (fsep (map (text . ST.unpack) unitExtDepFrameworkDirs)), + field "frameworks" (fsep (map (text . ST.unpack) unitExtDepFrameworks)), + field "haddock-interfaces" (fsep (map (text . ST.unpack) unitHaddockInterfaces)), + field "haddock-html" (fsep (map (text . ST.unpack) unitHaddockHTMLs)) ] where field name body = text name <> colon <+> nest 4 body ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -99,6 +99,7 @@ import GHC.Data.Maybe import System.Environment ( getEnv ) import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Error ( debugTraceMsg, MsgDoc, dumpIfSet_dyn, withTiming, DumpFormat (..) ) import GHC.Utils.Exception @@ -749,7 +750,7 @@ mungeUnitInfo :: FilePath -> FilePath -> UnitInfo -> UnitInfo mungeUnitInfo top_dir pkgroot = mungeDynLibFields - . mungeUnitInfoPaths top_dir pkgroot + . mungeUnitInfoPaths (ST.pack top_dir) (ST.pack pkgroot) mungeDynLibFields :: UnitInfo -> UnitInfo mungeDynLibFields pkg = @@ -1797,7 +1798,7 @@ getUnitIncludePath ctx unit_state home_unit pkgs = collectIncludeDirs `fmap` getPreloadUnitsAnd ctx unit_state home_unit pkgs collectIncludeDirs :: [UnitInfo] -> [FilePath] -collectIncludeDirs ps = ordNub (filter notNull (concatMap unitIncludeDirs ps)) +collectIncludeDirs ps = map ST.unpack $ ordNub (filter (not . ST.null) (concatMap unitIncludeDirs ps)) -- | Find all the library paths in these and the preload packages getUnitLibraryPath :: SDocContext -> UnitState -> HomeUnit -> Ways -> [UnitId] -> IO [String] @@ -1822,8 +1823,8 @@ collectLinkOpts :: DynFlags -> [UnitInfo] -> ([String], [String], [String]) collectLinkOpts dflags ps = ( concatMap (map ("-l" ++) . packageHsLibs dflags) ps, - concatMap (map ("-l" ++) . unitExtDepLibsSys) ps, - concatMap unitLinkerOptions ps + concatMap (map ("-l" ++) . map ST.unpack . unitExtDepLibsSys) ps, + concatMap (map ST.unpack . unitLinkerOptions) ps ) collectArchives :: DynFlags -> UnitInfo -> IO [FilePath] collectArchives dflags pc = @@ -1831,7 +1832,7 @@ collectArchives dflags pc = | searchPath <- searchPaths , lib <- libs ] where searchPaths = ordNub . filter notNull . libraryDirsForWay (ways dflags) $ pc - libs = packageHsLibs dflags pc ++ unitExtDepLibsSys pc + libs = packageHsLibs dflags pc ++ (map ST.unpack $ unitExtDepLibsSys pc) getLibs :: DynFlags -> [UnitId] -> IO [(String,String)] getLibs dflags pkgs = do @@ -1846,7 +1847,7 @@ getLibs dflags pkgs = do filterM (doesFileExist . fst) candidates packageHsLibs :: DynFlags -> UnitInfo -> [String] -packageHsLibs dflags p = map (mkDynName . addSuffix) (unitLibraries p) +packageHsLibs dflags p = map (mkDynName . addSuffix . ST.unpack) (unitLibraries p) where ways0 = ways dflags @@ -1895,27 +1896,27 @@ packageHsLibs dflags p = map (mkDynName . addSuffix) (unitLibraries p) -- | Either the 'unitLibraryDirs' or 'unitLibraryDynDirs' as appropriate for the way. libraryDirsForWay :: Ways -> UnitInfo -> [String] -libraryDirsForWay ws - | WayDyn `elem` ws = unitLibraryDynDirs - | otherwise = unitLibraryDirs +libraryDirsForWay ws ui + | WayDyn `elem` ws = map ST.unpack $ unitLibraryDynDirs ui + | otherwise = map ST.unpack $ unitLibraryDirs ui -- | Find all the C-compiler options in these and the preload packages getUnitExtraCcOpts :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitExtraCcOpts ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (concatMap unitCcOptions ps) + return $ map ST.unpack (concatMap unitCcOptions ps) -- | Find all the package framework paths in these and the preload packages getUnitFrameworkPath :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitFrameworkPath ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (ordNub (filter notNull (concatMap unitExtDepFrameworkDirs ps))) + return $ map ST.unpack (ordNub (filter (not . ST.null) (concatMap unitExtDepFrameworkDirs ps))) -- | Find all the package frameworks in these and the preload packages getUnitFrameworks :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitFrameworks ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (concatMap unitExtDepFrameworks ps) + return $ map ST.unpack (concatMap unitExtDepFrameworks ps) -- ----------------------------------------------------------------------------- -- Package Utils ===================================== compiler/ghc.cabal.in ===================================== @@ -239,7 +239,7 @@ Library GHC.Cmm.Lint GHC.Cmm.Liveness GHC.Cmm.MachOp - GHC.Cmm.Monad + GHC.Cmm.Parser.Monad GHC.Cmm.Switch GHC.Cmm.Node GHC.Cmm.Opt @@ -547,7 +547,6 @@ Library GHC.Data.BooleanFormula GHC.Utils.BufHandle GHC.Data.Graph.Directed - GHC.Utils.Encoding GHC.Utils.IO.Unsafe GHC.Data.FastMutInt GHC.Data.FastString ===================================== libraries/ghc-boot/GHC/Data/ShortText.hs ===================================== @@ -0,0 +1,112 @@ +{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples, GeneralizedNewtypeDeriving, DerivingStrategies #-} +{-# OPTIONS_GHC -O2 -funbox-strict-fields #-} + +-- | +-- An Unicode string for internal GHC use. Meant to replace String +-- in places where being a lazy linked is not very useful and a more +-- memory efficient data structure is desirable. + +-- Very similar to FastString, but not hash-consed and with some extra instances and +-- functions for serialisation and I/O. Should be imported qualified. + +module GHC.Data.ShortText ( + -- * ShortText + ShortText(..), + -- ** Conversion to and from String + pack, + unpack, + -- ** Operations + codepointLength, + byteLength, + GHC.Data.ShortText.null, + splitFilePath, + GHC.Data.ShortText.head, + stripPrefix + ) where + +import Prelude + +import Control.Monad (guard) +import Control.DeepSeq as DeepSeq +import Data.Binary +import qualified Data.ByteString.Char8 as B8 +import qualified Data.ByteString.Short.Internal as SBS +import GHC.Exts +import GHC.IO +import GHC.Utils.Encoding +import System.FilePath (isPathSeparator) + +{-| A 'ShortText' is a modified UTF-8 encoded string meant for short strings like +file paths, module descriptions, etc. +-} +newtype ShortText = ShortText { contents :: SBS.ShortByteString + } + deriving stock (Show) + deriving newtype (Eq, Ord, Binary, Semigroup, Monoid, NFData) + +-- We don't want to derive this one from ShortByteString since that one won't handle +-- UTF-8 characters correctly. +instance IsString ShortText where + fromString = pack + +-- | /O(n)/ Returns the length of the 'ShortText' in characters. +codepointLength :: ShortText -> Int +codepointLength st = unsafeDupablePerformIO $ countUTF8Chars (contents st) +-- | /O(1)/ Returns the length of the 'ShortText' in bytes. +byteLength :: ShortText -> Int +byteLength st = SBS.length $ contents st + +-- | /O(n)/ Convert a 'String' into a 'ShortText'. +pack :: String -> ShortText +pack s = unsafeDupablePerformIO $ ShortText <$> utf8EncodeShortByteString s + +-- | /O(n)/ Convert a 'ShortText' into a 'String'. +unpack :: ShortText -> String +unpack st = utf8DecodeShortByteString $ contents st + +-- | /O(1)/ Test whether the 'ShortText' is the empty string. +null :: ShortText -> Bool +null st = SBS.null $ contents st + +-- | /O(n)/ Split a 'ShortText' representing a file path into its components by separating +-- on the file separator characters for this platform. +splitFilePath :: ShortText -> [ShortText] +-- This seems dangerous, but since the path separators are in the ASCII set they map down +-- to a single byte when encoded in UTF-8 and so this should work even when casting to ByteString. +-- We DeepSeq.force the resulting list so that we can be sure that no references to the +-- bytestring in `st'` remain in unevaluated thunks, which might prevent `st'` from being +-- collected by the GC. +splitFilePath st = DeepSeq.force $ map (ShortText . SBS.toShort) $ B8.splitWith isPathSeparator st' + where st' = SBS.fromShort $ contents st + +-- | /O(1)/ Returns the first UTF-8 codepoint in the 'ShortText'. Depending on the string in +-- question, this may or may not be the actual first character in the string due to Unicode +-- non-printable characters. +head :: ShortText -> Char +head st + | SBS.null $ contents st = error "head: Empty ShortText" + | otherwise = Prelude.head $ unpack st + +-- | /O(n)/ The 'stripPrefix' function takes two 'ShortText's and returns 'Just' the remainder of +-- the second iff the first is its prefix, and otherwise Nothing. +stripPrefix :: ShortText -> ShortText -> Maybe ShortText +stripPrefix prefix st = do + let !(SBS.SBS prefixBA) = contents prefix + let !(SBS.SBS stBA) = contents st + let prefixLength = sizeofByteArray# prefixBA + let stLength = sizeofByteArray# stBA + -- If the length of 'st' is not >= than the length of 'prefix', it is impossible for 'prefix' + -- to be the prefix of `st`. + guard $ (I# stLength) >= (I# prefixLength) + -- 'prefix' is a prefix of 'st' if the first bytes of 'st' + -- are equal to 'prefix' + guard $ I# (compareByteArrays# prefixBA 0# stBA 0# prefixLength) == 0 + -- Allocate a new ByteArray# and copy the remainder of the 'st' into it + unsafeDupablePerformIO $ do + let newBAsize = (stLength -# prefixLength) + newSBS <- IO $ \s0 -> + let !(# s1, ba #) = newByteArray# newBAsize s0 + s2 = copyByteArray# stBA prefixLength ba 0# newBAsize s1 + !(# s3, fba #) = unsafeFreezeByteArray# ba s2 + in (# s3, SBS.SBS fba #) + return . Just . ShortText $ newSBS ===================================== libraries/ghc-boot/GHC/Unit/Database.hs ===================================== @@ -12,6 +12,7 @@ {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | @@ -82,16 +83,16 @@ import Data.Bifunctor import Data.Binary as Bin import Data.Binary.Put as Bin import Data.Binary.Get as Bin +import Data.List (intersperse) import Control.Exception as Exception import Control.Monad (when) import System.FilePath as FilePath -import qualified System.FilePath.Posix as FilePath.Posix import System.IO import System.IO.Error import GHC.IO.Exception (IOErrorType(InappropriateType)) +import qualified GHC.Data.ShortText as ST import GHC.IO.Handle.Lock import System.Directory -import Data.List (stripPrefix) -- | @ghc-boot@'s UnitInfo, serialized to the database. type DbUnitInfo = GenericUnitInfo BS.ByteString BS.ByteString BS.ByteString BS.ByteString BS.ByteString DbModule @@ -142,28 +143,28 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit -- components that can be registered in a database and used by other -- modules. - , unitAbiHash :: String + , unitAbiHash :: ST.ShortText -- ^ ABI hash used to avoid mixing up units compiled with different -- dependencies, compiler, options, etc. , unitDepends :: [uid] -- ^ Identifiers of the units this one depends on - , unitAbiDepends :: [(uid, String)] + , unitAbiDepends :: [(uid, ST.ShortText)] -- ^ Like 'unitDepends', but each dependency is annotated with the ABI hash -- we expect the dependency to respect. - , unitImportDirs :: [FilePath] + , unitImportDirs :: [FilePathST] -- ^ Directories containing module interfaces - , unitLibraries :: [String] + , unitLibraries :: [ST.ShortText] -- ^ Names of the Haskell libraries provided by this unit - , unitExtDepLibsSys :: [String] + , unitExtDepLibsSys :: [ST.ShortText] -- ^ Names of the external system libraries that this unit depends on. See -- also `unitExtDepLibsGhc` field. - , unitExtDepLibsGhc :: [String] + , unitExtDepLibsGhc :: [ST.ShortText] -- ^ Because of slight differences between the GHC dynamic linker (in -- GHC.Runtime.Linker) and the -- native system linker, some packages have to link with a different list @@ -174,46 +175,46 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit -- If this field is set, then we use that instead of the -- `unitExtDepLibsSys` field. - , unitLibraryDirs :: [FilePath] + , unitLibraryDirs :: [FilePathST] -- ^ Directories containing libraries provided by this unit. See also -- `unitLibraryDynDirs`. -- -- It seems to be used to store paths to external library dependencies -- too. - , unitLibraryDynDirs :: [FilePath] + , unitLibraryDynDirs :: [FilePathST] -- ^ Directories containing the dynamic libraries provided by this unit. -- See also `unitLibraryDirs`. -- -- It seems to be used to store paths to external dynamic library -- dependencies too. - , unitExtDepFrameworks :: [String] + , unitExtDepFrameworks :: [ST.ShortText] -- ^ Names of the external MacOS frameworks that this unit depends on. - , unitExtDepFrameworkDirs :: [FilePath] + , unitExtDepFrameworkDirs :: [FilePathST] -- ^ Directories containing MacOS frameworks that this unit depends -- on. - , unitLinkerOptions :: [String] + , unitLinkerOptions :: [ST.ShortText] -- ^ Linker (e.g. ld) command line options - , unitCcOptions :: [String] + , unitCcOptions :: [ST.ShortText] -- ^ C compiler options that needs to be passed to the C compiler when we -- compile some C code against this unit. - , unitIncludes :: [String] + , unitIncludes :: [ST.ShortText] -- ^ C header files that are required by this unit (provided by this unit -- or external) - , unitIncludeDirs :: [FilePath] + , unitIncludeDirs :: [FilePathST] -- ^ Directories containing C header files that this unit depends -- on. - , unitHaddockInterfaces :: [FilePath] + , unitHaddockInterfaces :: [FilePathST] -- ^ Paths to Haddock interface files for this unit - , unitHaddockHTMLs :: [FilePath] + , unitHaddockHTMLs :: [FilePathST] -- ^ Paths to Haddock directories containing HTML files , unitExposedModules :: [(modulename, Maybe mod)] @@ -242,6 +243,8 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit } deriving (Eq, Show) +type FilePathST = ST.ShortText + -- | Convert between GenericUnitInfo instances mapGenericUnitInfo :: (uid1 -> uid2) @@ -646,12 +649,12 @@ instance Binary DbInstUnitId where -- Also perform a similar substitution for the older GHC-specific -- "$topdir" variable. The "topdir" is the location of the ghc -- installation (obtained from the -B option). -mkMungePathUrl :: FilePath -> FilePath -> (FilePath -> FilePath, FilePath -> FilePath) +mkMungePathUrl :: FilePathST -> FilePathST -> (FilePathST -> FilePathST, FilePathST -> FilePathST) mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) where munge_path p - | Just p' <- stripVarPrefix "${pkgroot}" p = pkgroot ++ p' - | Just p' <- stripVarPrefix "$topdir" p = top_dir ++ p' + | Just p' <- stripVarPrefix "${pkgroot}" p = mappend pkgroot p' + | Just p' <- stripVarPrefix "$topdir" p = mappend top_dir p' | otherwise = p munge_url p @@ -659,20 +662,19 @@ mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) | Just p' <- stripVarPrefix "$httptopdir" p = toUrlPath top_dir p' | otherwise = p - toUrlPath r p = "file:///" - -- URLs always use posix style '/' separators: - ++ FilePath.Posix.joinPath - (r : -- We need to drop a leading "/" or "\\" - -- if there is one: - dropWhile (all isPathSeparator) - (FilePath.splitDirectories p)) + toUrlPath r p = mconcat $ "file:///" : (intersperse "/" (r : (splitDirectories p))) + -- URLs always use posix style '/' separators + + -- We need to drop a leading "/" or "\\" if there is one: + splitDirectories :: FilePathST -> [FilePathST] + splitDirectories p = filter (not . ST.null) $ ST.splitFilePath p -- We could drop the separator here, and then use above. However, -- by leaving it in and using ++ we keep the same path separator -- rather than letting FilePath change it to use \ as the separator - stripVarPrefix var path = case stripPrefix var path of - Just [] -> Just [] - Just cs@(c : _) | isPathSeparator c -> Just cs + stripVarPrefix var path = case ST.stripPrefix var path of + Just "" -> Just "" + Just cs | isPathSeparator (ST.head cs) -> Just cs _ -> Nothing @@ -684,7 +686,7 @@ mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) -- Also perform a similar substitution for the older GHC-specific -- "$topdir" variable. The "topdir" is the location of the ghc -- installation (obtained from the -B option). -mungeUnitInfoPaths :: FilePath -> FilePath -> GenericUnitInfo a b c d e f -> GenericUnitInfo a b c d e f +mungeUnitInfoPaths :: FilePathST -> FilePathST -> GenericUnitInfo a b c d e f -> GenericUnitInfo a b c d e f mungeUnitInfoPaths top_dir pkgroot pkg = -- TODO: similar code is duplicated in utils/ghc-pkg/Main.hs pkg ===================================== compiler/GHC/Utils/Encoding.hs → libraries/ghc-boot/GHC/Utils/Encoding.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-} -{-# OPTIONS_GHC -O2 #-} +{-# OPTIONS_GHC -O2 -fno-warn-name-shadowing #-} -- We always optimise this, otherwise performance of a non-optimised --- compiler is severely affected +-- compiler is severely affected. This module used to live in the `ghc` +-- package but has been moved to `ghc-boot` because the definition +-- of the package database (needed in both ghc and in ghc-pkg) lives in +-- `ghc-boot` and uses ShortText, which in turn depends on this module. -- ----------------------------------------------------------------------------- -- @@ -36,7 +39,7 @@ module GHC.Utils.Encoding ( toBase62Padded ) where -import GHC.Prelude +import Prelude import Foreign import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -38,6 +38,8 @@ Library exposed-modules: GHC.BaseDir + GHC.Data.ShortText + GHC.Utils.Encoding GHC.LanguageExtensions GHC.Unit.Database GHC.Serialized @@ -68,4 +70,5 @@ Library containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, + deepseq >= 1.4 && < 1.5, ghc-boot-th == @ProjectVersionMunged@ ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -31,12 +31,13 @@ module Main (main) where import qualified GHC.Unit.Database as GhcPkg -import GHC.Unit.Database +import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) +import qualified GHC.Data.ShortText as ST import GHC.Version ( cProjectVersion ) import qualified Distribution.Simple.PackageIndex as PackageIndex import qualified Data.Graph as Graph @@ -56,6 +57,7 @@ import Distribution.Types.MungedPackageId import Distribution.Simple.Utils (toUTF8BS, writeUTF8File, readUTF8File) import qualified Data.Version as Version import System.FilePath as FilePath +import qualified System.FilePath.Posix as FilePath.Posix import System.Directory ( getAppUserDataDirectory, createDirectoryIfMissing, getModificationTime ) import Text.Printf @@ -990,6 +992,35 @@ mungePackagePaths top_dir pkgroot pkg = munge_urls = map munge_url (munge_path,munge_url) = mkMungePathUrl top_dir pkgroot +mkMungePathUrl :: FilePath -> FilePath -> (FilePath -> FilePath, FilePath -> FilePath) +mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) + where + munge_path p + | Just p' <- stripVarPrefix "${pkgroot}" p = pkgroot ++ p' + | Just p' <- stripVarPrefix "$topdir" p = top_dir ++ p' + | otherwise = p + + munge_url p + | Just p' <- stripVarPrefix "${pkgrooturl}" p = toUrlPath pkgroot p' + | Just p' <- stripVarPrefix "$httptopdir" p = toUrlPath top_dir p' + | otherwise = p + + toUrlPath r p = "file:///" + -- URLs always use posix style '/' separators: + ++ FilePath.Posix.joinPath + (r : -- We need to drop a leading "/" or "\\" + -- if there is one: + dropWhile (all isPathSeparator) + (FilePath.splitDirectories p)) + + -- We could drop the separator here, and then use above. However, + -- by leaving it in and using ++ we keep the same path separator + -- rather than letting FilePath change it to use \ as the separator + stripVarPrefix var path = case stripPrefix var path of + Just [] -> Just [] + Just cs@(c : _) | isPathSeparator c -> Just cs + _ -> Nothing + -- ----------------------------------------------------------------------------- -- Workaround for old single-file style package dbs @@ -1331,7 +1362,7 @@ recomputeValidAbiDeps db pkg = newAbiDeps = catMaybes . flip map (GhcPkg.unitAbiDepends pkg) $ \(k, _) -> case filter (\d -> installedUnitId d == k) db of - [x] -> Just (k, unAbiHash (abiHash x)) + [x] -> Just (k, ST.pack $ unAbiHash (abiHash x)) _ -> Nothing abiDepsUpdated = GhcPkg.unitAbiDepends pkg /= newAbiDeps @@ -1370,22 +1401,22 @@ convertPackageInfoToCacheFormat pkg = GhcPkg.unitComponentName = fmap (mkPackageName . unUnqualComponentName) (libraryNameString $ sourceLibName pkg), GhcPkg.unitDepends = depends pkg, - GhcPkg.unitAbiDepends = map (\(AbiDependency k v) -> (k,unAbiHash v)) (abiDepends pkg), - GhcPkg.unitAbiHash = unAbiHash (abiHash pkg), - GhcPkg.unitImportDirs = importDirs pkg, - GhcPkg.unitLibraries = hsLibraries pkg, - GhcPkg.unitExtDepLibsSys = extraLibraries pkg, - GhcPkg.unitExtDepLibsGhc = extraGHCiLibraries pkg, - GhcPkg.unitLibraryDirs = libraryDirs pkg, - GhcPkg.unitLibraryDynDirs = libraryDynDirs pkg, - GhcPkg.unitExtDepFrameworks = frameworks pkg, - GhcPkg.unitExtDepFrameworkDirs = frameworkDirs pkg, - GhcPkg.unitLinkerOptions = ldOptions pkg, - GhcPkg.unitCcOptions = ccOptions pkg, - GhcPkg.unitIncludes = includes pkg, - GhcPkg.unitIncludeDirs = includeDirs pkg, - GhcPkg.unitHaddockInterfaces = haddockInterfaces pkg, - GhcPkg.unitHaddockHTMLs = haddockHTMLs pkg, + GhcPkg.unitAbiDepends = map (\(AbiDependency k v) -> (k,ST.pack $ unAbiHash v)) (abiDepends pkg), + GhcPkg.unitAbiHash = ST.pack $ unAbiHash (abiHash pkg), + GhcPkg.unitImportDirs = map ST.pack $ importDirs pkg, + GhcPkg.unitLibraries = map ST.pack $ hsLibraries pkg, + GhcPkg.unitExtDepLibsSys = map ST.pack $ extraLibraries pkg, + GhcPkg.unitExtDepLibsGhc = map ST.pack $ extraGHCiLibraries pkg, + GhcPkg.unitLibraryDirs = map ST.pack $ libraryDirs pkg, + GhcPkg.unitLibraryDynDirs = map ST.pack $ libraryDynDirs pkg, + GhcPkg.unitExtDepFrameworks = map ST.pack $ frameworks pkg, + GhcPkg.unitExtDepFrameworkDirs = map ST.pack $ frameworkDirs pkg, + GhcPkg.unitLinkerOptions = map ST.pack $ ldOptions pkg, + GhcPkg.unitCcOptions = map ST.pack $ ccOptions pkg, + GhcPkg.unitIncludes = map ST.pack $ includes pkg, + GhcPkg.unitIncludeDirs = map ST.pack $ includeDirs pkg, + GhcPkg.unitHaddockInterfaces = map ST.pack $ haddockInterfaces pkg, + GhcPkg.unitHaddockHTMLs = map ST.pack $ haddockHTMLs pkg, GhcPkg.unitExposedModules = map convertExposed (exposedModules pkg), GhcPkg.unitHiddenModules = hiddenModules pkg, GhcPkg.unitIsIndefinite = indefinite pkg, ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/431aea3ecec5acafcdd71f24a48562d9f13121b9...d8a9cdb6eaa8f70d8a6c4c7f84f762fab3f557ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/431aea3ecec5acafcdd71f24a48562d9f13121b9...d8a9cdb6eaa8f70d8a6c4c7f84f762fab3f557ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 12 23:56:26 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 12 Oct 2020 19:56:26 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18831 Message-ID: <5f84ed2abd130_80b3f848d9eb4b018519128@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18831 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18831 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 04:12:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 13 Oct 2020 00:12:56 -0400 Subject: [Git][ghc/ghc][master] Initial ShortText code and conversion of package db code Message-ID: <5f8529489e985_80b10d3a6981853346f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 13 changed files: - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools/ExtraObj.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - + libraries/ghc-boot/GHC/Data/ShortText.hs - libraries/ghc-boot/GHC/Unit/Database.hs - compiler/GHC/Utils/Encoding.hs → libraries/ghc-boot/GHC/Utils/Encoding.hs - libraries/ghc-boot/ghc-boot.cabal.in - utils/ghc-pkg/Main.hs Changes: ===================================== compiler/GHC/Driver/Backpack.hs ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NondecreasingIndentation #-} +{-# LANGUAGE OverloadedStrings #-} + -- | This is the driver for the 'ghc --backpack' mode, which -- is a reimplementation of the "package manager" bits of @@ -38,6 +40,7 @@ import GHC.Unit.State import GHC.Driver.Types import GHC.Data.StringBuffer import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Error import GHC.Types.SrcLoc import GHC.Driver.Main @@ -340,8 +343,8 @@ buildUnit session cid insts lunit = do unitAbiDepends = [], unitLinkerOptions = case session of TcSession -> [] - _ -> obj_files, - unitImportDirs = [ hi_dir ], + _ -> map ST.pack $ obj_files, + unitImportDirs = [ ST.pack $ hi_dir ], unitIsExposed = False, unitIsIndefinite = case session of TcSession -> True ===================================== compiler/GHC/Driver/CodeOutput.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Cmm.CLabel import GHC.Driver.Types import GHC.Driver.Session import GHC.Driver.Ppr +import qualified GHC.Data.ShortText as ST import GHC.Data.Stream ( Stream ) import qualified GHC.Data.Stream as Stream import GHC.SysTools.FileCleanup @@ -211,7 +212,7 @@ outputForeignStubs dflags mod location stubs let rts_includes = let rts_pkg = unsafeLookupUnitId (unitState dflags) rtsUnitId in concatMap mk_include (unitIncludes rts_pkg) - mk_include i = "#include \"" ++ i ++ "\"\n" + mk_include i = "#include \"" ++ ST.unpack i ++ "\"\n" -- wrapper code mentions the ffi_arg type, which comes from ffi.h ffi_includes ===================================== compiler/GHC/Driver/Finder.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Unit.State import GHC.Driver.Types import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Misc import GHC.Builtin.Names ( gHC_PRIM ) import GHC.Driver.Session @@ -380,7 +381,7 @@ findPackageModule_ hsc_env mod pkg_conf = mk_hi_loc = mkHiOnlyModLocation dflags package_hisuf - import_dirs = unitImportDirs pkg_conf + import_dirs = map ST.unpack $ unitImportDirs pkg_conf -- we never look for a .hi-boot file in an external package; -- .hi-boot files only make sense for the home package. in ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -61,6 +61,7 @@ import GHC.Types.SrcLoc import qualified GHC.Data.Maybe as Maybes import GHC.Types.Unique.DSet import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Platform import GHC.SysTools import GHC.SysTools.FileCleanup @@ -1282,10 +1283,10 @@ linkPackage hsc_env pkg let dflags = hsc_dflags hsc_env platform = targetPlatform dflags is_dyn = interpreterDynamic (hscInterp hsc_env) - dirs | is_dyn = Packages.unitLibraryDynDirs pkg - | otherwise = Packages.unitLibraryDirs pkg + dirs | is_dyn = map ST.unpack $ Packages.unitLibraryDynDirs pkg + | otherwise = map ST.unpack $ Packages.unitLibraryDirs pkg - let hs_libs = Packages.unitLibraries pkg + let hs_libs = map ST.unpack $ Packages.unitLibraries pkg -- The FFI GHCi import lib isn't needed as -- GHC.Runtime.Linker + rts/Linker.c link the -- interpreted references to FFI to the compiled FFI. @@ -1300,11 +1301,12 @@ linkPackage hsc_env pkg -- libs do not exactly match the .so/.dll equivalents. So if the -- package file provides an "extra-ghci-libraries" field then we use -- that instead of the "extra-libraries" field. - extra_libs = - (if null (Packages.unitExtDepLibsGhc pkg) - then Packages.unitExtDepLibsSys pkg - else Packages.unitExtDepLibsGhc pkg) - ++ [ lib | '-':'l':lib <- Packages.unitLinkerOptions pkg ] + extdeplibs = map ST.unpack (if null (Packages.unitExtDepLibsGhc pkg) + then Packages.unitExtDepLibsSys pkg + else Packages.unitExtDepLibsGhc pkg) + linkerlibs = [ lib | '-':'l':lib <- (map ST.unpack $ Packages.unitLinkerOptions pkg) ] + extra_libs = extdeplibs ++ linkerlibs + -- See Note [Fork/Exec Windows] gcc_paths <- getGCCPaths dflags (platformOS platform) dirs_env <- addEnvPaths "LIBRARY_PATH" dirs @@ -1434,8 +1436,8 @@ loadFrameworks :: HscEnv -> Platform -> UnitInfo -> IO () loadFrameworks hsc_env platform pkg = when (platformUsesFrameworks platform) $ mapM_ load frameworks where - fw_dirs = Packages.unitExtDepFrameworkDirs pkg - frameworks = Packages.unitExtDepFrameworks pkg + fw_dirs = map ST.unpack $ Packages.unitExtDepFrameworkDirs pkg + frameworks = map ST.unpack $ Packages.unitExtDepFrameworks pkg load fw = do r <- loadFramework hsc_env fw_dirs fw case r of ===================================== compiler/GHC/SysTools/ExtraObj.hs ===================================== @@ -25,6 +25,7 @@ import GHC.Unit import GHC.SysTools.Elf import GHC.Utils.Misc import GHC.Prelude +import qualified GHC.Data.ShortText as ST import Control.Monad import Data.Maybe @@ -57,7 +58,7 @@ mkExtraObj dflags extn xs -- we're compiling C or assembler. When compiling C, we pass the usual -- set of include directories and PIC flags. cOpts = map Option (picCCOpts dflags) - ++ map (FileOption "-I") + ++ map (FileOption "-I" . ST.unpack) (unitIncludeDirs $ unsafeLookupUnit pkgs rtsUnit) -- When compiling assembler code, we drop the usual C options, and if the ===================================== compiler/GHC/Unit/Info.hs ===================================== @@ -31,6 +31,7 @@ import Data.Version import Data.Bifunctor import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Outputable import GHC.Unit.Module as Module import GHC.Types.Unique @@ -124,21 +125,21 @@ pprUnitInfo GenericUnitInfo {..} = field "exposed-modules" (ppr unitExposedModules), field "hidden-modules" (fsep (map ppr unitHiddenModules)), field "trusted" (ppr unitIsTrusted), - field "import-dirs" (fsep (map text unitImportDirs)), - field "library-dirs" (fsep (map text unitLibraryDirs)), - field "dynamic-library-dirs" (fsep (map text unitLibraryDynDirs)), - field "hs-libraries" (fsep (map text unitLibraries)), - field "extra-libraries" (fsep (map text unitExtDepLibsSys)), - field "extra-ghci-libraries" (fsep (map text unitExtDepLibsGhc)), - field "include-dirs" (fsep (map text unitIncludeDirs)), - field "includes" (fsep (map text unitIncludes)), + field "import-dirs" (fsep (map (text . ST.unpack) unitImportDirs)), + field "library-dirs" (fsep (map (text . ST.unpack) unitLibraryDirs)), + field "dynamic-library-dirs" (fsep (map (text . ST.unpack) unitLibraryDynDirs)), + field "hs-libraries" (fsep (map (text . ST.unpack) unitLibraries)), + field "extra-libraries" (fsep (map (text . ST.unpack) unitExtDepLibsSys)), + field "extra-ghci-libraries" (fsep (map (text . ST.unpack) unitExtDepLibsGhc)), + field "include-dirs" (fsep (map (text . ST.unpack) unitIncludeDirs)), + field "includes" (fsep (map (text . ST.unpack) unitIncludes)), field "depends" (fsep (map ppr unitDepends)), - field "cc-options" (fsep (map text unitCcOptions)), - field "ld-options" (fsep (map text unitLinkerOptions)), - field "framework-dirs" (fsep (map text unitExtDepFrameworkDirs)), - field "frameworks" (fsep (map text unitExtDepFrameworks)), - field "haddock-interfaces" (fsep (map text unitHaddockInterfaces)), - field "haddock-html" (fsep (map text unitHaddockHTMLs)) + field "cc-options" (fsep (map (text . ST.unpack) unitCcOptions)), + field "ld-options" (fsep (map (text . ST.unpack) unitLinkerOptions)), + field "framework-dirs" (fsep (map (text . ST.unpack) unitExtDepFrameworkDirs)), + field "frameworks" (fsep (map (text . ST.unpack) unitExtDepFrameworks)), + field "haddock-interfaces" (fsep (map (text . ST.unpack) unitHaddockInterfaces)), + field "haddock-html" (fsep (map (text . ST.unpack) unitHaddockHTMLs)) ] where field name body = text name <> colon <+> nest 4 body ===================================== compiler/GHC/Unit/State.hs ===================================== @@ -99,6 +99,7 @@ import GHC.Data.Maybe import System.Environment ( getEnv ) import GHC.Data.FastString +import qualified GHC.Data.ShortText as ST import GHC.Utils.Error ( debugTraceMsg, MsgDoc, dumpIfSet_dyn, withTiming, DumpFormat (..) ) import GHC.Utils.Exception @@ -749,7 +750,7 @@ mungeUnitInfo :: FilePath -> FilePath -> UnitInfo -> UnitInfo mungeUnitInfo top_dir pkgroot = mungeDynLibFields - . mungeUnitInfoPaths top_dir pkgroot + . mungeUnitInfoPaths (ST.pack top_dir) (ST.pack pkgroot) mungeDynLibFields :: UnitInfo -> UnitInfo mungeDynLibFields pkg = @@ -1797,7 +1798,7 @@ getUnitIncludePath ctx unit_state home_unit pkgs = collectIncludeDirs `fmap` getPreloadUnitsAnd ctx unit_state home_unit pkgs collectIncludeDirs :: [UnitInfo] -> [FilePath] -collectIncludeDirs ps = ordNub (filter notNull (concatMap unitIncludeDirs ps)) +collectIncludeDirs ps = map ST.unpack $ ordNub (filter (not . ST.null) (concatMap unitIncludeDirs ps)) -- | Find all the library paths in these and the preload packages getUnitLibraryPath :: SDocContext -> UnitState -> HomeUnit -> Ways -> [UnitId] -> IO [String] @@ -1822,8 +1823,8 @@ collectLinkOpts :: DynFlags -> [UnitInfo] -> ([String], [String], [String]) collectLinkOpts dflags ps = ( concatMap (map ("-l" ++) . packageHsLibs dflags) ps, - concatMap (map ("-l" ++) . unitExtDepLibsSys) ps, - concatMap unitLinkerOptions ps + concatMap (map ("-l" ++) . map ST.unpack . unitExtDepLibsSys) ps, + concatMap (map ST.unpack . unitLinkerOptions) ps ) collectArchives :: DynFlags -> UnitInfo -> IO [FilePath] collectArchives dflags pc = @@ -1831,7 +1832,7 @@ collectArchives dflags pc = | searchPath <- searchPaths , lib <- libs ] where searchPaths = ordNub . filter notNull . libraryDirsForWay (ways dflags) $ pc - libs = packageHsLibs dflags pc ++ unitExtDepLibsSys pc + libs = packageHsLibs dflags pc ++ (map ST.unpack $ unitExtDepLibsSys pc) getLibs :: DynFlags -> [UnitId] -> IO [(String,String)] getLibs dflags pkgs = do @@ -1846,7 +1847,7 @@ getLibs dflags pkgs = do filterM (doesFileExist . fst) candidates packageHsLibs :: DynFlags -> UnitInfo -> [String] -packageHsLibs dflags p = map (mkDynName . addSuffix) (unitLibraries p) +packageHsLibs dflags p = map (mkDynName . addSuffix . ST.unpack) (unitLibraries p) where ways0 = ways dflags @@ -1895,27 +1896,27 @@ packageHsLibs dflags p = map (mkDynName . addSuffix) (unitLibraries p) -- | Either the 'unitLibraryDirs' or 'unitLibraryDynDirs' as appropriate for the way. libraryDirsForWay :: Ways -> UnitInfo -> [String] -libraryDirsForWay ws - | WayDyn `elem` ws = unitLibraryDynDirs - | otherwise = unitLibraryDirs +libraryDirsForWay ws ui + | WayDyn `elem` ws = map ST.unpack $ unitLibraryDynDirs ui + | otherwise = map ST.unpack $ unitLibraryDirs ui -- | Find all the C-compiler options in these and the preload packages getUnitExtraCcOpts :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitExtraCcOpts ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (concatMap unitCcOptions ps) + return $ map ST.unpack (concatMap unitCcOptions ps) -- | Find all the package framework paths in these and the preload packages getUnitFrameworkPath :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitFrameworkPath ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (ordNub (filter notNull (concatMap unitExtDepFrameworkDirs ps))) + return $ map ST.unpack (ordNub (filter (not . ST.null) (concatMap unitExtDepFrameworkDirs ps))) -- | Find all the package frameworks in these and the preload packages getUnitFrameworks :: SDocContext -> UnitState -> HomeUnit -> [UnitId] -> IO [String] getUnitFrameworks ctx unit_state home_unit pkgs = do ps <- getPreloadUnitsAnd ctx unit_state home_unit pkgs - return (concatMap unitExtDepFrameworks ps) + return $ map ST.unpack (concatMap unitExtDepFrameworks ps) -- ----------------------------------------------------------------------------- -- Package Utils ===================================== compiler/ghc.cabal.in ===================================== @@ -547,7 +547,6 @@ Library GHC.Data.BooleanFormula GHC.Utils.BufHandle GHC.Data.Graph.Directed - GHC.Utils.Encoding GHC.Utils.IO.Unsafe GHC.Data.FastMutInt GHC.Data.FastString ===================================== libraries/ghc-boot/GHC/Data/ShortText.hs ===================================== @@ -0,0 +1,112 @@ +{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples, GeneralizedNewtypeDeriving, DerivingStrategies #-} +{-# OPTIONS_GHC -O2 -funbox-strict-fields #-} + +-- | +-- An Unicode string for internal GHC use. Meant to replace String +-- in places where being a lazy linked is not very useful and a more +-- memory efficient data structure is desirable. + +-- Very similar to FastString, but not hash-consed and with some extra instances and +-- functions for serialisation and I/O. Should be imported qualified. + +module GHC.Data.ShortText ( + -- * ShortText + ShortText(..), + -- ** Conversion to and from String + pack, + unpack, + -- ** Operations + codepointLength, + byteLength, + GHC.Data.ShortText.null, + splitFilePath, + GHC.Data.ShortText.head, + stripPrefix + ) where + +import Prelude + +import Control.Monad (guard) +import Control.DeepSeq as DeepSeq +import Data.Binary +import qualified Data.ByteString.Char8 as B8 +import qualified Data.ByteString.Short.Internal as SBS +import GHC.Exts +import GHC.IO +import GHC.Utils.Encoding +import System.FilePath (isPathSeparator) + +{-| A 'ShortText' is a modified UTF-8 encoded string meant for short strings like +file paths, module descriptions, etc. +-} +newtype ShortText = ShortText { contents :: SBS.ShortByteString + } + deriving stock (Show) + deriving newtype (Eq, Ord, Binary, Semigroup, Monoid, NFData) + +-- We don't want to derive this one from ShortByteString since that one won't handle +-- UTF-8 characters correctly. +instance IsString ShortText where + fromString = pack + +-- | /O(n)/ Returns the length of the 'ShortText' in characters. +codepointLength :: ShortText -> Int +codepointLength st = unsafeDupablePerformIO $ countUTF8Chars (contents st) +-- | /O(1)/ Returns the length of the 'ShortText' in bytes. +byteLength :: ShortText -> Int +byteLength st = SBS.length $ contents st + +-- | /O(n)/ Convert a 'String' into a 'ShortText'. +pack :: String -> ShortText +pack s = unsafeDupablePerformIO $ ShortText <$> utf8EncodeShortByteString s + +-- | /O(n)/ Convert a 'ShortText' into a 'String'. +unpack :: ShortText -> String +unpack st = utf8DecodeShortByteString $ contents st + +-- | /O(1)/ Test whether the 'ShortText' is the empty string. +null :: ShortText -> Bool +null st = SBS.null $ contents st + +-- | /O(n)/ Split a 'ShortText' representing a file path into its components by separating +-- on the file separator characters for this platform. +splitFilePath :: ShortText -> [ShortText] +-- This seems dangerous, but since the path separators are in the ASCII set they map down +-- to a single byte when encoded in UTF-8 and so this should work even when casting to ByteString. +-- We DeepSeq.force the resulting list so that we can be sure that no references to the +-- bytestring in `st'` remain in unevaluated thunks, which might prevent `st'` from being +-- collected by the GC. +splitFilePath st = DeepSeq.force $ map (ShortText . SBS.toShort) $ B8.splitWith isPathSeparator st' + where st' = SBS.fromShort $ contents st + +-- | /O(1)/ Returns the first UTF-8 codepoint in the 'ShortText'. Depending on the string in +-- question, this may or may not be the actual first character in the string due to Unicode +-- non-printable characters. +head :: ShortText -> Char +head st + | SBS.null $ contents st = error "head: Empty ShortText" + | otherwise = Prelude.head $ unpack st + +-- | /O(n)/ The 'stripPrefix' function takes two 'ShortText's and returns 'Just' the remainder of +-- the second iff the first is its prefix, and otherwise Nothing. +stripPrefix :: ShortText -> ShortText -> Maybe ShortText +stripPrefix prefix st = do + let !(SBS.SBS prefixBA) = contents prefix + let !(SBS.SBS stBA) = contents st + let prefixLength = sizeofByteArray# prefixBA + let stLength = sizeofByteArray# stBA + -- If the length of 'st' is not >= than the length of 'prefix', it is impossible for 'prefix' + -- to be the prefix of `st`. + guard $ (I# stLength) >= (I# prefixLength) + -- 'prefix' is a prefix of 'st' if the first bytes of 'st' + -- are equal to 'prefix' + guard $ I# (compareByteArrays# prefixBA 0# stBA 0# prefixLength) == 0 + -- Allocate a new ByteArray# and copy the remainder of the 'st' into it + unsafeDupablePerformIO $ do + let newBAsize = (stLength -# prefixLength) + newSBS <- IO $ \s0 -> + let !(# s1, ba #) = newByteArray# newBAsize s0 + s2 = copyByteArray# stBA prefixLength ba 0# newBAsize s1 + !(# s3, fba #) = unsafeFreezeByteArray# ba s2 + in (# s3, SBS.SBS fba #) + return . Just . ShortText $ newSBS ===================================== libraries/ghc-boot/GHC/Unit/Database.hs ===================================== @@ -12,6 +12,7 @@ {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | @@ -82,16 +83,16 @@ import Data.Bifunctor import Data.Binary as Bin import Data.Binary.Put as Bin import Data.Binary.Get as Bin +import Data.List (intersperse) import Control.Exception as Exception import Control.Monad (when) import System.FilePath as FilePath -import qualified System.FilePath.Posix as FilePath.Posix import System.IO import System.IO.Error import GHC.IO.Exception (IOErrorType(InappropriateType)) +import qualified GHC.Data.ShortText as ST import GHC.IO.Handle.Lock import System.Directory -import Data.List (stripPrefix) -- | @ghc-boot@'s UnitInfo, serialized to the database. type DbUnitInfo = GenericUnitInfo BS.ByteString BS.ByteString BS.ByteString BS.ByteString BS.ByteString DbModule @@ -142,28 +143,28 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit -- components that can be registered in a database and used by other -- modules. - , unitAbiHash :: String + , unitAbiHash :: ST.ShortText -- ^ ABI hash used to avoid mixing up units compiled with different -- dependencies, compiler, options, etc. , unitDepends :: [uid] -- ^ Identifiers of the units this one depends on - , unitAbiDepends :: [(uid, String)] + , unitAbiDepends :: [(uid, ST.ShortText)] -- ^ Like 'unitDepends', but each dependency is annotated with the ABI hash -- we expect the dependency to respect. - , unitImportDirs :: [FilePath] + , unitImportDirs :: [FilePathST] -- ^ Directories containing module interfaces - , unitLibraries :: [String] + , unitLibraries :: [ST.ShortText] -- ^ Names of the Haskell libraries provided by this unit - , unitExtDepLibsSys :: [String] + , unitExtDepLibsSys :: [ST.ShortText] -- ^ Names of the external system libraries that this unit depends on. See -- also `unitExtDepLibsGhc` field. - , unitExtDepLibsGhc :: [String] + , unitExtDepLibsGhc :: [ST.ShortText] -- ^ Because of slight differences between the GHC dynamic linker (in -- GHC.Runtime.Linker) and the -- native system linker, some packages have to link with a different list @@ -174,46 +175,46 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit -- If this field is set, then we use that instead of the -- `unitExtDepLibsSys` field. - , unitLibraryDirs :: [FilePath] + , unitLibraryDirs :: [FilePathST] -- ^ Directories containing libraries provided by this unit. See also -- `unitLibraryDynDirs`. -- -- It seems to be used to store paths to external library dependencies -- too. - , unitLibraryDynDirs :: [FilePath] + , unitLibraryDynDirs :: [FilePathST] -- ^ Directories containing the dynamic libraries provided by this unit. -- See also `unitLibraryDirs`. -- -- It seems to be used to store paths to external dynamic library -- dependencies too. - , unitExtDepFrameworks :: [String] + , unitExtDepFrameworks :: [ST.ShortText] -- ^ Names of the external MacOS frameworks that this unit depends on. - , unitExtDepFrameworkDirs :: [FilePath] + , unitExtDepFrameworkDirs :: [FilePathST] -- ^ Directories containing MacOS frameworks that this unit depends -- on. - , unitLinkerOptions :: [String] + , unitLinkerOptions :: [ST.ShortText] -- ^ Linker (e.g. ld) command line options - , unitCcOptions :: [String] + , unitCcOptions :: [ST.ShortText] -- ^ C compiler options that needs to be passed to the C compiler when we -- compile some C code against this unit. - , unitIncludes :: [String] + , unitIncludes :: [ST.ShortText] -- ^ C header files that are required by this unit (provided by this unit -- or external) - , unitIncludeDirs :: [FilePath] + , unitIncludeDirs :: [FilePathST] -- ^ Directories containing C header files that this unit depends -- on. - , unitHaddockInterfaces :: [FilePath] + , unitHaddockInterfaces :: [FilePathST] -- ^ Paths to Haddock interface files for this unit - , unitHaddockHTMLs :: [FilePath] + , unitHaddockHTMLs :: [FilePathST] -- ^ Paths to Haddock directories containing HTML files , unitExposedModules :: [(modulename, Maybe mod)] @@ -242,6 +243,8 @@ data GenericUnitInfo compid srcpkgid srcpkgname uid modulename mod = GenericUnit } deriving (Eq, Show) +type FilePathST = ST.ShortText + -- | Convert between GenericUnitInfo instances mapGenericUnitInfo :: (uid1 -> uid2) @@ -646,12 +649,12 @@ instance Binary DbInstUnitId where -- Also perform a similar substitution for the older GHC-specific -- "$topdir" variable. The "topdir" is the location of the ghc -- installation (obtained from the -B option). -mkMungePathUrl :: FilePath -> FilePath -> (FilePath -> FilePath, FilePath -> FilePath) +mkMungePathUrl :: FilePathST -> FilePathST -> (FilePathST -> FilePathST, FilePathST -> FilePathST) mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) where munge_path p - | Just p' <- stripVarPrefix "${pkgroot}" p = pkgroot ++ p' - | Just p' <- stripVarPrefix "$topdir" p = top_dir ++ p' + | Just p' <- stripVarPrefix "${pkgroot}" p = mappend pkgroot p' + | Just p' <- stripVarPrefix "$topdir" p = mappend top_dir p' | otherwise = p munge_url p @@ -659,20 +662,19 @@ mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) | Just p' <- stripVarPrefix "$httptopdir" p = toUrlPath top_dir p' | otherwise = p - toUrlPath r p = "file:///" - -- URLs always use posix style '/' separators: - ++ FilePath.Posix.joinPath - (r : -- We need to drop a leading "/" or "\\" - -- if there is one: - dropWhile (all isPathSeparator) - (FilePath.splitDirectories p)) + toUrlPath r p = mconcat $ "file:///" : (intersperse "/" (r : (splitDirectories p))) + -- URLs always use posix style '/' separators + + -- We need to drop a leading "/" or "\\" if there is one: + splitDirectories :: FilePathST -> [FilePathST] + splitDirectories p = filter (not . ST.null) $ ST.splitFilePath p -- We could drop the separator here, and then use above. However, -- by leaving it in and using ++ we keep the same path separator -- rather than letting FilePath change it to use \ as the separator - stripVarPrefix var path = case stripPrefix var path of - Just [] -> Just [] - Just cs@(c : _) | isPathSeparator c -> Just cs + stripVarPrefix var path = case ST.stripPrefix var path of + Just "" -> Just "" + Just cs | isPathSeparator (ST.head cs) -> Just cs _ -> Nothing @@ -684,7 +686,7 @@ mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) -- Also perform a similar substitution for the older GHC-specific -- "$topdir" variable. The "topdir" is the location of the ghc -- installation (obtained from the -B option). -mungeUnitInfoPaths :: FilePath -> FilePath -> GenericUnitInfo a b c d e f -> GenericUnitInfo a b c d e f +mungeUnitInfoPaths :: FilePathST -> FilePathST -> GenericUnitInfo a b c d e f -> GenericUnitInfo a b c d e f mungeUnitInfoPaths top_dir pkgroot pkg = -- TODO: similar code is duplicated in utils/ghc-pkg/Main.hs pkg ===================================== compiler/GHC/Utils/Encoding.hs → libraries/ghc-boot/GHC/Utils/Encoding.hs ===================================== @@ -1,7 +1,10 @@ {-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-} -{-# OPTIONS_GHC -O2 #-} +{-# OPTIONS_GHC -O2 -fno-warn-name-shadowing #-} -- We always optimise this, otherwise performance of a non-optimised --- compiler is severely affected +-- compiler is severely affected. This module used to live in the `ghc` +-- package but has been moved to `ghc-boot` because the definition +-- of the package database (needed in both ghc and in ghc-pkg) lives in +-- `ghc-boot` and uses ShortText, which in turn depends on this module. -- ----------------------------------------------------------------------------- -- @@ -36,7 +39,7 @@ module GHC.Utils.Encoding ( toBase62Padded ) where -import GHC.Prelude +import Prelude import Foreign import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -38,6 +38,8 @@ Library exposed-modules: GHC.BaseDir + GHC.Data.ShortText + GHC.Utils.Encoding GHC.LanguageExtensions GHC.Unit.Database GHC.Serialized @@ -68,4 +70,5 @@ Library containers >= 0.5 && < 0.7, directory >= 1.2 && < 1.4, filepath >= 1.3 && < 1.5, + deepseq >= 1.4 && < 1.5, ghc-boot-th == @ProjectVersionMunged@ ===================================== utils/ghc-pkg/Main.hs ===================================== @@ -31,12 +31,13 @@ module Main (main) where import qualified GHC.Unit.Database as GhcPkg -import GHC.Unit.Database +import GHC.Unit.Database hiding (mkMungePathUrl) import GHC.HandleEncoding import GHC.BaseDir (getBaseDir) import GHC.Settings.Utils (getTargetArchOS, maybeReadFuzzy) import GHC.Platform.Host (hostPlatformArchOS) import GHC.UniqueSubdir (uniqueSubdir) +import qualified GHC.Data.ShortText as ST import GHC.Version ( cProjectVersion ) import qualified Distribution.Simple.PackageIndex as PackageIndex import qualified Data.Graph as Graph @@ -56,6 +57,7 @@ import Distribution.Types.MungedPackageId import Distribution.Simple.Utils (toUTF8BS, writeUTF8File, readUTF8File) import qualified Data.Version as Version import System.FilePath as FilePath +import qualified System.FilePath.Posix as FilePath.Posix import System.Directory ( getAppUserDataDirectory, createDirectoryIfMissing, getModificationTime ) import Text.Printf @@ -990,6 +992,35 @@ mungePackagePaths top_dir pkgroot pkg = munge_urls = map munge_url (munge_path,munge_url) = mkMungePathUrl top_dir pkgroot +mkMungePathUrl :: FilePath -> FilePath -> (FilePath -> FilePath, FilePath -> FilePath) +mkMungePathUrl top_dir pkgroot = (munge_path, munge_url) + where + munge_path p + | Just p' <- stripVarPrefix "${pkgroot}" p = pkgroot ++ p' + | Just p' <- stripVarPrefix "$topdir" p = top_dir ++ p' + | otherwise = p + + munge_url p + | Just p' <- stripVarPrefix "${pkgrooturl}" p = toUrlPath pkgroot p' + | Just p' <- stripVarPrefix "$httptopdir" p = toUrlPath top_dir p' + | otherwise = p + + toUrlPath r p = "file:///" + -- URLs always use posix style '/' separators: + ++ FilePath.Posix.joinPath + (r : -- We need to drop a leading "/" or "\\" + -- if there is one: + dropWhile (all isPathSeparator) + (FilePath.splitDirectories p)) + + -- We could drop the separator here, and then use above. However, + -- by leaving it in and using ++ we keep the same path separator + -- rather than letting FilePath change it to use \ as the separator + stripVarPrefix var path = case stripPrefix var path of + Just [] -> Just [] + Just cs@(c : _) | isPathSeparator c -> Just cs + _ -> Nothing + -- ----------------------------------------------------------------------------- -- Workaround for old single-file style package dbs @@ -1331,7 +1362,7 @@ recomputeValidAbiDeps db pkg = newAbiDeps = catMaybes . flip map (GhcPkg.unitAbiDepends pkg) $ \(k, _) -> case filter (\d -> installedUnitId d == k) db of - [x] -> Just (k, unAbiHash (abiHash x)) + [x] -> Just (k, ST.pack $ unAbiHash (abiHash x)) _ -> Nothing abiDepsUpdated = GhcPkg.unitAbiDepends pkg /= newAbiDeps @@ -1370,22 +1401,22 @@ convertPackageInfoToCacheFormat pkg = GhcPkg.unitComponentName = fmap (mkPackageName . unUnqualComponentName) (libraryNameString $ sourceLibName pkg), GhcPkg.unitDepends = depends pkg, - GhcPkg.unitAbiDepends = map (\(AbiDependency k v) -> (k,unAbiHash v)) (abiDepends pkg), - GhcPkg.unitAbiHash = unAbiHash (abiHash pkg), - GhcPkg.unitImportDirs = importDirs pkg, - GhcPkg.unitLibraries = hsLibraries pkg, - GhcPkg.unitExtDepLibsSys = extraLibraries pkg, - GhcPkg.unitExtDepLibsGhc = extraGHCiLibraries pkg, - GhcPkg.unitLibraryDirs = libraryDirs pkg, - GhcPkg.unitLibraryDynDirs = libraryDynDirs pkg, - GhcPkg.unitExtDepFrameworks = frameworks pkg, - GhcPkg.unitExtDepFrameworkDirs = frameworkDirs pkg, - GhcPkg.unitLinkerOptions = ldOptions pkg, - GhcPkg.unitCcOptions = ccOptions pkg, - GhcPkg.unitIncludes = includes pkg, - GhcPkg.unitIncludeDirs = includeDirs pkg, - GhcPkg.unitHaddockInterfaces = haddockInterfaces pkg, - GhcPkg.unitHaddockHTMLs = haddockHTMLs pkg, + GhcPkg.unitAbiDepends = map (\(AbiDependency k v) -> (k,ST.pack $ unAbiHash v)) (abiDepends pkg), + GhcPkg.unitAbiHash = ST.pack $ unAbiHash (abiHash pkg), + GhcPkg.unitImportDirs = map ST.pack $ importDirs pkg, + GhcPkg.unitLibraries = map ST.pack $ hsLibraries pkg, + GhcPkg.unitExtDepLibsSys = map ST.pack $ extraLibraries pkg, + GhcPkg.unitExtDepLibsGhc = map ST.pack $ extraGHCiLibraries pkg, + GhcPkg.unitLibraryDirs = map ST.pack $ libraryDirs pkg, + GhcPkg.unitLibraryDynDirs = map ST.pack $ libraryDynDirs pkg, + GhcPkg.unitExtDepFrameworks = map ST.pack $ frameworks pkg, + GhcPkg.unitExtDepFrameworkDirs = map ST.pack $ frameworkDirs pkg, + GhcPkg.unitLinkerOptions = map ST.pack $ ldOptions pkg, + GhcPkg.unitCcOptions = map ST.pack $ ccOptions pkg, + GhcPkg.unitIncludes = map ST.pack $ includes pkg, + GhcPkg.unitIncludeDirs = map ST.pack $ includeDirs pkg, + GhcPkg.unitHaddockInterfaces = map ST.pack $ haddockInterfaces pkg, + GhcPkg.unitHaddockHTMLs = map ST.pack $ haddockHTMLs pkg, GhcPkg.unitExposedModules = map convertExposed (exposedModules pkg), GhcPkg.unitHiddenModules = hiddenModules pkg, GhcPkg.unitIsIndefinite = indefinite pkg, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fdcce6d4d13a10a1b2336c1d40482c64dba664d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7fdcce6d4d13a10a1b2336c1d40482c64dba664d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 04:13:34 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 13 Oct 2020 00:13:34 -0400 Subject: [Git][ghc/ghc][master] Parser: don't require the HomeUnitId Message-ID: <5f85296e5bf9b_80b3f8468d1d2fc18535483@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 7 changed files: - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Parser/Lexer.x - compiler/ghc.cabal.in - utils/haddock Changes: ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -20,7 +20,7 @@ import GHC.Prelude import GHC.Cmm.Expr import GHC.Parser.Lexer -import GHC.Cmm.Monad +import GHC.Cmm.Parser.Monad import GHC.Types.SrcLoc import GHC.Types.Unique.FM import GHC.Data.StringBuffer ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -234,8 +234,8 @@ import GHC.Cmm.Info import GHC.Cmm.BlockId import GHC.Cmm.Lexer import GHC.Cmm.CLabel -import GHC.Cmm.Monad hiding (getPlatform, getProfile, getPtrOpts) -import qualified GHC.Cmm.Monad as PD +import GHC.Cmm.Parser.Monad hiding (getPlatform, getProfile, getPtrOpts) +import qualified GHC.Cmm.Parser.Monad as PD import GHC.Cmm.CallConv import GHC.Runtime.Heap.Layout import GHC.Parser.Lexer @@ -385,9 +385,11 @@ cmmtop :: { CmmParse () } | cmmdata { $1 } | decl { $1 } | 'CLOSURE' '(' NAME ',' NAME lits ')' ';' - {% liftP . withHomeUnitId $ \pkg -> - do lits <- sequence $6; - staticClosure pkg $3 $5 (map getLit lits) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + lits <- sequence $6; + staticClosure home_unit_id $3 $5 (map getLit lits) } -- The only static closures in the RTS are dummy closures like -- stg_END_TSO_QUEUE_closure and stg_dummy_ret. We don't need @@ -406,8 +408,10 @@ cmmdata :: { CmmParse () } data_label :: { CmmParse CLabel } : NAME ':' - {% liftP . withHomeUnitId $ \pkg -> - return (mkCmmDataLabel pkg (NeedExternDecl False) $1) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + pure (mkCmmDataLabel home_unit_id (NeedExternDecl False) $1) } statics :: { [CmmParse [CmmStatic]] } : {- empty -} { [] } @@ -464,103 +468,117 @@ maybe_body :: { CmmParse () } info :: { CmmParse (CLabel, Maybe CmmInfoTable, [LocalReg]) } : NAME - {% liftP . withHomeUnitId $ \pkg -> - do newFunctionName $1 pkg - return (mkCmmCodeLabel pkg $1, Nothing, []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + newFunctionName $1 home_unit_id + return (mkCmmCodeLabel home_unit_id $1, Nothing, []) } | 'INFO_TABLE' '(' NAME ',' INT ',' INT ',' INT ',' STRING ',' STRING ')' -- ptrs, nptrs, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $11 $13 - rep = mkRTSRep (fromIntegral $9) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) Thunk - -- not really Thunk, but that makes the info table - -- we want. - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $11 $13 + rep = mkRTSRep (fromIntegral $9) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) Thunk + -- not really Thunk, but that makes the info table + -- we want. + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_FUN' '(' NAME ',' INT ',' INT ',' INT ',' STRING ',' STRING ',' INT ')' -- ptrs, nptrs, closure type, description, type, fun type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $11 $13 - ty = Fun 0 (ArgSpec (fromIntegral $15)) - -- Arity zero, arg_type $15 - rep = mkRTSRep (fromIntegral $9) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $11 $13 + ty = Fun 0 (ArgSpec (fromIntegral $15)) + -- Arity zero, arg_type $15 + rep = mkRTSRep (fromIntegral $9) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } -- we leave most of the fields zero here. This is only used -- to generate the BCO info table in the RTS at the moment. | 'INFO_TABLE_CONSTR' '(' NAME ',' INT ',' INT ',' INT ',' INT ',' STRING ',' STRING ')' -- ptrs, nptrs, tag, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $13 $15 - ty = Constr (fromIntegral $9) -- Tag - (BS8.pack $13) - rep = mkRTSRep (fromIntegral $11) $ - mkHeapRep profile False (fromIntegral $5) - (fromIntegral $7) ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing,cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $13 $15 + ty = Constr (fromIntegral $9) -- Tag + (BS8.pack $13) + rep = mkRTSRep (fromIntegral $11) $ + mkHeapRep profile False (fromIntegral $5) + (fromIntegral $7) ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing,cit_clo = Nothing }, + []) } -- If profiling is on, this string gets duplicated, -- but that's the way the old code did it we can fix it some other time. | 'INFO_TABLE_SELECTOR' '(' NAME ',' INT ',' INT ',' STRING ',' STRING ')' -- selector, closure type, description, type - {% liftP . withHomeUnitId $ \pkg -> - do profile <- getProfile - let prof = profilingInfo profile $9 $11 - ty = ThunkSelector (fromIntegral $5) - rep = mkRTSRep (fromIntegral $7) $ - mkHeapRep profile False 0 0 ty - return (mkCmmEntryLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + profile <- getProfile + let prof = profilingInfo profile $9 $11 + ty = ThunkSelector (fromIntegral $5) + rep = mkRTSRep (fromIntegral $7) $ + mkHeapRep profile False 0 0 ty + return (mkCmmEntryLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_RET' '(' NAME ',' INT ')' -- closure type (no live regs) - {% liftP . withHomeUnitId $ \pkg -> - do let prof = NoProfilingInfo - rep = mkRTSRep (fromIntegral $5) $ mkStackRep [] - return (mkCmmRetLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - []) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + let prof = NoProfilingInfo + rep = mkRTSRep (fromIntegral $5) $ mkStackRep [] + return (mkCmmRetLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + []) } | 'INFO_TABLE_RET' '(' NAME ',' INT ',' formals0 ')' -- closure type, live regs - {% liftP . withHomeUnitId $ \pkg -> - do platform <- getPlatform - live <- sequence $7 - let prof = NoProfilingInfo - -- drop one for the info pointer - bitmap = mkLiveness platform (drop 1 live) - rep = mkRTSRep (fromIntegral $5) $ mkStackRep bitmap - return (mkCmmRetLabel pkg $3, - Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel pkg $3 - , cit_rep = rep - , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, - live) } + {% do + home_unit_id <- getHomeUnitId + liftP $ pure $ do + platform <- getPlatform + live <- sequence $7 + let prof = NoProfilingInfo + -- drop one for the info pointer + bitmap = mkLiveness platform (drop 1 live) + rep = mkRTSRep (fromIntegral $5) $ mkStackRep bitmap + return (mkCmmRetLabel home_unit_id $3, + Just $ CmmInfoTable { cit_lbl = mkCmmRetInfoLabel home_unit_id $3 + , cit_rep = rep + , cit_prof = prof, cit_srt = Nothing, cit_clo = Nothing }, + live) } body :: { CmmParse () } : {- empty -} { return () } ===================================== compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs ===================================== @@ -7,13 +7,14 @@ -- The parser for C-- requires access to a lot more of the 'DynFlags', -- so 'PD' provides access to 'DynFlags' via a 'HasDynFlags' instance. ----------------------------------------------------------------------------- -module GHC.Cmm.Monad ( +module GHC.Cmm.Parser.Monad ( PD(..) , liftP , failMsgPD , getProfile , getPlatform , getPtrOpts + , getHomeUnitId ) where import GHC.Prelude @@ -28,6 +29,8 @@ import GHC.Driver.Session import GHC.Parser.Lexer import GHC.Parser.Errors import GHC.Types.SrcLoc +import GHC.Unit.Types +import GHC.Unit.Home newtype PD a = PD { unPD :: DynFlags -> PState -> ParseResult a } @@ -73,3 +76,9 @@ getPtrOpts = do { po_profile = profile , po_align_check = gopt Opt_AlignmentSanitisation dflags } + +-- | Return the UnitId of the home-unit. This is used to create labels. +getHomeUnitId :: PD UnitId +getHomeUnitId = do + dflags <- getDynFlags + pure (homeUnitId (mkHomeUnitFromFlags dflags)) ===================================== compiler/GHC/Driver/Config.hs ===================================== @@ -32,7 +32,6 @@ initParserOpts = mkParserOpts <$> warningFlags <*> extensionFlags - <*> homeUnitId_ <*> safeImportsOn <*> gopt Opt_Haddock <*> gopt Opt_KeepRawTokenStream ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -55,7 +55,7 @@ module GHC.Parser.Lexer ( P(..), ParseResult(..), allocateComments, MonadP(..), - getRealSrcLoc, getPState, withHomeUnitId, + getRealSrcLoc, getPState, failMsgP, failLocMsgP, srcParseFail, getErrorMessages, getMessages, popContext, pushModuleContext, setLastToken, setSrcLoc, @@ -104,7 +104,6 @@ import GHC.Data.OrdList import GHC.Utils.Misc ( readRational, readHexRational ) import GHC.Types.SrcLoc -import GHC.Unit.Types import GHC.Types.Basic ( InlineSpec(..), RuleMatchInfo(..), IntegralLit(..), FractionalLit(..), SourceText(..) ) @@ -2210,10 +2209,8 @@ warnopt f options = f `EnumSet.member` pWarningFlags options -- | Parser options. -- -- See 'mkParserOpts' to construct this. -data ParserOpts = ParserOpts { - pWarningFlags :: EnumSet WarningFlag - , pHomeUnitId :: UnitId -- ^ id of the unit currently being compiled - -- (only used in Cmm parser) +data ParserOpts = ParserOpts + { pWarningFlags :: EnumSet WarningFlag -- ^ enabled warning flags , pExtsBitmap :: !ExtsBitmap -- ^ bitmap of permitted extensions } @@ -2322,9 +2319,6 @@ failLocMsgP loc1 loc2 f = getPState :: P PState getPState = P $ \s -> POk s s -withHomeUnitId :: (UnitId -> a) -> P a -withHomeUnitId f = P $ \s@(PState{options = o}) -> POk s (f (pHomeUnitId o)) - getExts :: P ExtsBitmap getExts = P $ \s -> POk s (pExtsBitmap . options $ s) @@ -2637,8 +2631,6 @@ data ExtBits mkParserOpts :: EnumSet WarningFlag -- ^ warnings flags enabled -> EnumSet LangExt.Extension -- ^ permitted language extensions enabled - -> UnitId -- ^ id of the unit currently being compiled - -- (used in Cmm parser) -> Bool -- ^ are safe imports on? -> Bool -- ^ keeping Haddock comment tokens -> Bool -- ^ keep regular comment tokens @@ -2650,11 +2642,10 @@ mkParserOpts -> ParserOpts -- ^ Given exactly the information needed, set up the 'ParserOpts' -mkParserOpts warningFlags extensionFlags homeUnitId +mkParserOpts warningFlags extensionFlags safeImports isHaddock rawTokStream usePosPrags = ParserOpts { pWarningFlags = warningFlags - , pHomeUnitId = homeUnitId , pExtsBitmap = safeHaskellBit .|. langExtBits .|. optBits } where ===================================== compiler/ghc.cabal.in ===================================== @@ -239,7 +239,7 @@ Library GHC.Cmm.Lint GHC.Cmm.Liveness GHC.Cmm.MachOp - GHC.Cmm.Monad + GHC.Cmm.Parser.Monad GHC.Cmm.Switch GHC.Cmm.Node GHC.Cmm.Opt ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a5f29185921cf2af908988ab3608602bcb40290 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a5f29185921cf2af908988ab3608602bcb40290 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 09:01:08 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Tue, 13 Oct 2020 05:01:08 -0400 Subject: [Git][ghc/ghc][wip/T18831] Make DataKinds the sole arbiter of kind-level literals (and friends) Message-ID: <5f856cd4d184e_80bd4524c0185555bb@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18831 at Glasgow Haskell Compiler / GHC Commits: 5b9e529d by Ryan Scott at 2020-10-13T05:00:36-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - 6 changed files: - compiler/GHC/Rename/HsType.hs - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/poly_kinds.rst - testsuite/tests/th/T17688b.hs - + testsuite/tests/typecheck/should_compile/T18831.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -441,9 +441,9 @@ sites. This is less precise, but more accurate. rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. -Note [QualTy in kinds] +Note [HsQualTy in kinds] ~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether QualTy could occur only at TypeLevel. But no, +I was wondering whether HsQualTy could occur only at TypeLevel. But no, we can have a qualified type in a kind too. Here is an example: type family F a where @@ -466,9 +466,9 @@ suitable message: Expected kind: G Bool Actual kind: F Bool -However: in a kind, the constraints in the QualTy must all be +However: in a kind, the constraints in the HsQualTy must all be equalities; or at least, any kinds with a class constraint are -uninhabited. +uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -574,7 +574,9 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , fvs) } } rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { checkPolyKinds env ty -- See Note [QualTy in kinds] + = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] + ; when (not data_kinds && isRnKindLevel env) + (addErr (dataKindsErr env ty)) ; (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' @@ -636,9 +638,8 @@ rnHsTyKi env listTy@(HsListTy _ ty) ; (ty', fvs) <- rnLHsTyKi env ty ; return (HsListTy noExtField ty', fvs) } -rnHsTyKi env t@(HsKindSig _ ty k) - = do { checkPolyKinds env t - ; kind_sigs_ok <- xoptM LangExt.KindSignatures +rnHsTyKi env (HsKindSig _ ty k) + = do { kind_sigs_ok <- xoptM LangExt.KindSignatures ; unless kind_sigs_ok (badKindSigErr (rtke_ctxt env) ty) ; (ty', lhs_fvs) <- rnLHsTyKi env ty ; (k', sig_fvs) <- rnLHsTyKi (env { rtke_level = KindLevel }) k @@ -665,7 +666,6 @@ rnHsTyKi env tyLit@(HsTyLit _ t) = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env tyLit)) ; when (negLit t) (addErr negLitErr) - ; checkPolyKinds env tyLit ; return (HsTyLit noExtField t, emptyFVs) } where negLit (HsStrTy _ _) = False @@ -705,15 +705,13 @@ rnHsTyKi _ (XHsType (NHsCoreTy ty)) -- but I don't think it matters rnHsTyKi env ty@(HsExplicitListTy _ ip tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitListTy noExtField ip tys', fvs) } rnHsTyKi env ty@(HsExplicitTupleTy _ tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitTupleTy noExtField tys', fvs) } ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -134,6 +134,12 @@ promotion quote and the data constructor: :: type S = 'A' -- ERROR: looks like a character type R = ' A' -- OK: promoted `A'` +Type-level literals +------------------- + +:extension:`DataKinds` enables the use of numeric and string literals at the +type level. For more information, see :ref:`type-level-literals`. + .. _promoted-lists-and-tuples: Promoted list and tuple types @@ -207,4 +213,8 @@ above code is valid. See also :ghc-ticket:`7347`. +Constraints in kinds +-------------------- +:extension:`DataKinds` enables the use of equality constraints in kinds. For +more information, see :ref:`constraints-in-kinds`. ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -787,6 +787,8 @@ distinction). GHC does not consider ``forall k. k -> Type`` and ``forall {k}. k -> Type`` to be equal at the kind level, and thus rejects ``Foo Proxy`` as ill-kinded. +.. _constraints_in_kinds: + Constraints in kinds -------------------- ===================================== testsuite/tests/th/T17688b.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE StandaloneKindSignatures #-} ===================================== testsuite/tests/typecheck/should_compile/T18831.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +module T18831 where + +import Data.Kind +import Data.Proxy + +data T1 :: Proxy 0 -> Type +data T2 :: () => Type +data T3 :: (Type :: Type) -> Type +data T4 :: Proxy '[Type,Type] -> Type +data T5 :: Proxy '(Type,Type) -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -722,5 +722,6 @@ test('T18412', normal, compile, ['']) test('T18470', normal, compile, ['']) test('T18323', normal, compile, ['']) test('T18585', normal, compile, ['']) +test('T18831', normal, compile, ['']) test('T15942', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b9e529d01eb1c9d88a3cb4832245f758b479cb9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5b9e529d01eb1c9d88a3cb4832245f758b479cb9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 09:43:51 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 13 Oct 2020 05:43:51 -0400 Subject: [Git][ghc/ghc][wip/T18815] 6 commits: Remove the dependency on the ghc-linters stage Message-ID: <5f8576d799e14_80bd90622818565913@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18815 at Glasgow Haskell Compiler / GHC Commits: 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - a2f637e0 by Simon Peyton Jones at 2020-10-13T10:42:56+01:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Env.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools/ExtraObj.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Name/Occurrence.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/State.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/296bf434d6ac5959598e739af5aee24b19f577a0...a2f637e0df06973e6a7c33034c3bd94251766da5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/296bf434d6ac5959598e739af5aee24b19f577a0...a2f637e0df06973e6a7c33034c3bd94251766da5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 09:57:36 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Tue, 13 Oct 2020 05:57:36 -0400 Subject: [Git][ghc/ghc][wip/T18793] 44 commits: Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Message-ID: <5f857a10eb0cb_80b3f8469b3644c185684af@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 8d46816a by Sebastian Graf at 2020-10-13T11:55:34+02:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - a9350186 by Sebastian Graf at 2020-10-13T11:55:53+02:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12707 - - - - - ef9dbc8f by Sebastian Graf at 2020-10-13T11:57:29+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f98fafce3fc1bfb3833ac341ad95793cbdd4b513...ef9dbc8f403194d4422a551bf6874c6d532f92bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f98fafce3fc1bfb3833ac341ad95793cbdd4b513...ef9dbc8f403194d4422a551bf6874c6d532f92bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 10:49:24 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Tue, 13 Oct 2020 06:49:24 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Remove stack_spOffset and test for TSO closure flags Message-ID: <5f85863420e96_80b3f846a6447e418578468@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 6e6bde03 by David Eichmann at 2020-10-13T11:47:58+01:00 Remove stack_spOffset and test for TSO closure flags - - - - - 3 changed files: - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - libraries/ghc-heap/tests/tso_and_stack_closures.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -381,8 +381,6 @@ getClosureDataFromHeapRep closureAddressMay heapRep infoTablePtr pts = do Nothing -> pure $ UnsupportedClosure itbl Just (Ptr closureAddress) -> withArray rawHeapWords (\ptr -> do fields <- FFIClosures.peekStackFields ptr - let sp = FFIClosures.stack_sp fields - spOffset = I# (minusAddr# sp closureAddress) pure $ StackClosure { info = itbl , stack_size = FFIClosures.stack_size fields @@ -390,7 +388,6 @@ getClosureDataFromHeapRep closureAddressMay heapRep infoTablePtr pts = do #if __GLASGOW_HASKELL__ >= 811 , stack_marking = FFIClosures.stack_marking fields #endif - , stack_spOffset = spOffset }) | otherwise -> fail $ "Expected 0 ptr argument to STACK, found " ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -318,11 +318,6 @@ data GenClosure b #if __GLASGOW_HASKELL__ >= 810 , stack_marking :: !Word8 #endif - -- | Offset of the `StgStack::sp` pointer in *bytes*: - -- - -- stgStack->sp == ((byte*)stgStack)+stack_spOffset - -- - , stack_spOffset :: !Int } ------------------------------------------------------------ ===================================== libraries/ghc-heap/tests/tso_and_stack_closures.hs ===================================== @@ -22,10 +22,20 @@ main :: IO () main = do (tso, stack) <- {-# SCC "MyCostCentre" #-} createAndUnpackTSOAndSTACKClosure assertEqual (getClosureType tso) TSO - assertEqual (getClosureType stack) STACK assertEqual (what_next tso) ThreadRunGHC assertEqual (why_blocked tso) NotBlocked assertEqual (saved_errno tso) 0 + forM_ (flags tso) $ \flag -> case flag of + TsoFlagsUnknownValue _ -> error $ "Unknown flag: " ++ show flag + _ | flag `elem` + [ TsoLocked + , TsoBlockx + , TsoStoppedOnBreakpoint + , TsoSqueezed + ] -> error $ "Unexpected flag: " ++ show flag + _ -> return () + + assertEqual (getClosureType stack) STACK #if defined(PROFILING) let costCentre = ccs_cc <$> (cccs =<< prof tso) @@ -71,7 +81,10 @@ foreign import ccall safe "create_tso.h create_and_unpack_tso_and_stack" -> Ptr (Ptr (Ptr Any)) -> IO () -createAndUnpackTSOAndSTACKClosure :: IO (GenClosure (Ptr Any), GenClosure (Ptr Any)) +createAndUnpackTSOAndSTACKClosure + :: IO ( GenClosure (Ptr Any) + , GenClosure (Ptr Any) + ) createAndUnpackTSOAndSTACKClosure = do alloca $ \ptrPtrTso -> do View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e6bde0352bbb73c0d3d81b689f388b6b5dc07c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6e6bde0352bbb73c0d3d81b689f388b6b5dc07c4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 11:05:45 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 07:05:45 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/warn-operator-whitespace Message-ID: <5f858a092249a_80bb520390185829c7@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/warn-operator-whitespace You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 11:12:54 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 13 Oct 2020 07:12:54 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] Increase -A default to 4MB. Message-ID: <5f858bb63f31d_80b3f8495f238bc185860c@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: 008d0ed0 by Andreas Klebinger at 2020-10-13T13:12:42+02:00 Increase -A default to 4MB. This gives a small increase in performance under most circumstances. For single threaded GC the improvement is on the order of 1-2%. For multi threaded GC the results are quite noisy but seem to fall into the same ballpark. Fixes #16499 - - - - - 3 changed files: - docs/users_guide/runtime_control.rst - rts/RtsFlags.c - testsuite/tests/rts/T9579/Makefile Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -418,7 +418,7 @@ performance. .. rts-flag:: -A ⟨size⟩ - :default: 1MB + :default: 4MB .. index:: single: allocation area, size @@ -427,15 +427,22 @@ performance. collector. The allocation area (actually generation 0 step 0) is fixed and is never resized (unless you use :rts-flag:`-H [⟨size⟩]`, below). - Increasing the allocation area size may or may not give better - performance (a bigger allocation area means worse cache behaviour - but fewer garbage collections and less promotion). + Optimal settings depend on the actual machine, program, and other RTS options. + Increasing the allocation area size means worse cache behaviour + but fewer garbage collections and less promotion. + + In general settings >= 4MB can reduce performance in some cases, in particular for single + threaded operation. However in a parallel setting increasing the allocation area + to ``16MB``, or even ``64MB`` can increase gc throughput significantly. With only 1 generation (e.g. ``-G1``, see :rts-flag:`-G ⟨generations⟩`) the ``-A`` option specifies the minimum allocation area, since the actual size of the allocation area will be resized according to the amount of data in the heap (see :rts-flag:`-F ⟨factor⟩`, below). + When heap profiling using a smaller allocation area can increase accuracy as more frequent + major garbage collections also results in more frequent heap snapshots + .. rts-flag:: -AL ⟨size⟩ :default: :rts-flag:`-A <-A ⟨size⟩>` value ===================================== rts/RtsFlags.c ===================================== @@ -153,10 +153,11 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.stkChunkSize = (32 * 1024) / sizeof(W_); RtsFlags.GcFlags.stkChunkBufferSize = (1 * 1024) / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (1024 * 1024) / BLOCK_SIZE; + /* -A default. See #16499 for a discussion about the tradeoffs */ + RtsFlags.GcFlags.minAllocAreaSize = (4 * 1024 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.largeAllocLim = 0; /* defaults to minAllocAreasize */ RtsFlags.GcFlags.nurseryChunkSize = 0; - RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; /* -O default */ RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ ===================================== testsuite/tests/rts/T9579/Makefile ===================================== @@ -3,43 +3,43 @@ include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk T9579_stackoverflow_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A1m -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtsnone \ StackOverflow.hs -o T9579_stackoverflow_rtsnone T9579_stackoverflow_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A1m -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtssome \ StackOverflow.hs -o T9579_stackoverflow_rtssome T9579_stackoverflow_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtsall \ StackOverflow.hs -o T9579_stackoverflow_rtsall T9579_stackoverflow_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -with-rtsopts -K1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_stackoverflow_rtsall_no_suggestions \ StackOverflow.hs -o T9579_stackoverflow_rtsall_no_suggestions T9579_outofheap_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A1m -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtsnone \ OutOfHeap.hs -o T9579_outofheap_rtsnone T9579_outofheap_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A1m -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtssome \ OutOfHeap.hs -o T9579_outofheap_rtssome T9579_outofheap_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtsall \ OutOfHeap.hs -o T9579_outofheap_rtsall T9579_outofheap_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A1m -with-rtsopts -M1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_outofheap_rtsall_no_suggestions \ OutOfHeap.hs -o T9579_outofheap_rtsall_no_suggestions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/008d0ed091eb1c842f55a5fae8b0868a3212a059 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/008d0ed091eb1c842f55a5fae8b0868a3212a059 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 11:16:52 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Tue, 13 Oct 2020 07:16:52 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] Add missing EOL Message-ID: <5f858ca42e6dc_80b3f848b27db941858709b@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 9988a0db by David Eichmann at 2020-10-13T12:16:16+01:00 Add missing EOL - - - - - 1 changed file: - libraries/ghc-heap/tests/create_tso.h Changes: ===================================== libraries/ghc-heap/tests/create_tso.h ===================================== @@ -16,4 +16,4 @@ void create_and_unpack_tso_and_stack , StgWord ** outStackHeapRep // Array of words , int * outStackPointersSize // Size of outPointers (in words) , StgClosure *** outStackPointers // Array of all pointers of the TSO - ); \ No newline at end of file + ); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9988a0db0fcf91103697bef5889c98fd8214ae9f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9988a0db0fcf91103697bef5889c98fd8214ae9f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 12:07:04 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Tue, 13 Oct 2020 08:07:04 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 94 commits: .gitignore *.hiedb files Message-ID: <5f859868df1e3_80b3f8394eef460185904b7@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - 46f02c80 by Matthew Pickering at 2020-10-13T12:37:18+01:00 rts: Implement ghc-debug API (#18405) There are four components to this patch which make it possible to implement `ghc-debug`. 1. Add four new functions to the RtsAPI. * rts_pause and rts_unpause allow an external process to completely pause and unpause the RTS. * rts_listThreads and rts_listMiscRoots are used to find the current roots of the garbage collector. These changes also mean that `Task.h` is exposed to the user. 2. Generalise the `ghc-heap` API so that raw `Word`s can be returned rather than actual objects. This is necessary when trying to decode closures on an external process because the pointers in such closures are correct for the internal rather than external process. If you used the previous API then you would get a segfault as the garbage collector would try to traverse into these nonsensical branches. ``` -- before getClosureData :: a -> IO Closure -- after getClosureDataX :: (forall c . c -> IO (Ptr StgInfoTable, [Word], [b])) -> a -> IO (GenClosure b) ``` For the normal case `b` is instantiated to `Box`, which contains a pointer to a heap object. ``` data Box = Box a -- GenClosure Box ``` For `ghc-debug` we instead just take the word of the address as we have to explicitly interpret it on the external process. ``` GenClosure Word ``` 3. Support for decoding `TSO` and `STACK` closures is partially implemented. There is still quite a bit of work to do to finish both but these at least allow us to make some more progress. 4. findPtr is generalised to take a callback argument. This means that its result can be communicated to the debugger rather than just printing out the result. The debugger has a function which invokes `findPtr` and passes a callback which sends the result over a socket. Co-authored-by: Ben Gamari <ben at smart-cactus.org> - - - - - a60279c0 by Sven Tennie at 2020-10-13T12:37:18+01:00 Decode more StgTSO and StgStack fields (#18405) Use hsc2hs to get an understandable and stable mapping from the C structs to Haskell. It's important to keep StgTSO and StgStack decoding downwards compatible. This is especially needed for hadrian/ghci. - - - - - 333e48a5 by Sven Tennie at 2020-10-13T12:37:18+01:00 Add test for StgTSO decoding (#18405) This makes sure ghc-heap decodes StgTSO and StgStack correctly. To assert - otherwise dynamic - properties, a new, non-running TSO is created in create_tso() (create_tso.c). size is renamed to stack_size to use a dedicated type. size was already defined as a HalfWord in GenClosure, which is only equivalent to Word32 on 64bit architectures. - - - - - 6180fd8c by Sven Tennie at 2020-10-13T12:37:18+01:00 Add documentation to ghc-debug functions (#18405) - - - - - 523dd89e by Sven Tennie at 2020-10-13T12:37:18+01:00 Adjust type of getClosureX to type of getClosureDataX (#18405) After a rebase the compiler complained: libraries/ghc-heap/GHC/Exts/Heap.hs:89:23: error: • Couldn't match type: a -> IO (Ptr StgInfoTable, [Word], [b]) with: forall c. c -> IO (Ptr StgInfoTable, [Word], [b]) Expected: (forall c. c -> IO (Ptr StgInfoTable, [Word], [b])) -> a -> IO (GenClosure b) Actual: (a -> IO (Ptr StgInfoTable, [Word], [b])) -> a -> IO (GenClosure b) • In the expression: getClosureX In an equation for ‘getClosureDataX’: getClosureDataX = getClosureX In the instance declaration for ‘HasHeapRep a’ • Relevant bindings include getClosureDataX :: (forall c. c -> IO (Ptr StgInfoTable, [Word], [b])) -> a -> IO (GenClosure b) (bound at libraries/ghc-heap/GHC/Exts/Heap.hs:89:5) | 89 | getClosureDataX = getClosureX | ^^^^^^^^^^^ ) - - - - - 8520bf2e by Sven Tennie at 2020-10-13T12:37:19+01:00 Add test for rts_pause and rts_unpause (#18405) - - - - - babbf82e by Sven Tennie at 2020-10-13T12:37:19+01:00 Add test list_threads_and_misc_roots (#18405) It uses rts_listThreads() and rts_listMiscRoots(). - - - - - b9d8aaed by Sven Tennie at 2020-10-13T12:37:19+01:00 Introduce rts_isPaused() (#18405) Some operations are only save when the RTS is paused. This predicate helps to make such checks. - - - - - f0f6514b by Sven Tennie at 2020-10-13T12:37:19+01:00 Decode CostCentreStacks, CostCentres and InfoTables (#18405) These are the data structures used by profiling, i.e. they are only available when the RTS is used with `-prof`. Otherwise fetching them results into `Nothing`. To reduce unnecessary decoding, a state monad transformer is used to provide caching for CostCentres. Because the three types form a circular data structure, loop-breakers are applied to prevent endless decoding loops. - - - - - 50999318 by Sven Tennie at 2020-10-13T12:37:19+01:00 Use more precise types in tests (#18405) Use `Ptr ()` instead of `Word` to communicate that addresses/pointers are meant. - - - - - f9202cc1 by Sven Tennie at 2020-10-13T12:37:19+01:00 Introduce LiftedClosure (#18405) This is a representation for closures that do not have a representation in the Haskell language. I.e. things like StgTSOs. - - - - - 29884e67 by Sven Tennie at 2020-10-13T12:37:19+01:00 Expect stack_marking starting from GHC 8.10 (#18405) This field was introduced with GHC 8.10. - - - - - 6dc5a7a2 by Sven Tennie at 2020-10-13T12:37:19+01:00 Add WhatNext, WhyBlocked and TsoFlags to TSO closure (#18405) These constants can easily be decoded to sum types. Additionally extract TestUtils with common test functions. - - - - - 655fa05e by Sven Tennie at 2020-10-13T12:37:19+01:00 END_TSO_QUEUE is not a closure type on it's own (#18405) Indeed it's a CONSTR_NOCAF. - - - - - 864ef7ae by Sven Tennie at 2020-10-13T12:37:19+01:00 Rename boundTaskExiting and getTask (#18405) Both are directly related to myTask, which the new names now reflect. - - - - - 9e929330 by Sven Tennie at 2020-10-13T12:37:19+01:00 Mark unsafe accesses (#18405) StgTSO and StgStack are very dynamic by nature. Accesses to outdated pointers lead to segmentation faults or absolutely wrong results. So, make sure (by naming) that the users nows about these facts. The safe way to access these fields it to stop the RTS via RTS API. - - - - - bc9b4d8b by Sven Tennie at 2020-10-13T12:37:19+01:00 Check pointers with pattern matching (#18405) This is nicer than to check the length of the pointer's list and index on it. - - - - - b44d37ea by Sven Tennie at 2020-10-13T12:37:19+01:00 Remove unsave function (#18405) heap_view_closurePtrsAsWords is currently only used by ghc-debug, so it can be defined there. - - - - - 2e10a6dc by Sven Tennie at 2020-10-13T12:37:19+01:00 Define a public API for Printer.c (#18405) The RtsAPI contains functions to inspect the heap. The published Printer.c functions help to print the found closures. - - - - - 6d985ce9 by Sven Tennie at 2020-10-13T12:37:19+01:00 Do not require ClosureTypes to be Bounded (#18405) A small change to list_threads_and_misc_roots.hs and being Bounded isn't necessary anymore. - - - - - 584eacb1 by Sven Tennie at 2020-10-13T12:37:19+01:00 Assure RTS is not paused after rts_unpause() (#18405) Assert this invariant in tests. - - - - - 1533e5ae by David Eichmann at 2020-10-13T12:37:19+01:00 Use `exitMyTask()` instead of `freeTask()` in `rts_unpause()` - - - - - 5373ca52 by David Eichmann at 2020-10-13T12:37:19+01:00 Correct documentation for Task_::stopped - - - - - c7d0049d by David Eichmann at 2020-10-13T12:37:19+01:00 Improve documentation - - - - - 042dd894 by David Eichmann at 2020-10-13T12:37:19+01:00 Record and restor owned capability on pause/unpause - - - - - c0cc0965 by David Eichmann at 2020-10-13T12:37:19+01:00 Add tests for calling ghc-debug API via safe/unsafe FFI call and via a new thread - - - - - b96af02c by David Eichmann at 2020-10-13T12:37:19+01:00 Remove addition of findPtrCb and related changes - - - - - 6db3dafb by David Eichmann at 2020-10-13T12:37:19+01:00 Rename rts_unpause to rts_resume - - - - - 936634db by David Eichmann at 2020-10-13T12:37:19+01:00 Simplify and speedup test - - - - - 70f2703c by David Eichmann at 2020-10-13T12:37:19+01:00 WIP Clarify multi-threaded behavior and correct usage of the ghc-debug API - - - - - 49cfd897 by David Eichmann at 2020-10-13T12:37:19+01:00 Fix list_threads_and_misc_roots test - - - - - 6609a3be by David Eichmann at 2020-10-13T12:37:19+01:00 Allow rts_pause to be called multiple times from the same thread - - - - - 14404f81 by David Eichmann at 2020-10-13T12:37:19+01:00 Return a Capability from rts_pause to allow use of other RtsAPI.h functions - - - - - c6016cb6 by David Eichmann at 2020-10-13T12:37:20+01:00 Replace uint with unsigned int. Needed for validate-x86_64-darwin build. - - - - - 591381f6 by David Eichmann at 2020-10-13T12:37:20+01:00 Fix warnings - - - - - 6067cf6c by David Eichmann at 2020-10-13T12:37:20+01:00 Error instead of deadlock when calling rts_lock after rts_pause - - - - - 3a8ccb27 by David Eichmann at 2020-10-13T12:37:20+01:00 Move and rewrite NOTE on RtsAPI thread safety - - - - - b5d863dc by David Eichmann at 2020-10-13T12:37:20+01:00 Correct RtsAPI documentation - - - - - dd374603 by David Eichmann at 2020-10-13T12:37:20+01:00 Remove transformers dependency from ghc-heap - - - - - 2ef6a896 by David Eichmann at 2020-10-13T12:37:20+01:00 Move ptrToInt to GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled - - - - - 303f456d by David Eichmann at 2020-10-13T12:37:20+01:00 Simplify getClosureDataX and rename to getClosureDataWith - - - - - d8d9d0da by David Eichmann at 2020-10-13T12:37:20+01:00 Add documentation to StgStack - - - - - 0d520cd8 by David Eichmann at 2020-10-13T12:37:20+01:00 Remove unneeded local variables in unpackClosure# primop - - - - - b2e84fcb by David Eichmann at 2020-10-13T12:37:20+01:00 Refactor ghc-heap to allow decoding TSO/STACK closures * Remove getClosureDataWith in favour of the old simpler getClosureData * Added getClosureDataFromHeapRep which is used by getClosureData and can be reused by ghc-debug - - - - - 10ccf75f by David Eichmann at 2020-10-13T12:37:20+01:00 Support STACK closures in collect_pointers() - - - - - 92408a0d by David Eichmann at 2020-10-13T12:37:20+01:00 Update documentation - - - - - 16bd48bf by David Eichmann at 2020-10-13T12:37:20+01:00 Update documentation - - - - - 0293b5ac by David Eichmann at 2020-10-13T12:37:20+01:00 Remove LiftedClosure. Use Any instead. - - - - - 3f969029 by David Eichmann at 2020-10-13T12:37:20+01:00 Remove first argument to peekTSOFields. Always use peekStgTSOProfInfo. - - - - - 01ebe65c by David Eichmann at 2020-10-13T12:37:20+01:00 Comobine prof_info tso_and_stack_closures test and test getClosureDataFromHeapRep - - - - - 59c9f6b3 by David Eichmann at 2020-10-13T12:37:20+01:00 Remove stack_spOffset and test for TSO closure flags - - - - - 5e6e8617 by David Eichmann at 2020-10-13T12:37:20+01:00 Add missing EOL - - - - - 27 changed files: - .gitignore - .gitlab-ci.yml - README.md - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FVs.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Data/Bag.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Driver/Hooks.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/HsToCore.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/GuardedRHSs.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/PmCheck.hs - compiler/GHC/HsToCore/PmCheck/Oracle.hs - compiler/GHC/HsToCore/PmCheck/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9988a0db0fcf91103697bef5889c98fd8214ae9f...5e6e86177678664da6f2ea7f977412e38eabbad3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9988a0db0fcf91103697bef5889c98fd8214ae9f...5e6e86177678664da6f2ea7f977412e38eabbad3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 12:10:28 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 08:10:28 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/postfix-operators Message-ID: <5f859934c774e_80b3f841090a078185917fd@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/postfix-operators at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/postfix-operators You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 12:57:46 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 08:57:46 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] Implement -Woperator-whitespace (#18834) Message-ID: <5f85a44a49b54_80b3f8469f07490186020fa@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: ce485f06 by Vladislav Zavialov at 2020-10-13T15:57:14+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates the containers submodule. - - - - - 16 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -499,6 +499,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4082,7 +4084,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnSimplifiableClassConstraints, Opt_WarnStarBinder, Opt_WarnInaccessibleCode, - Opt_WarnSpaceAfterBang + Opt_WarnSpaceAfterBang, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,33 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax by a future language extension." + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,56 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus - | s == fsLit "!" -> return ITbang - | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) +varsym_prefix = sym $ \span exts s -> + let returnWhenExt tok ext errtok + | xtest ext exts = return tok + | otherwise = do + addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + return (ITvarsym s) + in + case unpackFS s of + "@" -> return ITtypeApp -- regardless of TypeApplications for better error messages + "%" -> returnWhenExt ITpercent LinearTypesBit OperatorWhitespaceSymbol_PrefixPercent + "$" -> returnWhenExt ITdollar ThQuotesBit OperatorWhitespaceSymbol_PrefixDollar + "$$" -> returnWhenExt ITdollardollar ThQuotesBit OperatorWhitespaceSymbol_PrefixDollarDollar + "-" -> return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus and + -- don't hit this code path. See Note [Minus tokens] + "!" -> return ITbang + "~" -> return ITtilde + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_Prefix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> - if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) +varsym_suffix = sym $ \span _ s -> + case unpackFS s of + "@" -> failMsgP (Error ErrSuffixAT []) + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_Suffix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> - if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) +varsym_tight_infix = sym $ \span _ s -> + case unpackFS s of + "@" -> return ITat + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_TightInfix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1630,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1869,6 +1870,54 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 5ae82d447dd5ac7ef3c41adb925db85f26c3a190 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,12 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce485f0650353944a3904a47e69695e3824ddfed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce485f0650353944a3904a47e69695e3824ddfed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:33:33 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 09:33:33 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] Implement -Woperator-whitespace (#18834) Message-ID: <5f85acad76b42_80b3f84a05c98381861519f@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: dac5193f by Vladislav Zavialov at 2020-10-13T16:33:08+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 18 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -499,6 +499,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4082,7 +4084,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnSimplifiableClassConstraints, Opt_WarnStarBinder, Opt_WarnInaccessibleCode, - Opt_WarnSpaceAfterBang + Opt_WarnSpaceAfterBang, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,33 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax by a future language extension." + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,56 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus - | s == fsLit "!" -> return ITbang - | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) +varsym_prefix = sym $ \span exts s -> + let returnWhenExt tok ext errtok + | xtest ext exts = return tok + | otherwise = do + addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + return (ITvarsym s) + in + case unpackFS s of + "@" -> return ITtypeApp -- regardless of TypeApplications for better error messages + "%" -> returnWhenExt ITpercent LinearTypesBit OperatorWhitespaceSymbol_PrefixPercent + "$" -> returnWhenExt ITdollar ThQuotesBit OperatorWhitespaceSymbol_PrefixDollar + "$$" -> returnWhenExt ITdollardollar ThQuotesBit OperatorWhitespaceSymbol_PrefixDollarDollar + "-" -> return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus and + -- don't hit this code path. See Note [Minus tokens] + "!" -> return ITbang + "~" -> return ITtilde + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_Prefix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> - if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) +varsym_suffix = sym $ \span _ s -> + case unpackFS s of + "@" -> failMsgP (Error ErrSuffixAT []) + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_Suffix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> - if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) +varsym_tight_infix = sym $ \span _ s -> + case unpackFS s of + "@" -> return ITat + _ -> do + addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s OperatorWhitespaceOccurrence_TightInfix + return (ITvarsym s) -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1630,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1869,6 +1870,54 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 5ae82d447dd5ac7ef3c41adb925db85f26c3a190 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,12 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2 +Subproject commit e117ee0f403a09fe9c2883d0c4c5a8242bd30400 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dac5193f335e9b59c313c9b0af99a52b0ce9d081 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dac5193f335e9b59c313c9b0af99a52b0ce9d081 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:52:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 09:52:18 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] 38 commits: Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Message-ID: <5f85b112e96e8_80b1133172c186181f5@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 7ec1b31f by Ben Gamari at 2020-10-13T09:52:11-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - cbfba226 by Ben Gamari at 2020-10-13T09:52:13-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Core/TyCon.hs - + compiler/GHC/Core/TyCon/Env.hs - + compiler/GHC/Core/TyCon/RecWalk.hs - + compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a28c51ec2dfdafcb4dfe362171c28a0b7377e7d4...cbfba2260c74e6f73bc40af33f6f678f7b57d7df -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a28c51ec2dfdafcb4dfe362171c28a0b7377e7d4...cbfba2260c74e6f73bc40af33f6f678f7b57d7df You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:53:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 09:53:03 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/T18821-8.8 Message-ID: <5f85b13f62913_80b3f84696a14f4186211a1@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/T18821-8.8 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:53:02 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 09:53:02 -0400 Subject: [Git][ghc/ghc][ghc-8.8] get-win32-tarballs: Fix incorrect parenthesization Message-ID: <5f85b13e681ae_80b1133172c18620898@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 4ee172e6 by Ben Gamari at 2020-10-08T16:27:23-04:00 get-win32-tarballs: Fix incorrect parenthesization Previously the download fallback wasn't parenthesized correctly, resulting in the mirror being consulted regardless of whether the downloads.haskell.org download succeeded. Fixes #18821. - - - - - 1 changed file: - mk/get-win32-tarballs.sh Changes: ===================================== mk/get-win32-tarballs.sh ===================================== @@ -37,11 +37,13 @@ download_file() { return else echo "Downloading ${description} to ${dest_dir}..." - $curl_cmd || echo "Checking repo.msys2.org instead of Haskell.org..." && $curl_cmd_bnk || { - rm -f "${dest_file}" - fail "ERROR: Download failed." - exit 1 - } + $curl_cmd || ( + echo "Checking repo.msys2.org instead of Haskell.org..." && $curl_cmd_bnk || { + rm -f "${dest_file}" + fail "ERROR: Download failed." + exit 1 + } + ) fi fi @@ -55,11 +57,13 @@ download_file() { else local curl_cmd_bnk="true" fi - $curl_cmd || echo "Checking repo.msys2.org instead of Haskell.org..." && $curl_cmd_bnk || { + $curl_cmd || ( + echo "Checking repo.msys2.org instead of Haskell.org..." && $curl_cmd_bnk || { rm -f "${dest_file}.sig" fail "ERROR: Download failed." exit 1 } + ) fi if test "$verify" = "1" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ee172e66cd76c22da4d3b991f9eb92523266d0e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4ee172e66cd76c22da4d3b991f9eb92523266d0e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:54:10 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 09:54:10 -0400 Subject: [Git][ghc/ghc][wip/test-hadrian-stack-build] 46 commits: Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Message-ID: <5f85b182489e6_80b3f848e5848f81862366c@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/test-hadrian-stack-build at Glasgow Haskell Compiler / GHC Commits: bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - c7c94481 by Ben Gamari at 2020-10-13T09:54:06-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/525a233ffa42e406d61c462c943eabfc15f02f20...c7c9448108a1f0001f298d1fc399996e09d761b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/525a233ffa42e406d61c462c943eabfc15f02f20...c7c9448108a1f0001f298d1fc399996e09d761b6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:54:54 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 13 Oct 2020 09:54:54 -0400 Subject: [Git][ghc/ghc][wip/andreask/allocationArea] Increase -A default to 4MB. Message-ID: <5f85b1aec8889_80b3f849011070c186257a4@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/allocationArea at Glasgow Haskell Compiler / GHC Commits: b3c1e42e by Andreas Klebinger at 2020-10-13T15:54:41+02:00 Increase -A default to 4MB. This gives a small increase in performance under most circumstances. For single threaded GC the improvement is on the order of 1-2%. For multi threaded GC the results are quite noisy but seem to fall into the same ballpark. Fixes #16499 - - - - - 3 changed files: - docs/users_guide/runtime_control.rst - rts/RtsFlags.c - testsuite/tests/rts/T9579/Makefile Changes: ===================================== docs/users_guide/runtime_control.rst ===================================== @@ -418,7 +418,7 @@ performance. .. rts-flag:: -A ⟨size⟩ - :default: 1MB + :default: 4MB .. index:: single: allocation area, size @@ -427,15 +427,22 @@ performance. collector. The allocation area (actually generation 0 step 0) is fixed and is never resized (unless you use :rts-flag:`-H [⟨size⟩]`, below). - Increasing the allocation area size may or may not give better - performance (a bigger allocation area means worse cache behaviour - but fewer garbage collections and less promotion). + Optimal settings depend on the actual machine, program, and other RTS options. + Increasing the allocation area size means worse cache behaviour + but fewer garbage collections and less promotion. + + In general settings >= 4MB can reduce performance in some cases, in particular for single + threaded operation. However in a parallel setting increasing the allocation area + to ``16MB``, or even ``64MB`` can increase gc throughput significantly. With only 1 generation (e.g. ``-G1``, see :rts-flag:`-G ⟨generations⟩`) the ``-A`` option specifies the minimum allocation area, since the actual size of the allocation area will be resized according to the amount of data in the heap (see :rts-flag:`-F ⟨factor⟩`, below). + When heap profiling using a smaller allocation area can increase accuracy as more frequent + major garbage collections also results in more frequent heap snapshots + .. rts-flag:: -AL ⟨size⟩ :default: :rts-flag:`-A <-A ⟨size⟩>` value ===================================== rts/RtsFlags.c ===================================== @@ -153,10 +153,11 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.stkChunkSize = (32 * 1024) / sizeof(W_); RtsFlags.GcFlags.stkChunkBufferSize = (1 * 1024) / sizeof(W_); - RtsFlags.GcFlags.minAllocAreaSize = (1024 * 1024) / BLOCK_SIZE; + /* -A default. See #16499 for a discussion about the tradeoffs */ + RtsFlags.GcFlags.minAllocAreaSize = (4 * 1024 * 1024) / BLOCK_SIZE; RtsFlags.GcFlags.largeAllocLim = 0; /* defaults to minAllocAreasize */ RtsFlags.GcFlags.nurseryChunkSize = 0; - RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; + RtsFlags.GcFlags.minOldGenSize = (1024 * 1024) / BLOCK_SIZE; /* -O default */ RtsFlags.GcFlags.maxHeapSize = 0; /* off by default */ RtsFlags.GcFlags.heapLimitGrace = (1024 * 1024); RtsFlags.GcFlags.heapSizeSuggestion = 0; /* none */ ===================================== testsuite/tests/rts/T9579/Makefile ===================================== @@ -3,43 +3,43 @@ include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk T9579_stackoverflow_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A500k -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtsnone \ StackOverflow.hs -o T9579_stackoverflow_rtsnone T9579_stackoverflow_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A500k -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtssome \ StackOverflow.hs -o T9579_stackoverflow_rtssome T9579_stackoverflow_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A500k -with-rtsopts -K1m \ -outputdir tmp_T9579_stackoverflow_rtsall \ StackOverflow.hs -o T9579_stackoverflow_rtsall T9579_stackoverflow_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -K1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A500k -with-rtsopts -K1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_stackoverflow_rtsall_no_suggestions \ StackOverflow.hs -o T9579_stackoverflow_rtsall_no_suggestions T9579_outofheap_rtsnone: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=none -fforce-recomp -with-rtsopts -A500k -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtsnone \ OutOfHeap.hs -o T9579_outofheap_rtsnone T9579_outofheap_rtssome: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=some -fforce-recomp -with-rtsopts -A500k -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtssome \ OutOfHeap.hs -o T9579_outofheap_rtssome T9579_outofheap_rtsall: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A500k -with-rtsopts -M1m \ -outputdir tmp_T9579_outofheap_rtsall \ OutOfHeap.hs -o T9579_outofheap_rtsall T9579_outofheap_rtsall_no_suggestions: - '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -M1m \ + '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -rtsopts=all -fforce-recomp -with-rtsopts -A500k -with-rtsopts -M1m \ -no-rtsopts-suggestions \ -outputdir tmp_T9579_outofheap_rtsall_no_suggestions \ OutOfHeap.hs -o T9579_outofheap_rtsall_no_suggestions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3c1e42eb9c4f1ed7771e6e87be46cf5069769f1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b3c1e42eb9c4f1ed7771e6e87be46cf5069769f1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 13:57:14 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 09:57:14 -0400 Subject: [Git][ghc/ghc][wip/T18346] 673 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake Message-ID: <5f85b23a42836_80b3f848c24771418626726@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18346 at Glasgow Haskell Compiler / GHC Commits: 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - f1604cdd by Ben Gamari at 2020-10-13T09:57:00-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 22 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/test-metrics.sh - CODEOWNERS - Makefile - README.md - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Uniques.hs-boot - compiler/GHC/Builtin/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75c11258bb95d6e7dfd3bdfa37f0775b8688bbfe...f1604cdd622e5a674de6ddd6b93cc155a8017abe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75c11258bb95d6e7dfd3bdfa37f0775b8688bbfe...f1604cdd622e5a674de6ddd6b93cc155a8017abe You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 14:06:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 10:06:34 -0400 Subject: [Git][ghc/ghc][wip/bump-llvm] 145 commits: rts/nonmoving: Add missing STM write barrier Message-ID: <5f85b46a5875b_80ba57e25c18627883@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-llvm at Glasgow Haskell Compiler / GHC Commits: 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - b7d5a5f6 by Ben Gamari at 2020-10-13T10:06:26-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - aclocal.m4 - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/407c95e6e5426eabed58a7b9dc0b88bff7b4f3e0...b7d5a5f6b4fbe5558fa1f402576740d5985dcfbd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/407c95e6e5426eabed58a7b9dc0b88bff7b4f3e0...b7d5a5f6b4fbe5558fa1f402576740d5985dcfbd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 14:11:48 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 10:11:48 -0400 Subject: [Git][ghc/ghc][wip/T18835] hadrian: Suppress xelatex output unless it fails Message-ID: <5f85b5a47a886_80b10451554186284ef@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18835 at Glasgow Haskell Compiler / GHC Commits: ecba68a9 by Ben Gamari at 2020-10-13T10:11:42-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 1 changed file: - hadrian/src/Builder.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -286,7 +286,18 @@ instance H.Builder Builder where Makeinfo -> do cmd' echo [path] "--no-split" [ "-o", output] [input] - Xelatex -> unit $ cmd' [Cwd output] [path] buildArgs + Xelatex -> + -- xelatex produces an incredible amount of output, almost + -- all of which is useless. Suppress it unless user + -- requests a loud build. + if verbosity >= Loud + then cmd' [Cwd output] [path] buildArgs + else do (Stdouterr out, Exit code) <- cmd' [Cwd output] [path] buildArgs + when (code /= ExitSuccess) $ + BSL.hPutStrLn stderr out + putFailure "xelatex failed!" + fail "xelatex failed" + Makeindex -> unit $ cmd' [Cwd output] [path] (buildArgs ++ [input]) Tar _ -> cmd' buildOptions echo [path] buildArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecba68a997090529222d9c0ff547305dba648776 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecba68a997090529222d9c0ff547305dba648776 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 14:27:15 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 10:27:15 -0400 Subject: [Git][ghc/ghc][wip/tuple-width] 82 commits: Make 'undefined x' linear in 'x' (#18731) Message-ID: <5f85b94386d3a_80b3f849d60bc4018633285@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tuple-width at Glasgow Haskell Compiler / GHC Commits: bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 6e5a83bb by GHC GitLab CI at 2020-10-13T10:27:04-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Monad.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67539b61bc002386ec314fd313d75c3a71864799...6e5a83bb6052f9e251a54026294c87a5bd650c93 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/67539b61bc002386ec314fd313d75c3a71864799...6e5a83bb6052f9e251a54026294c87a5bd650c93 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 15:44:11 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 11:44:11 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18838 Message-ID: <5f85cb4b53a81_80b3f848a24c70c18649525@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18838 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18838 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 15:44:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 11:44:35 -0400 Subject: [Git][ghc/ghc][wip/T18838] testsuite: Sort metrics by metric type Message-ID: <5f85cb632df41_80b3f848c6a2304186497d7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18838 at Glasgow Haskell Compiler / GHC Commits: 72224228 by Ben Gamari at 2020-10-13T11:44:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - 1 changed file: - testsuite/driver/runtests.py Changes: ===================================== testsuite/driver/runtests.py ===================================== @@ -457,7 +457,20 @@ else: if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + # Group metrics by metric type + groups = {} + for stat in t.metrics: + if stat.metric not in groups: + groups[stat.metric] = [] + + groups[stat.metric].append(stat) + + for metric_name, stats in groups.items(): + heading = 'Metrics: %s' % metric_name + print(heading) + print('-' * len(heading)) + print() + tabulate_metrics(stats) else: print("\nNone collected.") print("") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72224228fbc53fc304af5706ed7e4f905f05f19e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72224228fbc53fc304af5706ed7e4f905f05f19e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 17:28:49 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 13:28:49 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] Implement -Woperator-whitespace (#18834) Message-ID: <5f85e3d1d4a4d_80bf0d5b9c1869875e@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: 98aedb3a by Vladislav Zavialov at 2020-10-13T20:20:17+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 18 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -499,6 +499,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4082,7 +4084,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnSimplifiableClassConstraints, Opt_WarnStarBinder, Opt_WarnInaccessibleCode, - Opt_WarnSpaceAfterBang + Opt_WarnSpaceAfterBang, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,33 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax by a future language extension." + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1869,6 +1870,54 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,12 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2 +Subproject commit e117ee0f403a09fe9c2883d0c4c5a8242bd30400 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98aedb3abbe6f1fe2c9f9a0e9189b9c76d20af26 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98aedb3abbe6f1fe2c9f9a0e9189b9c76d20af26 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 17:38:32 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Tue, 13 Oct 2020 13:38:32 -0400 Subject: [Git][ghc/ghc][wip/postfix-operators] 2 commits: Remove "Operator sections" from docs/users_guide/bugs.rst Message-ID: <5f85e618c1791_80bac2709018704184@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/postfix-operators at Glasgow Haskell Compiler / GHC Commits: 2ca1f851 by Vladislav Zavialov at 2020-10-13T20:37:30+03:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - db665fd6 by Vladislav Zavialov at 2020-10-13T20:37:30+03:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - 5 changed files: - compiler/GHC/HsToCore/Expr.hs - docs/users_guide/bugs.rst - + testsuite/tests/deSugar/should_run/T18151x.hs - + testsuite/tests/deSugar/should_run/T18151x.stdout - testsuite/tests/deSugar/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -70,6 +70,8 @@ import GHC.Utils.Panic import GHC.Core.PatSyn import Control.Monad +import qualified GHC.LanguageExtensions as LangExt + {- ************************************************************************ * * @@ -347,7 +349,11 @@ converting to core it must become a CO. Note [Desugaring operator sections] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -At first it looks as if we can convert +Desugaring left sections with -XPostfixOperators is straightforward: convert +(expr `op`) to (op expr). + +Without -XPostfixOperators it's a bit more tricky. At first it looks as if we +can convert (expr `op`) @@ -398,6 +404,13 @@ dsExpr e@(OpApp _ e1 op e2) -- See Note [Desugaring operator sections]. -- N.B. this also must handle postfix operator sections due to -XPostfixOperators. dsExpr e@(SectionL _ expr op) = do + postfix_operators <- xoptM LangExt.PostfixOperators + if postfix_operators then + -- Desugar (e !) to ((!) e) + do { op' <- dsLExpr op + ; dsWhenNoErrs (dsLExprNoLP expr) $ \expr' -> + mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr' } + else do core_op <- dsLExpr op x_core <- dsLExpr expr case splitFunTys (exprType core_op) of ===================================== docs/users_guide/bugs.rst ===================================== @@ -438,31 +438,6 @@ The Foreign Function Interface single: hs_init single: hs_exit -.. _infelicities-operator-sections: - -Operator sections -^^^^^^^^^^^^^^^^^ - -The Haskell Report demands that, for infix operators ``%``, the following -identities hold: - -:: - - (% expr) = \x -> x % expr - (expr %) = \x -> expr % x - -However, the second law is violated in the presence of undefined operators, - -:: - - (%) = error "urk" - (() %) `seq` () -- urk - (\x -> () % x) `seq` () -- OK, result () - -The operator section is treated like function application of an undefined -function, while the lambda form is in WHNF that contains an application of an -undefined function. - .. _haskell-98-2010-undefined: GHC's interpretation of undefined behaviour in Haskell 98 and Haskell 2010 ===================================== testsuite/tests/deSugar/should_run/T18151x.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE PostfixOperators #-} + +import Control.Exception + +data MyException = MyE + deriving (Show) + +instance Exception MyException + +(#) :: Bool -> Bool -> Bool +(#) = throw MyE + +main = do + r <- try (evaluate (seq (True #) ())) + case r of + Left MyE -> putStrLn "PostfixOperators ok" + Right () -> putStrLn "PostfixOperators broken" ===================================== testsuite/tests/deSugar/should_run/T18151x.stdout ===================================== @@ -0,0 +1 @@ +PostfixOperators ok ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -65,6 +65,7 @@ test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) test('T18151', normal, compile_and_run, ['']) +test('T18151x', normal, compile_and_run, ['']) test('T18172', [], ghci_script, ['T18172.script']) test('DsDoExprFailMsg', exit_code(1), compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac67a2a6dc56e95fdb93448e1f4c05873ebc65fd...db665fd671c23fb79b35f4a902d792dbb32f3531 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac67a2a6dc56e95fdb93448e1f4c05873ebc65fd...db665fd671c23fb79b35f4a902d792dbb32f3531 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 19:15:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 15:15:18 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/doc-fix Message-ID: <5f85fcc68fb68_28003fd4095d047c551c1@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/doc-fix at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/doc-fix You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 21:02:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 13 Oct 2020 17:02:04 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Initial ShortText code and conversion of package db code Message-ID: <5f8615cc4dfdb_28003fd3ed6d5b0481110@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 45e52af7 by Ben Gamari at 2020-10-13T17:01:55-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Linker.hs - compiler/GHC/SysTools/ExtraObj.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Unit/Info.hs - compiler/GHC/Unit/State.hs - compiler/ghc.cabal.in - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/type_literals.rst - hadrian/build-stack - hadrian/build-stack.bat - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Event/PSQ.hs - libraries/base/GHC/Generics.hs - libraries/base/GHC/TypeLits.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8a9cdb6eaa8f70d8a6c4c7f84f762fab3f557ff...45e52af724395be4f8aac3962f88b20a5aa4ad7b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8a9cdb6eaa8f70d8a6c4c7f84f762fab3f557ff...45e52af724395be4f8aac3962f88b20a5aa4ad7b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 21:17:54 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Tue, 13 Oct 2020 17:17:54 -0400 Subject: [Git][ghc/ghc][wip/T18831] Make DataKinds the sole arbiter of kind-level literals (and friends) Message-ID: <5f861982fa48_2800cf8b7ac895a8@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18831 at Glasgow Haskell Compiler / GHC Commits: 9365fb5e by Ryan Scott at 2020-10-13T17:17:26-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - 6 changed files: - compiler/GHC/Rename/HsType.hs - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/poly_kinds.rst - testsuite/tests/th/T17688b.hs - + testsuite/tests/typecheck/should_compile/T18831.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -441,9 +441,9 @@ sites. This is less precise, but more accurate. rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. -Note [QualTy in kinds] +Note [HsQualTy in kinds] ~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether QualTy could occur only at TypeLevel. But no, +I was wondering whether HsQualTy could occur only at TypeLevel. But no, we can have a qualified type in a kind too. Here is an example: type family F a where @@ -466,9 +466,9 @@ suitable message: Expected kind: G Bool Actual kind: F Bool -However: in a kind, the constraints in the QualTy must all be +However: in a kind, the constraints in the HsQualTy must all be equalities; or at least, any kinds with a class constraint are -uninhabited. +uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -574,7 +574,9 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , fvs) } } rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { checkPolyKinds env ty -- See Note [QualTy in kinds] + = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] + ; when (not data_kinds && isRnKindLevel env) + (addErr (dataKindsErr env ty)) ; (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' @@ -636,9 +638,8 @@ rnHsTyKi env listTy@(HsListTy _ ty) ; (ty', fvs) <- rnLHsTyKi env ty ; return (HsListTy noExtField ty', fvs) } -rnHsTyKi env t@(HsKindSig _ ty k) - = do { checkPolyKinds env t - ; kind_sigs_ok <- xoptM LangExt.KindSignatures +rnHsTyKi env (HsKindSig _ ty k) + = do { kind_sigs_ok <- xoptM LangExt.KindSignatures ; unless kind_sigs_ok (badKindSigErr (rtke_ctxt env) ty) ; (ty', lhs_fvs) <- rnLHsTyKi env ty ; (k', sig_fvs) <- rnLHsTyKi (env { rtke_level = KindLevel }) k @@ -665,7 +666,6 @@ rnHsTyKi env tyLit@(HsTyLit _ t) = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env tyLit)) ; when (negLit t) (addErr negLitErr) - ; checkPolyKinds env tyLit ; return (HsTyLit noExtField t, emptyFVs) } where negLit (HsStrTy _ _) = False @@ -705,15 +705,13 @@ rnHsTyKi _ (XHsType (NHsCoreTy ty)) -- but I don't think it matters rnHsTyKi env ty@(HsExplicitListTy _ ip tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitListTy noExtField ip tys', fvs) } rnHsTyKi env ty@(HsExplicitTupleTy _ tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitTupleTy noExtField tys', fvs) } ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -134,6 +134,12 @@ promotion quote and the data constructor: :: type S = 'A' -- ERROR: looks like a character type R = ' A' -- OK: promoted `A'` +Type-level literals +------------------- + +:extension:`DataKinds` enables the use of numeric and string literals at the +type level. For more information, see :ref:`type-level-literals`. + .. _promoted-lists-and-tuples: Promoted list and tuple types @@ -207,4 +213,27 @@ above code is valid. See also :ghc-ticket:`7347`. +.. _constraints_in_kinds: + +Constraints in kinds +-------------------- + +Kinds can (with :extension:`DataKinds`) contain type constraints. However, +only equality constraints are supported. + +Here is an example of a constrained kind: :: + + type family IsTypeLit a where + IsTypeLit Nat = 'True + IsTypeLit Symbol = 'True + IsTypeLit a = 'False + + data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where + MkNat :: T 42 + MkSymbol :: T "Don't panic!" +The declarations above are accepted. However, if we add ``MkOther :: T Int``, +we get an error that the equality constraint is not satisfied; ``Int`` is +not a type literal. Note that explicitly quantifying with ``forall a`` is +necessary in order for ``T`` to typecheck +(see :ref:`complete-kind-signatures`). ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -787,29 +787,6 @@ distinction). GHC does not consider ``forall k. k -> Type`` and ``forall {k}. k -> Type`` to be equal at the kind level, and thus rejects ``Foo Proxy`` as ill-kinded. -Constraints in kinds --------------------- - -As kinds and types are the same, kinds can (with :extension:`TypeInType`) -contain type constraints. However, only equality constraints are supported. - -Here is an example of a constrained kind: :: - - type family IsTypeLit a where - IsTypeLit Nat = 'True - IsTypeLit Symbol = 'True - IsTypeLit a = 'False - - data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where - MkNat :: T 42 - MkSymbol :: T "Don't panic!" - -The declarations above are accepted. However, if we add ``MkOther :: T Int``, -we get an error that the equality constraint is not satisfied; ``Int`` is -not a type literal. Note that explicitly quantifying with ``forall a`` is -necessary in order for ``T`` to typecheck -(see :ref:`complete-kind-signatures`). - The kind ``Type`` ----------------- ===================================== testsuite/tests/th/T17688b.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE StandaloneKindSignatures #-} ===================================== testsuite/tests/typecheck/should_compile/T18831.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +module T18831 where + +import Data.Kind +import Data.Proxy + +data T1 :: Proxy 0 -> Type +data T2 :: () => Type +data T3 :: (Type :: Type) -> Type +data T4 :: Proxy '[Type,Type] -> Type +data T5 :: Proxy '(Type,Type) -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -722,5 +722,6 @@ test('T18412', normal, compile, ['']) test('T18470', normal, compile, ['']) test('T18323', normal, compile, ['']) test('T18585', normal, compile, ['']) +test('T18831', normal, compile, ['']) test('T15942', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9365fb5e0c74a1a4ac24493272103ea00a0f997f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9365fb5e0c74a1a4ac24493272103ea00a0f997f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 21:40:56 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Tue, 13 Oct 2020 17:40:56 -0400 Subject: [Git][ghc/ghc][wip/T16762] 58 commits: Small documentation fixes Message-ID: <5f861ee8288c4_28003fd4090e3f5498427@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 1696e1d0 by Ryan Scott at 2020-10-13T17:39:20-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> - - - - - 96062474 by Simon Peyton Jones at 2020-10-13T17:39:20-04:00 Wibbbles - - - - - 1bebe994 by Simon Peyton Jones at 2020-10-13T17:39:20-04:00 More wibbles - - - - - 2e7d5ecd by Simon Peyton Jones at 2020-10-13T17:39:20-04:00 More wibbles - - - - - 5a14340d by Simon Peyton Jones at 2020-10-13T17:39:20-04:00 More wibbles --- getting there - - - - - 2c707d69 by Ryan Scott at 2020-10-13T17:39:20-04:00 Push through some Haddock changes, disable warnings in GHC.Iface.Ext.Ast for now - - - - - 6a31e9ff by Simon Peyton Jones at 2020-10-13T17:39:20-04:00 More wibbles - - - - - cd3825be by Ryan Scott at 2020-10-13T17:39:20-04:00 Use TTG in HsOuterTyVarBndrs - - - - - 79190b6b by Ryan Scott at 2020-10-13T17:39:20-04:00 Add some documentation, minor code cleanup - - - - - e99cba58 by Ryan Scott at 2020-10-13T17:39:20-04:00 Accept new DumpRenamedAst stderr - - - - - 458da7db by Ryan Scott at 2020-10-13T17:39:20-04:00 Fix a PolyKinds buglet - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a777a490038b2c6db8cdaa17ec4af18db5dc619...458da7dbd491bb21cf6a884d454f79ee2a97a5bd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a777a490038b2c6db8cdaa17ec4af18db5dc619...458da7dbd491bb21cf6a884d454f79ee2a97a5bd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 21:42:51 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Tue, 13 Oct 2020 17:42:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports-9.0 Message-ID: <5f861f5bc99b4_28003fd3ee5bbba010056@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/backports-9.0 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports-9.0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 22:45:49 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 13 Oct 2020 18:45:49 -0400 Subject: [Git][ghc/ghc][wip/T16762] 16 commits: Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f862e1d3e618_28003fd3eefb3b801135d9@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: f165f338 by Ryan Scott at 2020-10-13T09:42:14+01:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - 22e49693 by Simon Peyton Jones at 2020-10-13T09:42:15+01:00 Wibbbles - - - - - 2e84c96e by Simon Peyton Jones at 2020-10-13T09:42:15+01:00 More wibbles - - - - - 40a74cdc by Simon Peyton Jones at 2020-10-13T09:42:15+01:00 More wibbles - - - - - cd974c8a by Simon Peyton Jones at 2020-10-13T09:42:15+01:00 More wibbles --- getting there - - - - - d4013d21 by Ryan Scott at 2020-10-13T09:54:15+01:00 Push through some Haddock changes, disable warnings in GHC.Iface.Ext.Ast for now - - - - - c3bed6a2 by Simon Peyton Jones at 2020-10-13T09:54:15+01:00 More wibbles - - - - - 396fce54 by Ryan Scott at 2020-10-13T09:54:17+01:00 Use TTG in HsOuterTyVarBndrs - - - - - 450f3981 by Ryan Scott at 2020-10-13T09:54:18+01:00 Add some documentation, minor code cleanup - - - - - 10cca24b by Richard Eisenberg at 2020-10-13T09:54:18+01:00 Skolemise PatSyns - - - - - 08e61415 by Richard Eisenberg at 2020-10-13T09:54:18+01:00 Don't freshen when skolemising - - - - - 1805c836 by Simon Peyton Jones at 2020-10-13T09:54:18+01:00 Wibbles from Simon - - - - - be365ada by Richard Eisenberg at 2020-10-13T09:54:18+01:00 Still freshen existentials, though. - - - - - fd32885a by Simon Peyton Jones at 2020-10-13T23:31:51+01:00 Yet more wibbles - - - - - f34e6cfb by Ryan Scott at 2020-10-13T23:44:31+01:00 Accept new DumpRenamedAst stderr - - - - - 32447043 by Ryan Scott at 2020-10-13T23:45:04+01:00 Fix a PolyKinds buglet - - - - - 20 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/458da7dbd491bb21cf6a884d454f79ee2a97a5bd...324470433405fc434b27cf2ed2ff4d00242f1cac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/458da7dbd491bb21cf6a884d454f79ee2a97a5bd...324470433405fc434b27cf2ed2ff4d00242f1cac You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 22:47:12 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Tue, 13 Oct 2020 18:47:12 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f862e70e67c9_2800a538c841161f6@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 6c2e32fb by Alan Zimmerman at 2020-10-13T23:46:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 19 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -934,22 +934,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -964,20 +965,24 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- TODO: should the explicit IsUnicodeSyntax override the +-- 'unicodeSyntax` decision based on DynFlags? +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1962,10 +1967,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2621,9 +2621,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -723,10 +723,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1846,7 +1846,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -148,6 +148,7 @@ import Control.DeepSeq import Control.Monad import GHC.Tc.Errors.Hole.FitTypes ( HoleFitPluginR (..) ) +import GHC.Parser.Annotation #include "HsVersions.h" @@ -2455,7 +2456,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy (HsUnrestrictedArrow NormalSyntax) ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -74,6 +74,7 @@ import qualified GHC.Parser.Lexer as Lexer import GHC.Data.StringBuffer import GHC.Utils.Outputable +import GHC.Parser.Annotation import GHC.Runtime.Loader ( initializePlugins ) @@ -1683,7 +1684,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy (HsUnrestrictedArrow NormalSyntax) stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1752,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy (HsUnrestrictedArrow NormalSyntax) ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit fc128b4719970b741e60e6463bb14ea54fba0175 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c2e32fb05b6d4e481b75176711e7edfbf3296a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c2e32fb05b6d4e481b75176711e7edfbf3296a7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 13 23:21:38 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 19:21:38 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T14334 Message-ID: <5f86368261b46_28003fd3ee2a3328121731@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T14334 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T14334 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 00:59:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 13 Oct 2020 20:59:01 -0400 Subject: [Git][ghc/ghc][wip/T14334] compiler/ByteCode: Allow 2^32 local labels Message-ID: <5f864d55d078f_28003fd3ed11370c127134@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T14334 at Glasgow Haskell Compiler / GHC Commits: d52fab4c by Ben Gamari at 2020-10-14T00:58:51+00:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 3 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -177,7 +177,9 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (fromIntegral $ Map.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) env :: LocalLabel -> Word ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -50,7 +50,7 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -newtype LocalLabel = LocalLabel { getLocalLabel :: Word16 } +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } deriving (Eq, Ord) instance Outputable LocalLabel where ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1966,7 +1966,7 @@ data BcM_State { bcm_hsc_env :: HscEnv , uniqSupply :: UniqSupply -- for generating fresh variable names , thisModule :: Module -- current module (for breakpoints) - , nextlabel :: Word16 -- for generating local labels + , nextlabel :: Word32 -- for generating local labels , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints @@ -2038,7 +2038,7 @@ getLabelBc panic "getLabelBc: Ran out of labels" return (st{nextlabel = nl + 1}, LocalLabel nl) -getLabelsBc :: Word16 -> BcM [LocalLabel] +getLabelsBc :: Word32 -> BcM [LocalLabel] getLabelsBc n = BcM $ \st -> let ctr = nextlabel st in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52fab4ca043d154bc5ccd83a8ffadc4fc0a2b38 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52fab4ca043d154bc5ccd83a8ffadc4fc0a2b38 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 01:58:45 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Tue, 13 Oct 2020 21:58:45 -0400 Subject: [Git][ghc/ghc][wip/T18599] update comments Message-ID: <5f865b552e2dd_28003fd409676f48131351@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 49ce6d8e by Shayne Fletcher at 2020-10-13T21:58:32-04:00 update comments - - - - - 1 changed file: - compiler/GHC/Parser.y Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2616,7 +2616,7 @@ fexp :: { ECP } ams (sLL $1 $> $ HsStatic noExtField $2) [mj AnnStatic $1] } - -- See Note [Whitespace-sensitive operator parsing] in Lexer.x + -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | fexp TIGHT_INFIX_PROJ field {% runPV (unECP $1) >>= \ $1 -> -- Suppose lhs is an application term e.g. 'f a' @@ -2806,7 +2806,7 @@ aexp2 :: { ECP } projection :: { LHsExpr GhcPs } projection - -- See Note [Whitespace-sensitive operator parsing] in Lexer.x + -- See Note [Whitespace-sensitive operator parsing] in GHC.Parsing.Lexer : projection TIGHT_INFIX_PROJ field { mkProj (Just $1) $3 } | PREFIX_PROJ field { mkProj Nothing $2 } @@ -3254,14 +3254,14 @@ fbind :: { forall b. DisambECP b => PV (Fbind b) } -- In the punning case, use a place-holder -- The renamer fills in the final value - -- See Note [Whitespace-sensitive operator parsing] in Lexer.x + -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | field TIGHT_INFIX_PROJ fieldToUpdate '=' texp { do $5 <- unECP $5 fmap Pbind $ mkHsFieldUpdaterPV (comb2 $1 $5) ($1 : reverse $3) $5 } - -- See Note [Whitespace-sensitive operator parsing] in Lexer.x + -- See Note [Whitespace-sensitive operator parsing] in GHC.Parser.Lexer | field TIGHT_INFIX_PROJ fieldToUpdate { do let top = $1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49ce6d8e7c84715cf6e2b3dfbe63f5e737e51f31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/49ce6d8e7c84715cf6e2b3dfbe63f5e737e51f31 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 06:24:09 2020 From: gitlab at gitlab.haskell.org (wz1000) Date: Wed, 14 Oct 2020 02:24:09 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/16762 Message-ID: <5f869989eba37_2800e96b0641476a9@gitlab.haskell.org.mail> wz1000 pushed new branch wip/16762 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/16762 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 06:26:59 2020 From: gitlab at gitlab.haskell.org (wz1000) Date: Wed, 14 Oct 2020 02:26:59 -0400 Subject: [Git][ghc/ghc][wip/T16762] Fix HieAst Message-ID: <5f869a336dd54_28007b842801478f3@gitlab.haskell.org.mail> wz1000 pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: c4ac4e6e by Zubin Duggal at 2020-10-14T11:53:50+05:30 Fix HieAst - - - - - 1 changed file: - compiler/GHC/Iface/Ext/Ast.hs Changes: ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -18,10 +18,6 @@ Main functions for .hie file generation -} --- TODO RGS: This is a horrible hack that I put in place to get the test suite --- to run on GitLab CI. Please remove this hack before landing! -{-# OPTIONS_GHC -Wno-unused-matches -Wno-unused-local-binds #-} - module GHC.Iface.Ext.Ast ( mkHieFile, mkHieFileWithSource, getCompressedAsts, enrichHie) where import GHC.Utils.Outputable(ppr) @@ -514,32 +510,12 @@ This case in handled in the instance for HsPatSigType -} class HasLoc a where - -- ^ defined so that HsImplicitBndrs and HsWildCardBndrs can - -- know what their implicit bindings are scoping over - -- TODO RGS: Remove the HsImplicitBndrs reference above + -- ^ conveniently calculate locations for things without locations attached loc :: a -> SrcSpan -instance HasLoc thing => HasLoc (TScoped thing) where - loc (TS _ a) = loc a - instance HasLoc thing => HasLoc (PScoped thing) where loc (PS _ _ _ a) = loc a -instance HasLoc (LHsQTyVars GhcRn) where - loc (HsQTvs _ vs) = loc vs - -{- -TODO RGS: Delete this once we've learned what we can from this code - -instance HasLoc thing => HasLoc (HsImplicitBndrs a thing) where - loc (HsIB _ a) = loc a - loc _ = noSrcSpan --} - -instance HasLoc thing => HasLoc (HsWildCardBndrs a thing) where - loc (HsWC _ a) = loc a - loc _ = noSrcSpan - instance HasLoc (Located a) where loc (L l _) = l @@ -553,6 +529,7 @@ instance HasLoc a => HasLoc (FamEqn (GhcPass s) a) where foldl1' combineSrcSpans [loc a, loc b, loc c] HsOuterExplicit{hso_bndrs = tvs} -> foldl1' combineSrcSpans [loc a, loc tvs, loc b, loc c] + instance (HasLoc tm, HasLoc ty) => HasLoc (HsArg tm ty) where loc (HsValArg tm) = loc tm loc (HsTypeArg _ ty) = loc ty @@ -798,8 +775,7 @@ class ( IsPass p , ToHie (RFContext (Located (AmbiguousFieldOcc (GhcPass p)))) , ToHie (RFContext (Located (FieldOcc (GhcPass p)))) , ToHie (TScoped (LHsWcType (GhcPass (NoGhcTcPass p)))) - -- TODO RGS: Should I replace this with something? - -- , ToHie (TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))) + , ToHie (TScoped (LHsSigWcType (GhcPass (NoGhcTcPass p)))) , HasRealDataConName (GhcPass p) ) => HiePass p where @@ -1141,8 +1117,7 @@ instance HiePass p => ToHie (Located (HsExpr (GhcPass p))) where ] ExprWithTySig _ expr sig -> [ toHie expr - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ TS (ResolvedScopes [mkLScope expr]) sig + , toHie $ TS (ResolvedScopes [mkLScope expr]) sig ] ArithSeq _ _ info -> [ toHie info @@ -1485,10 +1460,7 @@ instance (ToHie rhs, HasLoc rhs) => ToHie (FamEqn GhcRn rhs) where toHie fe@(FamEqn _ var outer_bndrs pats _ rhs) = concatM $ [ toHie $ C (Decl InstDec $ getRealSpan $ loc fe) var - {- - TODO RGS: Figure out how to do this correctly - , toHie $ fmap (tvScopes (ResolvedScopes []) scope) tybndrs - -} + , toHie $ TVS (ResolvedScopes []) scope outer_bndrs , toHie pats , toHie rhs ] @@ -1526,19 +1498,15 @@ instance ToHie (Located (HsDerivingClause GhcRn)) where instance ToHie (Located (DerivClauseTys GhcRn)) where toHie (L span dct) = concatM $ makeNode dct span : case dct of - -- TODO RGS: Figure out how to do this properly - DctSingle _ ty -> [] -- [ toHie $ TS (ResolvedScopes[]) ty ] - DctMulti _ tys -> [] -- [ toHie $ map (TS (ResolvedScopes [])) tys ] + DctSingle _ ty -> [ toHie $ TS (ResolvedScopes []) ty ] + DctMulti _ tys -> [ toHie $ map (TS (ResolvedScopes [])) tys ] instance ToHie (Located (DerivStrategy GhcRn)) where toHie (L span strat) = concatM $ makeNode strat span : case strat of StockStrategy -> [] AnyclassStrategy -> [] NewtypeStrategy -> [] - ViaStrategy s -> [ {- - TODO RGS: Figure out how to do this properly - - toHie $ TS (ResolvedScopes []) s -} ] + ViaStrategy s -> [ toHie (TS (ResolvedScopes []) s) ] instance ToHie (Located OverlapMode) where toHie (L span _) = locOnly span @@ -1591,25 +1559,17 @@ instance ToHie (Located [Located (ConDeclField GhcRn)]) where , toHie decls ] -{- -TODO RGS: Delete this once we've learned what we can from this code - -instance ( HasLoc thing - , ToHie (TScoped thing) - ) => ToHie (TScoped (HsImplicitBndrs GhcRn thing)) where - toHie (TS sc (HsIB ibrn a)) = concatM $ - [ bindingsOnly $ map (C $ TyVarBind (mkScope span) sc) ibrn +instance ToHie (TScoped (HsWildCardBndrs GhcRn (Located (HsSigType GhcRn)))) where + toHie (TS sc (HsWC names a)) = concatM $ + [ bindingsOnly $ map (C $ TyVarBind (mkScope span) sc) names , toHie $ TS sc a ] where span = loc a --} -instance ( HasLoc thing - , ToHie (TScoped thing) - ) => ToHie (TScoped (HsWildCardBndrs GhcRn thing)) where +instance ToHie (TScoped (HsWildCardBndrs GhcRn (Located (HsType GhcRn)))) where toHie (TS sc (HsWC names a)) = concatM $ [ bindingsOnly $ map (C $ TyVarBind (mkScope span) sc) names - , toHie $ TS sc a + , toHie a ] where span = loc a @@ -1620,8 +1580,7 @@ instance ToHie (StandaloneKindSig GhcRn) where toHie sig = concatM $ case sig of StandaloneKindSig _ name typ -> [ toHie $ C TyDecl name - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ TS (ResolvedScopes []) typ + , toHie $ TS (ResolvedScopes []) typ ] instance HiePass p => ToHie (SigContext (Located (Sig (GhcPass p)))) where @@ -1631,20 +1590,17 @@ instance HiePass p => ToHie (SigContext (Located (Sig (GhcPass p)))) where HieRn -> concatM $ makeNode sig sp : case sig of TypeSig _ names typ -> [ toHie $ map (C TyDecl) names - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ TS (UnresolvedScope (map unLoc names) Nothing) typ + , toHie $ TS (UnresolvedScope (map unLoc names) Nothing) typ ] PatSynSig _ names typ -> [ toHie $ map (C TyDecl) names - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ TS (UnresolvedScope (map unLoc names) Nothing) typ + , toHie $ TS (UnresolvedScope (map unLoc names) Nothing) typ ] ClassOpSig _ _ names typ -> [ case styp of ClassSig -> toHie $ map (C $ ClassTyDecl $ getRealSpan sp) names _ -> toHie $ map (C $ TyDecl) names - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ TS (UnresolvedScope (map unLoc names) msp) typ + , toHie $ TS (UnresolvedScope (map unLoc names) msp) typ ] IdSig _ _ -> [] FixSig _ fsig -> @@ -1655,16 +1611,11 @@ instance HiePass p => ToHie (SigContext (Located (Sig (GhcPass p)))) where ] SpecSig _ name typs _ -> [ toHie $ (C Use) name - -- TODO RGS: Figure out how to do this correctly - -- , toHie $ map (TS (ResolvedScopes [])) typs + , toHie $ map (TS (ResolvedScopes [])) typs ] SpecInstSig _ _ typ -> - {- - -- TODO RGS: Figure out how to do this correctly [ toHie $ TS (ResolvedScopes []) typ ] - -} - [] MinimalSig _ _ form -> [ toHie form ] @@ -1678,18 +1629,26 @@ instance HiePass p => ToHie (SigContext (Located (Sig (GhcPass p)))) where , toHie $ fmap (C Use) typ ] -instance ToHie (Located (HsType GhcRn)) where - toHie x = toHie $ TS (ResolvedScopes []) x +instance ToHie (TScoped (Located (HsSigType GhcRn))) where + toHie (TS tsc (L span t at HsSig{sig_bndrs=bndrs,sig_body=body})) = concatM $ makeNode t span : + [ toHie (TVS tsc (mkScope span) bndrs) + , toHie body + ] + +instance Data flag => ToHie (TVScoped (HsOuterTyVarBndrs flag GhcRn)) where + toHie (TVS tsc sc bndrs) = case bndrs of + HsOuterImplicit xs -> bindingsOnly $ map (C $ TyVarBind sc tsc) xs + HsOuterExplicit _ xs -> toHie $ tvScopes tsc sc xs -instance ToHie (TScoped (Located (HsType GhcRn))) where - toHie (TS tsc (L span t)) = concatM $ makeNode t span : case t of +instance ToHie (Located (HsType GhcRn)) where + toHie (L span t) = concatM $ makeNode t span : case t of HsForAllTy _ tele body -> let scope = mkScope $ getLoc body in [ case tele of HsForAllVis { hsf_vis_bndrs = bndrs } -> - toHie $ tvScopes tsc scope bndrs + toHie $ tvScopes (ResolvedScopes []) scope bndrs HsForAllInvis { hsf_invis_bndrs = bndrs } -> - toHie $ tvScopes tsc scope bndrs + toHie $ tvScopes (ResolvedScopes []) scope bndrs , toHie body ] HsQualTy _ ctx body -> @@ -1705,7 +1664,7 @@ instance ToHie (TScoped (Located (HsType GhcRn))) where ] HsAppKindTy _ ty ki -> [ toHie ty - , toHie $ TS (ResolvedScopes []) ki + , toHie ki ] HsFunTy _ w a b -> [ toHie (arrowToHsType w) @@ -1888,11 +1847,8 @@ instance ToHie (Located (InstDecl GhcRn)) where instance ToHie (Located (ClsInstDecl GhcRn)) where toHie (L span decl) = concatM - [ {- - TODO RGS: Figure out what to do here - - toHie $ TS (ResolvedScopes [mkScope span]) $ cid_poly_ty decl - , -} toHie $ fmap (BC InstanceBind ModuleScope) $ cid_binds decl + [ toHie $ TS (ResolvedScopes [mkScope span]) $ cid_poly_ty decl + , toHie $ fmap (BC InstanceBind ModuleScope) $ cid_binds decl , toHie $ map (SC $ SI InstSig $ getRealSpan span) $ cid_sigs decl , concatMapM (locOnly . getLoc) $ cid_tyfam_insts decl , toHie $ cid_tyfam_insts decl @@ -1917,11 +1873,8 @@ instance ToHie (Context a) instance ToHie (Located (DerivDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of DerivDecl _ typ strat overlap -> - [ {- - TODO RGS: Figure out what to do here - - toHie $ TS (ResolvedScopes []) typ - , -} toHie strat + [ toHie $ TS (ResolvedScopes []) typ + , toHie strat , toHie overlap ] @@ -1941,18 +1894,12 @@ instance ToHie (Located (ForeignDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ForeignImport {fd_name = name, fd_sig_ty = sig, fd_fi = fi} -> [ toHie $ C (ValBind RegularBind ModuleScope $ getRealSpan span) name - {- - TODO RGS: Figure out how to do this properly , toHie $ TS (ResolvedScopes []) sig - -} , toHie fi ] ForeignExport {fd_name = name, fd_sig_ty = sig, fd_fe = fe} -> [ toHie $ C Use name - {- - TODO RGS: Figure out how to do this properly , toHie $ TS (ResolvedScopes []) sig - -} , toHie fe ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4ac4e6e36ea68cb86558a83599652423a9a69a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4ac4e6e36ea68cb86558a83599652423a9a69a0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 07:42:23 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 03:42:23 -0400 Subject: [Git][ghc/ghc][master] Unification of Nat and Naturals Message-ID: <5f86abdf80624_28003fd40994ded81642b5@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 29 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/type_literals.rst - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Event/PSQ.hs - libraries/base/GHC/Generics.hs - libraries/base/GHC/TypeLits.hs - libraries/base/GHC/TypeNats.hs - libraries/base/changelog.md - libraries/ghc-prim/GHC/Types.hs - testsuite/tests/ghci/scripts/T9181.stdout - testsuite/tests/indexed-types/should_compile/T13398b.hs - testsuite/tests/indexed-types/should_compile/T15322a.stderr - testsuite/tests/th/T15360b.stderr - + testsuite/tests/typecheck/should_compile/T10776.hs - testsuite/tests/typecheck/should_fail/T15799.stderr - testsuite/tests/typecheck/should_fail/UnliftedNewtypesFamilyKindFail1.stderr - testsuite/tests/typecheck/should_fail/UnliftedNewtypesFamilyKindFail2.stderr - testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout - testsuite/tests/typecheck/should_run/TypeOf.stdout - testsuite/tests/typecheck/should_run/TypeRep.stdout - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1872,7 +1872,7 @@ uIntTyConKey = mkPreludeTyConUnique 162 uWordTyConKey = mkPreludeTyConUnique 163 -- Type-level naturals -typeNatKindConNameKey, typeSymbolKindConNameKey, +typeSymbolKindConNameKey, typeNatAddTyFamNameKey, typeNatMulTyFamNameKey, typeNatExpTyFamNameKey, typeNatLeqTyFamNameKey, typeNatSubTyFamNameKey , typeSymbolCmpTyFamNameKey, typeNatCmpTyFamNameKey @@ -1880,7 +1880,6 @@ typeNatKindConNameKey, typeSymbolKindConNameKey, , typeNatModTyFamNameKey , typeNatLogTyFamNameKey :: Unique -typeNatKindConNameKey = mkPreludeTyConUnique 164 typeSymbolKindConNameKey = mkPreludeTyConUnique 165 typeNatAddTyFamNameKey = mkPreludeTyConUnique 166 typeNatMulTyFamNameKey = mkPreludeTyConUnique 167 ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -96,7 +96,7 @@ module GHC.Builtin.Types ( mkSumTy, sumTyCon, sumDataCon, -- * Kinds - typeNatKindCon, typeNatKind, typeSymbolKindCon, typeSymbolKind, + typeSymbolKindCon, typeSymbolKind, isLiftedTypeKindTyConName, liftedTypeKind, typeToTypeKind, constraintKind, liftedTypeKindTyCon, constraintKindTyCon, constraintKindTyConName, @@ -256,7 +256,6 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because they , heqTyCon , eqTyCon , coercibleTyCon - , typeNatKindCon , typeSymbolKindCon , runtimeRepTyCon , vecCountTyCon @@ -477,8 +476,7 @@ makeRecoveryTyCon tc -- at (promoted) use-sites of MkT. -- Kinds -typeNatKindConName, typeSymbolKindConName :: Name -typeNatKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Nat") typeNatKindConNameKey typeNatKindCon +typeSymbolKindConName :: Name typeSymbolKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Symbol") typeSymbolKindConNameKey typeSymbolKindCon constraintKindTyConName :: Name @@ -679,14 +677,11 @@ pcSpecialDataCon dc_name arg_tys tycon rri ************************************************************************ -} -typeNatKindCon, typeSymbolKindCon :: TyCon --- data Nat +typeSymbolKindCon :: TyCon -- data Symbol -typeNatKindCon = pcTyCon typeNatKindConName Nothing [] [] typeSymbolKindCon = pcTyCon typeSymbolKindConName Nothing [] [] -typeNatKind, typeSymbolKind :: Kind -typeNatKind = mkTyConTy typeNatKindCon +typeSymbolKind :: Kind typeSymbolKind = mkTyConTy typeSymbolKindCon constraintKindTyCon :: TyCon ===================================== compiler/GHC/Builtin/Types.hs-boot ===================================== @@ -8,7 +8,7 @@ import GHC.Types.Basic (Arity, TupleSort, Boxity, ConTag) import {-# SOURCE #-} GHC.Types.Name (Name) listTyCon :: TyCon -typeNatKind, typeSymbolKind :: Type +typeSymbolKind :: Type mkBoxedTupleTy :: [Type] -> Type coercibleTyCon, heqTyCon :: TyCon ===================================== compiler/GHC/Builtin/Types/Literals.hs ===================================== @@ -236,7 +236,7 @@ typeNatLogTyCon = mkTypeNatFunTyCon1 name typeNatLeqTyCon :: TyCon typeNatLeqTyCon = mkFamilyTyCon name - (mkTemplateAnonTyConBinders [ typeNatKind, typeNatKind ]) + (mkTemplateAnonTyConBinders [ naturalTy, naturalTy ]) boolTy Nothing (BuiltInSynFamTyCon ops) @@ -255,7 +255,7 @@ typeNatLeqTyCon = typeNatCmpTyCon :: TyCon typeNatCmpTyCon = mkFamilyTyCon name - (mkTemplateAnonTyConBinders [ typeNatKind, typeNatKind ]) + (mkTemplateAnonTyConBinders [ naturalTy, naturalTy ]) orderingKind Nothing (BuiltInSynFamTyCon ops) @@ -301,14 +301,12 @@ typeSymbolAppendTyCon = mkTypeSymbolFunTyCon2 name name = mkWiredInTyConName UserSyntax gHC_TYPELITS (fsLit "AppendSymbol") typeSymbolAppendFamNameKey typeSymbolAppendTyCon - - -- Make a unary built-in constructor of kind: Nat -> Nat mkTypeNatFunTyCon1 :: Name -> BuiltInSynFamily -> TyCon mkTypeNatFunTyCon1 op tcb = mkFamilyTyCon op - (mkTemplateAnonTyConBinders [ typeNatKind ]) - typeNatKind + (mkTemplateAnonTyConBinders [ naturalTy ]) + naturalTy Nothing (BuiltInSynFamTyCon tcb) Nothing @@ -319,8 +317,8 @@ mkTypeNatFunTyCon1 op tcb = mkTypeNatFunTyCon2 :: Name -> BuiltInSynFamily -> TyCon mkTypeNatFunTyCon2 op tcb = mkFamilyTyCon op - (mkTemplateAnonTyConBinders [ typeNatKind, typeNatKind ]) - typeNatKind + (mkTemplateAnonTyConBinders [ naturalTy, naturalTy ]) + naturalTy Nothing (BuiltInSynFamTyCon tcb) Nothing ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -253,7 +253,7 @@ import GHC.Types.Unique.Set import GHC.Core.TyCon import GHC.Builtin.Types.Prim import {-# SOURCE #-} GHC.Builtin.Types - ( listTyCon, typeNatKind + ( naturalTy, listTyCon , typeSymbolKind, liftedTypeKind , constraintKind , unrestrictedFunTyCon @@ -2599,7 +2599,7 @@ tcReturnsConstraintKind _ = False -------------------------- typeLiteralKind :: TyLit -> Kind -typeLiteralKind (NumTyLit {}) = typeNatKind +typeLiteralKind (NumTyLit {}) = naturalTy typeLiteralKind (StrTyLit {}) = typeSymbolKind -- | Returns True if a type is levity polymorphic. Should be the same ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Tc.Utils.TcType import GHC.Core.Type import GHC.Core.Coercion import GHC.Core.Multiplicity -import GHC.Builtin.Types ( typeNatKind, typeSymbolKind ) +import GHC.Builtin.Types ( naturalTy, typeSymbolKind ) import GHC.Types.Id import GHC.Types.Id.Make(proxyHashId) import GHC.Types.Name @@ -1306,7 +1306,7 @@ ds_ev_typeable ty (EvTypeableTyLit ev) -- tr_fun is the Name of -- typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a - tr_fun | ty_kind `eqType` typeNatKind = typeNatTypeRepName + tr_fun | ty_kind `eqType` naturalTy = typeNatTypeRepName | ty_kind `eqType` typeSymbolKind = typeSymbolTypeRepName | otherwise = panic "dsEvTypeable: unknown type lit kind" ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1192,8 +1192,8 @@ tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind --------- Literals tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind - = do { checkWiredInTyCon typeNatKindCon - ; checkExpectedKind rn_ty (mkNumLitTy n) typeNatKind exp_kind } + = do { checkWiredInTyCon naturalTyCon + ; checkExpectedKind rn_ty (mkNumLitTy n) naturalTy exp_kind } tc_hs_type _ rn_ty@(HsTyLit _ (HsStrTy _ s)) exp_kind = do { checkWiredInTyCon typeSymbolKindCon ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -418,7 +418,7 @@ matchTypeable clas [k,t] -- clas = Typeable | isJust (tcSplitPredFunTy_maybe t) = return NoInstance -- Qualified type -- Now cases that do work - | k `eqType` typeNatKind = doTyLit knownNatClassName t + | k `eqType` naturalTy = doTyLit knownNatClassName t | k `eqType` typeSymbolKind = doTyLit knownSymbolClassName t | tcIsConstraintKind t = doTyConApp clas t constraintKindTyCon [] | Just (mult,arg,ret) <- splitFunTy_maybe t = doFunTy clas t mult arg ret ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -28,8 +28,24 @@ Compiler since the argument was already forced in the first equation. For more details see :ghc-flag:`-Wredundant-bang-patterns`. +- Type checker plugins which work with the natural numbers now + should use ``naturalTy`` kind instead of ``typeNatKind``, which has been removed. + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. + +``base`` library +~~~~~~~~~~~~~~~~ + +- It's possible now to promote the ``Natural`` type: :: + + data Coordinate = Mk2D Natural Natural + type MyCoordinate = Mk2D 1 10 + + The separate kind ``Nat`` is removed and now it is just a type synonym for + ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` + in order to define instances for ``Nat``. + ===================================== docs/users_guide/exts/type_literals.rst ===================================== @@ -5,7 +5,7 @@ Type-Level Literals GHC supports numeric and string literals at the type level, giving convenient access to a large number of predefined type-level constants. -Numeric literals are of kind ``Nat``, while string literals are of kind +Numeric literals are of kind ``Natural``, while string literals are of kind ``Symbol``. This feature is enabled by the :extension:`DataKinds` language extension. @@ -23,11 +23,17 @@ safe interface to a low-level function: :: import Data.Word import Foreign - newtype ArrPtr (n :: Nat) a = ArrPtr (Ptr a) + newtype ArrPtr (n :: Natural) a = ArrPtr (Ptr a) clearPage :: ArrPtr 4096 Word8 -> IO () clearPage (ArrPtr p) = ... +Also type-level naturals could be promoted from the ``Natural`` data type +using `DataKinds`, for example: :: + + data Point = MkPoint Natural Natural + type MyCoordinates = MkPoint 95 101 + Here is an example of using type-level string literals to simulate simple record operations: :: ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -91,7 +91,7 @@ import GHC.List ( splitAt, foldl', elem ) import GHC.Word import GHC.Show import GHC.TypeLits ( KnownSymbol, symbolVal', AppendSymbol ) -import GHC.TypeNats ( KnownNat, natVal' ) +import GHC.TypeNats ( KnownNat, Nat, natVal' ) import Unsafe.Coerce ( unsafeCoerce ) import GHC.Fingerprint.Type ===================================== libraries/base/GHC/Event/PSQ.hs ===================================== @@ -40,7 +40,7 @@ module GHC.Event.PSQ , atMost ) where -import GHC.Base hiding (Nat, empty) +import GHC.Base hiding (empty) import GHC.Event.Unique import GHC.Word (Word64) import GHC.Num (Num(..)) ===================================== libraries/base/GHC/Generics.hs ===================================== @@ -748,7 +748,7 @@ import GHC.Fingerprint.Type ( Fingerprint(..) ) -- Needed for metadata import Data.Proxy ( Proxy(..) ) -import GHC.TypeLits ( KnownSymbol, KnownNat, symbolVal, natVal ) +import GHC.TypeLits ( KnownSymbol, KnownNat, Nat, symbolVal, natVal ) -------------------------------------------------------------------------------- -- Representation types ===================================== libraries/base/GHC/TypeLits.hs ===================================== @@ -31,7 +31,7 @@ working with type-level data will be defined in a separate library. module GHC.TypeLits ( -- * Kinds - Nat, Symbol -- Both declared in GHC.Types in package ghc-prim + Natural, Nat, Symbol -- Symbol is declared in GHC.Types in package ghc-prim -- * Linking type and value level , N.KnownNat, natVal, natVal' @@ -54,7 +54,7 @@ module GHC.TypeLits ) where import GHC.Base(Eq(..), Ord(..), Ordering(..), String, otherwise) -import GHC.Types( Nat, Symbol ) +import GHC.Types(Symbol) import GHC.Num(Integer, fromInteger) import GHC.Show(Show(..)) import GHC.Read(Read(..)) @@ -65,7 +65,7 @@ import Data.Proxy (Proxy(..)) import Data.Type.Equality((:~:)(Refl)) import Unsafe.Coerce(unsafeCoerce) -import GHC.TypeNats (KnownNat) +import GHC.TypeNats (Natural, Nat, KnownNat) import qualified GHC.TypeNats as N -------------------------------------------------------------------------------- ===================================== libraries/base/GHC/TypeNats.hs ===================================== @@ -22,8 +22,8 @@ for working with type-level naturals should be defined in a separate library. module GHC.TypeNats ( -- * Nat Kind - Nat -- declared in GHC.Types in package ghc-prim - + Natural -- declared in GHC.Num.Natural in package ghc-bignum + , Nat -- * Linking type and value level , KnownNat, natVal, natVal' , SomeNat(..) @@ -37,8 +37,8 @@ module GHC.TypeNats ) where -import GHC.Base(Eq(..), Ord(..), Bool(True), Ordering(..), otherwise) -import GHC.Types( Nat ) +import GHC.Base(Eq(..), Ord(..), otherwise) +import GHC.Types import GHC.Num.Natural(Natural) import GHC.Show(Show(..)) import GHC.Read(Read(..)) @@ -48,6 +48,13 @@ import Data.Proxy (Proxy(..)) import Data.Type.Equality((:~:)(Refl)) import Unsafe.Coerce(unsafeCoerce) + +-- | A type synonym for 'Natural'. +-- +-- Prevously, this was an opaque data type, but it was changed to a type synonym +-- @since @base-4.15.0.0 at . + +type Nat = Natural -------------------------------------------------------------------------------- -- | This class gives the integer associated with a type-level natural. ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.16.0.0 *TBA* + + * Make it possible to promote `Natural`s and remove the separate `Nat` kind. + For backwards compatibility, `Nat` is now a type synonym for `Natural`. + As a consequence, one must enable `TypeSynonymInstances` + in order to define instances for `Nat`. Also, different instances for `Nat` and `Natural` + won't typecheck anymore. + ## 4.15.0.0 *TBA* * `openFile` now calls the `open` system call with an `interruptible` FFI @@ -35,7 +43,7 @@ * `catMaybes` is now implemented using `mapMaybe`, so that it is both a "good consumer" and "good producer" for list-fusion (#18574) - + ## 4.14.0.0 *TBA* * Bundled with GHC 8.10.1 ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -30,7 +30,7 @@ module GHC.Types ( Ordering(..), IO(..), isTrue#, SPEC(..), - Nat, Symbol, + Symbol, Any, type (~~), Coercible, TYPE, RuntimeRep(..), Type, Constraint, @@ -98,13 +98,10 @@ type family MultMul (a :: Multiplicity) (b :: Multiplicity) :: Multiplicity wher {- ********************************************************************* * * - Nat and Symbol + Symbol * * ********************************************************************* -} --- | (Kind) This is the kind of type-level natural numbers. -data Nat - -- | (Kind) This is the kind of type-level symbols. -- Declared here because class IP needs it data Symbol ===================================== testsuite/tests/ghci/scripts/T9181.stdout ===================================== @@ -39,47 +39,53 @@ GHC.TypeLits.symbolVal :: GHC.TypeLits.KnownSymbol n => proxy n -> String GHC.TypeLits.symbolVal' :: GHC.TypeLits.KnownSymbol n => GHC.Prim.Proxy# n -> String -type (GHC.TypeNats.*) :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type (GHC.TypeNats.*) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family (GHC.TypeNats.*) a b -type (GHC.TypeNats.+) :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type (GHC.TypeNats.+) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family (GHC.TypeNats.+) a b -type (GHC.TypeNats.-) :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type (GHC.TypeNats.-) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family (GHC.TypeNats.-) a b -type (GHC.TypeNats.<=) :: GHC.Types.Nat - -> GHC.Types.Nat -> Constraint +type (GHC.TypeNats.<=) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> Constraint type (GHC.TypeNats.<=) x y = (x GHC.TypeNats.<=? y) ~ 'True :: Constraint -type (GHC.TypeNats.<=?) :: GHC.Types.Nat -> GHC.Types.Nat -> Bool +type (GHC.TypeNats.<=?) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> Bool type family (GHC.TypeNats.<=?) a b -type GHC.TypeNats.CmpNat :: GHC.Types.Nat - -> GHC.Types.Nat -> Ordering +type GHC.TypeNats.CmpNat :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> Ordering type family GHC.TypeNats.CmpNat a b -type GHC.TypeNats.Div :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type GHC.TypeNats.Div :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family GHC.TypeNats.Div a b -type GHC.TypeNats.KnownNat :: GHC.Types.Nat -> Constraint +type GHC.TypeNats.KnownNat :: GHC.TypeNats.Nat -> Constraint class GHC.TypeNats.KnownNat n where GHC.TypeNats.natSing :: GHC.TypeNats.SNat n {-# MINIMAL natSing #-} -type GHC.TypeNats.Log2 :: GHC.Types.Nat -> GHC.Types.Nat +type GHC.TypeNats.Log2 :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural type family GHC.TypeNats.Log2 a -type GHC.TypeNats.Mod :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type GHC.TypeNats.Mod :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family GHC.TypeNats.Mod a b -type GHC.Types.Nat :: * -data GHC.Types.Nat +type GHC.TypeNats.Nat :: * +type GHC.TypeNats.Nat = GHC.Num.Natural.Natural +type GHC.Num.Natural.Natural :: * +data GHC.Num.Natural.Natural + = GHC.Num.Natural.NS GHC.Prim.Word# + | GHC.Num.Natural.NB GHC.Prim.ByteArray# type GHC.TypeNats.SomeNat :: * data GHC.TypeNats.SomeNat - = forall (n :: GHC.Types.Nat). + = forall (n :: GHC.TypeNats.Nat). GHC.TypeNats.KnownNat n => GHC.TypeNats.SomeNat (Data.Proxy.Proxy n) type GHC.Types.Symbol :: * data GHC.Types.Symbol -type (GHC.TypeNats.^) :: GHC.Types.Nat - -> GHC.Types.Nat -> GHC.Types.Nat +type (GHC.TypeNats.^) :: GHC.Num.Natural.Natural + -> GHC.Num.Natural.Natural -> GHC.Num.Natural.Natural type family (GHC.TypeNats.^) a b GHC.TypeNats.sameNat :: (GHC.TypeNats.KnownNat a, GHC.TypeNats.KnownNat b) => ===================================== testsuite/tests/indexed-types/should_compile/T13398b.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DataKinds, PolyKinds #-} +{-# LANGUAGE TypeSynonymInstances #-} module T13398b where import GHC.TypeLits ===================================== testsuite/tests/indexed-types/should_compile/T15322a.stderr ===================================== @@ -4,7 +4,7 @@ T15322a.hs:12:7: error: arising from a use of ‘typeRep’ from the context: KnownNat n bound by the type signature for: - f :: forall (n :: GHC.Types.Nat). + f :: forall (n :: GHC.TypeNats.Nat). KnownNat n => Proxy n -> TypeRep (n + 1) at T15322a.hs:11:1-56 ===================================== testsuite/tests/th/T15360b.stderr ===================================== @@ -5,7 +5,7 @@ T15360b.hs:10:13: error: In the type signature: x :: Proxy (Type Double) T15360b.hs:13:13: error: - • Expected kind ‘* -> k2’, but ‘1’ has kind ‘GHC.Types.Nat’ + • Expected kind ‘* -> k2’, but ‘1’ has kind ‘GHC.Num.Natural.Natural’ • In the first argument of ‘Proxy’, namely ‘(1 Int)’ In the type signature: y :: Proxy (1 Int) ===================================== testsuite/tests/typecheck/should_compile/T10776.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE TypeFamilies, DataKinds, KindSignatures, TypeOperators #-} + +module T10776 where + +import GHC.TypeLits (Nat, Natural, Symbol, KnownNat) +import Data.Type.Equality ((:~:)(..)) +import Data.Proxy + +nat_is_natural :: Nat :~: Natural +nat_is_natural = Refl + +data NatPair = TN Natural Natural + +type X = TN 1 101 + +type family SecondNat (a :: NatPair) :: Nat where + SecondNat ('TN _ a) = a ===================================== testsuite/tests/typecheck/should_fail/T15799.stderr ===================================== @@ -1,4 +1,5 @@ T15799.hs:46:62: error: + Couldn't match kind ‘TypeLits.Natural’ with ‘Op Nat’ • Expected kind ‘Op Nat’, but ‘UnOp b’ has kind ‘Nat’ • In the first argument of ‘(<=)’, namely ‘UnOp b’ ===================================== testsuite/tests/typecheck/should_fail/UnliftedNewtypesFamilyKindFail1.stderr ===================================== @@ -1,5 +1,5 @@ UnliftedNewtypesFamilyKindFail1.hs:11:31: error: - • Expected a type, but ‘5’ has kind ‘GHC.Types.Nat’ + • Expected a type, but ‘5’ has kind ‘GHC.Num.Natural.Natural’ • In the kind ‘5’ In the data family declaration for ‘DF’ ===================================== testsuite/tests/typecheck/should_fail/UnliftedNewtypesFamilyKindFail2.stderr ===================================== @@ -1,10 +1,10 @@ UnliftedNewtypesFamilyKindFail2.hs:12:20: - Expected a type, but ‘5’ has kind ‘GHC.Types.Nat’ + Expected a type, but ‘5’ has kind ‘GHC.Num.Natural.Natural’ In the first argument of ‘F’, namely ‘5’ In the newtype instance declaration for ‘F’ UnliftedNewtypesFamilyKindFail2.hs:12:31: - Expected a type, but ‘5’ has kind ‘GHC.Types.Nat’ + Expected a type, but ‘5’ has kind ‘GHC.Num.Natural.Natural’ In the first argument of ‘F’, namely ‘5’ In the type ‘(F 5)’ In the definition of data constructor ‘MkF’ ===================================== testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout ===================================== @@ -12,4 +12,4 @@ good: * good: Int -> Int good: 5 good: "hello world" -good: 'Just Nat 5 +good: 'Just Natural 5 ===================================== testsuite/tests/typecheck/should_run/TypeOf.stdout ===================================== @@ -12,13 +12,13 @@ Int -> Int Proxy Constraint (Eq Int) Proxy * (Int,Int) Proxy Symbol "hello world" -Proxy Nat 1 -Proxy [Nat] (': Nat 1 (': Nat 2 (': Nat 3 ('[] Nat)))) +Proxy Natural 1 +Proxy [Natural] (': Natural 1 (': Natural 2 (': Natural 3 ('[] Natural)))) Proxy Ordering 'EQ Proxy (RuntimeRep -> *) TYPE Proxy * * Proxy * * Proxy * * Proxy RuntimeRep 'LiftedRep -Proxy (Nat,Symbol) ('(,) Nat Symbol 1 "hello") +Proxy (Natural,Symbol) ('(,) Natural Symbol 1 "hello") Proxy (* -> * -> Constraint) ((~~) * *) ===================================== testsuite/tests/typecheck/should_run/TypeRep.stdout ===================================== @@ -17,8 +17,8 @@ Int# Proxy Constraint (Eq Int) Proxy * (Int,Int) Proxy Symbol "hello world" -Proxy Nat 1 -Proxy [Nat] (': Nat 1 (': Nat 2 (': Nat 3 ('[] Nat)))) +Proxy Natural 1 +Proxy [Natural] (': Natural 1 (': Natural 2 (': Natural 3 ('[] Natural)))) Proxy Ordering 'EQ Proxy (RuntimeRep -> *) TYPE Proxy * * ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 6f16399e0320d0ef5e6c3dd0329ce7ed3715b6b2 +Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f4f5794eb3504bf2ca093dc5895742395fdbde9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f4f5794eb3504bf2ca093dc5895742395fdbde9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 07:42:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 03:42:56 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: Verify that Hadrian builds with Stack Message-ID: <5f86ac00513e7_28003fd388ee4f58165029@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 3 changed files: - .gitlab-ci.yml - hadrian/build-stack - hadrian/build-stack.bat Changes: ===================================== .gitlab-ci.yml ===================================== @@ -233,6 +233,17 @@ lint-release-changelogs: tags: - x86_64-linux +# Verify that Hadrian builds with stack. Note that we don't actually perform a +# build of GHC itself; we merely test that the Hadrian executable builds and +# works (by invoking `hadrian --version`). +stack-hadrian-build: + extends: .validate-linux-hadrian + stage: build + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - hadrian/build-stack --version + validate-x86_64-linux-deb9-hadrian: extends: .validate-linux-hadrian needs: [hadrian-ghc-in-ghci] ===================================== hadrian/build-stack ===================================== @@ -3,11 +3,13 @@ # Make sure that the script exits if Hadrian fails to build set -euo pipefail +STACK="${STACK:-stack}" + # Make sure Hadrian is up-to-date cd hadrian -stack build --no-library-profiling ${HADRIAN_NIX:+--nix} +$STACK build --no-library-profiling ${HADRIAN_NIX:+--nix} # Run Hadrian in the top-level GHC directory -stack exec hadrian -- \ +$STACK exec hadrian -- \ --directory ".." \ "$@" ===================================== hadrian/build-stack.bat ===================================== @@ -3,5 +3,9 @@ setlocal rem Change the current directory to the one containing this script cd %~dp0 +if "%STACK%"=="" ( + set STACK=stack +) + rem Build and run Hadrian in GHC top directory forwarding additional user arguments -stack run hadrian --cwd=.. -- %* +%STACK% run hadrian --cwd=.. -- %* View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fc1cb54d1afc0f002deb4d080c9b824f423b647 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fc1cb54d1afc0f002deb4d080c9b824f423b647 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 08:13:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 04:13:56 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: gitlab-ci: Verify that Hadrian builds with Stack Message-ID: <5f86b344ab088_28003fd3e86d0370174255@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 39a725fe by Ben Gamari at 2020-10-14T04:13:39-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 606822ab by Ryan Scott at 2020-10-14T04:13:42-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - 56dd839b by Vladislav Zavialov at 2020-10-14T04:13:43-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - 6070787f by Vladislav Zavialov at 2020-10-14T04:13:43-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - 15 changed files: - .gitlab-ci.yml - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Rename/HsType.hs - configure.ac - docs/users_guide/bugs.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/poly_kinds.rst - hadrian/build-stack - hadrian/build-stack.bat - + testsuite/tests/deSugar/should_run/T18151x.hs - + testsuite/tests/deSugar/should_run/T18151x.stdout - testsuite/tests/deSugar/should_run/all.T - testsuite/tests/th/T17688b.hs - + testsuite/tests/typecheck/should_compile/T18831.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -233,6 +233,17 @@ lint-release-changelogs: tags: - x86_64-linux +# Verify that Hadrian builds with stack. Note that we don't actually perform a +# build of GHC itself; we merely test that the Hadrian executable builds and +# works (by invoking `hadrian --version`). +stack-hadrian-build: + extends: .validate-linux-hadrian + stage: build + script: + - .gitlab/ci.sh setup + - .gitlab/ci.sh configure + - hadrian/build-stack --version + validate-x86_64-linux-deb9-hadrian: extends: .validate-linux-hadrian needs: [hadrian-ghc-in-ghci] @@ -827,6 +838,9 @@ validate-x86_64-linux-fedora27: stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: + # LLVM 10 is not available for Fedora27 + LLC: /bin/false + OPT: /bin/false TEST_ENV: "x86_64-linux-fedora27" BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -70,6 +70,8 @@ import GHC.Utils.Panic import GHC.Core.PatSyn import Control.Monad +import qualified GHC.LanguageExtensions as LangExt + {- ************************************************************************ * * @@ -347,7 +349,11 @@ converting to core it must become a CO. Note [Desugaring operator sections] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -At first it looks as if we can convert +Desugaring left sections with -XPostfixOperators is straightforward: convert +(expr `op`) to (op expr). + +Without -XPostfixOperators it's a bit more tricky. At first it looks as if we +can convert (expr `op`) @@ -398,6 +404,13 @@ dsExpr e@(OpApp _ e1 op e2) -- See Note [Desugaring operator sections]. -- N.B. this also must handle postfix operator sections due to -XPostfixOperators. dsExpr e@(SectionL _ expr op) = do + postfix_operators <- xoptM LangExt.PostfixOperators + if postfix_operators then + -- Desugar (e !) to ((!) e) + do { op' <- dsLExpr op + ; dsWhenNoErrs (dsLExprNoLP expr) $ \expr' -> + mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr' } + else do core_op <- dsLExpr op x_core <- dsLExpr expr case splitFunTys (exprType core_op) of ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -441,9 +441,9 @@ sites. This is less precise, but more accurate. rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. -Note [QualTy in kinds] +Note [HsQualTy in kinds] ~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether QualTy could occur only at TypeLevel. But no, +I was wondering whether HsQualTy could occur only at TypeLevel. But no, we can have a qualified type in a kind too. Here is an example: type family F a where @@ -466,9 +466,9 @@ suitable message: Expected kind: G Bool Actual kind: F Bool -However: in a kind, the constraints in the QualTy must all be +However: in a kind, the constraints in the HsQualTy must all be equalities; or at least, any kinds with a class constraint are -uninhabited. +uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -574,7 +574,9 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , fvs) } } rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { checkPolyKinds env ty -- See Note [QualTy in kinds] + = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] + ; when (not data_kinds && isRnKindLevel env) + (addErr (dataKindsErr env ty)) ; (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' @@ -636,9 +638,8 @@ rnHsTyKi env listTy@(HsListTy _ ty) ; (ty', fvs) <- rnLHsTyKi env ty ; return (HsListTy noExtField ty', fvs) } -rnHsTyKi env t@(HsKindSig _ ty k) - = do { checkPolyKinds env t - ; kind_sigs_ok <- xoptM LangExt.KindSignatures +rnHsTyKi env (HsKindSig _ ty k) + = do { kind_sigs_ok <- xoptM LangExt.KindSignatures ; unless kind_sigs_ok (badKindSigErr (rtke_ctxt env) ty) ; (ty', lhs_fvs) <- rnLHsTyKi env ty ; (k', sig_fvs) <- rnLHsTyKi (env { rtke_level = KindLevel }) k @@ -665,7 +666,6 @@ rnHsTyKi env tyLit@(HsTyLit _ t) = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env tyLit)) ; when (negLit t) (addErr negLitErr) - ; checkPolyKinds env tyLit ; return (HsTyLit noExtField t, emptyFVs) } where negLit (HsStrTy _ _) = False @@ -705,15 +705,13 @@ rnHsTyKi _ (XHsType (NHsCoreTy ty)) -- but I don't think it matters rnHsTyKi env ty@(HsExplicitListTy _ ip tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitListTy noExtField ip tys', fvs) } rnHsTyKi env ty@(HsExplicitTupleTy _ tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitTupleTy noExtField tys', fvs) } ===================================== configure.ac ===================================== @@ -715,7 +715,7 @@ AC_SUBST(InstallNameToolCmd) # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around # 3.5/3.6 release of LLVM. -LlvmVersion=9 +LlvmVersion=10 AC_SUBST([LlvmVersion]) sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/') AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number]) ===================================== docs/users_guide/bugs.rst ===================================== @@ -438,31 +438,6 @@ The Foreign Function Interface single: hs_init single: hs_exit -.. _infelicities-operator-sections: - -Operator sections -^^^^^^^^^^^^^^^^^ - -The Haskell Report demands that, for infix operators ``%``, the following -identities hold: - -:: - - (% expr) = \x -> x % expr - (expr %) = \x -> expr % x - -However, the second law is violated in the presence of undefined operators, - -:: - - (%) = error "urk" - (() %) `seq` () -- urk - (\x -> () % x) `seq` () -- OK, result () - -The operator section is treated like function application of an undefined -function, while the lambda form is in WHNF that contains an application of an -undefined function. - .. _haskell-98-2010-undefined: GHC's interpretation of undefined behaviour in Haskell 98 and Haskell 2010 ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -134,6 +134,12 @@ promotion quote and the data constructor: :: type S = 'A' -- ERROR: looks like a character type R = ' A' -- OK: promoted `A'` +Type-level literals +------------------- + +:extension:`DataKinds` enables the use of numeric and string literals at the +type level. For more information, see :ref:`type-level-literals`. + .. _promoted-lists-and-tuples: Promoted list and tuple types @@ -207,4 +213,27 @@ above code is valid. See also :ghc-ticket:`7347`. +.. _constraints_in_kinds: + +Constraints in kinds +-------------------- + +Kinds can (with :extension:`DataKinds`) contain type constraints. However, +only equality constraints are supported. + +Here is an example of a constrained kind: :: + + type family IsTypeLit a where + IsTypeLit Nat = 'True + IsTypeLit Symbol = 'True + IsTypeLit a = 'False + + data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where + MkNat :: T 42 + MkSymbol :: T "Don't panic!" +The declarations above are accepted. However, if we add ``MkOther :: T Int``, +we get an error that the equality constraint is not satisfied; ``Int`` is +not a type literal. Note that explicitly quantifying with ``forall a`` is +necessary in order for ``T`` to typecheck +(see :ref:`complete-kind-signatures`). ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -787,29 +787,6 @@ distinction). GHC does not consider ``forall k. k -> Type`` and ``forall {k}. k -> Type`` to be equal at the kind level, and thus rejects ``Foo Proxy`` as ill-kinded. -Constraints in kinds --------------------- - -As kinds and types are the same, kinds can (with :extension:`TypeInType`) -contain type constraints. However, only equality constraints are supported. - -Here is an example of a constrained kind: :: - - type family IsTypeLit a where - IsTypeLit Nat = 'True - IsTypeLit Symbol = 'True - IsTypeLit a = 'False - - data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where - MkNat :: T 42 - MkSymbol :: T "Don't panic!" - -The declarations above are accepted. However, if we add ``MkOther :: T Int``, -we get an error that the equality constraint is not satisfied; ``Int`` is -not a type literal. Note that explicitly quantifying with ``forall a`` is -necessary in order for ``T`` to typecheck -(see :ref:`complete-kind-signatures`). - The kind ``Type`` ----------------- ===================================== hadrian/build-stack ===================================== @@ -3,11 +3,13 @@ # Make sure that the script exits if Hadrian fails to build set -euo pipefail +STACK="${STACK:-stack}" + # Make sure Hadrian is up-to-date cd hadrian -stack build --no-library-profiling ${HADRIAN_NIX:+--nix} +$STACK build --no-library-profiling ${HADRIAN_NIX:+--nix} # Run Hadrian in the top-level GHC directory -stack exec hadrian -- \ +$STACK exec hadrian -- \ --directory ".." \ "$@" ===================================== hadrian/build-stack.bat ===================================== @@ -3,5 +3,9 @@ setlocal rem Change the current directory to the one containing this script cd %~dp0 +if "%STACK%"=="" ( + set STACK=stack +) + rem Build and run Hadrian in GHC top directory forwarding additional user arguments -stack run hadrian --cwd=.. -- %* +%STACK% run hadrian --cwd=.. -- %* ===================================== testsuite/tests/deSugar/should_run/T18151x.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE PostfixOperators #-} + +import Control.Exception + +data MyException = MyE + deriving (Show) + +instance Exception MyException + +(#) :: Bool -> Bool -> Bool +(#) = throw MyE + +main = do + r <- try (evaluate (seq (True #) ())) + case r of + Left MyE -> putStrLn "PostfixOperators ok" + Right () -> putStrLn "PostfixOperators broken" ===================================== testsuite/tests/deSugar/should_run/T18151x.stdout ===================================== @@ -0,0 +1 @@ +PostfixOperators ok ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -65,6 +65,7 @@ test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) test('T18151', normal, compile_and_run, ['']) +test('T18151x', normal, compile_and_run, ['']) test('T18172', [], ghci_script, ['T18172.script']) test('DsDoExprFailMsg', exit_code(1), compile_and_run, ['']) ===================================== testsuite/tests/th/T17688b.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE StandaloneKindSignatures #-} ===================================== testsuite/tests/typecheck/should_compile/T18831.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +module T18831 where + +import Data.Kind +import Data.Proxy + +data T1 :: Proxy 0 -> Type +data T2 :: () => Type +data T3 :: (Type :: Type) -> Type +data T4 :: Proxy '[Type,Type] -> Type +data T5 :: Proxy '(Type,Type) -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -722,5 +722,6 @@ test('T18412', normal, compile, ['']) test('T18470', normal, compile, ['']) test('T18323', normal, compile, ['']) test('T18585', normal, compile, ['']) +test('T18831', normal, compile, ['']) test('T15942', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/45e52af724395be4f8aac3962f88b20a5aa4ad7b...6070787fee9f31569ed97f8ecf8a1de3294e6652 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/45e52af724395be4f8aac3962f88b20a5aa4ad7b...6070787fee9f31569ed97f8ecf8a1de3294e6652 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 11:35:36 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 14 Oct 2020 07:35:36 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] Accepting metric changes to advance CI Message-ID: <5f86e288f0741_28003fd3ed5bf1701980df@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 4f4bfd68 by Sebastian Graf at 2020-10-14T13:34:35+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 Metric Increase ['max_bytes_used', 'peak_megabytes_allocated']: T10370 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T7360.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -190,6 +190,7 @@ T7360.$tc'Foo2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T7360.$tc'Foo9 [InlPrag=NOUSERINLINE[~]] :: GHC.Types.KindRep +[GblId, Unf=OtherCon []] T7360.$tc'Foo9 = GHC.Types.KindRepFun $krep T7360.$tc'Foo4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -219,3 +220,6 @@ T7360.$tc'Foo3 T7360.$tc'Foo10 0# T7360.$tc'Foo9 + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f4bfd687b108199c5cdbc6f093eac4af561a7fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f4bfd687b108199c5cdbc6f093eac4af561a7fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 12:59:55 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 14 Oct 2020 08:59:55 -0400 Subject: [Git][ghc/ghc][wip/T16762] 3 commits: Unification of Nat and Naturals Message-ID: <5f86f64baf228_2800d3457f82164c1@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - c8a9343a by Ryan Scott at 2020-10-14T08:59:28-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 27 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4ac4e6e36ea68cb86558a83599652423a9a69a0...c8a9343aa67467d71ac4f2a2ac115506f2998957 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c4ac4e6e36ea68cb86558a83599652423a9a69a0...c8a9343aa67467d71ac4f2a2ac115506f2998957 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 16:04:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 12:04:04 -0400 Subject: [Git][ghc/ghc][master] Bump LLVM version to 10.0 Message-ID: <5f8721745bf4a_2800e16cf482382a6@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 2 changed files: - .gitlab-ci.yml - configure.ac Changes: ===================================== .gitlab-ci.yml ===================================== @@ -838,6 +838,9 @@ validate-x86_64-linux-fedora27: stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" variables: + # LLVM 10 is not available for Fedora27 + LLC: /bin/false + OPT: /bin/false TEST_ENV: "x86_64-linux-fedora27" BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: ===================================== configure.ac ===================================== @@ -715,7 +715,7 @@ AC_SUBST(InstallNameToolCmd) # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around # 3.5/3.6 release of LLVM. -LlvmVersion=9 +LlvmVersion=10 AC_SUBST([LlvmVersion]) sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/') AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89f4d8e950a1ed2a3ffab424233d3bcd243b1771 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89f4d8e950a1ed2a3ffab424233d3bcd243b1771 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 16:04:43 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 12:04:43 -0400 Subject: [Git][ghc/ghc][master] Make DataKinds the sole arbiter of kind-level literals (and friends) Message-ID: <5f87219b65736_28003fd3ed4aadc02422bd@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - 6 changed files: - compiler/GHC/Rename/HsType.hs - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/poly_kinds.rst - testsuite/tests/th/T17688b.hs - + testsuite/tests/typecheck/should_compile/T18831.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -441,9 +441,9 @@ sites. This is less precise, but more accurate. rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. -Note [QualTy in kinds] +Note [HsQualTy in kinds] ~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether QualTy could occur only at TypeLevel. But no, +I was wondering whether HsQualTy could occur only at TypeLevel. But no, we can have a qualified type in a kind too. Here is an example: type family F a where @@ -466,9 +466,9 @@ suitable message: Expected kind: G Bool Actual kind: F Bool -However: in a kind, the constraints in the QualTy must all be +However: in a kind, the constraints in the HsQualTy must all be equalities; or at least, any kinds with a class constraint are -uninhabited. +uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -574,7 +574,9 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , fvs) } } rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { checkPolyKinds env ty -- See Note [QualTy in kinds] + = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] + ; when (not data_kinds && isRnKindLevel env) + (addErr (dataKindsErr env ty)) ; (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' @@ -636,9 +638,8 @@ rnHsTyKi env listTy@(HsListTy _ ty) ; (ty', fvs) <- rnLHsTyKi env ty ; return (HsListTy noExtField ty', fvs) } -rnHsTyKi env t@(HsKindSig _ ty k) - = do { checkPolyKinds env t - ; kind_sigs_ok <- xoptM LangExt.KindSignatures +rnHsTyKi env (HsKindSig _ ty k) + = do { kind_sigs_ok <- xoptM LangExt.KindSignatures ; unless kind_sigs_ok (badKindSigErr (rtke_ctxt env) ty) ; (ty', lhs_fvs) <- rnLHsTyKi env ty ; (k', sig_fvs) <- rnLHsTyKi (env { rtke_level = KindLevel }) k @@ -665,7 +666,6 @@ rnHsTyKi env tyLit@(HsTyLit _ t) = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env tyLit)) ; when (negLit t) (addErr negLitErr) - ; checkPolyKinds env tyLit ; return (HsTyLit noExtField t, emptyFVs) } where negLit (HsStrTy _ _) = False @@ -705,15 +705,13 @@ rnHsTyKi _ (XHsType (NHsCoreTy ty)) -- but I don't think it matters rnHsTyKi env ty@(HsExplicitListTy _ ip tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitListTy noExtField ip tys', fvs) } rnHsTyKi env ty@(HsExplicitTupleTy _ tys) - = do { checkPolyKinds env ty - ; data_kinds <- xoptM LangExt.DataKinds + = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitTupleTy noExtField tys', fvs) } ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -134,6 +134,12 @@ promotion quote and the data constructor: :: type S = 'A' -- ERROR: looks like a character type R = ' A' -- OK: promoted `A'` +Type-level literals +------------------- + +:extension:`DataKinds` enables the use of numeric and string literals at the +type level. For more information, see :ref:`type-level-literals`. + .. _promoted-lists-and-tuples: Promoted list and tuple types @@ -207,4 +213,27 @@ above code is valid. See also :ghc-ticket:`7347`. +.. _constraints_in_kinds: + +Constraints in kinds +-------------------- + +Kinds can (with :extension:`DataKinds`) contain type constraints. However, +only equality constraints are supported. + +Here is an example of a constrained kind: :: + + type family IsTypeLit a where + IsTypeLit Nat = 'True + IsTypeLit Symbol = 'True + IsTypeLit a = 'False + + data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where + MkNat :: T 42 + MkSymbol :: T "Don't panic!" +The declarations above are accepted. However, if we add ``MkOther :: T Int``, +we get an error that the equality constraint is not satisfied; ``Int`` is +not a type literal. Note that explicitly quantifying with ``forall a`` is +necessary in order for ``T`` to typecheck +(see :ref:`complete-kind-signatures`). ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -787,29 +787,6 @@ distinction). GHC does not consider ``forall k. k -> Type`` and ``forall {k}. k -> Type`` to be equal at the kind level, and thus rejects ``Foo Proxy`` as ill-kinded. -Constraints in kinds --------------------- - -As kinds and types are the same, kinds can (with :extension:`TypeInType`) -contain type constraints. However, only equality constraints are supported. - -Here is an example of a constrained kind: :: - - type family IsTypeLit a where - IsTypeLit Nat = 'True - IsTypeLit Symbol = 'True - IsTypeLit a = 'False - - data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where - MkNat :: T 42 - MkSymbol :: T "Don't panic!" - -The declarations above are accepted. However, if we add ``MkOther :: T Int``, -we get an error that the equality constraint is not satisfied; ``Int`` is -not a type literal. Note that explicitly quantifying with ``forall a`` is -necessary in order for ``T`` to typecheck -(see :ref:`complete-kind-signatures`). - The kind ``Type`` ----------------- ===================================== testsuite/tests/th/T17688b.hs ===================================== @@ -1,3 +1,4 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE StandaloneKindSignatures #-} ===================================== testsuite/tests/typecheck/should_compile/T18831.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE KindSignatures #-} +module T18831 where + +import Data.Kind +import Data.Proxy + +data T1 :: Proxy 0 -> Type +data T2 :: () => Type +data T3 :: (Type :: Type) -> Type +data T4 :: Proxy '[Type,Type] -> Type +data T5 :: Proxy '(Type,Type) -> Type ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -722,5 +722,6 @@ test('T18412', normal, compile, ['']) test('T18470', normal, compile, ['']) test('T18323', normal, compile, ['']) test('T18585', normal, compile, ['']) +test('T18831', normal, compile, ['']) test('T15942', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/716385c90f2f89ac45e256cdb7cdada1981b31ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/716385c90f2f89ac45e256cdb7cdada1981b31ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 16:05:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 12:05:25 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Remove "Operator sections" from docs/users_guide/bugs.rst Message-ID: <5f8721c535570_2800e9cb1d02454bd@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - 5 changed files: - compiler/GHC/HsToCore/Expr.hs - docs/users_guide/bugs.rst - + testsuite/tests/deSugar/should_run/T18151x.hs - + testsuite/tests/deSugar/should_run/T18151x.stdout - testsuite/tests/deSugar/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -70,6 +70,8 @@ import GHC.Utils.Panic import GHC.Core.PatSyn import Control.Monad +import qualified GHC.LanguageExtensions as LangExt + {- ************************************************************************ * * @@ -347,7 +349,11 @@ converting to core it must become a CO. Note [Desugaring operator sections] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -At first it looks as if we can convert +Desugaring left sections with -XPostfixOperators is straightforward: convert +(expr `op`) to (op expr). + +Without -XPostfixOperators it's a bit more tricky. At first it looks as if we +can convert (expr `op`) @@ -398,6 +404,13 @@ dsExpr e@(OpApp _ e1 op e2) -- See Note [Desugaring operator sections]. -- N.B. this also must handle postfix operator sections due to -XPostfixOperators. dsExpr e@(SectionL _ expr op) = do + postfix_operators <- xoptM LangExt.PostfixOperators + if postfix_operators then + -- Desugar (e !) to ((!) e) + do { op' <- dsLExpr op + ; dsWhenNoErrs (dsLExprNoLP expr) $ \expr' -> + mkCoreAppDs (text "sectionl" <+> ppr expr) op' expr' } + else do core_op <- dsLExpr op x_core <- dsLExpr expr case splitFunTys (exprType core_op) of ===================================== docs/users_guide/bugs.rst ===================================== @@ -438,31 +438,6 @@ The Foreign Function Interface single: hs_init single: hs_exit -.. _infelicities-operator-sections: - -Operator sections -^^^^^^^^^^^^^^^^^ - -The Haskell Report demands that, for infix operators ``%``, the following -identities hold: - -:: - - (% expr) = \x -> x % expr - (expr %) = \x -> expr % x - -However, the second law is violated in the presence of undefined operators, - -:: - - (%) = error "urk" - (() %) `seq` () -- urk - (\x -> () % x) `seq` () -- OK, result () - -The operator section is treated like function application of an undefined -function, while the lambda form is in WHNF that contains an application of an -undefined function. - .. _haskell-98-2010-undefined: GHC's interpretation of undefined behaviour in Haskell 98 and Haskell 2010 ===================================== testsuite/tests/deSugar/should_run/T18151x.hs ===================================== @@ -0,0 +1,17 @@ +{-# LANGUAGE PostfixOperators #-} + +import Control.Exception + +data MyException = MyE + deriving (Show) + +instance Exception MyException + +(#) :: Bool -> Bool -> Bool +(#) = throw MyE + +main = do + r <- try (evaluate (seq (True #) ())) + case r of + Left MyE -> putStrLn "PostfixOperators ok" + Right () -> putStrLn "PostfixOperators broken" ===================================== testsuite/tests/deSugar/should_run/T18151x.stdout ===================================== @@ -0,0 +1 @@ +PostfixOperators ok ===================================== testsuite/tests/deSugar/should_run/all.T ===================================== @@ -65,6 +65,7 @@ test('T11747', normal, compile_and_run, ['-dcore-lint']) test('T12595', normal, compile_and_run, ['']) test('T13285', normal, compile_and_run, ['']) test('T18151', normal, compile_and_run, ['']) +test('T18151x', normal, compile_and_run, ['']) test('T18172', [], ghci_script, ['T18172.script']) test('DsDoExprFailMsg', exit_code(1), compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/716385c90f2f89ac45e256cdb7cdada1981b31ad...bf2411a3c198cb2df93a9e0aa0c3b8297f47058d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/716385c90f2f89ac45e256cdb7cdada1981b31ad...bf2411a3c198cb2df93a9e0aa0c3b8297f47058d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 16:36:11 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 12:36:11 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Bump LLVM version to 10.0 Message-ID: <5f8728fb84839_28006da6e4c2532a@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - b41860d4 by Fumiaki Kinoshita at 2020-10-14T12:36:01-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 95f24c28 by Simon Peyton Jones at 2020-10-14T12:36:03-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 9a5fa43b by Ben Gamari at 2020-10-14T12:36:04-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Utils/Binary.hs - configure.ac - docs/users_guide/9.0.1-notes.rst - docs/users_guide/bugs.rst - docs/users_guide/exts/data_kinds.rst - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/phases.rst - testsuite/tests/codeGen/should_compile/jmp_tbl.hs - testsuite/tests/cpranal/should_compile/Cpr001_imp.hs - + testsuite/tests/deSugar/should_run/T18151x.hs - + testsuite/tests/deSugar/should_run/T18151x.stdout - testsuite/tests/deSugar/should_run/all.T - testsuite/tests/deriving/should_compile/drv020.hs - testsuite/tests/determinism/determ019/A.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6070787fee9f31569ed97f8ecf8a1de3294e6652...9a5fa43b90508d11cc8a4f87f91ec6b95da685a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6070787fee9f31569ed97f8ecf8a1de3294e6652...9a5fa43b90508d11cc8a4f87f91ec6b95da685a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 17:23:33 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 13:23:33 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-conc059 Message-ID: <5f87341523a8f_28003fd3ee9938a425961@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/fix-conc059 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-conc059 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 17:50:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 13:50:01 -0400 Subject: [Git][ghc/ghc][wip/angerman/ghc-9.0-runpath-backport] 19 commits: Linear types: fix kind inference when checking datacons Message-ID: <5f873a49ab565_28003fd3ed3795002631b6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/angerman/ghc-9.0-runpath-backport at Glasgow Haskell Compiler / GHC Commits: 93df442a by Krzysztof Gogolewski at 2020-09-30T01:05:27+03:00 Linear types: fix kind inference when checking datacons (cherry picked from b31a3360e2ef12f3ec7eaf66b3600247c1eb36c3) - - - - - 7c7bd94d by Vladislav Zavialov at 2020-09-30T01:06:07+03:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. (cherry-picked from 5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - d5e13ceb by Vladislav Zavialov at 2020-10-02T01:39:25+03:00 Fix pretty-printing of the mult-polymorphic arrow (cherry-picked from a8018c17747342444c67eeec21a506c89c1110e8) - - - - - 89a00150 by Sylvain Henry at 2020-10-05T10:32:31+02:00 Bignum: add integerNegate RULE - - - - - 175d7141 by Sylvain Henry at 2020-10-05T10:32:38+02:00 Bignum: implement integerRecipMod (#18427) - - - - - 5d414fdc by Sylvain Henry at 2020-10-05T10:32:43+02:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - b936c542 by MaxGabriel at 2020-10-12T14:19:41+02:00 Document -Wderiving-typeable Tracking: #18641 (cherry picked from commit 73d2521688bd1da4b6bd1202e5325a00cb410a44) - - - - - c073a4ab by Hécate at 2020-10-12T14:20:47+02:00 Remove the list of loaded modules from the ghci prompt (cherry picked from commit 086ef01813069fad84cafe81cab37527d41c8568) - - - - - aff164bc by Benjamin Maurer at 2020-10-12T14:21:51+02:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. (cherry picked from commit 74c797f6b72c4d01f5e0092dfac1461f3f3dd7a2) - - - - - 44779899 by Krzysztof Gogolewski at 2020-10-12T14:22:35+02:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. (cherry picked from commit e48cab2a57f2342891f985bcb44817e17e985275) - - - - - ba446875 by Krzysztof Gogolewski at 2020-10-12T14:23:25+02:00 Fix linear types in TH splices (#18465) (cherry picked from commit 802b5e6fdd6dfc58396a9dca1903dc5a1d6634ca) - - - - - b10154d6 by Icelandjack at 2020-10-12T14:25:47+02:00 Replaced MkT1 with T1 in type signatures. (cherry picked from commit b81350bb925f8cb309355ee46238dbc11b796faf) - - - - - baa55369 by Krzysztof Gogolewski at 2020-10-12T14:26:12+02:00 Linear types: fix quantification in GADTs (#18790) (cherry picked from commit 22f218b729a751bc5e5965624a716fc542f502a5) - - - - - 146cff70 by Alan Zimmerman at 2020-10-12T14:27:02+02:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 (cherry picked from commit d6dff830754a97220eacf032c32cd54b18654917) - - - - - 8c370e11 by Alan Zimmerman at 2020-10-12T14:27:30+02:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. (cherry picked from commit 36787bba78ae5acbb857c84b85b8feb7c83e54a5) - - - - - 15c4eb1f by Krzysztof Gogolewski at 2020-10-12T14:28:15+02:00 Linear types: fix roles in GADTs (#18799) (cherry picked from commit 8fafb304cacae69f8dbbdcf22ab858a5b28b6818) - - - - - a740aa0b by Sylvain Henry at 2020-10-12T15:10:13+02:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - d09e7e41 by Sylvain Henry at 2020-10-12T15:10:30+02:00 Bignum: fix bigNatCompareWord# bug (#18813) (cherry picked from commit 74ee1237bf243dd7d8b758a53695575c364c3088) - - - - - 07385545 by Moritz Angermann at 2020-10-14T13:49:56-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 89a753308deb2c7ed012e875e220b1d39e1798d8) Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Multiplicity.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/SimpleOpt.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Utils.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Utils/Outputable.hs - configure.ac - docs/users_guide/9.0.1-notes.rst - docs/users_guide/expected-undocumented-flags.txt The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7895dbef7f903615d212ebcb733812b8e60cc37c...07385545bed6099c7e5b7fd28f0b0a7fa7910fae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7895dbef7f903615d212ebcb733812b8e60cc37c...07385545bed6099c7e5b7fd28f0b0a7fa7910fae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 17:51:39 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 13:51:39 -0400 Subject: [Git][ghc/ghc][wip/angerman/ghc-8.10-backport-rpath] 5 commits: Bump text submodule to 1.2.4.0+ Message-ID: <5f873aab96c0d_28003fd41a0cd39c264389@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/angerman/ghc-8.10-backport-rpath at Glasgow Haskell Compiler / GHC Commits: a259e6da by Ben Gamari at 2020-10-06T11:00:27-04:00 Bump text submodule to 1.2.4.0+ Fixes #18588 and #17956. - - - - - 8a85216c by Ömer Sinan Ağacan at 2020-10-06T11:00:27-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 (cherry picked from commit 08c1cb0f30770acbf366423f085f8ef92f7f6a06) - - - - - fec3a3cf by GHC GitLab CI at 2020-10-06T11:00:27-04:00 configure: Avoid hard-coded ld path on Windows 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). (cherry picked from commit 34e0fa963f35a77093fc7111a80c557fc6bd614f) - - - - - a491d1cb by Ben Gamari at 2020-10-08T08:51:10-04:00 Fix Windows build - - - - - 43f97049 by Moritz Angermann at 2020-10-14T13:51:31-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 4ff93292243888545da452ea4d4c1987f2343591) Signed-off-by: Moritz Angermann <moritz.angermann at iohk.io> - - - - - 23 changed files: - aclocal.m4 - compiler/ghci/Linker.hs - compiler/main/DriverPipeline.hs - compiler/main/DynFlags.hs - compiler/main/Settings.hs - compiler/main/SysTools.hs - compiler/main/SysTools/Settings.hs - compiler/main/SysTools/Tasks.hs - compiler/main/ToolSettings.hs - configure.ac - docs/users_guide/phases.rst - ghc.mk - hadrian/cfg/system.config.in - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - includes/ghc.mk - libraries/text - mk/config.mk.in - rts/Linker.c - rules/build-package-way.mk - testsuite/tests/rts/all.T - utils/ghc-cabal/ghc.mk Changes: ===================================== aclocal.m4 ===================================== @@ -516,6 +516,10 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="${mingw_bin_prefix}gcc.exe" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="${mingw_bin_prefix}ld.exe" + # Overrides FIND_MERGE_OBJECTS in order to avoid hard-coding linker + # path on Windows (#18550). + SettingsMergeObjectsCommand="${SettingsLdCommand}" + SettingsMergeObjectsFlags="-r --oformat=pe-bigobj-x86-64" SettingsArCommand="${mingw_bin_prefix}ar.exe" SettingsRanlibCommand="${mingw_bin_prefix}ranlib.exe" SettingsDllWrapCommand="${mingw_bin_prefix}dllwrap.exe" @@ -529,6 +533,8 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="$(basename $HaskellCPPCmd)" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="$(basename $LdCmd)" + SettingsMergeObjectsCommand="$(basename $MergeObjsCmd)" + SettingsMergeObjectsFlags="$MergeObjsArgs" SettingsArCommand="$(basename $ArCmd)" SettingsDllWrapCommand="$(basename $DllWrapCmd)" SettingsWindresCommand="$(basename $WindresCmd)" @@ -538,6 +544,8 @@ AC_DEFUN([FP_SETTINGS], SettingsHaskellCPPCommand="$HaskellCPPCmd" SettingsHaskellCPPFlags="$HaskellCPPArgs" SettingsLdCommand="$LdCmd" + SettingsMergeObjectsCommand="$MergeObjsCmd" + SettingsMergeObjectsFlags="$MergeObjsArgs" SettingsArCommand="$ArCmd" SettingsRanlibCommand="$RanlibCmd" if test -z "$DllWrapCmd" @@ -578,6 +586,18 @@ AC_DEFUN([FP_SETTINGS], else SettingsOptCommand="$OptCmd" fi + if test -z "$OtoolCmd" + then + SettingsOtoolCommand="otool" + else + SettingsOtoolCommand="$OtoolCmd" + fi + if test -z "$InstallNameToolCmd" + then + SettingsInstallNameToolCommand="install_name_tool" + else + SettingsInstallNameToolCommand="$InstallNameToolCmd" + fi SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2" @@ -592,8 +612,12 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsCCompilerSupportsNoPie) AC_SUBST(SettingsLdCommand) AC_SUBST(SettingsLdFlags) + AC_SUBST(SettingsMergeObjectsCommand) + AC_SUBST(SettingsMergeObjectsFlags) AC_SUBST(SettingsArCommand) AC_SUBST(SettingsRanlibCommand) + AC_SUBST(SettingsOtoolCommand) + AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) AC_SUBST(SettingsLibtoolCommand) @@ -2589,7 +2613,7 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[ ]) $CC -c -o conftest.a.o conftest.a.c || AC_MSG_ERROR([Failed to compile test]) - $SettingsMergeObjectsCommand $SettingsMergeObjectsFlags -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object]) + $MergeObjsCmd $MergeObjsArgs -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object]) $CC -c -o conftest.main.o conftest.main.c || AC_MSG_ERROR([Failed to compile test driver]) $CC conftest.ar.o conftest.main.o -o conftest || AC_MSG_ERROR([Failed to link test driver]) @@ -2609,33 +2633,30 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[ # ------------------ # Find which linker to use to merge object files. # +# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline. AC_DEFUN([FIND_MERGE_OBJECTS],[ AC_REQUIRE([FIND_LD]) - if test -z "$SettingsMergeObjectsCommand"; then - SettingsMergeObjectsCommand="$LD" + if test -z "$MergeObjsCmd"; then + MergeObjsCmd="$LD" fi - if test -z "$SettingsMergeObjectsFlags"; then - SettingsMergeObjectsFlags="-r" + if test -z "$MergeObjsArgs"; then + MergeObjsArgs="-r" fi - CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand) + CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then - AC_MSG_NOTICE([$SettingsMergeObjectsCommand is broken due to binutils 22266, looking for another linker...]) - SettingsMergeObjectsCommand="" - AC_CHECK_TARGET_TOOL([SettingsMergeObjectsCommand], [ld]) - CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand) + AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...]) + MergeObjsCmd="" + AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld]) + CHECK_FOR_GOLD_T22266($MergeObjsCmd) if test "$result" = "1"; then - AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the SettingsMergeObjectsCommand variable to a functional linker.]) + AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.]) fi fi - if test "$windows" = YES -a "$EnableDistroToolchain" = "NO" -a "$WORD_SIZE" = 64; then - SettingsMergeObjectsFlags="$SettingsMergeObjectsFlags --oformat=pe-bigobj-x86-64" - fi - - AC_SUBST(SettingsMergeObjectsCommand) - AC_SUBST(SettingsMergeObjectsFlags) + AC_SUBST([MergeObjsCmd]) + AC_SUBST([MergeObjsArgs]) ]) # FIND_PYTHON ===================================== compiler/ghci/Linker.hs ===================================== @@ -913,20 +913,22 @@ dynLoadObjs hsc_env pls at PersistentLinkerState{..} objs = do ldInputs = concatMap (\l -> [ Option ("-l" ++ l) ]) (nub $ snd <$> temp_sos) - ++ concatMap (\lp -> [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp ]) + ++ concatMap (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) (nub $ fst <$> temp_sos) ++ concatMap - (\lp -> - [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp - ]) + (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) minus_big_ls -- See Note [-Xlinker -rpath vs -Wl,-rpath] ++ map (\l -> Option ("-l" ++ l)) minus_ls, ===================================== compiler/main/DriverPipeline.hs ===================================== @@ -382,7 +382,56 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- --------------------------------------------------------------------------- -- Link - +-- +-- Note [Dynamic linking on macOS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Since macOS Sierra (10.14), the dynamic system linker enforces +-- a limit on the Load Commands. Specifically the Load Command Size +-- Limit is at 32K (32768). The Load Commands contain the install +-- name, dependencies, runpaths, and a few other commands. We however +-- only have control over the install name, dependencies and runpaths. +-- +-- The install name is the name by which this library will be +-- referenced. This is such that we do not need to bake in the full +-- absolute location of the library, and can move the library around. +-- +-- The dependency commands contain the install names from of referenced +-- libraries. Thus if a libraries install name is @rpath/libHS...dylib, +-- that will end up as the dependency. +-- +-- Finally we have the runpaths, which informs the linker about the +-- directories to search for the referenced dependencies. +-- +-- The system linker can do recursive linking, however using only the +-- direct dependencies conflicts with ghc's ability to inline across +-- packages, and as such would end up with unresolved symbols. +-- +-- Thus we will pass the full dependency closure to the linker, and then +-- ask the linker to remove any unused dynamic libraries (-dead_strip_dylibs). +-- +-- We still need to add the relevant runpaths, for the dynamic linker to +-- lookup the referenced libraries though. The linker (ld64) does not +-- have any option to dead strip runpaths; which makes sense as runpaths +-- can be used for dependencies of dependencies as well. +-- +-- The solution we then take in GHC is to not pass any runpaths to the +-- linker at link time, but inject them after the linking. For this to +-- work we'll need to ask the linker to create enough space in the header +-- to add more runpaths after the linking (-headerpad 8000). +-- +-- After the library has been linked by $LD (usually ld64), we will use +-- otool to inspect the libraries left over after dead stripping, compute +-- the relevant runpaths, and inject them into the linked product using +-- the install_name_tool command. +-- +-- This strategy should produce the smallest possible set of load commands +-- while still retaining some form of relocatability via runpaths. +-- +-- The only way I can see to reduce the load command size further would be +-- by shortening the library names, or start putting libraries into the same +-- folders, such that one runpath would be sufficient for multiple/all +-- libraries. link :: GhcLink -- interactive or batch -> DynFlags -- dynamic flags -> Bool -- attempt linking in batch mode? @@ -1769,9 +1818,12 @@ linkBinary' staticLink dflags o_files dep_packages = do rc_objs <- maybeCreateManifest dflags output_fn - let link = if staticLink - then SysTools.runLibtool - else SysTools.runLink + let link dflags args | staticLink = SysTools.runLibtool dflags args + | platformOS platform == OSDarwin + = SysTools.runLink dflags args >> SysTools.runInjectRPaths dflags pkg_lib_paths output_fn + | otherwise + = SysTools.runLink dflags args + link dflags ( map SysTools.Option verbFlags ++ [ SysTools.Option "-o" @@ -1838,7 +1890,13 @@ linkBinary' staticLink dflags o_files dep_packages = do ++ pkg_link_opts ++ pkg_framework_opts ++ (if platformOS platform == OSDarwin - then [ "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the left over + -- libraries during runInjectRpaths phase. + -- + -- See Note [Dynamic linking on macOS]. + then [ "-Wl,-dead_strip_dylibs", "-Wl,-headerpad,8000" ] else []) )) ===================================== compiler/main/DynFlags.hs ===================================== @@ -155,8 +155,8 @@ module DynFlags ( versionedAppDir, versionedFilePath, extraGccViaCFlags, systemPackageConfig, pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_libtool, pgm_ar, pgm_ranlib, pgm_lo, pgm_lc, - pgm_lcc, pgm_i, + pgm_windres, pgm_libtool, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, opt_P_signature, opt_windres, opt_lo, opt_lc, opt_lcc, @@ -1463,6 +1463,10 @@ pgm_lcc :: DynFlags -> (String,[Option]) pgm_lcc dflags = toolSettings_pgm_lcc $ toolSettings dflags pgm_ar :: DynFlags -> String pgm_ar dflags = toolSettings_pgm_ar $ toolSettings dflags +pgm_otool :: DynFlags -> String +pgm_otool dflags = toolSettings_pgm_otool $ toolSettings dflags +pgm_install_name_tool :: DynFlags -> String +pgm_install_name_tool dflags = toolSettings_pgm_install_name_tool $ toolSettings dflags pgm_ranlib :: DynFlags -> String pgm_ranlib dflags = toolSettings_pgm_ranlib $ toolSettings dflags pgm_lo :: DynFlags -> (String,[Option]) @@ -3089,6 +3093,10 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_libtool = f } , make_ord_flag defFlag "pgmar" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ar = f } + , make_ord_flag defFlag "pgmotool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_otool = f} + , make_ord_flag defFlag "pgminstall_name_tool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_install_name_tool = f} , make_ord_flag defFlag "pgmranlib" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ranlib = f } @@ -4589,7 +4597,6 @@ defaultFlags settings Opt_OmitYields, Opt_PrintBindContents, Opt_ProfCountEntries, - Opt_RPath, Opt_SharedImplib, Opt_SimplPreInlining, Opt_VersionMacros @@ -4600,6 +4607,8 @@ defaultFlags settings ++ default_PIC platform + ++ default_RPath platform + ++ concatMap (wayGeneralFlags platform) (defaultWays settings) ++ validHoleFitDefaults @@ -4640,6 +4649,29 @@ default_PIC platform = -- information. _ -> [] + +-- We usually want to use RPath, except on macOS (OSDarwin). On recent macOS +-- versions the number of load commands we can embed in a dynamic library is +-- restricted. Hence since b592bd98ff2 we rely on -dead_strip_dylib to only +-- link the needed dylibs instead of linking the full dependency closure. +-- +-- If we split the library linking into injecting -rpath and -l @rpath/... +-- components, we will reduce the number of libraries we link, however we will +-- still inject one -rpath entry for each library, independent of their use. +-- That is, we even inject -rpath values for libraries that we dead_strip in +-- the end. As such we can run afoul of the load command size limit simply +-- by polluting the load commands with RPATH entries. +-- +-- Thus, we disable Opt_RPath by default on OSDarwin. The savvy user can always +-- enable it with -use-rpath if they so wish. +-- +-- See Note [Dynamic linking on macOS] + +default_RPath :: Platform -> [GeneralFlag] +default_RPath platform | platformOS platform == OSDarwin = [] +default_RPath _ = [Opt_RPath] + + -- General flags that are switched on/off when other general flags are switched -- on impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] ===================================== compiler/main/Settings.hs ===================================== @@ -25,6 +25,8 @@ module Settings , sPgm_windres , sPgm_libtool , sPgm_ar + , sPgm_otool + , sPgm_install_name_tool , sPgm_ranlib , sPgm_lo , sPgm_lc @@ -139,6 +141,10 @@ sPgm_libtool :: Settings -> String sPgm_libtool = toolSettings_pgm_libtool . sToolSettings sPgm_ar :: Settings -> String sPgm_ar = toolSettings_pgm_ar . sToolSettings +sPgm_otool :: Settings -> String +sPgm_otool = toolSettings_pgm_otool . sToolSettings +sPgm_install_name_tool :: Settings -> String +sPgm_install_name_tool = toolSettings_pgm_install_name_tool . sToolSettings sPgm_ranlib :: Settings -> String sPgm_ranlib = toolSettings_pgm_ranlib . sToolSettings sPgm_lo :: Settings -> (String, [Option]) ===================================== compiler/main/SysTools.hs ===================================== @@ -254,7 +254,10 @@ linkDynLib dflags0 o_files dep_packages | ( osElfTarget (platformOS (targetPlatform dflags)) || osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && - WayDyn `elem` ways dflags + -- Only if we want dynamic libraries + WayDyn `elem` ways dflags && + -- Only use RPath if we explicitly asked for it + gopt Opt_RPath dflags = ["-L" ++ l, "-Xlinker", "-rpath", "-Xlinker", l] -- See Note [-Xlinker -rpath vs -Wl,-rpath] | otherwise = ["-L" ++ l] @@ -377,8 +380,15 @@ linkDynLib dflags0 o_files dep_packages ++ map Option pkg_lib_path_opts ++ map Option pkg_link_opts ++ map Option pkg_framework_opts - ++ [ Option "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the leftover + -- libraries in the runInjectRpaths phase below. + -- + -- See Note [Dynamic linking on macOS] + ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) + runInjectRPaths dflags pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/main/SysTools/Settings.hs ===================================== @@ -119,6 +119,8 @@ initSettings top_dir = do windres_path <- getToolSetting "windres command" libtool_path <- getToolSetting "libtool command" ar_path <- getToolSetting "ar command" + otool_path <- getToolSetting "otool command" + install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" -- TODO this side-effect doesn't belong here. Reading and parsing the settings @@ -141,7 +143,7 @@ initSettings top_dir = do as_args = map Option cc_args ld_prog = cc_prog ld_args = map Option (cc_args ++ words cc_link_args_str) - ld_r_prog <- getSetting "Merge objects command" + ld_r_prog <- getToolSetting "Merge objects command" ld_r_args <- getSetting "Merge objects flags" llvmTarget <- getSetting "LLVM target" @@ -210,6 +212,8 @@ initSettings top_dir = do , toolSettings_pgm_windres = windres_path , toolSettings_pgm_libtool = libtool_path , toolSettings_pgm_ar = ar_path + , toolSettings_pgm_otool = otool_path + , toolSettings_pgm_install_name_tool = install_name_tool_path , toolSettings_pgm_ranlib = ranlib_path , toolSettings_pgm_lo = (lo_prog,[]) , toolSettings_pgm_lc = (lc_prog,[]) ===================================== compiler/main/SysTools/Tasks.hs ===================================== @@ -28,6 +28,10 @@ import LlvmCodeGen.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, pars import SysTools.Process import SysTools.Info +import Control.Monad (join, forM, filterM) +import System.Directory (doesFileExist) +import System.FilePath (()) + {- ************************************************************************ * * @@ -237,6 +241,41 @@ figureLlvmVersion dflags = traceToolCommand dflags "llc" $ do return Nothing) +-- | On macOS we rely on the linkers @-dead_strip_dylibs@ flag to remove unused +-- libraries from the dynamic library. We do this to reduce the number of load +-- commands that end up in the dylib, and has been limited to 32K (32768) since +-- macOS Sierra (10.14). +-- +-- @-dead_strip_dylibs@ does not dead strip @-rpath@ entries, as such passing +-- @-l@ and @-rpath@ to the linker will result in the unnecesasry libraries not +-- being included in the load commands, however the @-rpath@ entries are all +-- forced to be included. This can lead to 100s of @-rpath@ entries being +-- included when only a handful of libraries end up being truely linked. +-- +-- Thus after building the library, we run a fixup phase where we inject the +-- @-rpath@ for each found library (in the given library search paths) into the +-- dynamic library through @-add_rpath at . +-- +-- See Note [Dynamic linking on macOS] +runInjectRPaths :: DynFlags -> [FilePath] -> FilePath -> IO () +runInjectRPaths dflags lib_paths dylib = do + info <- lines <$> askOtool dflags Nothing [Option "-L", Option dylib] + -- filter the output for only the libraries. And then drop the @rpath prefix. + let libs = fmap (drop 7) $ filter (isPrefixOf "@rpath") $ fmap (head.words) $ info + -- find any pre-existing LC_PATH items + info <- fmap words.lines <$> askOtool dflags Nothing [Option "-l", Option dylib] + let paths = concatMap f info + where f ("path":p:_) = [p] + f _ = [] + lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] + -- only find those rpaths, that aren't already in the library. + rpaths <- nub.sort.join <$> forM libs (\f -> filterM (\l -> doesFileExist (l f)) lib_paths') + -- inject the rpaths + case rpaths of + [] -> return () + _ -> runInstallNameTool dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + + runLink :: DynFlags -> [Option] -> IO () runLink dflags args = traceToolCommand dflags "linker" $ do -- See Note [Run-time linker info] @@ -335,6 +374,17 @@ askAr dflags mb_cwd args = traceToolCommand dflags "ar" $ do runSomethingWith dflags "Ar" ar args $ \real_args -> readCreateProcessWithExitCode' (proc ar real_args){ cwd = mb_cwd } +askOtool :: DynFlags -> Maybe FilePath -> [Option] -> IO String +askOtool dflags mb_cwd args = do + let otool = pgm_otool dflags + runSomethingWith dflags "otool" otool args $ \real_args -> + readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } + +runInstallNameTool :: DynFlags -> [Option] -> IO () +runInstallNameTool dflags args = do + let tool = pgm_install_name_tool dflags + runSomethingFiltered dflags id "Install Name Tool" tool args Nothing Nothing + runRanlib :: DynFlags -> [Option] -> IO () runRanlib dflags args = traceToolCommand dflags "ranlib" $ do let ranlib = pgm_ranlib dflags ===================================== compiler/main/ToolSettings.hs ===================================== @@ -31,6 +31,8 @@ data ToolSettings = ToolSettings , toolSettings_pgm_windres :: String , toolSettings_pgm_libtool :: String , toolSettings_pgm_ar :: String + , toolSettings_pgm_otool :: String + , toolSettings_pgm_install_name_tool :: String , toolSettings_pgm_ranlib :: String , -- | LLVM: opt llvm optimiser toolSettings_pgm_lo :: (String, [Option]) ===================================== configure.ac ===================================== @@ -429,6 +429,8 @@ then NM="${mingwbin}nm.exe" RANLIB="${mingwbin}ranlib.exe" OBJDUMP="${mingwbin}objdump.exe" + MergeObjsCmd="$LD" + MergeObjsArgs="-r --oformat=pe-bigobj-x86-64" fp_prog_ar="${mingwbin}ar.exe" AC_PATH_PROG([Genlib],[genlib]) @@ -669,6 +671,18 @@ else fi AC_SUBST([LibtoolCmd]) +dnl ** Which otool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +OtoolCmd="$OTOOL" +AC_SUBST(OtoolCmd) + +dnl ** Which install_name_tool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +InstallNameToolCmd="$INSTALL_NAME_TOOL" +AC_SUBST(InstallNameToolCmd) + # Here is where we re-target which specific version of the LLVM # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around @@ -1479,6 +1493,8 @@ echo "\ libtool : $LibtoolCmd objdump : $ObjdumpCmd ranlib : $RanlibCmd + otool : $OtoolCmd + install_name_tool : $InstallNameToolCmd windres : $WindresCmd dllwrap : $DllWrapCmd genlib : $GenlibCmd ===================================== docs/users_guide/phases.rst ===================================== @@ -95,6 +95,24 @@ given compilation phase: Use ⟨cmd⟩ as the pre-processor (with :ghc-flag:`-F` only). +.. ghc-flag:: -pgmotool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inspect mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inspect mach-o dynamic libraries and + executables to read the dynamic library dependencies. We will compute + the necessary ``runpath``s to embed for the dependencies based on the + result of the ``otool`` call. + +.. ghc-flag:: -pgminstall_name_tool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inject ``runpath`` into mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inject ``runpath``s into mach-o dynamic + libraries and executables. As detected by the ``otool`` call. + .. ghc-flag:: -pgmwindres ⟨cmd⟩ :shortdesc: Use ⟨cmd⟩ as the program for embedding manifests on Windows. :type: dynamic ===================================== ghc.mk ===================================== @@ -414,7 +414,7 @@ else # CLEANING # programs such as GHC and ghc-pkg, that we do not assume the stage0 # compiler already has installed (or up-to-date enough). -PACKAGES_STAGE0 = binary text transformers mtl parsec Cabal/Cabal hpc ghc-boot-th ghc-boot template-haskell ghc-heap ghci +PACKAGES_STAGE0 = binary transformers mtl hpc ghc-boot-th ghc-boot template-haskell text parsec Cabal/Cabal ghc-heap ghci ifeq "$(Windows_Host)" "NO" PACKAGES_STAGE0 += terminfo endif @@ -441,14 +441,14 @@ PACKAGES_STAGE1 += process PACKAGES_STAGE1 += hpc PACKAGES_STAGE1 += pretty PACKAGES_STAGE1 += binary -PACKAGES_STAGE1 += text PACKAGES_STAGE1 += transformers PACKAGES_STAGE1 += mtl -PACKAGES_STAGE1 += parsec -PACKAGES_STAGE1 += Cabal/Cabal PACKAGES_STAGE1 += ghc-boot-th PACKAGES_STAGE1 += ghc-boot PACKAGES_STAGE1 += template-haskell +PACKAGES_STAGE1 += text +PACKAGES_STAGE1 += parsec +PACKAGES_STAGE1 += Cabal/Cabal PACKAGES_STAGE1 += ghc-compact PACKAGES_STAGE1 += ghc-heap ===================================== hadrian/cfg/system.config.in ===================================== @@ -14,6 +14,7 @@ hs-cpp = @HaskellCPPCmd@ ld = @LdCmd@ make = @MakeCmd@ nm = @NmCmd@ +merge-objects = @MergeObjsCmd@ objdump = @ObjdumpCmd@ ranlib = @REAL_RANLIB_CMD@ sphinx-build = @SPHINXBUILD@ @@ -114,10 +115,10 @@ conf-ld-linker-args-stage1 = @CONF_LD_LINKER_OPTS_STAGE1@ conf-ld-linker-args-stage2 = @CONF_LD_LINKER_OPTS_STAGE2@ conf-ld-linker-args-stage3 = @CONF_LD_LINKER_OPTS_STAGE3@ -conf-merge-objects-args-stage0 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage1 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage2 = @SettingsMergeObjectsFlags@ -conf-merge-objects-args-stage3 = @SettingsMergeObjectsFlags@ +conf-merge-objects-args-stage0 = @MergeObjsArgs@ +conf-merge-objects-args-stage1 = @MergeObjsArgs@ +conf-merge-objects-args-stage2 = @MergeObjsArgs@ +conf-merge-objects-args-stage3 = @MergeObjsArgs@ # Settings: @@ -147,6 +148,8 @@ settings-merge-objects-command = @SettingsMergeObjectsCommand@ settings-merge-objects-flags = @SettingsMergeObjectsFlags@ settings-ar-command = @SettingsArCommand@ settings-ranlib-command = @SettingsRanlibCommand@ +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ settings-libtool-command = @SettingsLibtoolCommand@ ===================================== hadrian/src/Builder.hs ===================================== @@ -313,7 +313,7 @@ systemBuilderPath builder = case builder of Happy -> fromKey "happy" HsCpp -> fromKey "hs-cpp" Ld _ -> fromKey "ld" - MergeObjects _ -> fromKey "settings-merge-objects-command" + MergeObjects _ -> fromKey "merge-objects" Make _ -> fromKey "make" Makeinfo -> fromKey "makeinfo" Nm -> fromKey "nm" ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -113,6 +113,8 @@ data SettingsFileSetting | SettingsFileSetting_MergeObjectsFlags | SettingsFileSetting_ArCommand | SettingsFileSetting_RanlibCommand + | SettingsFileSetting_OtoolCommand + | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand | SettingsFileSetting_LibtoolCommand @@ -198,6 +200,8 @@ settingsFileSetting key = lookupValueOrError configFile $ case key of SettingsFileSetting_MergeObjectsFlags -> "settings-merge-objects-flags" SettingsFileSetting_ArCommand -> "settings-ar-command" SettingsFileSetting_RanlibCommand -> "settings-ranlib-command" + SettingsFileSetting_OtoolCommand -> "settings-otool-command" + SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" SettingsFileSetting_LibtoolCommand -> "settings-libtool-command" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -294,6 +294,8 @@ generateSettings = do , ("ar flags", expr $ lookupValueOrError configFile "ar-args") , ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile) , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) + , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) + , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) ===================================== includes/ghc.mk ===================================== @@ -228,6 +228,8 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/. @echo ',("ar flags", "$(ArArgs)")' >> $@ @echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@ @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ + @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ + @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ ===================================== libraries/text ===================================== @@ -1 +1 @@ -Subproject commit c6768a2a07e94b8b26d0f0e53517773de1110ce2 +Subproject commit e07c14940c25f33fe5b282912d745d3a79dd4ade ===================================== mk/config.mk.in ===================================== @@ -515,6 +515,8 @@ SettingsLdFlags = @SettingsLdFlags@ SettingsMergeObjectsCommand = @SettingsMergeObjectsCommand@ SettingsMergeObjectsFlags = @SettingsMergeObjectsFlags@ SettingsArCommand = @SettingsArCommand@ +SettingsOtoolCommand = @SettingsOtoolCommand@ +SettingsInstallNameToolCommand = @SettingsInstallNameToolCommand@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ @@ -556,6 +558,16 @@ LD_STAGE1 = $(LD) LD_STAGE2 = $(LD) LD_STAGE3 = $(LD) +MERGE_OBJS_STAGE0 = @MergeObjsCmd@ +MERGE_OBJS_STAGE1 = @MergeObjsCmd@ +MERGE_OBJS_STAGE2 = @MergeObjsCmd@ +MERGE_OBJS_STAGE3 = @MergeObjsCmd@ + +MERGE_OBJS_STAGE0_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE1_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE2_FLAGS = @MergeObjsArgs@ +MERGE_OBJS_STAGE3_FLAGS = @MergeObjsArgs@ + # Cross-compiling options # See Note [CrossCompiling vs Stage1Only] CrossCompiling = @CrossCompiling@ ===================================== rts/Linker.c ===================================== @@ -1371,23 +1371,6 @@ void freeObjectCode (ObjectCode *oc) stgFree(oc); } -/* ----------------------------------------------------------------------------- -* Sets the initial status of a fresh ObjectCode -*/ -static void setOcInitialStatus(ObjectCode* oc) { - /* If a target has requested the ObjectCode not to be resolved then - honor this requests. Usually this means the ObjectCode has not been - initialized and can't be. */ - if (oc->status == OBJECT_DONT_RESOLVE) - return; - - if (oc->archiveMemberName == NULL) { - oc->status = OBJECT_NEEDED; - } else { - oc->status = OBJECT_LOADED; - } -} - ObjectCode* mkOc( pathchar *path, char *image, int imageSize, bool mapped, char *archiveMemberName, int misalignment ) { @@ -1420,7 +1403,11 @@ mkOc( pathchar *path, char *image, int imageSize, oc->archiveMemberName = NULL; } - setOcInitialStatus( oc ); + if (oc->archiveMemberName == NULL) { + oc->status = OBJECT_NEEDED; + } else { + oc->status = OBJECT_LOADED; + } oc->fileSize = imageSize; oc->symbols = NULL; @@ -1711,8 +1698,17 @@ HsInt loadOc (ObjectCode* oc) # endif #endif - /* loaded, but not resolved yet, ensure the OC is in a consistent state */ - setOcInitialStatus( oc ); + /* Loaded, but not resolved yet, ensure the OC is in a consistent state. + If a target has requested the ObjectCode not to be resolved then honor + this requests. Usually this means the ObjectCode has not been initialized + and can't be. */ + if (oc->status != OBJECT_DONT_RESOLVE) { + if (oc->archiveMemberName == NULL) { + oc->status = OBJECT_NEEDED; + } else { + oc->status = OBJECT_LOADED; + } + } IF_DEBUG(linker, debugBelch("loadOc: done.\n")); return 1; ===================================== rules/build-package-way.mk ===================================== @@ -107,6 +107,7 @@ endif endif # Build the GHCi library +# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline. ifneq "$(filter $3, v p)" "" $1_$2_$3_GHCI_LIB = $1/$2/build/HS$$($1_$2_COMPONENT_ID).$$($3_osuf) ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" @@ -116,7 +117,7 @@ BINDIST_LIBS += $$($1_$2_$3_GHCI_LIB) endif endif $$($1_$2_$3_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT) - $$(call cmd,SettingsMergeObjectsCommand) $(SettingsMergeObjectsFlags) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) + $$(call cmd,MERGE_OBJS_STAGE$4) $(MERGE_OBJS_STAGE$4_FLAGS) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES" # Don't bother making ghci libs for bootstrapping packages ifneq "$4" "0" ===================================== testsuite/tests/rts/all.T ===================================== @@ -403,7 +403,7 @@ test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp - test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', - [when(opsys('darwin') or opsys('mingw32'), expect_broken(17447)), + [when(opsys('mingw32'), expect_broken(17447)), extra_files(['T13676.hs'])], ghci_script, ['T13676.script']) ===================================== utils/ghc-cabal/ghc.mk ===================================== @@ -23,9 +23,9 @@ CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)" # macros is triggered by `-hide-all-packages`, so we have to explicitly # enumerate all packages we need in scope. ifeq "$(Windows_Host)" "YES" -CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory filepath Win32 +CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory filepath Win32 template-haskell else -CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory filepath unix +CABAL_BUILD_DEPS := ghc-prim base array transformers time containers bytestring deepseq process pretty directory filepath unix template-haskell endif ghc-cabal_DIST_BINARY_NAME = ghc-cabal$(exeext0) @@ -75,7 +75,7 @@ $(ghc-cabal_DIST_BINARY): $(CABAL_LEXER_DEP) utils/ghc-cabal/Main.hs $(TOUCH_DEP -ilibraries/filepath \ -ilibraries/hpc \ -ilibraries/mtl \ - -ilibraries/text \ + -ilibraries/text/src \ libraries/text/cbits/cbits.c \ -Ilibraries/text/include \ -ilibraries/parsec/src \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e2c9625a82516f4fcd516218f782d7007357aa77...43f970499d053098d1928ce3921176192ec07d7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e2c9625a82516f4fcd516218f782d7007357aa77...43f970499d053098d1928ce3921176192ec07d7a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 18:11:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 14:11:00 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-9.0 Message-ID: <5f873f348289e_28003fd388b5329027335@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backports-9.0 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 18:11:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 14:11:04 -0400 Subject: [Git][ghc/ghc][ghc-9.0] 4 commits: Care with implicit-parameter superclasses Message-ID: <5f873f38c519a_28003fd3e87c0b40273587@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: 7e257575 by Simon Peyton Jones at 2020-10-13T23:35:26+02:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. (cherry picked from commit c7182a5c67fe8b5bd256cb8eb805562636853ea2) - - - - - 9060a9dd by Ben Gamari at 2020-10-13T23:36:56+02:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. (cherry picked from commit 9657f6f34a1a00008a0db935dbf25733cb483cd4) - - - - - fb5eb8ab by Simon Peyton Jones at 2020-10-13T23:37:29+02:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. (cherry picked from commit bfdccac6acce84e15292a454d12f4e0d87ef6f10) - - - - - 64ab97bf by Krzysztof Gogolewski at 2020-10-13T23:39:06+02:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. (cherry picked from commit fd302e938ebf48c73d9f715d67ce8cd990f972ff) - - - - - 26 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/Tc/Utils/TcType.hs - ghc.mk - + testsuite/tests/indexed-types/should_compile/T18809.hs - testsuite/tests/indexed-types/should_compile/all.T - + testsuite/tests/simplCore/should_compile/T18649.hs - + testsuite/tests/simplCore/should_compile/T18649.stderr - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/typecheck/should_run/T18627.hs - + testsuite/tests/typecheck/should_run/T18627.stdout - testsuite/tests/typecheck/should_run/all.T Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -41,6 +41,7 @@ module GHC.Core.Coercion ( downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, mkKindCo, castCoercionKind, castCoercionKindI, + mkFamilyTyConAppCo, mkHeteroCoercionType, mkPrimEqPred, mkReprPrimEqPred, mkPrimEqPredRole, @@ -1505,6 +1506,27 @@ castCoercionKindI g h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) where (Pair t1 t2, r) = coercionKindRole g +mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN +-- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the +-- corresponding family 'Coercion'. E.g: +-- +-- > data family T a +-- > data instance T (Maybe b) = MkT b +-- +-- Where the instance 'TyCon' is :RTL, so: +-- +-- > mkFamilyTyConAppCo :RTL (co :: a ~# Int) = T (Maybe a) ~# T (Maybe Int) +-- +-- cf. 'mkFamilyTyConApp' +mkFamilyTyConAppCo tc cos + | Just (fam_tc, fam_tys) <- tyConFamInst_maybe tc + , let tvs = tyConTyVars tc + fam_cos = ASSERT2( tvs `equalLength` cos, ppr tc <+> ppr cos ) + map (liftCoSubstWith Nominal tvs cos) fam_tys + = mkTyConAppCo Nominal fam_tc fam_cos + | otherwise + = mkTyConAppCo Nominal tc cos + -- See note [Newtype coercions] in GHC.Core.TyCon mkPiCos :: Role -> [Var] -> Coercion -> Coercion ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -580,6 +580,7 @@ variables: purposes of TypeApplications, and as a consequence, they do not come equipped with visibilities (that is, they are TyVars/TyCoVars instead of TyCoVarBinders). + * dcUserTyVarBinders, for the type variables binders in the order in which they originally arose in the user-written type signature. Their order *does* matter for TypeApplications, so they are full TyVarBinders, complete with @@ -600,10 +601,10 @@ dcExTyCoVars. That is, the tyvars in dcUserTyVarBinders are a permutation of ordering, they in fact share the same type variables (with the same Uniques). We sometimes refer to this as "the dcUserTyVarBinders invariant". -dcUserTyVarBinders, as the name suggests, is the one that users will see most of -the time. It's used when computing the type signature of a data constructor (see -dataConWrapperType), and as a result, it's what matters from a TypeApplications -perspective. +dcUserTyVarBinders, as the name suggests, is the one that users will +see most of the time. It's used when computing the type signature of a +data constructor wrapper (see dataConWrapperType), and as a result, +it's what matters from a TypeApplications perspective. Note [The dcEqSpec domain invariant] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -2508,9 +2508,12 @@ mkCallUDs' env f args -- we decide on a case by case basis if we want to specialise -- on this argument; if so, SpecDict, if not UnspecArg mk_spec_arg arg (Anon InvisArg pred) - | type_determines_value (scaledThing pred) - , interestingDict env arg -- Note [Interesting dictionary arguments] + | not (isIPLikePred (scaledThing pred)) + -- See Note [Type determines value] + , interestingDict env arg + -- See Note [Interesting dictionary arguments] = SpecDict arg + | otherwise = UnspecArg mk_spec_arg _ (Anon VisArg _) @@ -2523,41 +2526,18 @@ mkCallUDs' env f args -- in specImports -- Use 'realIdUnfolding' to ignore the loop-breaker flag! - type_determines_value pred -- See Note [Type determines value] - = case classifyPredType pred of - ClassPred cls _ -> not (isIPClass cls) -- Superclasses can't be IPs - EqPred {} -> True - IrredPred {} -> True -- Things like (D []) where D is a - -- Constraint-ranged family; #7785 - ForAllPred {} -> True - -{- -Note [Type determines value] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Only specialise on non-IP *class* params, because these are the ones -whose *type* determines their *value*. In particular, with implicit -params, the type args *don't* say what the value of the implicit param -is! See #7101. +{- Note [Type determines value] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Only specialise on non-impicit-parameter predicates, because these +are the ones whose *type* determines their *value*. In particular, +with implicit params, the type args *don't* say what the value of the +implicit param is! See #7101. So we treat implicit params just like ordinary arguments for the purposes of specialisation. Note that we still want to specialise functions with implicit params if they have *other* dicts which are class params; see #17930. -One apparent additional complexity involves type families. For -example, consider - type family D (v::*->*) :: Constraint - type instance D [] = () - f :: D v => v Char -> Int -If we see a call (f "foo"), we'll pass a "dictionary" - () |> (g :: () ~ D []) -and it's good to specialise f at this dictionary. - -So the question is: can an implicit parameter "hide inside" a -type-family constraint like (D a). Well, no. We don't allow - type instance D Maybe = ?x:Int -Hence the IrredPred case in type_determines_value. See #7785. - Note [Interesting dictionary arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider this ===================================== compiler/GHC/Core/Predicate.hs ===================================== @@ -20,9 +20,10 @@ module GHC.Core.Predicate ( mkClassPred, isDictTy, isClassPred, isEqPredClass, isCTupleClass, getClassPredTys, getClassPredTys_maybe, + classMethodTy, classMethodInstTy, -- Implicit parameters - isIPPred, isIPPred_maybe, isIPTyCon, isIPClass, hasIPPred, + isIPLikePred, hasIPSuperClasses, isIPTyCon, isIPClass, -- Evidence variables DictId, isEvVar, isDictId @@ -38,12 +39,10 @@ import GHC.Core.Coercion import GHC.Builtin.Names -import GHC.Data.FastString import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Core.Multiplicity ( scaledThing ) -import Control.Monad ( guard ) -- | A predicate in the solver. The solver tries to prove Wanted predicates -- from Given ones. @@ -94,6 +93,26 @@ getClassPredTys_maybe ty = case splitTyConApp_maybe ty of Just (tc, tys) | Just clas <- tyConClass_maybe tc -> Just (clas, tys) _ -> Nothing +classMethodTy :: Id -> Type +-- Takes a class selector op :: forall a. C a => meth_ty +-- and returns the type of its method, meth_ty +-- The selector can be a superclass selector, in which case +-- you get back a superclass +classMethodTy sel_id + = funResultTy $ -- meth_ty + dropForAlls $ -- C a => meth_ty + varType sel_id -- forall a. C n => meth_ty + +classMethodInstTy :: Id -> [Type] -> Type +-- Takes a class selector op :: forall a b. C a b => meth_ty +-- and the types [ty1, ty2] at which it is instantiated, +-- returns the instantiated type of its method, meth_ty[t1/a,t2/b] +-- The selector can be a superclass selector, in which case +-- you get back a superclass +classMethodInstTy sel_id arg_tys + = funResultTy $ + piResultTys (varType sel_id) arg_tys + -- --------------------- Equality predicates --------------------------------- -- | A choice of equality relation. This is separate from the type 'Role' @@ -169,7 +188,7 @@ isEqPredClass :: Class -> Bool isEqPredClass cls = cls `hasKey` eqTyConKey || cls `hasKey` heqTyConKey -isClassPred, isEqPred, isEqPrimPred, isIPPred :: PredType -> Bool +isClassPred, isEqPred, isEqPrimPred :: PredType -> Bool isClassPred ty = case tyConAppTyCon_maybe ty of Just tyCon | isClassTyCon tyCon -> True _ -> False @@ -185,9 +204,15 @@ isEqPred ty -- True of (a ~ b) and (a ~~ b) isEqPrimPred ty = isCoVarType ty -- True of (a ~# b) (a ~R# b) -isIPPred ty = case tyConAppTyCon_maybe ty of - Just tc -> isIPTyCon tc - _ -> False +isCTupleClass :: Class -> Bool +isCTupleClass cls = isTupleTyCon (classTyCon cls) + + +{- ********************************************************************* +* * + Implicit parameters +* * +********************************************************************* -} isIPTyCon :: TyCon -> Bool isIPTyCon tc = tc `hasKey` ipClassKey @@ -196,31 +221,103 @@ isIPTyCon tc = tc `hasKey` ipClassKey isIPClass :: Class -> Bool isIPClass cls = cls `hasKey` ipClassKey -isCTupleClass :: Class -> Bool -isCTupleClass cls = isTupleTyCon (classTyCon cls) +isIPLikePred :: Type -> Bool +-- See Note [Local implicit parameters] +isIPLikePred = is_ip_like_pred initIPRecTc -isIPPred_maybe :: Type -> Maybe (FastString, Type) -isIPPred_maybe ty = - do (tc,[t1,t2]) <- splitTyConApp_maybe ty - guard (isIPTyCon tc) - x <- isStrLitTy t1 - return (x,t2) - -hasIPPred :: PredType -> Bool -hasIPPred pred - = case classifyPredType pred of - ClassPred cls tys - | isIPClass cls -> True - | isCTupleClass cls -> any hasIPPred tys - _other -> False -{- -************************************************************************ +is_ip_like_pred :: RecTcChecker -> Type -> Bool +is_ip_like_pred rec_clss ty + | Just (tc, tys) <- splitTyConApp_maybe ty + , Just rec_clss' <- if isTupleTyCon tc -- Tuples never cause recursion + then Just rec_clss + else checkRecTc rec_clss tc + , Just cls <- tyConClass_maybe tc + = isIPClass cls || has_ip_super_classes rec_clss' cls tys + + | otherwise + = False -- Includes things like (D []) where D is + -- a Constraint-ranged family; #7785 + +hasIPSuperClasses :: Class -> [Type] -> Bool +-- See Note [Local implicit parameters] +hasIPSuperClasses = has_ip_super_classes initIPRecTc + +has_ip_super_classes :: RecTcChecker -> Class -> [Type] -> Bool +has_ip_super_classes rec_clss cls tys + = any ip_ish (classSCSelIds cls) + where + -- Check that the type of a superclass determines its value + -- sc_sel_id :: forall a b. C a b -> + ip_ish sc_sel_id = is_ip_like_pred rec_clss $ + classMethodInstTy sc_sel_id tys + +initIPRecTc :: RecTcChecker +initIPRecTc = setRecTcMaxBound 1 initRecTc + +{- Note [Local implicit parameters] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The function isIPLikePred tells if this predicate, or any of its +superclasses, is an implicit parameter. + +Why are implicit parameters special? Unlike normal classes, we can +have local instances for implicit parameters, in the form of + let ?x = True in ... +So in various places we must be careful not to assume that any value +of the right type will do; we must carefully look for the innermost binding. +So isIPLikePred checks whether this is an implicit parameter, or has +a superclass that is an implicit parameter. + +Several wrinkles + +* We must be careful with superclasses, as #18649 showed. Haskell + doesn't allow an implicit parameter as a superclass + class (?x::a) => C a where ... + but with a constraint tuple we might have + (% Eq a, ?x::Int %) + and /its/ superclasses, namely (Eq a) and (?x::Int), /do/ include an + implicit parameter. + + With ConstraintKinds this can apply to /any/ class, e.g. + class sc => C sc where ... + Then (C (?x::Int)) has (?x::Int) as a superclass. So we must + instantiate and check each superclass, one by one, in + hasIPSuperClasses. + +* With -XRecursiveSuperClasses, the superclass hunt can go on forever, + so we need a RecTcChecker to cut it off. + +* Another apparent additional complexity involves type families. For + example, consider + type family D (v::*->*) :: Constraint + type instance D [] = () + f :: D v => v Char -> Int + If we see a call (f "foo"), we'll pass a "dictionary" + () |> (g :: () ~ D []) + and it's good to specialise f at this dictionary. + +So the question is: can an implicit parameter "hide inside" a +type-family constraint like (D a). Well, no. We don't allow + type instance D Maybe = ?x:Int +Hence the umbrella 'otherwise' case in is_ip_like_pred. See #7785. + +Small worries (Sept 20): +* I don't see what stops us having that 'type instance'. Indeed I + think nothing does. +* I'm a little concerned about type variables; such a variable might + be instantiated to an implicit parameter. I don't think this + matters in the cases for which isIPLikePred is used, and it's pretty + obscure anyway. +* The superclass hunt stops when it encounters the same class again, + but in principle we could have the same class, differently instantiated, + and the second time it could have an implicit parameter +I'm going to treat these as problems for another day. They are all exotic. -} + +{- ********************************************************************* * * Evidence variables * * -************************************************************************ --} +********************************************************************* -} isEvVar :: Var -> Bool isEvVar var = isEvVarType (varType var) ===================================== compiler/GHC/Core/TyCo/Subst.hs ===================================== @@ -435,8 +435,8 @@ mkTvSubstPrs prs = zipTyEnv :: HasDebugCallStack => [TyVar] -> [Type] -> TvSubstEnv zipTyEnv tyvars tys | debugIsOn - , not (all isTyVar tyvars) - = pprPanic "zipTyEnv" (ppr tyvars <+> ppr tys) + , not (all isTyVar tyvars && (tyvars `equalLength` tys)) + = pprPanic "zipTyEnv" (ppr tyvars $$ ppr tys) | otherwise = ASSERT( all (not . isCoercionTy) tys ) mkVarEnv (zipEqual "zipTyEnv" tyvars tys) ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2360,6 +2360,8 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lo = (f,[]) } , make_ord_flag defFlag "pgmlc" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lc = (f,[]) } + , make_ord_flag defFlag "pgmlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lm = (f,[]) } , make_ord_flag defFlag "pgmi" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_i = f } , make_ord_flag defFlag "pgmL" @@ -2396,6 +2398,8 @@ dynamic_flags_deps = [ -- need to appear before -optl/-opta to be parsed as LLVM flags. + , make_ord_flag defFlag "optlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lm = f : toolSettings_opt_lm s } , make_ord_flag defFlag "optlo" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lo = f : toolSettings_opt_lo s } , make_ord_flag defFlag "optlc" ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -574,8 +574,9 @@ data RecordUpdTc = RecordUpdTc , rupd_in_tys :: [Type] -- Argument types of *input* record type , rupd_out_tys :: [Type] -- and *output* record type - -- The original type can be reconstructed - -- with conLikeResTy + -- For a data family, these are the type args of the + -- /representation/ type constructor + , rupd_wrap :: HsWrapper -- See note [Record Update HsWrapper] } ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Tc.Types.Evidence import GHC.Tc.Utils.Monad import GHC.Core.Type import GHC.Core.Multiplicity +import GHC.Core.Coercion( Coercion ) import GHC.Core import GHC.Core.Utils import GHC.Core.Make @@ -54,6 +55,7 @@ import GHC.Driver.Session import GHC.Types.CostCentre import GHC.Types.Id import GHC.Types.Id.Make +import GHC.Types.Var.Env import GHC.Unit.Module import GHC.Core.ConLike import GHC.Core.DataCon @@ -62,13 +64,11 @@ import GHC.Builtin.Types import GHC.Builtin.Names import GHC.Types.Basic import GHC.Data.Maybe -import GHC.Types.Var.Env import GHC.Types.SrcLoc import GHC.Utils.Misc import GHC.Data.Bag import GHC.Utils.Outputable as Outputable import GHC.Core.PatSyn - import Control.Monad import Data.List.NonEmpty ( nonEmpty ) @@ -614,13 +614,70 @@ Note [Update for GADTs] ~~~~~~~~~~~~~~~~~~~~~~~ Consider data T a b where - T1 :: { f1 :: a } -> T a Int + MkT :: { foo :: a } -> T a Int + + upd :: T s t -> s -> T s t + upd z y = z { foo = y} + +We need to get this: + $WMkT :: a -> T a Int + MkT :: (b ~# Int) => a -> T a b + + upd = /\s t. \(z::T s t) (y::s) -> + case z of + MkT (co :: t ~# Int) _ -> $WMkT @s y |> T (Refl s) (Sym co) -Then the wrapper function for T1 has type - $WT1 :: a -> T a Int -But if x::T a b, then - x { f1 = v } :: T a b (not T a Int!) -So we need to cast (T a Int) to (T a b). Sigh. +Note the final cast + T (Refl s) (Sym co) :: T s Int ~ T s t +which uses co, bound by the GADT match. This is the wrap_co coercion +in wrapped_rhs. How do we produce it? + +* Start with raw materials + tc, the tycon: T + univ_tvs, the universally quantified tyvars of MkT: a,b + NB: these are in 1-1 correspondence with the tyvars of tc + +* Form univ_cos, a coercion for each of tc's args: (Refl s) (Sym co) + We replaced + a by (Refl s) since 's' instantiates 'a' + b by (Sym co) since 'b' is in the data-con's EqSpec + +* Then form the coercion T (Refl s) (Sym co) + +It gets more complicated when data families are involved (#18809). +Consider + data family F x + data instance F (a,b) where + MkF :: { foo :: Int } -> F (Int,b) + + bar :: F (s,t) -> Int -> F (s,t) + bar z y = z { foo = y} + +We have + data R:FPair a b where + MkF :: { foo :: Int } -> R:FPair Int b + + $WMkF :: Int -> F (Int,b) + MkF :: forall a b. (a ~# Int) => Int -> R:FPair a b + + bar :: F (s,t) -> Int -> F (s,t) + bar = /\s t. \(z::F (s,t)) \(y::Int) -> + case z |> co1 of + MkF (co2::s ~# Int) _ -> $WMkF @t y |> co3 + +(Side note: here (z |> co1) is built by typechecking the scrutinee, so +we ignore it here. In general the scrutinee is an aribtrary expression.) + +The question is: what is co3, the cast for the RHS? + co3 :: F (Int,t) ~ F (s,t) +Again, we can construct it using co2, bound by the GADT match. +We do /exactly/ the same as the non-family case up to building +univ_cos. But that gives us + rep_tc: R:FPair + univ_cos: (Sym co2) (Refl t) +But then we use mkTcFamilyTyConAppCo to "lift" this to the coercion +we want, namely + F (Sym co2, Refl t) :: F (Int,t) ~ F (s,t) -} @@ -707,8 +764,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields dict_req_wrap <.> mkWpTyApps [ lookupTyVar out_subst tv `orElse` mkTyVarTy tv - | tv <- user_tvs - , not (tv `elemVarEnv` wrap_subst) ] + | tv <- user_tvs ] -- Be sure to use user_tvs (which may be ordered -- differently than `univ_tvs ++ ex_tvs) above. -- See Note [DataCon user type variable binders] @@ -719,27 +775,30 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields -- Note [Update for GADTs] wrapped_rhs = case con of - RealDataCon data_con -> - let - wrap_co = - mkTcTyConAppCo Nominal - (dataConTyCon data_con) - [ lookup tv ty - | (tv,ty) <- univ_tvs `zip` out_inst_tys ] - lookup univ_tv ty = - case lookupVarEnv wrap_subst univ_tv of - Just co' -> co' - Nothing -> mkTcReflCo Nominal ty - in if null eq_spec - then rhs - else mkLHsWrap (mkWpCastN wrap_co) rhs + RealDataCon data_con + | null eq_spec -> rhs + | otherwise -> mkLHsWrap (mkWpCastN wrap_co) rhs + -- This wrap is the punchline: Note [Update for GADTs] + where + rep_tc = dataConTyCon data_con + wrap_co = mkTcFamilyTyConAppCo rep_tc univ_cos + univ_cos = zipWithEqual "dsExpr:upd" mk_univ_co univ_tvs out_inst_tys + + mk_univ_co :: TyVar -- Universal tyvar from the DataCon + -> Type -- Corresponding instantiating type + -> Coercion + mk_univ_co univ_tv inst_ty + = case lookupVarEnv eq_spec_env univ_tv of + Just co -> co + Nothing -> mkTcNomReflCo inst_ty + + eq_spec_env :: VarEnv Coercion + eq_spec_env = mkVarEnv [ (eqSpecTyVar spec, mkTcSymCo (mkTcCoVarCo eqs_var)) + | (spec,eqs_var) <- zipEqual "dsExpr:upd2" eq_spec eqs_vars ] + -- eq_spec is always null for a PatSynCon PatSynCon _ -> rhs - wrap_subst = - mkVarEnv [ (tv, mkTcSymCo (mkTcCoVarCo eq_var)) - | (spec, eq_var) <- eq_spec `zip` eqs_vars - , let tv = eqSpecTyVar spec ] req_wrap = dict_req_wrap <.> mkWpTyApps in_inst_tys ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -387,10 +387,9 @@ makeLitDict clas ty et | Just (_, co_dict) <- tcInstNewTyCon_maybe (classTyCon clas) [ty] -- co_dict :: KnownNat n ~ SNat n , [ meth ] <- classMethods clas - , Just tcRep <- tyConAppTyCon_maybe -- SNat - $ funResultTy -- SNat n - $ dropForAlls -- KnownNat n => SNat n - $ idType meth -- forall n. KnownNat n => SNat n + , Just tcRep <- tyConAppTyCon_maybe (classMethodTy meth) + -- If the method type is forall n. KnownNat n => SNat n + -- then tcRep is SNat , Just (_, co_rep) <- tcInstNewTyCon_maybe tcRep [ty] -- SNat n ~ Integer , let ev_tm = mkEvCast et (mkTcSymCo (mkTcTransCo co_dict co_rep)) ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -65,9 +65,10 @@ import GHC.Builtin.Types ( unitTy, mkListTy ) import GHC.Driver.Plugins import GHC.Driver.Session import GHC.Hs -import GHC.Iface.Syntax ( ShowSub(..), showToHeader ) -import GHC.Iface.Type ( ShowForAllFlag(..) ) -import GHC.Core.PatSyn( pprPatSynType ) +import GHC.Iface.Syntax ( ShowSub(..), showToHeader ) +import GHC.Iface.Type ( ShowForAllFlag(..) ) +import GHC.Core.PatSyn ( pprPatSynType ) +import GHC.Core.Predicate ( classMethodTy ) import GHC.Builtin.Names import GHC.Builtin.Utils import GHC.Types.Name.Reader @@ -1014,10 +1015,8 @@ checkBootTyCon is_boot tc1 tc2 name2 = idName id2 pname1 = quotes (ppr name1) pname2 = quotes (ppr name2) - (_, rho_ty1) = splitForAllTys (idType id1) - op_ty1 = funResultTy rho_ty1 - (_, rho_ty2) = splitForAllTys (idType id2) - op_ty2 = funResultTy rho_ty2 + op_ty1 = classMethodTy id1 + op_ty2 = classMethodTy id2 eqAT (ATI tc1 def_ats1) (ATI tc2 def_ats2) = checkBootTyCon is_boot tc1 tc2 `andThenCheck` ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -1376,7 +1376,7 @@ growThetaTyVars theta tcvs | otherwise = transCloVarSet mk_next seed_tcvs where seed_tcvs = tcvs `unionVarSet` tyCoVarsOfTypes ips - (ips, non_ips) = partition isIPPred theta + (ips, non_ips) = partition isIPLikePred theta -- See Note [Inheriting implicit parameters] in GHC.Tc.Utils.TcType mk_next :: VarSet -> VarSet -- Maps current set to newly-grown ones ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -29,7 +29,7 @@ import GHC.Core.Multiplicity import GHC.Core.TyCo.Rep -- cleverly decomposes types, good for completeness checking import GHC.Core.Coercion import GHC.Core -import GHC.Types.Id( idType, mkTemplateLocals ) +import GHC.Types.Id( mkTemplateLocals ) import GHC.Core.FamInstEnv ( FamInstEnvs ) import GHC.Tc.Instance.Family ( tcTopNormaliseNewTypeTF_maybe ) import GHC.Types.Var @@ -541,7 +541,7 @@ mk_strict_superclasses rec_clss (CtGiven { ctev_evar = evar, ctev_loc = loc }) mk_given_desc sel_id sc_pred ; mk_superclasses rec_clss given_ev tvs theta sc_pred } where - sc_pred = funResultTy (piResultTys (idType sel_id) tys) + sc_pred = classMethodInstTy sel_id tys -- See Note [Nested quantified constraint superclasses] mk_given_desc :: Id -> PredType -> (PredType, EvTerm) ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -565,10 +565,10 @@ solveOneFromTheOther ev_i ev_w ev_id_w = ctEvEvId ev_w different_level_strategy -- Both Given - | isIPPred pred = if lvl_w > lvl_i then KeepWork else KeepInert - | otherwise = if lvl_w > lvl_i then KeepInert else KeepWork + | isIPLikePred pred = if lvl_w > lvl_i then KeepWork else KeepInert + | otherwise = if lvl_w > lvl_i then KeepInert else KeepWork -- See Note [Replacement vs keeping] (the different-level bullet) - -- For the isIPPred case see Note [Shadowing of Implicit Parameters] + -- For the isIPLikePred case see Note [Shadowing of Implicit Parameters] same_level_strategy binds -- Both Given | GivenOrigin (InstSC s_i) <- ctLocOrigin loc_i @@ -1070,6 +1070,8 @@ shortCutSolver dflags ev_w ev_i -- programs should typecheck regardless of whether we take this step or -- not. See Note [Shortcut solving] + && not (isIPLikePred (ctEvPred ev_w)) -- Not for implicit parameters (#18627) + && not (xopt LangExt.IncoherentInstances dflags) -- If IncoherentInstances is on then we cannot rely on coherence of proofs -- in order to justify this optimization: The proof provided by the @@ -1078,6 +1080,7 @@ shortCutSolver dflags ev_w ev_i && gopt Opt_SolveConstantDicts dflags -- Enabled by the -fsolve-constant-dicts flag + = do { ev_binds_var <- getTcEvBindsVar ; ev_binds <- ASSERT2( not (isCoEvBindsVar ev_binds_var ), ppr ev_w ) getTcEvBindsMap ev_binds_var ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -2526,8 +2526,7 @@ emptyDictMap = emptyTcAppMap findDict :: DictMap a -> CtLoc -> Class -> [Type] -> Maybe a findDict m loc cls tys - | isCTupleClass cls - , any hasIPPred tys -- See Note [Tuples hiding implicit parameters] + | hasIPSuperClasses cls tys -- See Note [Tuples hiding implicit parameters] = Nothing | Just {} <- isCallStackPred cls tys ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -53,6 +53,7 @@ import GHC.Core ( Expr(..), mkApps, mkVarApps, mkLams ) import GHC.Core.Make ( nO_METHOD_BINDING_ERROR_ID ) import GHC.Core.Unfold ( mkInlineUnfoldingWithArity, mkDFunUnfolding ) import GHC.Core.Type +import GHC.Core.Predicate( classMethodInstTy ) import GHC.Tc.Types.Evidence import GHC.Core.TyCon import GHC.Core.Coercion.Axiom @@ -1631,7 +1632,7 @@ tcMethods dfun_id clas tyvars dfun_ev_vars inst_tys nO_METHOD_BINDING_ERROR_ID error_msg dflags = L inst_loc (HsLit noExtField (HsStringPrim NoSourceText (unsafeMkByteString (error_string dflags)))) - meth_tau = funResultTy (piResultTys (idType sel_id) inst_tys) + meth_tau = classMethodInstTy sel_id inst_tys error_string dflags = showSDoc dflags (hcat [ppr inst_loc, vbar, ppr sel_id ]) lam_wrapper = mkWpTyLams tyvars <.> mkWpLams dfun_ev_vars ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -48,6 +48,7 @@ module GHC.Tc.Types.Evidence ( mkTcKindCo, tcCoercionKind, mkTcCoVarCo, + mkTcFamilyTyConAppCo, isTcReflCo, isTcReflexiveCo, tcCoercionRole, unwrapIP, wrapIP, @@ -139,6 +140,7 @@ mkTcCoherenceRightCo :: Role -> TcType -> TcCoercionN mkTcPhantomCo :: TcCoercionN -> TcType -> TcType -> TcCoercionP mkTcKindCo :: TcCoercion -> TcCoercionN mkTcCoVarCo :: CoVar -> TcCoercion +mkTcFamilyTyConAppCo :: TyCon -> [TcCoercionN] -> TcCoercionN tcCoercionKind :: TcCoercion -> Pair TcType tcCoercionRole :: TcCoercion -> Role @@ -172,6 +174,7 @@ mkTcCoherenceRightCo = mkCoherenceRightCo mkTcPhantomCo = mkPhantomCo mkTcKindCo = mkKindCo mkTcCoVarCo = mkCoVarCo +mkTcFamilyTyConAppCo = mkFamilyTyConAppCo tcCoercionKind = coercionKind tcCoercionRole = coercionRole ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -79,7 +79,7 @@ module GHC.Tc.Utils.TcType ( isFloatingTy, isDoubleTy, isFloatTy, isIntTy, isWordTy, isStringTy, isIntegerTy, isNaturalTy, isBoolTy, isUnitTy, isCharTy, isCallStackTy, isCallStackPred, - hasIPPred, isTauTy, isTauTyCon, tcIsTyVarTy, tcIsForAllTy, + isTauTy, isTauTyCon, tcIsTyVarTy, tcIsForAllTy, isPredTy, isTyVarClassPred, isTyVarHead, isInsolubleOccursCheck, checkValidClsArgs, hasTyVarHead, isRigidTy, isAlmostFunctionFree, @@ -141,7 +141,7 @@ module GHC.Tc.Utils.TcType ( mkTyConTy, mkTyVarTy, mkTyVarTys, mkTyCoVarTy, mkTyCoVarTys, - isClassPred, isEqPrimPred, isIPPred, isEqPred, isEqPredClass, + isClassPred, isEqPrimPred, isIPLikePred, isEqPred, isEqPredClass, mkClassPred, tcSplitDFunTy, tcSplitDFunHead, tcSplitMethodTy, isRuntimeRepVar, isKindLevPoly, @@ -1746,7 +1746,7 @@ pickCapturedPreds pickCapturedPreds qtvs theta = filter captured theta where - captured pred = isIPPred pred || (tyCoVarsOfType pred `intersectsVarSet` qtvs) + captured pred = isIPLikePred pred || (tyCoVarsOfType pred `intersectsVarSet` qtvs) -- Superclasses ===================================== ghc.mk ===================================== @@ -1168,7 +1168,8 @@ SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME). # Files to include in source distributions # SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \ - utils docs rts compiler ghc driver libraries libffi-tarballs + utils docs rts compiler ghc driver libraries libffi-tarballs \ + hadrian SRC_DIST_GHC_FILES += \ configure.ac config.guess config.sub configure \ aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \ @@ -1209,6 +1210,7 @@ sdist-ghc-prep-tree : cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/) + $(call removeTrees,$(SRC_DIST_GHC_DIR)/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123]) $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk) $(call removeFiles,$(SRC_DIST_GHC_DIR)/rts/rts.cabal) ===================================== testsuite/tests/indexed-types/should_compile/T18809.hs ===================================== @@ -0,0 +1,33 @@ +{-# LANGUAGE GADTs, TypeFamilies #-} + +module T18809 where + +-- Ordinary +data F2 s where + MkF2 :: { foo2 :: Int } -> F2 s + +bar2 :: F2 s -> Int -> F2 s +bar2 z y = z { foo2 = y } + +-- GADT +data F1 s where + MkF1 :: { foo1 :: Int } -> F1 Int + +bar1 :: F1 s -> Int -> F1 s +bar1 z y = z { foo1 = y } + +-- Orinary data family +data family F3 a +data instance F3 (s,t) where + MkF2b :: { foo3 :: Int } -> F3 (s,t) + +bar3 :: F3 (s,t) -> Int -> F3 (s,t) +bar3 z y = z {foo3 = y} + +-- GADT + data family +data family F4 a +data instance F4 (s,t) where + MkF2a :: { foo4 :: Int } -> F4 (Int,t) + +bar4 :: F4 (s,t) -> Int -> F4 (s,t) +bar4 z y = z { foo4 = y} ===================================== testsuite/tests/indexed-types/should_compile/all.T ===================================== @@ -296,3 +296,4 @@ test('T17056', normal, compile, ['']) test('T17405', normal, multimod_compile, ['T17405c', '-v0']) test('T17923', normal, compile, ['']) test('T18065', normal, compile, ['-O']) +test('T18809', normal, compile, ['-O']) ===================================== testsuite/tests/simplCore/should_compile/T18649.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE FlexibleContexts #-} + +module Test where + +import Prelude + +type Hidden a = + ( ?enable :: a + , Eq a -- removing this "fixes" the issue + ) + +{-# NOINLINE a #-} +a :: Hidden Bool => Integer -> Bool +a _ = ?enable + +system :: Hidden Bool => Bool +system = a 0 + +topEntity :: Bool -> Bool +topEntity ena = let ?enable = ena + in system + +someVar = let ?enable = True + in system ===================================== testsuite/tests/simplCore/should_compile/T18649.stderr ===================================== @@ -0,0 +1,4 @@ + +==================== Tidy Core rules ==================== + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -336,3 +336,6 @@ test('T18589', normal, compile, ['-dcore-lint -O']) test('T18747A', normal, compile, ['']) test('T18747B', normal, compile, ['']) + +# T18649 should /not/ generate a specialisation rule +test('T18649', normal, compile, ['-O -ddump-rules -Wno-simplifiable-class-constraints']) ===================================== testsuite/tests/typecheck/should_run/T18627.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE MultiParamTypeClasses #-} +module Main where + +import GHC.Classes + +instance IP "x" Int where + ip = 21 + +baz :: (?x :: Int) => Int +baz = ?x + +main :: IO () +main = let ?x = 42 + in print baz ===================================== testsuite/tests/typecheck/should_run/T18627.stdout ===================================== @@ -0,0 +1 @@ +42 ===================================== testsuite/tests/typecheck/should_run/all.T ===================================== @@ -146,3 +146,4 @@ test('UnliftedNewtypesDependentFamilyRun', normal, compile_and_run, ['']) test('UnliftedNewtypesIdentityRun', normal, compile_and_run, ['']) test('UnliftedNewtypesCoerceRun', normal, compile_and_run, ['']) test('T17104', normal, compile_and_run, ['']) +test('T18627', normal, compile_and_run, ['-O']) # Optimisation shows up the bug View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d09e7e41cf79fe981a61eae46a93d8881859ff1f...64ab97bfdae8ca094d677ad27aecf514e7acafd0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d09e7e41cf79fe981a61eae46a93d8881859ff1f...64ab97bfdae8ca094d677ad27aecf514e7acafd0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 18:31:39 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Wed, 14 Oct 2020 14:31:39 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f87440bb8205_28003fd40cf17708280547@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 2acc1270 by Alan Zimmerman at 2020-10-14T19:31:06+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -934,22 +934,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -964,20 +965,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See https://gitlab.haskell.org/ghc/ghc/-/issues/18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1962,10 +1966,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2621,9 +2621,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -723,10 +723,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1846,7 +1846,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -148,6 +148,7 @@ import Control.DeepSeq import Control.Monad import GHC.Tc.Errors.Hole.FitTypes ( HoleFitPluginR (..) ) +import GHC.Parser.Annotation #include "HsVersions.h" @@ -2455,7 +2456,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -74,6 +74,7 @@ import qualified GHC.Parser.Lexer as Lexer import GHC.Data.StringBuffer import GHC.Utils.Outputable +import GHC.Parser.Annotation import GHC.Runtime.Loader ( initializePlugins ) @@ -1683,7 +1684,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1752,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit fc128b4719970b741e60e6463bb14ea54fba0175 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2acc1270fecb929a5424f3ab3d772a20075ffadb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2acc1270fecb929a5424f3ab3d772a20075ffadb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 21:35:42 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 14 Oct 2020 17:35:42 -0400 Subject: [Git][ghc/ghc][wip/T16762] Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f876f2eed9aa_28003fd3ec0fcf6c2874c8@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 98fd267d by Ryan Scott at 2020-10-14T17:34:09-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 20 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98fd267d68644a2fbb5ed35ce42bb3ec038d2cf1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98fd267d68644a2fbb5ed35ce42bb3ec038d2cf1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 21:38:42 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 14 Oct 2020 17:38:42 -0400 Subject: [Git][ghc/ghc][wip/T16762] Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f876fe221c61_2800cca3aa8288186@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: ecd52cf1 by Ryan Scott at 2020-10-14T17:38:14-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 20 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecd52cf12d769d744ff70eb75bda6f8701d9e0fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ecd52cf12d769d744ff70eb75bda6f8701d9e0fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 22:06:18 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 18:06:18 -0400 Subject: [Git][ghc/ghc][master] Add -Wnoncanonical-{monad, monoid}-instances to standardWarnings Message-ID: <5f87765ac18aa_28003fd3dc788224304413@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 30 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Rename/Module.hs - docs/users_guide/9.0.1-notes.rst - testsuite/tests/codeGen/should_compile/jmp_tbl.hs - testsuite/tests/cpranal/should_compile/Cpr001_imp.hs - testsuite/tests/deriving/should_compile/drv020.hs - testsuite/tests/determinism/determ019/A.hs - testsuite/tests/gadt/gadt16.hs - testsuite/tests/gadt/nbe.hs - testsuite/tests/ghci.debugger/HappyTest.hs - testsuite/tests/ghci/scripts/T4127.script - testsuite/tests/ghci/scripts/T4127.stdout - testsuite/tests/ghci/scripts/T9293.stdout - testsuite/tests/ghci/scripts/ghci024.stdout - testsuite/tests/ghci/scripts/ghci057.stdout - testsuite/tests/mdo/should_fail/mdofail004.hs - testsuite/tests/partial-sigs/should_compile/Meltdown.hs - testsuite/tests/perf/compiler/T12425.hs - testsuite/tests/perf/compiler/T3064.hs - testsuite/tests/rebindable/rebindable9.hs - testsuite/tests/simplCore/prog002/Simpl009Help.hs - testsuite/tests/simplCore/should_compile/EvalTest.hs - testsuite/tests/simplCore/should_compile/T10176.hs - testsuite/tests/simplCore/should_compile/T3831.hs - testsuite/tests/simplCore/should_compile/T4203.hs - testsuite/tests/simplCore/should_compile/T8331.hs - testsuite/tests/typecheck/should_compile/T3955.hs - testsuite/tests/typecheck/should_compile/T4952.hs - testsuite/tests/typecheck/should_compile/Tc239_Help.hs - testsuite/tests/typecheck/should_compile/tc093.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e60ae8a38394370fd8818ad004a101466fc7d2dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e60ae8a38394370fd8818ad004a101466fc7d2dc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 22:06:55 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 18:06:55 -0400 Subject: [Git][ghc/ghc][master] Fix some missed opportunities for preInlineUnconditionally Message-ID: <5f87767f77804_28003fd3e8b1ed78307562@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 30 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Utils/Binary.hs - testsuite/tests/roles/should_compile/Roles1.stderr - testsuite/tests/roles/should_compile/Roles14.stderr - testsuite/tests/roles/should_compile/Roles2.stderr - testsuite/tests/roles/should_compile/Roles3.stderr - testsuite/tests/roles/should_compile/Roles4.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/simplCore/should_compile/Makefile - testsuite/tests/simplCore/should_compile/T13143.stderr - + testsuite/tests/simplCore/should_compile/T18815.hs - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/T7865.stdout - testsuite/tests/simplCore/should_compile/all.T - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/stranal/should_compile/T10482.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15d2340cb9dc833adb87784e6de86dba235290f7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/15d2340cb9dc833adb87784e6de86dba235290f7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 22:07:31 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 18:07:31 -0400 Subject: [Git][ghc/ghc][master] users-guide: Add missing :ghc-flag: directive Message-ID: <5f8776a3c4e41_280010e4c270310498@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 1 changed file: - docs/users_guide/phases.rst Changes: ===================================== docs/users_guide/phases.rst ===================================== @@ -850,8 +850,8 @@ for example). This flag tells GHC to link against shared Haskell libraries. This flag only affects the selection of dependent libraries, not the form - of the current target (see -shared). See :ref:`using-shared-libs` on - how to create them. + of the current target (see :ghc-flag:`-shared`). + See :ref:`using-shared-libs` on how to create them. Note that this option also has an effect on code generation (see above). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c4bfed849d454bee707fcb2989eb7c6339eaedb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c4bfed849d454bee707fcb2989eb7c6339eaedb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 22:14:45 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 14 Oct 2020 18:14:45 -0400 Subject: [Git][ghc/ghc][wip/T16762] Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f877855793f8_28003fd40db7b74c31068c@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: c56f0535 by Ryan Scott at 2020-10-14T23:13:50+01:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * TODO RGS: Describe typechecker changes Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 20 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56f05352b20d3b189a8dcbbc5d762f083e7bd0f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c56f05352b20d3b189a8dcbbc5d762f083e7bd0f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 14 22:19:43 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Wed, 14 Oct 2020 18:19:43 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f87797fb1182_2800e1753783129bf@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 94f3ef27 by Alan Zimmerman at 2020-10-14T23:19:07+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -934,22 +934,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -964,20 +965,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1962,10 +1966,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2621,9 +2621,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -723,10 +723,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1846,7 +1846,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -148,6 +148,7 @@ import Control.DeepSeq import Control.Monad import GHC.Tc.Errors.Hole.FitTypes ( HoleFitPluginR (..) ) +import GHC.Parser.Annotation #include "HsVersions.h" @@ -2455,7 +2456,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -74,6 +74,7 @@ import qualified GHC.Parser.Lexer as Lexer import GHC.Data.StringBuffer import GHC.Utils.Outputable +import GHC.Parser.Annotation import GHC.Runtime.Loader ( initializePlugins ) @@ -1683,7 +1684,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1752,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit fc128b4719970b741e60e6463bb14ea54fba0175 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94f3ef27a7e72c4eca463560619f64108de9c8d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94f3ef27a7e72c4eca463560619f64108de9c8d9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:28:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:28:51 -0400 Subject: [Git][ghc/ghc][wip/T14334] compiler/ByteCode: Allow 2^32 local labels Message-ID: <5f87a5d315879_2800fea7324325911@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T14334 at Glasgow Haskell Compiler / GHC Commits: c5b78f30 by Ben Gamari at 2020-10-14T21:28:41-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 3 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -177,7 +177,9 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (M.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) env :: LocalLabel -> Word ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -50,7 +50,8 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -newtype LocalLabel = LocalLabel { getLocalLabel :: Word16 } +-- | A local block label (e.g. identifying a case alternative). +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } deriving (Eq, Ord) instance Outputable LocalLabel where ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1966,7 +1966,7 @@ data BcM_State { bcm_hsc_env :: HscEnv , uniqSupply :: UniqSupply -- for generating fresh variable names , thisModule :: Module -- current module (for breakpoints) - , nextlabel :: Word16 -- for generating local labels + , nextlabel :: Word32 -- for generating local labels , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints @@ -2038,7 +2038,7 @@ getLabelBc panic "getLabelBc: Ran out of labels" return (st{nextlabel = nl + 1}, LocalLabel nl) -getLabelsBc :: Word16 -> BcM [LocalLabel] +getLabelsBc :: Word32 -> BcM [LocalLabel] getLabelsBc n = BcM $ \st -> let ctr = nextlabel st in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5b78f305a7707dad034954aecbc7a73e82d4362 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c5b78f305a7707dad034954aecbc7a73e82d4362 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:32:23 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:32:23 -0400 Subject: [Git][ghc/ghc][wip/T18838] testsuite: Sort metrics by metric type Message-ID: <5f87a6a7401c7_28003fd3eee472d8326687@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18838 at Glasgow Haskell Compiler / GHC Commits: 72965792 by Ben Gamari at 2020-10-14T21:32:15-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - 1 changed file: - testsuite/driver/runtests.py Changes: ===================================== testsuite/driver/runtests.py ===================================== @@ -457,7 +457,20 @@ else: if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + # Group metrics by metric type + groups = {} # type: Dict[MetricName, List[PerfMetric]] + for m in t.metrics: + if m.stat.metric not in groups: + groups[m.stat.metric] = [] + + groups[m.stat.metric].append(m) + + for metric_name, stats in groups.items(): + heading = 'Metrics: %s' % metric_name + print(heading) + print('-' * len(heading)) + print() + tabulate_metrics(stats) else: print("\nNone collected.") print("") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72965792deb4c37dbfbe1a27b6e5125077dac3ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/72965792deb4c37dbfbe1a27b6e5125077dac3ab You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:40:20 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 14 Oct 2020 21:40:20 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings Message-ID: <5f87a884ab151_28003fd3ee1914d032752b@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - d029503c by Krzysztof Gogolewski at 2020-10-14T21:40:11-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 62192308 by Sylvain Henry at 2020-10-14T21:40:15-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - fa362f10 by Ben Gamari at 2020-10-14T21:40:16-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 30 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Utils/Binary.hs - docs/users_guide/9.0.1-notes.rst - docs/users_guide/phases.rst - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Exception.hs-boot - testsuite/tests/codeGen/should_compile/jmp_tbl.hs - testsuite/tests/concurrent/should_run/conc059_c.c - testsuite/tests/cpranal/should_compile/Cpr001_imp.hs - testsuite/tests/deriving/should_compile/drv020.hs - testsuite/tests/determinism/determ019/A.hs - testsuite/tests/gadt/gadt16.hs - testsuite/tests/gadt/nbe.hs - testsuite/tests/ghci.debugger/HappyTest.hs - testsuite/tests/ghci/scripts/T4127.script - testsuite/tests/ghci/scripts/T4127.stdout The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a5fa43b90508d11cc8a4f87f91ec6b95da685a8...fa362f102215f335b98b23a45772c33363122d1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a5fa43b90508d11cc8a4f87f91ec6b95da685a8...fa362f102215f335b98b23a45772c33363122d1a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:53:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:53:50 -0400 Subject: [Git][ghc/ghc][wip/T14334] compiler/ByteCode: Allow 2^32 local labels Message-ID: <5f87abaed95bd_28003fd3e83cf964336228@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T14334 at Glasgow Haskell Compiler / GHC Commits: d52fab4c by Ben Gamari at 2020-10-14T00:58:51+00:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 3 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -177,7 +177,9 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (fromIntegral $ Map.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) env :: LocalLabel -> Word ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -50,7 +50,7 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -newtype LocalLabel = LocalLabel { getLocalLabel :: Word16 } +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } deriving (Eq, Ord) instance Outputable LocalLabel where ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1966,7 +1966,7 @@ data BcM_State { bcm_hsc_env :: HscEnv , uniqSupply :: UniqSupply -- for generating fresh variable names , thisModule :: Module -- current module (for breakpoints) - , nextlabel :: Word16 -- for generating local labels + , nextlabel :: Word32 -- for generating local labels , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints @@ -2038,7 +2038,7 @@ getLabelBc panic "getLabelBc: Ran out of labels" return (st{nextlabel = nl + 1}, LocalLabel nl) -getLabelsBc :: Word16 -> BcM [LocalLabel] +getLabelsBc :: Word32 -> BcM [LocalLabel] getLabelsBc n = BcM $ \st -> let ctr = nextlabel st in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52fab4ca043d154bc5ccd83a8ffadc4fc0a2b38 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d52fab4ca043d154bc5ccd83a8ffadc4fc0a2b38 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:54:44 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:54:44 -0400 Subject: [Git][ghc/ghc][wip/T14334] compiler/ByteCode: Allow 2^32 local labels Message-ID: <5f87abe437d1a_28003fd402823b2c336982@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T14334 at Glasgow Haskell Compiler / GHC Commits: 61222af1 by Ben Gamari at 2020-10-14T21:54:24-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 3 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -177,7 +177,9 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (fromIntegral $ Map.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) env :: LocalLabel -> Word ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -50,7 +50,8 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -newtype LocalLabel = LocalLabel { getLocalLabel :: Word16 } +-- | A local block label (e.g. identifying a case alternative). +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } deriving (Eq, Ord) instance Outputable LocalLabel where ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1966,7 +1966,7 @@ data BcM_State { bcm_hsc_env :: HscEnv , uniqSupply :: UniqSupply -- for generating fresh variable names , thisModule :: Module -- current module (for breakpoints) - , nextlabel :: Word16 -- for generating local labels + , nextlabel :: Word32 -- for generating local labels , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints @@ -2038,7 +2038,7 @@ getLabelBc panic "getLabelBc: Ran out of labels" return (st{nextlabel = nl + 1}, LocalLabel nl) -getLabelsBc :: Word16 -> BcM [LocalLabel] +getLabelsBc :: Word32 -> BcM [LocalLabel] getLabelsBc n = BcM $ \st -> let ctr = nextlabel st in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61222af1a92d896b31ed8e3c44746b9b98082615 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61222af1a92d896b31ed8e3c44746b9b98082615 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:58:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:58:27 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] 21 commits: Move File Target parser to library #18596 Message-ID: <5f87acc38228a_28003fd3ed2349ec33908d@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - baabfabf by Ben Gamari at 2020-10-14T21:58:16-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 5df8eefa by Ben Gamari at 2020-10-14T21:58:16-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - ceb6589c by Ben Gamari at 2020-10-14T21:58:16-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbfba2260c74e6f73bc40af33f6f678f7b57d7df...ceb6589cc84c7ba30332253a04b1cd1a7cfc3cb0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbfba2260c74e6f73bc40af33f6f678f7b57d7df...ceb6589cc84c7ba30332253a04b1cd1a7cfc3cb0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 01:59:53 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 14 Oct 2020 21:59:53 -0400 Subject: [Git][ghc/ghc][wip/ticky-eventlog] 680 commits: Enable large address space optimization on windows. Message-ID: <5f87ad1963c4d_28003fd3dd7a6430339630@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/ticky-eventlog at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 08a6edac by Ben Gamari at 2020-10-14T21:59:49-04:00 rts: Post ticky entry counts to the eventlog We currently only post the entry counters, not the other global counters as in my experience the former are more useful. We use the heap profiler's census period to decide when to dump. Also spruces up the documentation surrounding ticky-ticky a bit. - - - - - 23 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/test-metrics.sh - CODEOWNERS - Makefile - README.md - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Uniques.hs-boot - compiler/GHC/Builtin/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5dad91a76b2e33163a970634372ed8897af3c231...08a6edac840a66c9e12cd2320595969e95d8fd65 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5dad91a76b2e33163a970634372ed8897af3c231...08a6edac840a66c9e12cd2320595969e95d8fd65 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 03:15:39 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Wed, 14 Oct 2020 23:15:39 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] 14 commits: Move core flattening algorithm to Core.Unify Message-ID: <5f87bedb2ffd0_28003fd41a88d02834048c@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: e50008c4 by Richard Eisenberg at 2020-10-14T18:26:51-04:00 Move core flattening algorithm to Core.Unify This sets the stage for a later change, where this algorithm will be needed from GHC.Core.InstEnv. This commit also splits GHC.Core.Map into a new file GHC.Core.Map.Type, in order to avoid module import cycles with GHC.Core. - - - - - 19be54a6 by Richard Eisenberg at 2020-10-14T18:27:34-04:00 Start of work in simplifying flattening - - - - - b10ee81e by Richard Eisenberg at 2020-10-14T18:27:34-04:00 Much work toward simplifying CFunEqCan - - - - - 2b9de155 by Richard Eisenberg at 2020-10-14T18:27:34-04:00 Canonicalized function equalities. Now, onto interactions. - - - - - 27360b44 by Richard Eisenberg at 2020-10-14T18:27:34-04:00 CEqCan, and canonicalization for it - - - - - cbf44c90 by Richard Eisenberg at 2020-10-14T18:27:34-04:00 Main changes done. Now to delete code. - - - - - 149dd406 by Richard Eisenberg at 2020-10-14T18:27:35-04:00 Kill off CFunEqCan and CTyEqCan - - - - - f9a7de7a by Richard Eisenberg at 2020-10-14T18:27:35-04:00 It compiles. - - - - - a11a94e6 by Richard Eisenberg at 2020-10-14T18:27:35-04:00 Some bugfixing - - - - - c2b5da0f by Richard Eisenberg at 2020-10-14T18:27:35-04:00 Lots of bug fixing - - - - - 86a1c32a by Richard Eisenberg at 2020-10-14T18:27:36-04:00 Expand synonyms that mention families, obvs - - - - - 31e5ded7 by Richard Eisenberg at 2020-10-14T18:27:36-04:00 Super skolems are really super. - - - - - b61c0aea by Richard Eisenberg at 2020-10-14T18:27:36-04:00 Another bug bites the dust. - - - - - ea4da989 by Richard Eisenberg at 2020-10-14T23:15:10-04:00 Put variable on left only when it will unify - - - - - 20 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Map.hs - + compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/HsToCore/Monad.hs - compiler/GHC/HsToCore/Types.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Stg/CSE.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Instance/Family.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Flatten.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbdfe1b9957e3c1f83feaf10e344e21864c202f2...ea4da989370c4ac093c5bd9fc06fdabcc8941cc8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cbdfe1b9957e3c1f83feaf10e344e21864c202f2...ea4da989370c4ac093c5bd9fc06fdabcc8941cc8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 04:15:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 00:15:46 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/angerman/ghc-8.10-backport-rpath Message-ID: <5f87ccf2a4e05_28003fd3ed9c1e08352673@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/angerman/ghc-8.10-backport-rpath at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 04:15:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 00:15:49 -0400 Subject: [Git][ghc/ghc][ghc-8.10] [macOS] improved runpath handling Message-ID: <5f87ccf56e22_28003fd3ed441fa03528b@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 43f97049 by Moritz Angermann at 2020-10-14T13:51:31-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 4ff93292243888545da452ea4d4c1987f2343591) Signed-off-by: Moritz Angermann <moritz.angermann at iohk.io> - - - - - 17 changed files: - aclocal.m4 - compiler/ghci/Linker.hs - compiler/main/DriverPipeline.hs - compiler/main/DynFlags.hs - compiler/main/Settings.hs - compiler/main/SysTools.hs - compiler/main/SysTools/Settings.hs - compiler/main/SysTools/Tasks.hs - compiler/main/ToolSettings.hs - configure.ac - docs/users_guide/phases.rst - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - includes/ghc.mk - mk/config.mk.in - testsuite/tests/rts/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -586,6 +586,18 @@ AC_DEFUN([FP_SETTINGS], else SettingsOptCommand="$OptCmd" fi + if test -z "$OtoolCmd" + then + SettingsOtoolCommand="otool" + else + SettingsOtoolCommand="$OtoolCmd" + fi + if test -z "$InstallNameToolCmd" + then + SettingsInstallNameToolCommand="install_name_tool" + else + SettingsInstallNameToolCommand="$InstallNameToolCmd" + fi SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2" @@ -604,6 +616,8 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsMergeObjectsFlags) AC_SUBST(SettingsArCommand) AC_SUBST(SettingsRanlibCommand) + AC_SUBST(SettingsOtoolCommand) + AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) AC_SUBST(SettingsLibtoolCommand) ===================================== compiler/ghci/Linker.hs ===================================== @@ -913,20 +913,22 @@ dynLoadObjs hsc_env pls at PersistentLinkerState{..} objs = do ldInputs = concatMap (\l -> [ Option ("-l" ++ l) ]) (nub $ snd <$> temp_sos) - ++ concatMap (\lp -> [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp ]) + ++ concatMap (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) (nub $ fst <$> temp_sos) ++ concatMap - (\lp -> - [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp - ]) + (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) minus_big_ls -- See Note [-Xlinker -rpath vs -Wl,-rpath] ++ map (\l -> Option ("-l" ++ l)) minus_ls, ===================================== compiler/main/DriverPipeline.hs ===================================== @@ -382,7 +382,56 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- --------------------------------------------------------------------------- -- Link - +-- +-- Note [Dynamic linking on macOS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Since macOS Sierra (10.14), the dynamic system linker enforces +-- a limit on the Load Commands. Specifically the Load Command Size +-- Limit is at 32K (32768). The Load Commands contain the install +-- name, dependencies, runpaths, and a few other commands. We however +-- only have control over the install name, dependencies and runpaths. +-- +-- The install name is the name by which this library will be +-- referenced. This is such that we do not need to bake in the full +-- absolute location of the library, and can move the library around. +-- +-- The dependency commands contain the install names from of referenced +-- libraries. Thus if a libraries install name is @rpath/libHS...dylib, +-- that will end up as the dependency. +-- +-- Finally we have the runpaths, which informs the linker about the +-- directories to search for the referenced dependencies. +-- +-- The system linker can do recursive linking, however using only the +-- direct dependencies conflicts with ghc's ability to inline across +-- packages, and as such would end up with unresolved symbols. +-- +-- Thus we will pass the full dependency closure to the linker, and then +-- ask the linker to remove any unused dynamic libraries (-dead_strip_dylibs). +-- +-- We still need to add the relevant runpaths, for the dynamic linker to +-- lookup the referenced libraries though. The linker (ld64) does not +-- have any option to dead strip runpaths; which makes sense as runpaths +-- can be used for dependencies of dependencies as well. +-- +-- The solution we then take in GHC is to not pass any runpaths to the +-- linker at link time, but inject them after the linking. For this to +-- work we'll need to ask the linker to create enough space in the header +-- to add more runpaths after the linking (-headerpad 8000). +-- +-- After the library has been linked by $LD (usually ld64), we will use +-- otool to inspect the libraries left over after dead stripping, compute +-- the relevant runpaths, and inject them into the linked product using +-- the install_name_tool command. +-- +-- This strategy should produce the smallest possible set of load commands +-- while still retaining some form of relocatability via runpaths. +-- +-- The only way I can see to reduce the load command size further would be +-- by shortening the library names, or start putting libraries into the same +-- folders, such that one runpath would be sufficient for multiple/all +-- libraries. link :: GhcLink -- interactive or batch -> DynFlags -- dynamic flags -> Bool -- attempt linking in batch mode? @@ -1769,9 +1818,12 @@ linkBinary' staticLink dflags o_files dep_packages = do rc_objs <- maybeCreateManifest dflags output_fn - let link = if staticLink - then SysTools.runLibtool - else SysTools.runLink + let link dflags args | staticLink = SysTools.runLibtool dflags args + | platformOS platform == OSDarwin + = SysTools.runLink dflags args >> SysTools.runInjectRPaths dflags pkg_lib_paths output_fn + | otherwise + = SysTools.runLink dflags args + link dflags ( map SysTools.Option verbFlags ++ [ SysTools.Option "-o" @@ -1838,7 +1890,13 @@ linkBinary' staticLink dflags o_files dep_packages = do ++ pkg_link_opts ++ pkg_framework_opts ++ (if platformOS platform == OSDarwin - then [ "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the left over + -- libraries during runInjectRpaths phase. + -- + -- See Note [Dynamic linking on macOS]. + then [ "-Wl,-dead_strip_dylibs", "-Wl,-headerpad,8000" ] else []) )) ===================================== compiler/main/DynFlags.hs ===================================== @@ -155,8 +155,8 @@ module DynFlags ( versionedAppDir, versionedFilePath, extraGccViaCFlags, systemPackageConfig, pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_libtool, pgm_ar, pgm_ranlib, pgm_lo, pgm_lc, - pgm_lcc, pgm_i, + pgm_windres, pgm_libtool, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, opt_P_signature, opt_windres, opt_lo, opt_lc, opt_lcc, @@ -1463,6 +1463,10 @@ pgm_lcc :: DynFlags -> (String,[Option]) pgm_lcc dflags = toolSettings_pgm_lcc $ toolSettings dflags pgm_ar :: DynFlags -> String pgm_ar dflags = toolSettings_pgm_ar $ toolSettings dflags +pgm_otool :: DynFlags -> String +pgm_otool dflags = toolSettings_pgm_otool $ toolSettings dflags +pgm_install_name_tool :: DynFlags -> String +pgm_install_name_tool dflags = toolSettings_pgm_install_name_tool $ toolSettings dflags pgm_ranlib :: DynFlags -> String pgm_ranlib dflags = toolSettings_pgm_ranlib $ toolSettings dflags pgm_lo :: DynFlags -> (String,[Option]) @@ -3089,6 +3093,10 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_libtool = f } , make_ord_flag defFlag "pgmar" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ar = f } + , make_ord_flag defFlag "pgmotool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_otool = f} + , make_ord_flag defFlag "pgminstall_name_tool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_install_name_tool = f} , make_ord_flag defFlag "pgmranlib" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ranlib = f } @@ -4589,7 +4597,6 @@ defaultFlags settings Opt_OmitYields, Opt_PrintBindContents, Opt_ProfCountEntries, - Opt_RPath, Opt_SharedImplib, Opt_SimplPreInlining, Opt_VersionMacros @@ -4600,6 +4607,8 @@ defaultFlags settings ++ default_PIC platform + ++ default_RPath platform + ++ concatMap (wayGeneralFlags platform) (defaultWays settings) ++ validHoleFitDefaults @@ -4640,6 +4649,29 @@ default_PIC platform = -- information. _ -> [] + +-- We usually want to use RPath, except on macOS (OSDarwin). On recent macOS +-- versions the number of load commands we can embed in a dynamic library is +-- restricted. Hence since b592bd98ff2 we rely on -dead_strip_dylib to only +-- link the needed dylibs instead of linking the full dependency closure. +-- +-- If we split the library linking into injecting -rpath and -l @rpath/... +-- components, we will reduce the number of libraries we link, however we will +-- still inject one -rpath entry for each library, independent of their use. +-- That is, we even inject -rpath values for libraries that we dead_strip in +-- the end. As such we can run afoul of the load command size limit simply +-- by polluting the load commands with RPATH entries. +-- +-- Thus, we disable Opt_RPath by default on OSDarwin. The savvy user can always +-- enable it with -use-rpath if they so wish. +-- +-- See Note [Dynamic linking on macOS] + +default_RPath :: Platform -> [GeneralFlag] +default_RPath platform | platformOS platform == OSDarwin = [] +default_RPath _ = [Opt_RPath] + + -- General flags that are switched on/off when other general flags are switched -- on impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] ===================================== compiler/main/Settings.hs ===================================== @@ -25,6 +25,8 @@ module Settings , sPgm_windres , sPgm_libtool , sPgm_ar + , sPgm_otool + , sPgm_install_name_tool , sPgm_ranlib , sPgm_lo , sPgm_lc @@ -139,6 +141,10 @@ sPgm_libtool :: Settings -> String sPgm_libtool = toolSettings_pgm_libtool . sToolSettings sPgm_ar :: Settings -> String sPgm_ar = toolSettings_pgm_ar . sToolSettings +sPgm_otool :: Settings -> String +sPgm_otool = toolSettings_pgm_otool . sToolSettings +sPgm_install_name_tool :: Settings -> String +sPgm_install_name_tool = toolSettings_pgm_install_name_tool . sToolSettings sPgm_ranlib :: Settings -> String sPgm_ranlib = toolSettings_pgm_ranlib . sToolSettings sPgm_lo :: Settings -> (String, [Option]) ===================================== compiler/main/SysTools.hs ===================================== @@ -254,7 +254,10 @@ linkDynLib dflags0 o_files dep_packages | ( osElfTarget (platformOS (targetPlatform dflags)) || osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && - WayDyn `elem` ways dflags + -- Only if we want dynamic libraries + WayDyn `elem` ways dflags && + -- Only use RPath if we explicitly asked for it + gopt Opt_RPath dflags = ["-L" ++ l, "-Xlinker", "-rpath", "-Xlinker", l] -- See Note [-Xlinker -rpath vs -Wl,-rpath] | otherwise = ["-L" ++ l] @@ -377,8 +380,15 @@ linkDynLib dflags0 o_files dep_packages ++ map Option pkg_lib_path_opts ++ map Option pkg_link_opts ++ map Option pkg_framework_opts - ++ [ Option "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the leftover + -- libraries in the runInjectRpaths phase below. + -- + -- See Note [Dynamic linking on macOS] + ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) + runInjectRPaths dflags pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/main/SysTools/Settings.hs ===================================== @@ -119,6 +119,8 @@ initSettings top_dir = do windres_path <- getToolSetting "windres command" libtool_path <- getToolSetting "libtool command" ar_path <- getToolSetting "ar command" + otool_path <- getToolSetting "otool command" + install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" -- TODO this side-effect doesn't belong here. Reading and parsing the settings @@ -210,6 +212,8 @@ initSettings top_dir = do , toolSettings_pgm_windres = windres_path , toolSettings_pgm_libtool = libtool_path , toolSettings_pgm_ar = ar_path + , toolSettings_pgm_otool = otool_path + , toolSettings_pgm_install_name_tool = install_name_tool_path , toolSettings_pgm_ranlib = ranlib_path , toolSettings_pgm_lo = (lo_prog,[]) , toolSettings_pgm_lc = (lc_prog,[]) ===================================== compiler/main/SysTools/Tasks.hs ===================================== @@ -28,6 +28,10 @@ import LlvmCodeGen.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, pars import SysTools.Process import SysTools.Info +import Control.Monad (join, forM, filterM) +import System.Directory (doesFileExist) +import System.FilePath (()) + {- ************************************************************************ * * @@ -237,6 +241,41 @@ figureLlvmVersion dflags = traceToolCommand dflags "llc" $ do return Nothing) +-- | On macOS we rely on the linkers @-dead_strip_dylibs@ flag to remove unused +-- libraries from the dynamic library. We do this to reduce the number of load +-- commands that end up in the dylib, and has been limited to 32K (32768) since +-- macOS Sierra (10.14). +-- +-- @-dead_strip_dylibs@ does not dead strip @-rpath@ entries, as such passing +-- @-l@ and @-rpath@ to the linker will result in the unnecesasry libraries not +-- being included in the load commands, however the @-rpath@ entries are all +-- forced to be included. This can lead to 100s of @-rpath@ entries being +-- included when only a handful of libraries end up being truely linked. +-- +-- Thus after building the library, we run a fixup phase where we inject the +-- @-rpath@ for each found library (in the given library search paths) into the +-- dynamic library through @-add_rpath at . +-- +-- See Note [Dynamic linking on macOS] +runInjectRPaths :: DynFlags -> [FilePath] -> FilePath -> IO () +runInjectRPaths dflags lib_paths dylib = do + info <- lines <$> askOtool dflags Nothing [Option "-L", Option dylib] + -- filter the output for only the libraries. And then drop the @rpath prefix. + let libs = fmap (drop 7) $ filter (isPrefixOf "@rpath") $ fmap (head.words) $ info + -- find any pre-existing LC_PATH items + info <- fmap words.lines <$> askOtool dflags Nothing [Option "-l", Option dylib] + let paths = concatMap f info + where f ("path":p:_) = [p] + f _ = [] + lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] + -- only find those rpaths, that aren't already in the library. + rpaths <- nub.sort.join <$> forM libs (\f -> filterM (\l -> doesFileExist (l f)) lib_paths') + -- inject the rpaths + case rpaths of + [] -> return () + _ -> runInstallNameTool dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + + runLink :: DynFlags -> [Option] -> IO () runLink dflags args = traceToolCommand dflags "linker" $ do -- See Note [Run-time linker info] @@ -335,6 +374,17 @@ askAr dflags mb_cwd args = traceToolCommand dflags "ar" $ do runSomethingWith dflags "Ar" ar args $ \real_args -> readCreateProcessWithExitCode' (proc ar real_args){ cwd = mb_cwd } +askOtool :: DynFlags -> Maybe FilePath -> [Option] -> IO String +askOtool dflags mb_cwd args = do + let otool = pgm_otool dflags + runSomethingWith dflags "otool" otool args $ \real_args -> + readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } + +runInstallNameTool :: DynFlags -> [Option] -> IO () +runInstallNameTool dflags args = do + let tool = pgm_install_name_tool dflags + runSomethingFiltered dflags id "Install Name Tool" tool args Nothing Nothing + runRanlib :: DynFlags -> [Option] -> IO () runRanlib dflags args = traceToolCommand dflags "ranlib" $ do let ranlib = pgm_ranlib dflags ===================================== compiler/main/ToolSettings.hs ===================================== @@ -31,6 +31,8 @@ data ToolSettings = ToolSettings , toolSettings_pgm_windres :: String , toolSettings_pgm_libtool :: String , toolSettings_pgm_ar :: String + , toolSettings_pgm_otool :: String + , toolSettings_pgm_install_name_tool :: String , toolSettings_pgm_ranlib :: String , -- | LLVM: opt llvm optimiser toolSettings_pgm_lo :: (String, [Option]) ===================================== configure.ac ===================================== @@ -671,6 +671,18 @@ else fi AC_SUBST([LibtoolCmd]) +dnl ** Which otool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +OtoolCmd="$OTOOL" +AC_SUBST(OtoolCmd) + +dnl ** Which install_name_tool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +InstallNameToolCmd="$INSTALL_NAME_TOOL" +AC_SUBST(InstallNameToolCmd) + # Here is where we re-target which specific version of the LLVM # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around @@ -1481,6 +1493,8 @@ echo "\ libtool : $LibtoolCmd objdump : $ObjdumpCmd ranlib : $RanlibCmd + otool : $OtoolCmd + install_name_tool : $InstallNameToolCmd windres : $WindresCmd dllwrap : $DllWrapCmd genlib : $GenlibCmd ===================================== docs/users_guide/phases.rst ===================================== @@ -95,6 +95,24 @@ given compilation phase: Use ⟨cmd⟩ as the pre-processor (with :ghc-flag:`-F` only). +.. ghc-flag:: -pgmotool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inspect mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inspect mach-o dynamic libraries and + executables to read the dynamic library dependencies. We will compute + the necessary ``runpath``s to embed for the dependencies based on the + result of the ``otool`` call. + +.. ghc-flag:: -pgminstall_name_tool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inject ``runpath`` into mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inject ``runpath``s into mach-o dynamic + libraries and executables. As detected by the ``otool`` call. + .. ghc-flag:: -pgmwindres ⟨cmd⟩ :shortdesc: Use ⟨cmd⟩ as the program for embedding manifests on Windows. :type: dynamic ===================================== hadrian/cfg/system.config.in ===================================== @@ -148,6 +148,8 @@ settings-merge-objects-command = @SettingsMergeObjectsCommand@ settings-merge-objects-flags = @SettingsMergeObjectsFlags@ settings-ar-command = @SettingsArCommand@ settings-ranlib-command = @SettingsRanlibCommand@ +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ settings-libtool-command = @SettingsLibtoolCommand@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -113,6 +113,8 @@ data SettingsFileSetting | SettingsFileSetting_MergeObjectsFlags | SettingsFileSetting_ArCommand | SettingsFileSetting_RanlibCommand + | SettingsFileSetting_OtoolCommand + | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand | SettingsFileSetting_LibtoolCommand @@ -198,6 +200,8 @@ settingsFileSetting key = lookupValueOrError configFile $ case key of SettingsFileSetting_MergeObjectsFlags -> "settings-merge-objects-flags" SettingsFileSetting_ArCommand -> "settings-ar-command" SettingsFileSetting_RanlibCommand -> "settings-ranlib-command" + SettingsFileSetting_OtoolCommand -> "settings-otool-command" + SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" SettingsFileSetting_LibtoolCommand -> "settings-libtool-command" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -294,6 +294,8 @@ generateSettings = do , ("ar flags", expr $ lookupValueOrError configFile "ar-args") , ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile) , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) + , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) + , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) ===================================== includes/ghc.mk ===================================== @@ -228,6 +228,8 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/. @echo ',("ar flags", "$(ArArgs)")' >> $@ @echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@ @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ + @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ + @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ ===================================== mk/config.mk.in ===================================== @@ -515,6 +515,8 @@ SettingsLdFlags = @SettingsLdFlags@ SettingsMergeObjectsCommand = @SettingsMergeObjectsCommand@ SettingsMergeObjectsFlags = @SettingsMergeObjectsFlags@ SettingsArCommand = @SettingsArCommand@ +SettingsOtoolCommand = @SettingsOtoolCommand@ +SettingsInstallNameToolCommand = @SettingsInstallNameToolCommand@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ ===================================== testsuite/tests/rts/all.T ===================================== @@ -403,7 +403,7 @@ test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp - test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', - [when(opsys('darwin') or opsys('mingw32'), expect_broken(17447)), + [when(opsys('mingw32'), expect_broken(17447)), extra_files(['T13676.hs'])], ghci_script, ['T13676.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43f970499d053098d1928ce3921176192ec07d7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/43f970499d053098d1928ce3921176192ec07d7a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 04:30:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 00:30:41 -0400 Subject: [Git][ghc/ghc][wip/ticky-eventlog] rts: Post ticky entry counts to the eventlog Message-ID: <5f87d0716005a_28003fd3ecb2690c3530ed@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/ticky-eventlog at Glasgow Haskell Compiler / GHC Commits: 239a2289 by Ben Gamari at 2020-10-15T00:30:32-04:00 rts: Post ticky entry counts to the eventlog We currently only post the entry counters, not the other global counters as in my experience the former are more useful. We use the heap profiler's census period to decide when to dump. Also spruces up the documentation surrounding ticky-ticky a bit. - - - - - 14 changed files: - docs/users_guide/eventlog-formats.rst - docs/users_guide/expected-undocumented-flags.txt - docs/users_guide/profiling.rst - includes/rts/EventLogFormat.h - includes/rts/Flags.h - rts/Proftimer.c - rts/Proftimer.h - rts/RtsFlags.c - rts/RtsStartup.c - rts/Ticky.c - rts/Ticky.h - rts/eventlog/EventLog.c - rts/eventlog/EventLog.h - rts/sm/GC.c Changes: ===================================== docs/users_guide/eventlog-formats.rst ===================================== @@ -755,3 +755,34 @@ intended to provide insight into fragmentation of the non-moving heap. :field Word32: number of live blocks. Describes the occupancy of the *blk_sz* sub-heap. + +Ticky counters +~~~~~~~~~~~~~~ + +Programs compiled with :ghc-flag:`-ticky` and :ghc-flag:`-eventlog` and invoked +with ``+RTS -lT`` will emit periodic samples of the ticky entry counters to the +eventlog. + +.. event-type:: TICKY_COUNTER_DEF + + :tag: 210 + :length: variable + :field Word64: counter ID + :field Word16: arity/field count + :field String: argument kinds. This is the same as the synonymous field in the + textual ticky summary. + :field String: counter name + + Defines a ticky counter. + +.. event-type:: TICKY_COUNTER_SAMPLE + + :tag: 211 + :length: fixed + :field Word64: counter ID + :field Word64: number of times closures of this type has been entered. + :field Word64: number of allocations (words) + :field Word64: number of times this has been allocated (words). Only + produced for modules compiled with :ghc-flag:`-ticky-allocd`. + + Records the counter statistics at a moment in time. ===================================== docs/users_guide/expected-undocumented-flags.txt ===================================== @@ -117,5 +117,3 @@ -syslib -this-component-id -ticky-LNE --ticky-allocd --ticky-dyn-thunk ===================================== docs/users_guide/profiling.rst ===================================== @@ -1661,11 +1661,27 @@ Using “ticky-ticky” profiling (for implementors) single: ticky-ticky profiling .. ghc-flag:: -ticky - :shortdesc: :ref:`Turn on ticky-ticky profiling ` + :shortdesc: Turn on :ref:`ticky-ticky profiling ` :type: dynamic :category: - Enable ticky-ticky profiling. + Enable ticky-ticky profiling. By default this only tracks the allocations + *by* each closure type. See :ghc-flag:`-ticky-allocd` to keep track of + allocations *of* each closure type as well. + +.. ghc-flag:: -ticky-allocd + :shortdesc: Track the number of times each closure type is allocated. + :type: dynamic + :category: + + Keep track of how much each closure type is allocated. + +.. ghc-flag:: -ticky-dyn-thunk + :shortdesc: Track allocations of dynamic thunks + :type: dynamic + :category: + + Track allocations of dynamic thunks. Because ticky-ticky profiling requires a certain familiarity with GHC internals, we have moved the documentation to the GHC developers wiki. ===================================== includes/rts/EventLogFormat.h ===================================== @@ -154,12 +154,15 @@ #define EVENT_CONC_UPD_REM_SET_FLUSH 206 #define EVENT_NONMOVING_HEAP_CENSUS 207 +#define EVENT_TICKY_COUNTER_DEF 210 +#define EVENT_TICKY_COUNTER_SAMPLE 211 + /* * The highest event code +1 that ghc itself emits. Note that some event * ranges higher than this are reserved but not currently emitted by ghc. * This must match the size of the EventDesc[] array in EventLog.c */ -#define NUM_GHC_EVENT_TAGS 208 +#define NUM_GHC_EVENT_TAGS 212 #if 0 /* DEPRECATED EVENTS: */ /* we don't actually need to record the thread, it's implicit */ ===================================== includes/rts/Flags.h ===================================== @@ -176,6 +176,7 @@ typedef struct _TRACE_FLAGS { bool nonmoving_gc; /* trace nonmoving GC events */ bool sparks_sampled; /* trace spark events by a sampled method */ bool sparks_full; /* trace spark events 100% accurately */ + bool ticky; /* trace ticky-ticky samples */ bool user; /* trace user events (emitted from Haskell code) */ char *trace_output; /* output filename for eventlog */ } TRACE_FLAGS; ===================================== rts/Proftimer.c ===================================== @@ -20,6 +20,12 @@ static bool do_prof_ticks = false; // enable profiling ticks static bool do_heap_prof_ticks = false; // enable heap profiling ticks +// Sampling of Ticky-Ticky profiler to eventlog +#if defined(TICKY_TICKY) && defined(TRACING) +static int ticks_to_ticky_sample = 0; +bool performTickySample = false; +#endif + // Number of ticks until next heap census static int ticks_to_heap_profile; @@ -83,6 +89,16 @@ handleProfTick(void) } #endif +#if defined(TICKY_TICKY) && defined(TRACING) + if (RtsFlags.TraceFlags.ticky) { + ticks_to_ticky_sample--; + if (ticks_to_ticky_sample <= 0) { + ticks_to_ticky_sample = RtsFlags.ProfFlags.heapProfileIntervalTicks; + performTickySample = true; + } + } +#endif + if (do_heap_prof_ticks) { ticks_to_heap_profile--; if (ticks_to_heap_profile <= 0) { ===================================== rts/Proftimer.h ===================================== @@ -17,5 +17,6 @@ void stopHeapProfTimer ( void ); void startHeapProfTimer ( void ); extern bool performHeapProfile; +extern bool performTickySample; #include "EndPrivate.h" ===================================== rts/RtsFlags.c ===================================== @@ -235,6 +235,7 @@ void initRtsFlagsDefaults(void) RtsFlags.TraceFlags.sparks_sampled= false; RtsFlags.TraceFlags.sparks_full = false; RtsFlags.TraceFlags.user = false; + RtsFlags.TraceFlags.ticky = false; RtsFlags.TraceFlags.trace_output = NULL; #endif @@ -403,6 +404,9 @@ usage_text[] = { " p par spark events (sampled)", " f par spark events (full detail)", " u user events (emitted from Haskell code)", +#if defined(TICKY_TICKY) +" T ticky-ticky counter samples", +#endif " a all event classes above", # if defined(DEBUG) " t add time stamps (only useful with -v)", @@ -1855,6 +1859,11 @@ static void normaliseRtsOpts (void) "the compacting collector."); errorUsage(); } + + if (RtsFlags.TraceFlags.ticky && RtsFlags.TickyFlags.showTickyStats) { + barf("The ticky-ticky eventlog output cannot be used in conjunction with\n" + "+RTS -r."); + } } static void errorUsage (void) @@ -2297,6 +2306,15 @@ static void read_trace_flags(const char *arg) RtsFlags.TraceFlags.user = enabled; enabled = true; break; + case 'T': +#if defined(TICKY_TICKY) + RtsFlags.TraceFlags.ticky = enabled; + enabled = true; + break; +#else + errorBelch("Program not compiled with ticky-ticky support"); + break; +#endif default: errorBelch("unknown trace option: %c",*c); break; ===================================== rts/RtsStartup.c ===================================== @@ -481,6 +481,17 @@ hs_exit_(bool wait_foreign) */ exitTimer(true); + /* + * Dump the ticky counter definitions + * We do this at the end of execution since tickers are registered in the + * course of program execution. + */ +#if defined(TICKY_TICKY) && defined(TRACING) + if (RtsFlags.TraceFlags.ticky) { + emitTickyCounterDefs(); + } +#endif + // set the terminal settings back to what they were #if !defined(mingw32_HOST_OS) resetTerminalSettings(); ===================================== rts/Ticky.c ===================================== @@ -10,6 +10,8 @@ #include "PosixSource.h" #include "Rts.h" +#include "eventlog/EventLog.h" + /* Catch-all top-level counter struct. Allocations from CAFs will go * here. */ @@ -46,6 +48,10 @@ static void printRegisteredCounterInfo (FILE *); /* fwd decl */ void PrintTickyInfo(void) { + if (RtsFlags.TraceFlags.ticky) { + barf("Ticky eventlog output can't be used with +RTS -r"); + } + unsigned long i; unsigned long tot_thk_enters = ENT_STATIC_THK_MANY_ctr + ENT_DYN_THK_MANY_ctr @@ -374,4 +380,19 @@ printRegisteredCounterInfo (FILE *tf) } } + +void emitTickyCounterDefs() +{ +#if defined(TRACING) + postTickyCounterDefs(ticky_entry_ctrs); +#endif +} + +void emitTickyCounterSamples() +{ +#if defined(TRACING) + postTickyCounterSamples(ticky_entry_ctrs); +#endif +} + #endif /* TICKY_TICKY */ ===================================== rts/Ticky.h ===================================== @@ -8,4 +8,11 @@ #pragma once -RTS_PRIVATE void PrintTickyInfo(void); +#include "BeginPrivate.h" + +void PrintTickyInfo(void); + +void emitTickyCounterSamples(void); +void emitTickyCounterDefs(void); + +#include "EndPrivate.h" ===================================== rts/eventlog/EventLog.c ===================================== @@ -119,7 +119,9 @@ char *EventDesc[] = { [EVENT_CONC_SWEEP_BEGIN] = "Begin concurrent sweep", [EVENT_CONC_SWEEP_END] = "End concurrent sweep", [EVENT_CONC_UPD_REM_SET_FLUSH] = "Update remembered set flushed", - [EVENT_NONMOVING_HEAP_CENSUS] = "Nonmoving heap census" + [EVENT_NONMOVING_HEAP_CENSUS] = "Nonmoving heap census", + [EVENT_TICKY_COUNTER_DEF] = "Ticky-ticky entry counter definition", + [EVENT_TICKY_COUNTER_SAMPLE] = "Ticky-ticky entry counter sample", }; // Event type. @@ -487,6 +489,14 @@ init_event_types(void) eventTypes[t].size = 13; break; + case EVENT_TICKY_COUNTER_DEF: // (counter_id, arity, arg_kinds, name) + eventTypes[t].size = EVENT_SIZE_DYNAMIC; + break; + + case EVENT_TICKY_COUNTER_SAMPLE: // (counter_id, entry_count, allocs, allocd) + eventTypes[t].size = 8*4; + break; + default: continue; /* ignore deprecated events */ } @@ -1472,6 +1482,53 @@ void postProfBegin(void) } #endif /* PROFILING */ +#if defined(TICKY_TICKY) +static void postTickyCounterDef(EventsBuf *eb, StgEntCounter *p) +{ + StgWord len = 8 + 2 + strlen(p->arg_kinds)+1 + strlen(p->str)+1; + ensureRoomForVariableEvent(eb, len); + postEventHeader(eb, EVENT_TICKY_COUNTER_DEF); + postPayloadSize(eb, len); + postWord64(eb, (uint64_t) p); + postWord16(eb, (uint16_t) p->arity); + postString(eb, p->arg_kinds); + postString(eb, p->str); +} + +void postTickyCounterDefs(StgEntCounter *counters) +{ + ACQUIRE_LOCK(&eventBufMutex); + for (StgEntCounter *p = counters; p != NULL; p = p->link) { + postTickyCounterDef(&eventBuf, p); + } + RELEASE_LOCK(&eventBufMutex); +} + +static void postTickyCounterSample(EventsBuf *eb, StgEntCounter *p) +{ + if ( p->entry_count == 0 + && p->allocs == 0 + && p->allocd == 0) + return; + + ensureRoomForEvent(eb, EVENT_TICKY_COUNTER_SAMPLE); + postEventHeader(eb, EVENT_TICKY_COUNTER_SAMPLE); + postWord64(eb, (uint64_t) p); + postWord64(eb, p->entry_count); + postWord64(eb, p->allocs); + postWord64(eb, p->allocd); +} + +void postTickyCounterSamples(StgEntCounter *counters) +{ + ACQUIRE_LOCK(&eventBufMutex); + for (StgEntCounter *p = counters; p != NULL; p = p->link) { + postTickyCounterSample(&eventBuf, p); + } + RELEASE_LOCK(&eventBufMutex); +} +#endif /* TICKY_TICKY */ + void printAndClearEventBuf (EventsBuf *ebuf) { closeBlockMarker(ebuf); ===================================== rts/eventlog/EventLog.h ===================================== @@ -173,6 +173,11 @@ void postConcMarkEnd(StgWord32 marked_obj_count); void postNonmovingHeapCensus(int log_blk_size, const struct NonmovingAllocCensus *census); +#if defined(TICKY_TICKY) +void postTickyCounterDefs(StgEntCounter *p); +void postTickyCounterSamples(StgEntCounter *p); +#endif /* TICKY_TICKY */ + #else /* !TRACING */ INLINE_HEADER void postSchedEvent (Capability *cap STG_UNUSED, ===================================== rts/sm/GC.c ===================================== @@ -38,6 +38,7 @@ #include "Sanity.h" #include "BlockAlloc.h" #include "ProfHeap.h" +#include "Proftimer.h" #include "Weak.h" #include "Prelude.h" #include "RtsSignals.h" @@ -52,6 +53,7 @@ #include "CNF.h" #include "RtsFlags.h" #include "NonMoving.h" +#include "Ticky.h" #include // for memset() #include @@ -860,6 +862,16 @@ GarbageCollect (uint32_t collect_gen, ACQUIRE_SM_LOCK; } +#if defined(TICKY_TICKY) + // Post ticky counter sample. + // We do this at the end of execution since tickers are registered in the + // course of program execution. + if (performTickySample) { + emitTickyCounterSamples(); + performTickySample = false; + } +#endif + // send exceptions to any threads which were about to die RELEASE_SM_LOCK; resurrectThreads(resurrected_threads); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/239a228917cd5d152d66fe21fd0c421dead042c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/239a228917cd5d152d66fe21fd0c421dead042c6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 07:49:10 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Thu, 15 Oct 2020 03:49:10 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f87fef63d6c9_28003fd40c99633835828c@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: c294db51 by Alan Zimmerman at 2020-10-15T08:48:25+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -934,22 +934,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -964,20 +965,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1962,10 +1966,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2621,9 +2621,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -723,10 +723,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1846,7 +1846,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2455,7 +2455,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -74,6 +74,7 @@ import qualified GHC.Parser.Lexer as Lexer import GHC.Data.StringBuffer import GHC.Utils.Outputable +import GHC.Parser.Annotation import GHC.Runtime.Loader ( initializePlugins ) @@ -1683,7 +1684,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1752,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit fc128b4719970b741e60e6463bb14ea54fba0175 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c294db515fbe31f523564ecded3e279660ad27ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c294db515fbe31f523564ecded3e279660ad27ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:30:33 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 04:30:33 -0400 Subject: [Git][ghc/ghc][master] Remove Proxy# argument in Data.Typeable.Internal Message-ID: <5f8808a955f64_2800a208528366159@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 5 changed files: - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Exception.hs-boot Changes: ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -55,7 +55,6 @@ import GHC.Core.Coercion import GHC.Core.Multiplicity import GHC.Builtin.Types ( naturalTy, typeSymbolKind ) import GHC.Types.Id -import GHC.Types.Id.Make(proxyHashId) import GHC.Types.Name import GHC.Types.Var.Set import GHC.Core.Rules @@ -1219,7 +1218,7 @@ dsEvTerm (EvFun { et_tvs = tvs, et_given = given dsEvTypeable :: Type -> EvTypeable -> DsM CoreExpr -- Return a CoreExpr :: Typeable ty -- This code is tightly coupled to the representation --- of TypeRep, in base library Data.Typeable.Internals +-- of TypeRep, in base library Data.Typeable.Internal dsEvTypeable ty ev = do { tyCl <- dsLookupTyCon typeableClassName -- Typeable ; let kind = typeKind ty @@ -1298,14 +1297,13 @@ ds_ev_typeable ty (EvTypeableTyLit ev) = -- See Note [Typeable for Nat and Symbol] in GHC.Tc.Solver.Interact do { fun <- dsLookupGlobalId tr_fun ; dict <- dsEvTerm ev -- Of type KnownNat/KnownSymbol - ; let proxy = mkTyApps (Var proxyHashId) [ty_kind, ty] - ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict, proxy ]) } + ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict ]) } where ty_kind = typeKind ty -- tr_fun is the Name of - -- typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a - -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a + -- typeNatTypeRep :: KnownNat a => TypeRep a + -- of typeSymbolTypeRep :: KnownSymbol a => TypeRep a tr_fun | ty_kind `eqType` naturalTy = typeNatTypeRepName | ty_kind `eqType` typeSymbolKind = typeSymbolTypeRepName | otherwise = panic "dsEvTypeable: unknown type lit kind" ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -548,7 +548,7 @@ have this instance, implemented here by doTyLit: instance KnownNat n => Typeable (n :: Nat) where typeRep = typeNatTypeRep @n where - Data.Typeable.Internals.typeNatTypeRep :: KnownNat a => TypeRep a + Data.Typeable.Internal.typeNatTypeRep :: KnownNat a => TypeRep a Ultimately typeNatTypeRep uses 'natSing' from KnownNat to get a runtime value 'n'; it turns it into a string with 'show' and uses ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -1022,7 +1022,7 @@ instance Outputable EvTypeable where -- overloaded-label dictionary to expose the underlying value. We -- expect the 'Type' to have the form `IP sym ty` or `IsLabel sym ty`, -- and return a 'Coercion' `co :: IP sym ty ~ ty` or --- `co :: IsLabel sym ty ~ Proxy# sym -> ty`. See also +-- `co :: IsLabel sym ty ~ ty`. See also -- Note [Type-checking overloaded labels] in "GHC.Tc.Gen.Expr". unwrapIP :: Type -> CoercionR unwrapIP ty = ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -979,12 +979,12 @@ mkTypeLitTyCon name kind_tycon where kind = KindRepTyConApp kind_tycon [] -- | Used to make `'Typeable' instance for things of kind Nat -typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a -typeNatTypeRep p = typeLitTypeRep (show (natVal' p)) tcNat +typeNatTypeRep :: forall a. KnownNat a => TypeRep a +typeNatTypeRep = typeLitTypeRep (show (natVal' (proxy# @a))) tcNat -- | Used to make `'Typeable' instance for things of kind Symbol -typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a -typeSymbolTypeRep p = typeLitTypeRep (show (symbolVal' p)) tcSymbol +typeSymbolTypeRep :: forall a. KnownSymbol a => TypeRep a +typeSymbolTypeRep = typeLitTypeRep (show (symbolVal' (proxy# @a))) tcSymbol mkTypeLitFromString :: TypeLitSort -> String -> SomeTypeRep mkTypeLitFromString TypeLitSymbol s = ===================================== libraries/base/GHC/Exception.hs-boot ===================================== @@ -14,7 +14,7 @@ More dramatically GHC.Exception imports Data.Typeable -imports Data.Typeable.Internals +imports Data.Typeable.Internal imports GHC.Arr (fingerprint representation etc) imports GHC.Real imports {-# SOURCE #-} GHC.Exception View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51c4b851965abdece2f88f8e583256e15f3140fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51c4b851965abdece2f88f8e583256e15f3140fe You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:31:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 04:31:13 -0400 Subject: [Git][ghc/ghc][master] Fix parsing of PIE flags Message-ID: <5f8808d1bbc0a_28003fd40273d5b43714e8@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 1 changed file: - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2977,8 +2977,8 @@ dynamic_flags_deps = [ ------ position independent flags ---------------------------------- , make_ord_flag defGhcFlag "fPIC" (NoArg (setGeneralFlag Opt_PIC)) , make_ord_flag defGhcFlag "fno-PIC" (NoArg (unSetGeneralFlag Opt_PIC)) - , make_ord_flag defGhcFlag "fPIE" (NoArg (setGeneralFlag Opt_PIC)) - , make_ord_flag defGhcFlag "fno-PIE" (NoArg (unSetGeneralFlag Opt_PIC)) + , make_ord_flag defGhcFlag "fPIE" (NoArg (setGeneralFlag Opt_PIE)) + , make_ord_flag defGhcFlag "fno-PIE" (NoArg (unSetGeneralFlag Opt_PIE)) ------ Debugging flags ---------------------------------------------- , make_ord_flag defGhcFlag "g" (OptIntSuffix setDebugLevel) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/809f09e8a7060691b1f2f5d6b95ca75e66437e55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/809f09e8a7060691b1f2f5d6b95ca75e66437e55 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:31:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 04:31:50 -0400 Subject: [Git][ghc/ghc][master] testsuite: Add missing #include on Message-ID: <5f8808f65047e_28009c6eba83741b0@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 1 changed file: - testsuite/tests/concurrent/should_run/conc059_c.c Changes: ===================================== testsuite/tests/concurrent/should_run/conc059_c.c ===================================== @@ -1,6 +1,7 @@ #include "HsFFI.h" #include "conc059_stub.h" #include +#include #include #if mingw32_HOST_OS #include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d7db1488c4bd7764e8b1fe3cfde4c5a548cde16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d7db1488c4bd7764e8b1fe3cfde4c5a548cde16 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:36:26 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Thu, 15 Oct 2020 04:36:26 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] 13 commits: Unification of Nat and Naturals Message-ID: <5f880a0a9a9e2_28003fd40273d5b43743d6@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 7137012d by Vladislav Zavialov at 2020-10-15T11:36:14+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - compiler/GHC/ThToHs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/98aedb3abbe6f1fe2c9f9a0e9189b9c76d20af26...7137012d70ef861b9e4bb11b6c80923b26dfb310 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/98aedb3abbe6f1fe2c9f9a0e9189b9c76d20af26...7137012d70ef861b9e4bb11b6c80923b26dfb310 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:46:30 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 15 Oct 2020 04:46:30 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 45 commits: Fall back to types when looking up data constructors (#18740) Message-ID: <5f880c66dd8e6_28003fd3ed533b0c3749d2@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 76cf4569 by Sebastian Graf at 2020-10-15T10:45:46+02:00 Nested CPR - - - - - f2e99705 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Move tests from stranal to cpranal - - - - - 86b94dc1 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Accept FacState - - - - - 3666301c by Sebastian Graf at 2020-10-15T10:45:48+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - 6a274590 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - d4412216 by Sebastian Graf at 2020-10-15T10:45:48+02:00 stuff - - - - - 70e852f0 by Sebastian Graf at 2020-10-15T10:45:48+02:00 A slew of testsuite changes - - - - - 7df43bac by Sebastian Graf at 2020-10-15T10:45:48+02:00 Fix T1600 - - - - - 3f9b2f7f by Sebastian Graf at 2020-10-15T10:45:48+02:00 Fix primop termination - - - - - 9f9cb6c7 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Test for DataCon wrapper CPR - - - - - f5c64f63 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Fix CPR of bottoming functions/primops - - - - - 567e66ab by Sebastian Graf at 2020-10-15T10:45:48+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - 50e9a93b by Sebastian Graf at 2020-10-15T10:45:48+02:00 Accept two more changed test outputs - - - - - 4846f157 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Update CaseBinderCPR with a new function - - - - - a9692af8 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Don't give the case binder the CPR property - - - - - 22a94094 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Prune CPR sigs to constant depth on all bindings - - - - - 473d5b2a by Sebastian Graf at 2020-10-15T10:45:48+02:00 Use variable length coding for ConTags - - - - - df7a59f1 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Accept testuite output - - - - - 2e4f33f3 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - b2048e17 by Sebastian Graf at 2020-10-15T10:45:48+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 4133de48 by Sebastian Graf at 2020-10-15T10:45:49+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - 996147f6 by Sebastian Graf at 2020-10-15T10:45:49+02:00 Fix T9291 - - - - - 0dea2f53 by Sebastian Graf at 2020-10-15T10:45:49+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - 67200d5e by Sebastian Graf at 2020-10-15T10:45:49+02:00 Testsuite changes - - - - - 9da2dd75 by Sebastian Graf at 2020-10-15T10:45:49+02:00 Refactoring around cprAnalBind - - - - - 578d73c2 by Sebastian Graf at 2020-10-15T10:45:49+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - 1e23f24b by Sebastian Graf at 2020-10-15T10:45:49+02:00 Fix T16893 - - - - - 2c26ffe4 by Sebastian Graf at 2020-10-15T10:45:49+02:00 Accept new test output for T17673 - - - - - 546788b5 by Sebastian Graf at 2020-10-15T10:46:19+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 Metric Increase ['max_bytes_used', 'peak_megabytes_allocated']: T10370 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f4bfd687b108199c5cdbc6f093eac4af561a7fa...546788b5119e34f3f7313f01b56eaa7f437422b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f4bfd687b108199c5cdbc6f093eac4af561a7fa...546788b5119e34f3f7313f01b56eaa7f437422b4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 08:55:25 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 15 Oct 2020 04:55:25 -0400 Subject: [Git][ghc/ghc][wip/T5075] 55 commits: Document profiling flags, warning flags, and no-pie Message-ID: <5f880e7d41774_28003fd386162c88376133@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T5075 at Glasgow Haskell Compiler / GHC Commits: 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - e3951ac4 by Sebastian Graf at 2020-10-15T10:55:18+02:00 CprAnal: Activate Sum CPR for local bindings We've had Sum CPR (#5075) for top-level bindings for a couple of years now. That begs the question why we didn't also activate it for local bindings, and the reasons for that are described in `Note [CPR for sum types]`. Only that it didn't make sense! The Note said that Sum CPR would destroy let-no-escapes, but that should be a non-issue since we have syntactic join points in Core now and we don't WW for them (`Note [Don't w/w join points for CPR]`). So I simply activated CPR for all bindings of sum type, thus fixing #5075. - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90161b96adcb8a73216bf779e304713df46a624b...e3951ac4fc0039ebef01eddb87738b28ec569a8d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90161b96adcb8a73216bf779e304713df46a624b...e3951ac4fc0039ebef01eddb87738b28ec569a8d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 10:37:58 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 15 Oct 2020 06:37:58 -0400 Subject: [Git][ghc/ghc][wip/T18793] 19 commits: Fall back to types when looking up data constructors (#18740) Message-ID: <5f882686ea627_28003fd3ec0fc7c4385896@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - f075090b by Sebastian Graf at 2020-10-15T12:23:30+02:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - e956d42a by Sebastian Graf at 2020-10-15T12:37:43+02:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - ef3e4b2c by Sebastian Graf at 2020-10-15T12:37:51+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Backpack.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config.hs - compiler/GHC/Driver/Finder.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Lexer.x - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/HsType.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef9dbc8f403194d4422a551bf6874c6d532f92bd...ef3e4b2cb6e2d57951052420fe0bf6ec11011a83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef9dbc8f403194d4422a551bf6874c6d532f92bd...ef3e4b2cb6e2d57951052420fe0bf6ec11011a83 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 10:41:12 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 15 Oct 2020 06:41:12 -0400 Subject: [Git][ghc/ghc][wip/T18793] 2 commits: Arity: Record arity types for non-recursive lets Message-ID: <5f88274847c88_28003fd400059218386429@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18793 at Glasgow Haskell Compiler / GHC Commits: 89d2a1b3 by Sebastian Graf at 2020-10-15T12:41:06+02:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 67b8e742 by Sebastian Graf at 2020-10-15T12:41:06+02:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr - testsuite/tests/arityanal/f1.hs → testsuite/tests/arityanal/should_compile/Arity01.hs - + testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/f2.hs → testsuite/tests/arityanal/should_compile/Arity02.hs - + testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/f3.hs → testsuite/tests/arityanal/should_compile/Arity03.hs - + testsuite/tests/arityanal/should_compile/Arity03.stderr - testsuite/tests/arityanal/f4.hs → testsuite/tests/arityanal/should_compile/Arity04.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef3e4b2cb6e2d57951052420fe0bf6ec11011a83...67b8e742724dd1680b1971369d2622f5e6a24e83 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef3e4b2cb6e2d57951052420fe0bf6ec11011a83...67b8e742724dd1680b1971369d2622f5e6a24e83 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 12:35:53 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 15 Oct 2020 08:35:53 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18844 Message-ID: <5f8842294cff8_28003fd3889880c8398076@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18844 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18844 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 13:18:31 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 09:18:31 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] mingw: Extract zst toolchain archives Message-ID: <5f884c2715270_28003fd3ec0efe344061b3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: e319c9fe by Ben Gamari at 2020-10-15T09:18:22-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - 2 changed files: - .gitlab-ci.yml - configure.ac Changes: ===================================== .gitlab-ci.yml ===================================== @@ -5,8 +5,8 @@ variables: DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/ci.sh. - WINDOWS_TOOLCHAIN_VERSION: 3 + # .gitlab/ci.sh. Used for invalidation of GitLab CI cache. + WINDOWS_TOOLCHAIN_VERSION: 4 # Disable shallow clones; they break our linting rules GIT_DEPTH: 0 ===================================== configure.ac ===================================== @@ -417,7 +417,8 @@ set_up_tarballs() { rm -rf inplace/mingw local base_dir="../ghc-tarballs/${tarball_dest_dir}" ( cd inplace && - find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; && + find "${base_dir}" -name "*.tar.xz" -exec tar --xz -xf {} \; && + find "${base_dir}" -name "*.tar.zst" -exec tar --zstd -xf {} \; && rm ".MTREE" && rm ".PKGINFO" && cd .. ) || AC_MSG_ERROR([Could not extract Windows toolchains.]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e319c9fe09628f9d65fe8a8f4a1341a62123c1fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e319c9fe09628f9d65fe8a8f4a1341a62123c1fc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 13:21:23 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Thu, 15 Oct 2020 09:21:23 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/base_pragmas Message-ID: <5f884cd376eef_28003fd3ef63c5c440980@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/base_pragmas at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/base_pragmas You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 13:29:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 09:29:27 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] base: Reintroduce necessary LANGUAGE pragmas Message-ID: <5f884eb74c273_28008598ba44197d4@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: 338c2dfa by Ben Gamari at 2020-10-15T09:28:58-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - 1 changed file: - libraries/base/GHC/IO/Handle/Lock/Windows.hsc Changes: ===================================== libraries/base/GHC/IO/Handle/Lock/Windows.hsc ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} -- | File locking for Windows. module GHC.IO.Handle.Lock.Windows where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/338c2dfa5adc5ffe0074dc77f854a895a4b2268a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/338c2dfa5adc5ffe0074dc77f854a895a4b2268a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 16:39:54 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 12:39:54 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18854 Message-ID: <5f887b5accbf_28003fd409679dc445815c@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18854 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18854 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 16:40:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 12:40:49 -0400 Subject: [Git][ghc/ghc][wip/T18854] Document that ccall convention doesn't support varargs Message-ID: <5f887b917efc6_28003fd408f9fb204597a8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: aa9282aa by Ben Gamari at 2020-10-15T12:40:44-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 3 changed files: - docs/users_guide/exts/ffi.rst - testsuite/tests/rts/T5423_c.c - testsuite/tests/rts/T5423_cmm.cmm Changes: ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -83,6 +83,21 @@ For more details on the implementation see the Paper: Last known to be accessible `here `_. +Varargs not supported by ``ccall`` calling convention +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that functions requiring varargs arguments are unsupported by the ``ccall`` +calling convention. Foreign imports needing to call such functions should rather +``capi`` convention, giving an explicit signature for the needed call-pattern. +For instance, one could write: :: + + foreign import "capi" "printf" + my_printf :: Ptr CChar -> CInt -> IO () + + printInt :: CInt -> IO () + printInt n = my_printf "printed number %d" n + + .. _ffi-ghcexts: GHC extensions to the FFI Chapter ===================================== testsuite/tests/rts/T5423_c.c ===================================== @@ -1,6 +1,24 @@ #include +#include "Stg.h" void flush_stdout(void) { fflush(stdout); } + +void print_it( + StgWord r1, + StgWord r2, + StgWord r3, + StgWord r4, + StgWord r5, + StgWord r5, + StgWord r7, + StgWord r8, + StgWord r9, + StgWord r10 + ) +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", + r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); +} ===================================== testsuite/tests/rts/T5423_cmm.cmm ===================================== @@ -10,7 +10,6 @@ test (W_ r1, W_ r9, W_ r10) { - foreign "C" printf("%d %d %d %d %d %d %d %d %d %d\n", - r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); + foreign "C" test_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); return (r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa9282aaaa7c0549173ec8c4af4d5dd1d0e836be -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aa9282aaaa7c0549173ec8c4af4d5dd1d0e836be You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 17:07:09 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 13:07:09 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Remove Proxy# argument in Data.Typeable.Internal Message-ID: <5f8881bdbc1ec_28003fd3ecf4999447219b@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 083594ed by GHC GitLab CI at 2020-10-15T13:06:58-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - 06ccde77 by Ben Gamari at 2020-10-15T13:07:01-04:00 rts: Clean-up whitespace in Interpreter - - - - - 04f9ae4e by Ben Gamari at 2020-10-15T13:07:01-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - 3bc2a86b by Ben Gamari at 2020-10-15T13:07:01-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - 3a702517 by Ben Gamari at 2020-10-15T13:07:01-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - docs/users_guide/9.2.1-notes.rst - docs/users_guide/using-optimisation.rst - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Exception.hs-boot - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Tuple.hs - rts/Interpreter.c - testsuite/tests/concurrent/should_run/conc059_c.c - + testsuite/tests/deriving/should_compile/T11068_aggressive.hs - + testsuite/tests/deriving/should_compile/T11068_aggressive.stderr - testsuite/tests/deriving/should_compile/all.T - testsuite/tests/perf/compiler/Makefile - + testsuite/tests/perf/compiler/T11068.hs - + testsuite/tests/perf/compiler/T11068a.hs - + testsuite/tests/perf/compiler/T11068b.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa362f102215f335b98b23a45772c33363122d1a...3a7025172cc0322d3b1a4756e73c25e380723154 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa362f102215f335b98b23a45772c33363122d1a...3a7025172cc0322d3b1a4756e73c25e380723154 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 17:44:29 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Thu, 15 Oct 2020 13:44:29 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f888a7df078d_28003fd3ef4f71644800e6@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 88e6f7d6 by Alan Zimmerman at 2020-10-15T18:39:31+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -934,22 +934,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -964,20 +965,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1962,10 +1966,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2621,9 +2621,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -981,10 +981,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -622,11 +622,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -723,10 +723,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1846,7 +1846,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2455,7 +2455,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -1683,7 +1683,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1751,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 7b5972402afad755cd45aaad1a96aac509e9d5d2 +Subproject commit fc128b4719970b741e60e6463bb14ea54fba0175 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88e6f7d6de778bfb68ddb8b7c20338dbae926275 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88e6f7d6de778bfb68ddb8b7c20338dbae926275 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 20:05:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 16:05:25 -0400 Subject: [Git][ghc/ghc][wip/T18854] Document that ccall convention doesn't support varargs Message-ID: <5f88ab85bfc8_28007beff9450954c@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: be2ee946 by Ben Gamari at 2020-10-15T16:05:15-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 3 changed files: - docs/users_guide/exts/ffi.rst - testsuite/tests/rts/T5423_c.c - testsuite/tests/rts/T5423_cmm.cmm Changes: ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -83,6 +83,21 @@ For more details on the implementation see the Paper: Last known to be accessible `here `_. +Varargs not supported by ``ccall`` calling convention +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that functions requiring varargs arguments are unsupported by the ``ccall`` +calling convention. Foreign imports needing to call such functions should rather +``capi`` convention, giving an explicit signature for the needed call-pattern. +For instance, one could write: :: + + foreign import "capi" "printf" + my_printf :: Ptr CChar -> CInt -> IO () + + printInt :: CInt -> IO () + printInt n = my_printf "printed number %d" n + + .. _ffi-ghcexts: GHC extensions to the FFI Chapter ===================================== testsuite/tests/rts/T5423_c.c ===================================== @@ -1,6 +1,24 @@ +#include #include void flush_stdout(void) { fflush(stdout); } + +void print_it( + StgWord r1, + StgWord r2, + StgWord r3, + StgWord r4, + StgWord r5, + StgWord r5, + StgWord r7, + StgWord r8, + StgWord r9, + StgWord r10 + ) +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", + r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); +} ===================================== testsuite/tests/rts/T5423_cmm.cmm ===================================== @@ -10,7 +10,6 @@ test (W_ r1, W_ r9, W_ r10) { - foreign "C" printf("%d %d %d %d %d %d %d %d %d %d\n", - r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); + foreign "C" test_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); return (r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be2ee9467890b0ebf553d69e0576566dd7fe081b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/be2ee9467890b0ebf553d69e0576566dd7fe081b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 20:07:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 16:07:00 -0400 Subject: [Git][ghc/ghc][wip/T18838] testsuite: Sort metrics by metric type Message-ID: <5f88abe43328f_28003fd4027135705101a4@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18838 at Glasgow Haskell Compiler / GHC Commits: 6fbc9242 by Ben Gamari at 2020-10-15T16:06:50-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - 1 changed file: - testsuite/driver/runtests.py Changes: ===================================== testsuite/driver/runtests.py ===================================== @@ -457,7 +457,21 @@ else: if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + # Group metrics by metric type + groups = {} # type: Dict[MetricName, List[PerfMetric]] + for m in t.metrics: + if m.stat.metric not in groups: + groups[m.stat.metric] = [] + + groups[m.stat.metric].append(m) + + for metric_name, stats in groups.items(): + heading = 'Metrics: %s' % metric_name + print() + print(heading) + print('-' * len(heading)) + print() + tabulate_metrics(stats) else: print("\nNone collected.") print("") View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fbc924259a24271d3aadeb5d58bd2306ed61958 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fbc924259a24271d3aadeb5d58bd2306ed61958 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 21:23:19 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Thu, 15 Oct 2020 17:23:19 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Tiny little changes Message-ID: <5f88bdc72fe51_28003fd3885bd6005326cb@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 7a92bf45 by Richard Eisenberg at 2020-10-15T17:23:04-04:00 Tiny little changes - - - - - 3 changed files: - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Interact.hs Changes: ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1974,7 +1974,8 @@ buildSynTyCon name binders res_kind roles rhs where is_tau = isTauTy rhs is_fam_free = isFamFreeTy rhs - is_forgetful = any (not . (`elemVarSet` tyCoVarsOfType rhs) . binderVar) binders + is_forgetful = any (not . (`elemVarSet` tyCoVarsOfType rhs) . binderVar) binders || + uniqSetAny isForgetfulSynTyCon (tyConsOfType rhs) {- ************************************************************************ ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -2216,10 +2216,14 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco | (arg1, arg2, True) <- zip3 fun_args1 fun_args2 inj ] | otherwise -> return () - ; let tvs2 = tyCoVarsOfTypes fun_args2 + ; let tvs1 = tyCoVarsOfTypes fun_args1 + tvs2 = tyCoVarsOfTypes fun_args2 ; tclvl <- getTcLevel - ; if anyVarSet (isTouchableMetaTyVar tclvl) tvs2 + ; if anyVarSet (isTouchableMetaTyVar tclvl) tvs2 && -- swap 'em: Note [Put touchable variables on the left] + not (anyVarSet (isTouchableMetaTyVar tclvl) tvs1) + -- this check is just to avoid unfruitful swapping + then do { new_ev <- do_swap ; canEqCanLHSFinish new_ev eq_rel IsSwapped lhs2 (ps_xi1 `mkCastTyMCo` sym_mco) } else finish_without_swapping } ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -2439,7 +2439,7 @@ matchClassInst dflags inerts clas tys loc -- First check whether there is an in-scope Given that could -- match this constraint. In that case, do not use any instance -- whether top level, or local quantified constraints. --- ee Note [Instance and Given overlap] +-- See Note [Instance and Given overlap] | not (xopt LangExt.IncoherentInstances dflags) , not (naturallyCoherentClass clas) , let matchable_givens = matchableGivens loc pred inerts View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a92bf457b225c58f3396cd950e75f42915ddb27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7a92bf457b225c58f3396cd950e75f42915ddb27 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 22:37:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 15 Oct 2020 18:37:36 -0400 Subject: [Git][ghc/ghc][wip/bump-win32] 10 commits: Remove Proxy# argument in Data.Typeable.Internal Message-ID: <5f88cf307f9d1_28003fd40df96b24534671@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-win32 at Glasgow Haskell Compiler / GHC Commits: 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - a848d527 by Ben Gamari at 2020-10-15T18:37:17-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - 247d493c by Ben Gamari at 2020-10-15T18:37:17-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - bc4897ea by Ben Gamari at 2020-10-15T18:37:17-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - d76224c2 by Ben Gamari at 2020-10-15T18:37:17-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 6434c2e3 by Ben Gamari at 2020-10-15T18:37:17-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - 399ac08a by Ben Gamari at 2020-10-15T18:37:17-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 7d617697 by Ben Gamari at 2020-10-15T18:37:17-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 16 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Types/Evidence.hs - configure.ac - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/Exception.hs-boot - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - rts/RtsSymbols.c - testsuite/driver/runtests.py - testsuite/tests/concurrent/should_run/conc059_c.c - testsuite/tests/ghci/scripts/T9293.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci057.stdout-mingw32 Changes: ===================================== .gitlab-ci.yml ===================================== @@ -5,8 +5,8 @@ variables: DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/ci.sh. - WINDOWS_TOOLCHAIN_VERSION: 3 + # .gitlab/ci.sh. Used for invalidation of GitLab CI cache. + WINDOWS_TOOLCHAIN_VERSION: 4 # Disable shallow clones; they break our linting rules GIT_DEPTH: 0 @@ -212,7 +212,7 @@ lint-release-changelogs: junit: junit.xml expire_in: 2 week paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .validate-linux-hadrian: @@ -220,6 +220,7 @@ lint-release-changelogs: image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9-hadrian" + BIN_DIST_NAME: "ghc-x86_64-deb9-linux" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . @@ -399,7 +400,7 @@ release-x86_64-freebsd: HADRIAN_ARGS: "--docs=no-sphinx" GHC_VERSION: 8.6.3 CABAL_INSTALL_VERSION: 3.0.0.0 - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + BIN_DIST_NAME: "ghc-x86_64-portbld-freebsd" TEST_ENV: "x86_64-freebsd-hadrian" FLAVOUR: "validate" after_script: @@ -464,6 +465,7 @@ validate-x86_64-darwin: LANG: "en_US.UTF-8" CONFIGURE_ARGS: --with-intree-gmp TEST_ENV: "x86_64-darwin-hadrian" + BIN_DIST_NAME: "ghc-x86_64-apple-darwin" FLAVOUR: "validate" script: - .gitlab/ci.sh setup @@ -479,7 +481,7 @@ validate-x86_64-darwin: reports: junit: junit.xml paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .validate-linux: @@ -785,7 +787,7 @@ release-x86_64-linux-deb8: allow_failure: true variables: TEST_ENV: "x86_64-linux-alpine" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + BIN_DIST_NAME: "ghc-x86_64-alpine-linux" # Can't use ld.gold due to #13958. CONFIGURE_ARGS: "--disable-ld-override" HADRIAN_ARGS: "--docs=no-sphinx" @@ -856,9 +858,7 @@ validate-x86_64-linux-fedora27: ############################################################ .build-windows: - # For the reasons given in #17777 this build isn't reliable. needs: [validate-x86_64-linux-deb9-hadrian] - allow_failure: true before_script: - git clean -xdf @@ -903,7 +903,7 @@ validate-x86_64-linux-fedora27: expire_in: 2 week when: always paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .build-x86_64-windows-hadrian: @@ -911,6 +911,7 @@ validate-x86_64-linux-fedora27: variables: MSYSTEM: MINGW64 TEST_ENV: "x86_64-windows" + BIN_DIST_NAME: "ghc-x86_64-unknown-mingw32" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" @@ -970,6 +971,7 @@ release-x86_64-windows-integer-simple: variables: BIGNUM_BACKEND: native BUILD_FLAVOUR: "perf" + BIN_DIST_NAME: "ghc-x86_64-mingw32-unknown-nogmp" ############################################################ @@ -987,9 +989,7 @@ doc-tarball: - validate-x86_64-windows-hadrian variables: LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" - WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" - # Due to Windows allow_failure - allow_failure: true + WINDOWS_BINDIST: "ghc-x86_64-unknown-mingw32.tar.xz" artifacts: paths: - haddock.html.tar.xz @@ -1155,8 +1155,6 @@ pages: dependencies: - doc-tarball image: ghcci/x86_64-linux-deb9:0.2 - # Due to Windows allow_failure - allow_failure: true tags: - x86_64-linux script: ===================================== .gitlab/ci.sh ===================================== @@ -377,10 +377,13 @@ function build_hadrian() { if [ -z "$FLAVOUR" ]; then fail "FLAVOUR not set" fi + if [ -z "$BIN_DIST_NAME" ]; then + fail "BIN_DIST_NAME not set" + fi run_hadrian binary-dist - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + mv _build/bindist/ghc*.tar.xz $BIN_DIST_NAME.tar.xz } function test_hadrian() { ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2977,8 +2977,8 @@ dynamic_flags_deps = [ ------ position independent flags ---------------------------------- , make_ord_flag defGhcFlag "fPIC" (NoArg (setGeneralFlag Opt_PIC)) , make_ord_flag defGhcFlag "fno-PIC" (NoArg (unSetGeneralFlag Opt_PIC)) - , make_ord_flag defGhcFlag "fPIE" (NoArg (setGeneralFlag Opt_PIC)) - , make_ord_flag defGhcFlag "fno-PIE" (NoArg (unSetGeneralFlag Opt_PIC)) + , make_ord_flag defGhcFlag "fPIE" (NoArg (setGeneralFlag Opt_PIE)) + , make_ord_flag defGhcFlag "fno-PIE" (NoArg (unSetGeneralFlag Opt_PIE)) ------ Debugging flags ---------------------------------------------- , make_ord_flag defGhcFlag "g" (OptIntSuffix setDebugLevel) ===================================== compiler/GHC/HsToCore/Binds.hs ===================================== @@ -55,7 +55,6 @@ import GHC.Core.Coercion import GHC.Core.Multiplicity import GHC.Builtin.Types ( naturalTy, typeSymbolKind ) import GHC.Types.Id -import GHC.Types.Id.Make(proxyHashId) import GHC.Types.Name import GHC.Types.Var.Set import GHC.Core.Rules @@ -1219,7 +1218,7 @@ dsEvTerm (EvFun { et_tvs = tvs, et_given = given dsEvTypeable :: Type -> EvTypeable -> DsM CoreExpr -- Return a CoreExpr :: Typeable ty -- This code is tightly coupled to the representation --- of TypeRep, in base library Data.Typeable.Internals +-- of TypeRep, in base library Data.Typeable.Internal dsEvTypeable ty ev = do { tyCl <- dsLookupTyCon typeableClassName -- Typeable ; let kind = typeKind ty @@ -1298,14 +1297,13 @@ ds_ev_typeable ty (EvTypeableTyLit ev) = -- See Note [Typeable for Nat and Symbol] in GHC.Tc.Solver.Interact do { fun <- dsLookupGlobalId tr_fun ; dict <- dsEvTerm ev -- Of type KnownNat/KnownSymbol - ; let proxy = mkTyApps (Var proxyHashId) [ty_kind, ty] - ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict, proxy ]) } + ; return (mkApps (mkTyApps (Var fun) [ty]) [ dict ]) } where ty_kind = typeKind ty -- tr_fun is the Name of - -- typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a - -- of typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a + -- typeNatTypeRep :: KnownNat a => TypeRep a + -- of typeSymbolTypeRep :: KnownSymbol a => TypeRep a tr_fun | ty_kind `eqType` naturalTy = typeNatTypeRepName | ty_kind `eqType` typeSymbolKind = typeSymbolTypeRepName | otherwise = panic "dsEvTypeable: unknown type lit kind" ===================================== compiler/GHC/Tc/Instance/Class.hs ===================================== @@ -548,7 +548,7 @@ have this instance, implemented here by doTyLit: instance KnownNat n => Typeable (n :: Nat) where typeRep = typeNatTypeRep @n where - Data.Typeable.Internals.typeNatTypeRep :: KnownNat a => TypeRep a + Data.Typeable.Internal.typeNatTypeRep :: KnownNat a => TypeRep a Ultimately typeNatTypeRep uses 'natSing' from KnownNat to get a runtime value 'n'; it turns it into a string with 'show' and uses ===================================== compiler/GHC/Tc/Types/Evidence.hs ===================================== @@ -1022,7 +1022,7 @@ instance Outputable EvTypeable where -- overloaded-label dictionary to expose the underlying value. We -- expect the 'Type' to have the form `IP sym ty` or `IsLabel sym ty`, -- and return a 'Coercion' `co :: IP sym ty ~ ty` or --- `co :: IsLabel sym ty ~ Proxy# sym -> ty`. See also +-- `co :: IsLabel sym ty ~ ty`. See also -- Note [Type-checking overloaded labels] in "GHC.Tc.Gen.Expr". unwrapIP :: Type -> CoercionR unwrapIP ty = ===================================== configure.ac ===================================== @@ -417,7 +417,8 @@ set_up_tarballs() { rm -rf inplace/mingw local base_dir="../ghc-tarballs/${tarball_dest_dir}" ( cd inplace && - find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; && + find "${base_dir}" -name "*.tar.xz" -exec tar --xz -xf {} \; && + find "${base_dir}" -name "*.tar.zst" -exec tar --zstd -xf {} \; && rm ".MTREE" && rm ".PKGINFO" && cd .. ) || AC_MSG_ERROR([Could not extract Windows toolchains.]) ===================================== libraries/base/Data/Typeable/Internal.hs ===================================== @@ -979,12 +979,12 @@ mkTypeLitTyCon name kind_tycon where kind = KindRepTyConApp kind_tycon [] -- | Used to make `'Typeable' instance for things of kind Nat -typeNatTypeRep :: KnownNat a => Proxy# a -> TypeRep a -typeNatTypeRep p = typeLitTypeRep (show (natVal' p)) tcNat +typeNatTypeRep :: forall a. KnownNat a => TypeRep a +typeNatTypeRep = typeLitTypeRep (show (natVal' (proxy# @a))) tcNat -- | Used to make `'Typeable' instance for things of kind Symbol -typeSymbolTypeRep :: KnownSymbol a => Proxy# a -> TypeRep a -typeSymbolTypeRep p = typeLitTypeRep (show (symbolVal' p)) tcSymbol +typeSymbolTypeRep :: forall a. KnownSymbol a => TypeRep a +typeSymbolTypeRep = typeLitTypeRep (show (symbolVal' (proxy# @a))) tcSymbol mkTypeLitFromString :: TypeLitSort -> String -> SomeTypeRep mkTypeLitFromString TypeLitSymbol s = ===================================== libraries/base/GHC/Exception.hs-boot ===================================== @@ -14,7 +14,7 @@ More dramatically GHC.Exception imports Data.Typeable -imports Data.Typeable.Internals +imports Data.Typeable.Internal imports GHC.Arr (fingerprint representation etc) imports GHC.Real imports {-# SOURCE #-} GHC.Exception ===================================== libraries/base/GHC/IO/Handle/Lock/Windows.hsc ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} -- | File locking for Windows. module GHC.IO.Handle.Lock.Windows where ===================================== rts/RtsSymbols.c ===================================== @@ -151,7 +151,9 @@ __imp___acrt_iob_func, __rts_iob_func, true)) \ RTS_WIN32_ONLY(SymI_HasProto_redirect( \ __imp____acrt_iob_func, __rts_iob_func, true)) \ - SymI_HasProto(__mingw_vsnwprintf) + SymI_HasProto(__mingw_vsnwprintf) \ + /* ^^ Need to figure out why this is needed. */ \ + SymI_HasProto(__mingw_vfprintf) \ /* ^^ Need to figure out why this is needed. */ #define RTS_MINGW_COMPAT_SYMBOLS \ ===================================== testsuite/driver/runtests.py ===================================== @@ -457,7 +457,21 @@ else: if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + # Group metrics by metric type + groups = {} # type: Dict[MetricName, List[PerfMetric]] + for m in t.metrics: + if m.stat.metric not in groups: + groups[m.stat.metric] = [] + + groups[m.stat.metric].append(m) + + for metric_name, stats in groups.items(): + heading = 'Metrics: %s' % metric_name + print() + print(heading) + print('-' * len(heading)) + print() + tabulate_metrics(stats) else: print("\nNone collected.") print("") ===================================== testsuite/tests/concurrent/should_run/conc059_c.c ===================================== @@ -1,6 +1,7 @@ #include "HsFFI.h" #include "conc059_stub.h" #include +#include #include #if mingw32_HOST_OS #include ===================================== testsuite/tests/ghci/scripts/T9293.stdout-mingw32 ===================================== @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is not enabled @@ -35,7 +34,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should work, GADTs is in force from :set @@ -56,7 +54,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is now disabled @@ -79,7 +76,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is only enabled at the prompt ===================================== testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 ===================================== @@ -14,7 +14,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports ~~~~~~~~~~ Testing :set -a ===================================== testsuite/tests/ghci/scripts/ghci057.stdout-mingw32 ===================================== @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is not enabled @@ -35,7 +34,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should work, GADTs is in force from :set @@ -56,7 +54,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is now disabled @@ -79,7 +76,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is only enabled at the prompt View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/338c2dfa5adc5ffe0074dc77f854a895a4b2268a...7d617697c31df3cb198e79e95f3121a4323a9a42 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/338c2dfa5adc5ffe0074dc77f854a895a4b2268a...7d617697c31df3cb198e79e95f3121a4323a9a42 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 15 23:24:41 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Thu, 15 Oct 2020 19:24:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports-8.10 Message-ID: <5f88da39b046f_2800d569e4454035f@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/backports-8.10 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports-8.10 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 01:57:23 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 21:57:23 -0400 Subject: [Git][ghc/ghc][master] Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Message-ID: <5f88fe03e509c_2800d10b17c552641@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 15 changed files: - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - docs/users_guide/9.2.1-notes.rst - docs/users_guide/using-optimisation.rst - + testsuite/tests/deriving/should_compile/T11068_aggressive.hs - + testsuite/tests/deriving/should_compile/T11068_aggressive.stderr - testsuite/tests/deriving/should_compile/all.T - testsuite/tests/perf/compiler/Makefile - + testsuite/tests/perf/compiler/T11068.hs - + testsuite/tests/perf/compiler/T11068a.hs - + testsuite/tests/perf/compiler/T11068b.hs - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -158,6 +158,8 @@ data GeneralFlag | Opt_Specialise | Opt_SpecialiseAggressively | Opt_CrossModuleSpecialise + | Opt_InlineGenerics + | Opt_InlineGenericsAggressively | Opt_StaticArgumentTransformation | Opt_CSE | Opt_StgCSE ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3468,6 +3468,8 @@ fFlagsDeps = [ flagSpec "specialize-aggressively" Opt_SpecialiseAggressively, flagSpec "cross-module-specialise" Opt_CrossModuleSpecialise, flagSpec "cross-module-specialize" Opt_CrossModuleSpecialise, + flagSpec "inline-generics" Opt_InlineGenerics, + flagSpec "inline-generics-aggressively" Opt_InlineGenericsAggressively, flagSpec "static-argument-transformation" Opt_StaticArgumentTransformation, flagSpec "strictness" Opt_Strictness, flagSpec "use-rpaths" Opt_RPath, @@ -3981,6 +3983,7 @@ optLevelFlags -- see Note [Documenting optimisation flags] , ([1,2], Opt_Specialise) , ([1,2], Opt_CrossModuleSpecialise) + , ([1,2], Opt_InlineGenerics) , ([1,2], Opt_Strictness) , ([1,2], Opt_UnboxSmallStrictFields) , ([1,2], Opt_CprAnal) ===================================== compiler/GHC/Tc/Deriv.hs ===================================== @@ -2049,8 +2049,7 @@ genDerivStuff mechanism loc clas inst_tys tyvars , dit_rep_tc_args = rep_tc_args } , dsm_stock_gen_fn = gen_fn } - -> do (binds, faminsts, field_names) <- gen_fn loc rep_tc rep_tc_args inst_tys - pure (binds, [], faminsts, field_names) + -> gen_fn loc rep_tc rep_tc_args inst_tys -- Try DeriveAnyClass DerivSpecAnyClass -> do ===================================== compiler/GHC/Tc/Deriv/Generics.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Builtin.Types import GHC.Builtin.Names import GHC.Tc.Utils.Env import GHC.Tc.Utils.Monad +import GHC.Driver.Session import GHC.Driver.Types import GHC.Utils.Error( Validity(..), andValid ) import GHC.Types.SrcLoc @@ -76,10 +77,12 @@ For the generic representation we need to generate: -} gen_Generic_binds :: GenericKind -> TyCon -> [Type] - -> TcM (LHsBinds GhcPs, FamInst) + -> TcM (LHsBinds GhcPs, [LSig GhcPs], FamInst) gen_Generic_binds gk tc inst_tys = do + dflags <- getDynFlags repTyInsts <- tc_mkRepFamInsts gk tc inst_tys - return (mkBindsRep gk tc, repTyInsts) + let (binds, sigs) = mkBindsRep dflags gk tc + return (binds, sigs, repTyInsts) {- ************************************************************************ @@ -332,12 +335,33 @@ gk2gkDC Gen1_{} d = Gen1_DC $ last $ dataConUnivTyVars d -- Bindings for the Generic instance -mkBindsRep :: GenericKind -> TyCon -> LHsBinds GhcPs -mkBindsRep gk tycon = - unitBag (mkRdrFunBind (L loc from01_RDR) [from_eqn]) - `unionBags` - unitBag (mkRdrFunBind (L loc to01_RDR) [to_eqn]) +mkBindsRep :: DynFlags -> GenericKind -> TyCon -> (LHsBinds GhcPs, [LSig GhcPs]) +mkBindsRep dflags gk tycon = (binds, sigs) where + binds = unitBag (mkRdrFunBind (L loc from01_RDR) [from_eqn]) + `unionBags` + unitBag (mkRdrFunBind (L loc to01_RDR) [to_eqn]) + + -- See Note [Generics performance tricks] + sigs = if gopt Opt_InlineGenericsAggressively dflags + || (gopt Opt_InlineGenerics dflags && inlining_useful) + then [inline1 from01_RDR, inline1 to01_RDR] + else [] + where + inlining_useful + | cons <= 1 = True + | cons <= 4 = max_fields <= 5 + | cons <= 8 = max_fields <= 2 + | cons <= 16 = max_fields <= 1 + | cons <= 24 = max_fields == 0 + | otherwise = False + where + cons = length datacons + max_fields = maximum $ map dataConSourceArity datacons + + inline1 f = L loc . InlineSig noExtField (L loc f) + $ alwaysInlinePragma { inl_act = ActiveAfter NoSourceText 1 } + -- The topmost M1 (the datatype metadata) has the exact same type -- across all cases of a from/to definition, and can be factored out -- to save some allocations during typechecking. @@ -1039,4 +1063,48 @@ factor it out reduce the typechecker's burden: A simple change, but one that pays off, since it goes turns an O(n) amount of coercions to an O(1) amount. + +Note [Generics performance tricks] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Generics-based algorithms tend to rely on GHC optimizing away the intermediate +representation for optimal performance. However, the default unfolding threshold +is usually too small for GHC to do that. + +The recommended approach thus far was to increase unfolding threshold, but this +makes GHC inline more aggressively in general, whereas it should only be more +aggresive with generics-based code. + +The solution is to use a heuristic that'll annotate Generic class methods with +INLINE[1] pragmas (the explicit phase is used to give users phase control as +they can annotate their functions with INLINE[2] or INLINE[0] if appropriate). + +The current heuristic was chosen by looking at how annotating Generic methods +INLINE[1] helps with optimal code generation for several types of generic +algorithms: + +* Round trip through the generic representation. + +* Generation of NFData instances. + +* Generation of field lenses. + +The experimentation was done by picking data types having N constructors with M +fields each and using their derived Generic instances to generate code with the +above algorithms. + +The results are threshold values for N and M (contained in +`mkBindsRep.inlining_useful`) for which inlining is beneficial, i.e. it usually +leads to performance improvements at both compile time (the simplifier has to do +more work, but then there's much less code left for subsequent phases to work +with) and run time (the generic representation of a data type is optimized +away). + +The T11068 test case, which includes the algorithms mentioned above, tests that +the generic representations of several data types optimize away using the +threshold values in `mkBindsRep.inlining_useful`. + +If one uses threshold values higher what is found in +`mkBindsRep.inlining_useful`, then annotating Generic class methods with INLINE +pragmas tends to be at best useless and at worst lead to code size blowup +without runtime performance improvements. -} ===================================== compiler/GHC/Tc/Deriv/Utils.hs ===================================== @@ -222,19 +222,22 @@ data DerivSpecMechanism SrcSpan -> TyCon -- dit_rep_tc -> [Type] -- dit_rep_tc_args -> [Type] -- inst_tys - -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]) - -- ^ This function returns three things: + -> TcM (LHsBinds GhcPs, [LSig GhcPs], BagDerivStuff, [Name]) + -- ^ This function returns four things: -- -- 1. @LHsBinds GhcPs@: The derived instance's function bindings -- (e.g., @compare (T x) (T y) = compare x y@) -- - -- 2. @BagDerivStuff@: Auxiliary bindings needed to support the derived + -- 2. @[LSig GhcPs]@: A list of instance specific signatures/pragmas. + -- Most likely INLINE pragmas for class methods. + -- + -- 3. @BagDerivStuff@: Auxiliary bindings needed to support the derived -- instance. As examples, derived 'Generic' instances require -- associated type family instances, and derived 'Eq' and 'Ord' -- instances require top-level @con2tag@ functions. -- See @Note [Auxiliary binders]@ in "GHC.Tc.Deriv.Generate". -- - -- 3. @[Name]@: A list of Names for which @-Wunused-binds@ should be + -- 4. @[Name]@: A list of Names for which @-Wunused-binds@ should be -- suppressed. This is used to suppress unused warnings for record -- selectors when deriving 'Read', 'Show', or 'Generic'. -- See @Note [Deriving and unused record selectors]@. @@ -427,7 +430,7 @@ instance Outputable DerivContext where data OriginativeDerivStatus = CanDeriveStock -- Stock class, can derive (SrcSpan -> TyCon -> [Type] -> [Type] - -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) + -> TcM (LHsBinds GhcPs, [LSig GhcPs], BagDerivStuff, [Name])) | StockClassError SDoc -- Stock class, but can't do it | CanDeriveAnyClass -- See Note [Deriving any class] | NonDerivableClass SDoc -- Cannot derive with either stock or anyclass @@ -566,7 +569,7 @@ hasStockDeriving -> TyCon -> [Type] -> [Type] - -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name])) + -> TcM (LHsBinds GhcPs, [LSig GhcPs], BagDerivStuff, [Name])) hasStockDeriving clas = assocMaybe gen_list (getUnique clas) where @@ -575,7 +578,7 @@ hasStockDeriving clas -> TyCon -> [Type] -> [Type] - -> TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))] + -> TcM (LHsBinds GhcPs, [LSig GhcPs], BagDerivStuff, [Name]))] gen_list = [ (eqClassKey, simpleM gen_Eq_binds) , (ordClassKey, simpleM gen_Ord_binds) , (enumClassKey, simpleM gen_Enum_binds) @@ -593,7 +596,7 @@ hasStockDeriving clas simple gen_fn loc tc tc_args _ = let (binds, deriv_stuff) = gen_fn loc tc tc_args - in return (binds, deriv_stuff, []) + in return (binds, [], deriv_stuff, []) -- Like `simple`, but monadic. The only monadic thing that these functions -- do is allocate new Uniques, which are used for generating the names of @@ -601,18 +604,18 @@ hasStockDeriving clas -- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate. simpleM gen_fn loc tc tc_args _ = do { (binds, deriv_stuff) <- gen_fn loc tc tc_args - ; return (binds, deriv_stuff, []) } + ; return (binds, [], deriv_stuff, []) } read_or_show gen_fn loc tc tc_args _ = do { fix_env <- getDataConFixityFun tc ; let (binds, deriv_stuff) = gen_fn fix_env loc tc tc_args field_names = all_field_names tc - ; return (binds, deriv_stuff, field_names) } + ; return (binds, [], deriv_stuff, field_names) } generic gen_fn _ tc _ inst_tys - = do { (binds, faminst) <- gen_fn tc inst_tys + = do { (binds, sigs, faminst) <- gen_fn tc inst_tys ; let field_names = all_field_names tc - ; return (binds, unitBag (DerivFamInst faminst), field_names) } + ; return (binds, sigs, unitBag (DerivFamInst faminst), field_names) } -- See Note [Deriving and unused record selectors] all_field_names = map flSelector . concatMap dataConFieldLabels ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -28,6 +28,12 @@ Compiler since the argument was already forced in the first equation. For more details see :ghc-flag:`-Wredundant-bang-patterns`. +- New ``-finline-generics`` and ``-finline-generics-aggressively`` flags for + improving performance of generics-based algorithms. + + For more details see :ghc-flag:`-finline-generics` and + :ghc-flag:`-finline-generics-aggressively`. + - Type checker plugins which work with the natural numbers now should use ``naturalTy`` kind instead of ``typeNatKind``, which has been removed. ===================================== docs/users_guide/using-optimisation.rst ===================================== @@ -979,6 +979,50 @@ by saying ``-fno-wombat``. which returns a constrained type. For example, a type class where one of the methods implements a traversal. +.. ghc-flag:: -finline-generics + :shortdesc: Annotate methods of derived Generic and Generic1 instances with + INLINE[1] pragmas based on heuristics. Implied by :ghc-flag:`-O`. + :type: dynamic + :reverse: -fno-inline-generics + :category: + + :default: on + :since: 9.2.1 + + .. index:: + single: inlining, controlling + single: unfolding, controlling + + Annotate methods of derived Generic and Generic1 instances with INLINE[1] + pragmas based on heuristics dependent on the size of the data type in + question. Improves performance of generics-based algorithms as GHC is able + to optimize away intermediate representation more often. + +.. ghc-flag:: -finline-generics-aggressively + :shortdesc: Annotate methods of all derived Generic and Generic1 instances + with INLINE[1] pragmas. + :type: dynamic + :reverse: -fno-inline-generics-aggressively + :category: + + :default: off + :since: 9.2.1 + + .. index:: + single: inlining, controlling + single: unfolding, controlling + + Annotate methods of all derived Generic and Generic1 instances with + INLINE[1] pragmas. + + This flag should only be used in modules deriving Generic instances that + weren't considered appropriate for INLINE[1] annotations by heuristics of + :ghc-flag:`-finline-generics`, yet you know that doing so would be + beneficial. + + When enabled globally it will most likely lead to worse compile times and + code size blowup without runtime performance gains. + .. ghc-flag:: -fsolve-constant-dicts :shortdesc: When solving constraints, try to eagerly solve super classes using available dictionaries. ===================================== testsuite/tests/deriving/should_compile/T11068_aggressive.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# OPTIONS_GHC -finline-generics-aggressively #-} +module T11068_aggressive where + +import GHC.Generics + +-- For 2 data constructors -finline-generics annotates class methods of the +-- derived Generic instance as INLINE[1] only if each has at most 5 fields. +data X + = X1 Int Int Int Int Int Int Int Int Int Int + | X2 Int Int Int Int Int Int Int Int Int Int + deriving Generic ===================================== testsuite/tests/deriving/should_compile/T11068_aggressive.stderr ===================================== @@ -0,0 +1,250 @@ + +==================== Derived instances ==================== +Derived class instances: + instance GHC.Generics.Generic T11068_aggressive.X where + {-# INLINE [1] GHC.Generics.from #-} + {-# INLINE [1] GHC.Generics.to #-} + GHC.Generics.from x + = GHC.Generics.M1 + (case x of + T11068_aggressive.X1 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 + -> GHC.Generics.L1 + (GHC.Generics.M1 + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g1)) + (GHC.Generics.M1 (GHC.Generics.K1 g2))) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g3)) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g4)) + (GHC.Generics.M1 (GHC.Generics.K1 g5))))) + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g6)) + (GHC.Generics.M1 (GHC.Generics.K1 g7))) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g8)) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g9)) + (GHC.Generics.M1 (GHC.Generics.K1 g10))))))) + T11068_aggressive.X2 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 + -> GHC.Generics.R1 + (GHC.Generics.M1 + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g1)) + (GHC.Generics.M1 (GHC.Generics.K1 g2))) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g3)) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g4)) + (GHC.Generics.M1 (GHC.Generics.K1 g5))))) + ((GHC.Generics.:*:) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g6)) + (GHC.Generics.M1 (GHC.Generics.K1 g7))) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g8)) + ((GHC.Generics.:*:) + (GHC.Generics.M1 (GHC.Generics.K1 g9)) + (GHC.Generics.M1 (GHC.Generics.K1 g10)))))))) + GHC.Generics.to (GHC.Generics.M1 x) + = case x of + (GHC.Generics.L1 (GHC.Generics.M1 ((GHC.Generics.:*:) ((GHC.Generics.:*:) ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g1)) + (GHC.Generics.M1 (GHC.Generics.K1 g2))) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g3)) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g4)) + (GHC.Generics.M1 (GHC.Generics.K1 g5))))) + ((GHC.Generics.:*:) ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g6)) + (GHC.Generics.M1 (GHC.Generics.K1 g7))) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g8)) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g9)) + (GHC.Generics.M1 (GHC.Generics.K1 g10)))))))) + -> T11068_aggressive.X1 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 + (GHC.Generics.R1 (GHC.Generics.M1 ((GHC.Generics.:*:) ((GHC.Generics.:*:) ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g1)) + (GHC.Generics.M1 (GHC.Generics.K1 g2))) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g3)) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g4)) + (GHC.Generics.M1 (GHC.Generics.K1 g5))))) + ((GHC.Generics.:*:) ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g6)) + (GHC.Generics.M1 (GHC.Generics.K1 g7))) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g8)) + ((GHC.Generics.:*:) (GHC.Generics.M1 (GHC.Generics.K1 g9)) + (GHC.Generics.M1 (GHC.Generics.K1 g10)))))))) + -> T11068_aggressive.X2 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 + + +Derived type family instances: + type GHC.Generics.Rep T11068_aggressive.X = GHC.Generics.D1 + ('GHC.Generics.MetaData + "X" "T11068_aggressive" "main" 'GHC.Types.False) + (GHC.Generics.C1 + ('GHC.Generics.MetaCons + "X1" 'GHC.Generics.PrefixI 'GHC.Types.False) + (((GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)))) + GHC.Generics.:*: ((GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int))))) + GHC.Generics.:+: GHC.Generics.C1 + ('GHC.Generics.MetaCons + "X2" + 'GHC.Generics.PrefixI + 'GHC.Types.False) + (((GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)))) + GHC.Generics.:*: ((GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: (GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int) + GHC.Generics.:*: GHC.Generics.S1 + ('GHC.Generics.MetaSel + 'GHC.Maybe.Nothing + 'GHC.Generics.NoSourceUnpackedness + 'GHC.Generics.NoSourceStrictness + 'GHC.Generics.DecidedLazy) + (GHC.Generics.Rec0 + GHC.Types.Int)))))) ===================================== testsuite/tests/deriving/should_compile/all.T ===================================== @@ -65,6 +65,7 @@ test('T7947', [], multimod_compile, ['T7947', '-v0']) test('T10561', normal, compile, ['']) test('T10487', [], multimod_compile, ['T10487', '-v0']) test('T10524', normal, compile, ['']) +test('T11068_aggressive', [normalise_errmsg_fun(just_the_deriving)], compile, ['-ddump-deriv -dsuppress-uniques']) test('T11148', normal, makefile_test, []) test('T9968', normal, compile, ['']) test('T9968a', normal, compile, ['']) ===================================== testsuite/tests/perf/compiler/Makefile ===================================== @@ -7,3 +7,8 @@ T4007: $(RM) -f T4007.hi T4007.o '$(TEST_HC)' $(TEST_HC_OPTS) -c -O -ddump-rule-firings T4007.hs +T11068: + $(RM) -f T11068a.hi T11068a.o T11068b.hi T11068b.o T11068.hi T11068.o + '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T11068a.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -c -O T11068b.hs + -'$(TEST_HC)' $(TEST_HC_OPTS) -c -O T11068.hs -ddump-simpl | grep 'Generic' ===================================== testsuite/tests/perf/compiler/T11068.hs ===================================== @@ -0,0 +1,104 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE TypeApplications #-} +module T11068 where + +import Control.DeepSeq +import GHC.Generics + +import T11068a +import T11068b + +-- X1 + +instance NFData X1 + +x1_id :: X1 -> X1 +x1_id = to . from + +x1_lens :: Lens' X1 Integer +x1_lens = gfield @"x1_f1" + +-- X1' + +instance NFData X1' + +x1'_id :: X1' -> X1' +x1'_id = to . from + +x1'_lens :: Lens' X1' Integer +x1'_lens = gfield @"x1'_f1" + +-- X4 + +instance NFData X4 + +x4_id :: X4 -> X4 +x4_id = to . from + +x4_lens :: Lens' X4 Integer +x4_lens = gfield @"x4_f1" + +-- X4' + +instance NFData X4' + +x4'_id :: X4' -> X4' +x4'_id = to . from + +x4'_lens :: Lens' X4' Integer +x4'_lens = gfield @"x4'_f1" + +-- X8 + +instance NFData X8 + +x8_id :: X8 -> X8 +x8_id = to . from + +x8_lens :: Lens' X8 Integer +x8_lens = gfield @"x8_f1" + +-- X8' + +instance NFData X8' + +x8'_id :: X8' -> X8' +x8'_id = to . from + +x8'_lens :: Lens' X8' Integer +x8'_lens = gfield @"x8'_f1" + +-- X12' + +instance NFData X12' + +-- id for data types with strict fields fully optimizes up to 12x1 +x12'_id :: X12' -> X12' +x12'_id = to . from + +x12'_lens :: Lens' X12' Integer +x12'_lens = gfield @"x12'_f1" + +-- X16 + +instance NFData X16 + +x16_id :: X16 -> X16 +x16_id = to . from + +x16_lens :: Lens' X16 Integer +x16_lens = gfield @"x16_f1" + +-- X16' + +instance NFData X16' + +x16'_lens :: Lens' X16' Integer +x16'_lens = gfield @"x16'_f1" + +-- X24 + +instance NFData X24 + +x24_id :: X24 -> X24 +x24_id = to . from ===================================== testsuite/tests/perf/compiler/T11068a.hs ===================================== @@ -0,0 +1,394 @@ +{-# LANGUAGE DeriveGeneric #-} +module T11068a where + +import GHC.Generics + +data X1 + = X11 { x1_f1 :: Integer + , x1_f2 :: Integer + , x1_f3 :: Integer + , x1_f4 :: Integer + , x1_f5 :: Integer + , x1_f6 :: Integer + , x1_f7 :: Integer + , x1_f8 :: Integer + , x1_f9 :: Integer + , x1_f10 :: Integer + , x1_f11 :: Integer + , x1_f12 :: Integer + , x1_f13 :: Integer + , x1_f14 :: Integer + , x1_f15 :: Integer + , x1_f16 :: Integer + , x1_f17 :: Integer + , x1_f18 :: Integer + , x1_f19 :: Integer + , x1_f20 :: Integer + , x1_f21 :: Integer + , x1_f22 :: Integer + , x1_f23 :: Integer + , x1_f24 :: Integer + , x1_f25 :: Integer + , x1_f26 :: Integer + , x1_f27 :: Integer + , x1_f28 :: Integer + , x1_f29 :: Integer + , x1_f30 :: Integer + , x1_f31 :: Integer + , x1_f32 :: Integer + , x1_f33 :: Integer + , x1_f34 :: Integer + , x1_f35 :: Integer + , x1_f36 :: Integer + , x1_f37 :: Integer + , x1_f38 :: Integer + , x1_f39 :: Integer + , x1_f40 :: Integer + , x1_f41 :: Integer + , x1_f42 :: Integer + , x1_f43 :: Integer + , x1_f44 :: Integer + , x1_f45 :: Integer + , x1_f46 :: Integer + , x1_f47 :: Integer + , x1_f48 :: Integer + , x1_f49 :: Integer + , x1_f50 :: Integer + , x1_f51 :: Integer + , x1_f52 :: Integer + , x1_f53 :: Integer + , x1_f54 :: Integer + , x1_f55 :: Integer + , x1_f56 :: Integer + , x1_f57 :: Integer + , x1_f58 :: Integer + , x1_f59 :: Integer + , x1_f60 :: Integer + , x1_f61 :: Integer + , x1_f62 :: Integer + , x1_f63 :: Integer + , x1_f64 :: Integer + , x1_f65 :: Integer + , x1_f66 :: Integer + , x1_f67 :: Integer + , x1_f68 :: Integer + , x1_f69 :: Integer + , x1_f70 :: Integer + , x1_f71 :: Integer + , x1_f72 :: Integer + , x1_f73 :: Integer + , x1_f74 :: Integer + , x1_f75 :: Integer + , x1_f76 :: Integer + , x1_f77 :: Integer + , x1_f78 :: Integer + , x1_f79 :: Integer + , x1_f80 :: Integer + , x1_f81 :: Integer + , x1_f82 :: Integer + , x1_f83 :: Integer + , x1_f84 :: Integer + , x1_f85 :: Integer + , x1_f86 :: Integer + , x1_f87 :: Integer + , x1_f88 :: Integer + , x1_f89 :: Integer + , x1_f90 :: Integer + , x1_f91 :: Integer + , x1_f92 :: Integer + , x1_f93 :: Integer + , x1_f94 :: Integer + , x1_f95 :: Integer + , x1_f96 :: Integer + , x1_f97 :: Integer + , x1_f98 :: Integer + , x1_f99 :: Integer + , x1_f100 :: Integer + } deriving Generic + +data X1' + = X1'1 { x1'_f1 :: !Integer + , x1'_f2 :: !Integer + , x1'_f3 :: !Integer + , x1'_f4 :: !Integer + , x1'_f5 :: !Integer + , x1'_f6 :: !Integer + , x1'_f7 :: !Integer + , x1'_f8 :: !Integer + , x1'_f9 :: !Integer + , x1'_f10 :: !Integer + , x1'_f11 :: !Integer + , x1'_f12 :: !Integer + , x1'_f13 :: !Integer + , x1'_f14 :: !Integer + , x1'_f15 :: !Integer + , x1'_f16 :: !Integer + , x1'_f17 :: !Integer + , x1'_f18 :: !Integer + , x1'_f19 :: !Integer + , x1'_f20 :: !Integer + , x1'_f21 :: !Integer + , x1'_f22 :: !Integer + , x1'_f23 :: !Integer + , x1'_f24 :: !Integer + , x1'_f25 :: !Integer + , x1'_f26 :: !Integer + , x1'_f27 :: !Integer + , x1'_f28 :: !Integer + , x1'_f29 :: !Integer + , x1'_f30 :: !Integer + , x1'_f31 :: !Integer + , x1'_f32 :: !Integer + , x1'_f33 :: !Integer + , x1'_f34 :: !Integer + , x1'_f35 :: !Integer + , x1'_f36 :: !Integer + , x1'_f37 :: !Integer + , x1'_f38 :: !Integer + , x1'_f39 :: !Integer + , x1'_f40 :: !Integer + , x1'_f41 :: !Integer + , x1'_f42 :: !Integer + , x1'_f43 :: !Integer + , x1'_f44 :: !Integer + , x1'_f45 :: !Integer + , x1'_f46 :: !Integer + , x1'_f47 :: !Integer + , x1'_f48 :: !Integer + , x1'_f49 :: !Integer + , x1'_f50 :: !Integer + , x1'_f51 :: !Integer + , x1'_f52 :: !Integer + , x1'_f53 :: !Integer + , x1'_f54 :: !Integer + , x1'_f55 :: !Integer + , x1'_f56 :: !Integer + , x1'_f57 :: !Integer + , x1'_f58 :: !Integer + , x1'_f59 :: !Integer + , x1'_f60 :: !Integer + , x1'_f61 :: !Integer + , x1'_f62 :: !Integer + , x1'_f63 :: !Integer + , x1'_f64 :: !Integer + , x1'_f65 :: !Integer + , x1'_f66 :: !Integer + , x1'_f67 :: !Integer + , x1'_f68 :: !Integer + , x1'_f69 :: !Integer + , x1'_f70 :: !Integer + , x1'_f71 :: !Integer + , x1'_f72 :: !Integer + , x1'_f73 :: !Integer + , x1'_f74 :: !Integer + , x1'_f75 :: !Integer + , x1'_f76 :: !Integer + , x1'_f77 :: !Integer + , x1'_f78 :: !Integer + , x1'_f79 :: !Integer + , x1'_f80 :: !Integer + , x1'_f81 :: !Integer + , x1'_f82 :: !Integer + , x1'_f83 :: !Integer + , x1'_f84 :: !Integer + , x1'_f85 :: !Integer + , x1'_f86 :: !Integer + , x1'_f87 :: !Integer + , x1'_f88 :: !Integer + , x1'_f89 :: !Integer + , x1'_f90 :: !Integer + , x1'_f91 :: !Integer + , x1'_f92 :: !Integer + , x1'_f93 :: !Integer + , x1'_f94 :: !Integer + , x1'_f95 :: !Integer + , x1'_f96 :: !Integer + , x1'_f97 :: !Integer + , x1'_f98 :: !Integer + , x1'_f99 :: !Integer + , x1'_f100 :: !Integer + } deriving Generic + +data X4 + = X41 { x4_f1 :: Integer + , x4_f2 :: Integer + , x4_f3 :: Integer + , x4_f4 :: Integer + , x4_f5 :: Integer + } + | X42 { x4_f1 :: Integer + , x4_f2 :: Integer + , x4_f3 :: Integer + , x4_f4 :: Integer + , x4_f5 :: Integer + } + | X43 { x4_f1 :: Integer + , x4_f2 :: Integer + , x4_f3 :: Integer + , x4_f4 :: Integer + , x4_f5 :: Integer + } + | X44 { x4_f1 :: Integer + , x4_f2 :: Integer + , x4_f3 :: Integer + , x4_f4 :: Integer + , x4_f5 :: Integer + } deriving Generic + +data X4' + = X4'1 { x4'_f1 :: !Integer + , x4'_f2 :: !Integer + , x4'_f3 :: !Integer + , x4'_f4 :: !Integer + , x4'_f5 :: !Integer + } + | X4'2 { x4'_f1 :: !Integer + , x4'_f2 :: !Integer + , x4'_f3 :: !Integer + , x4'_f4 :: !Integer + , x4'_f5 :: !Integer + } + | X4'3 { x4'_f1 :: !Integer + , x4'_f2 :: !Integer + , x4'_f3 :: !Integer + , x4'_f4 :: !Integer + , x4'_f5 :: !Integer + } + | X4'4 { x4'_f1 :: !Integer + , x4'_f2 :: !Integer + , x4'_f3 :: !Integer + , x4'_f4 :: !Integer + , x4'_f5 :: !Integer + } deriving Generic + +data X8 + = X81 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X82 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X83 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X84 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X85 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X86 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X87 { x8_f1 :: Integer + , x8_f2 :: Integer + } + | X88 { x8_f1 :: Integer + , x8_f2 :: Integer + } deriving Generic + +data X8' + = X8'1 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'2 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'3 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'4 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'5 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'6 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'7 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } + | X8'8 { x8'_f1 :: !Integer + , x8'_f2 :: !Integer + } deriving Generic + +data X12' + = X12'1 { x12'_f1 :: !Integer } + | X12'2 { x12'_f1 :: !Integer } + | X12'3 { x12'_f1 :: !Integer } + | X12'4 { x12'_f1 :: !Integer } + | X12'5 { x12'_f1 :: !Integer } + | X12'6 { x12'_f1 :: !Integer } + | X12'7 { x12'_f1 :: !Integer } + | X12'8 { x12'_f1 :: !Integer } + | X12'9 { x12'_f1 :: !Integer } + | X12'10 { x12'_f1 :: !Integer } + | X12'11 { x12'_f1 :: !Integer } + | X12'12 { x12'_f1 :: !Integer } + deriving Generic + +data X16 + = X161 { x16_f1 :: Integer } + | X162 { x16_f1 :: Integer } + | X163 { x16_f1 :: Integer } + | X164 { x16_f1 :: Integer } + | X165 { x16_f1 :: Integer } + | X166 { x16_f1 :: Integer } + | X167 { x16_f1 :: Integer } + | X168 { x16_f1 :: Integer } + | X169 { x16_f1 :: Integer } + | X1610 { x16_f1 :: Integer } + | X1611 { x16_f1 :: Integer } + | X1612 { x16_f1 :: Integer } + | X1613 { x16_f1 :: Integer } + | X1614 { x16_f1 :: Integer } + | X1615 { x16_f1 :: Integer } + | X1616 { x16_f1 :: Integer } + deriving Generic + +data X16' + = X16'1 { x16'_f1 :: !Integer } + | X16'2 { x16'_f1 :: !Integer } + | X16'3 { x16'_f1 :: !Integer } + | X16'4 { x16'_f1 :: !Integer } + | X16'5 { x16'_f1 :: !Integer } + | X16'6 { x16'_f1 :: !Integer } + | X16'7 { x16'_f1 :: !Integer } + | X16'8 { x16'_f1 :: !Integer } + | X16'9 { x16'_f1 :: !Integer } + | X16'10 { x16'_f1 :: !Integer } + | X16'11 { x16'_f1 :: !Integer } + | X16'12 { x16'_f1 :: !Integer } + | X16'13 { x16'_f1 :: !Integer } + | X16'14 { x16'_f1 :: !Integer } + | X16'15 { x16'_f1 :: !Integer } + | X16'16 { x16'_f1 :: !Integer } + deriving Generic + +data X24 + = X241 + | X242 + | X243 + | X244 + | X245 + | X246 + | X247 + | X248 + | X249 + | X2410 + | X2411 + | X2412 + | X2413 + | X2414 + | X2415 + | X2416 + | X2417 + | X2418 + | X2419 + | X2420 + | X2421 + | X2422 + | X2423 + | X2424 + deriving Generic ===================================== testsuite/tests/perf/compiler/T11068b.hs ===================================== @@ -0,0 +1,200 @@ +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FunctionalDependencies #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE UndecidableInstances #-} +module T11068b (Lens', GField(..)) where + +import Data.Kind +import Data.Type.Bool +import Data.Type.Equality +import GHC.Generics +import GHC.TypeLits + +-- Code taken from the optics / generic-lens-lite library. + +---------------------------------------- +-- Profunctors + +data Context a b t = Context (b -> t) a + deriving Functor + +class Profunctor p where + dimap :: (a -> b) -> (c -> d) -> p b c -> p a d + lmap :: (a -> b) -> p b c -> p a c + rmap :: (c -> d) -> p b c -> p b d + +class Profunctor p => Strong p where + first' :: p a b -> p (a, c) (b, c) + second' :: p a b -> p (c, a) (c, b) + + linear :: LensVL s t a b -> p a b -> p s t + linear f = dimap + ((\(Context bt a) -> (a, bt)) . f (Context id)) + (\(b, bt) -> bt b) + . first' + {-# INLINE linear #-} + +data Store a b s t = Store (s -> a) (s -> b -> t) + +instance Profunctor (Store a b) where + dimap f g (Store get set) = Store (get . f) (\s -> g . set (f s)) + lmap f (Store get set) = Store (get . f) (\s -> set (f s)) + rmap g (Store get set) = Store get (\s -> g . set s) + +instance Strong (Store a b) where + first' (Store get set) = Store (get . fst) (\(s, c) b -> (set s b, c)) + second' (Store get set) = Store (get . snd) (\(c, s) b -> (c, set s b)) + +---------------------------------------- +-- Lens + +type LensVL s t a b = forall f. Functor f => (a -> f b) -> s -> f t +type LensVL' s a = LensVL s s a a + +newtype Lens s t a b = Lens (forall p. Strong p => p a b -> p s t) +type Lens' s a = Lens s s a a + +lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b +lens get set = Lens $ dimap (\s -> (get s, s)) + (\(b, s) -> set s b) + . first' + +lensVL :: LensVL s t a b -> Lens s t a b +lensVL l = Lens (linear l) + +withLens :: Lens s t a b -> ((s -> a) -> (s -> b -> t) -> r) -> r +withLens (Lens l) k = case l $ Store id (\_ -> id) of + Store get set -> k get set + +---------------------------------------- +-- Field + +class GField (name :: Symbol) s a | name s -> a where + gfield :: Lens' s a + +instance + ( Generic s + , path ~ GetPathTree name (Rep s) + , GFieldSum name s path (Rep s) a + ) => GField name s a where + gfield = withLens + (lensVL (\f s -> to <$> gfieldSum @name @s @path f (from s))) + (\get set -> lensVL $ \f s -> set s <$> f (get s)) + {-# INLINE gfield #-} + +data Void0 +-- | Hidden instance. +instance a ~ Void0 => GField name Void0 a where + gfield = lensVL id + +class GFieldSum (name :: Symbol) s (path :: PathTree) (g :: Type -> Type) a + | name g -> a where + gfieldSum :: LensVL' (g x) a + +instance + ( GFieldSum name s path V1 a + , TypeError ('Text "Type " ':<>: Quoted ('ShowType s) ':<>: + 'Text " has no data constructors") + ) => GFieldSum name s path V1 a where + gfieldSum = error "unreachable" + +instance + ( GFieldSum name s path g a + ) => GFieldSum name s path (M1 D m g) a where + gfieldSum f (M1 x) = M1 <$> gfieldSum @name @s @path f x + +instance + ( GFieldSum name s path1 g1 a + , GFieldSum name s path2 g2 a + ) => GFieldSum name s ('PathTree path1 path2) (g1 :+: g2) a where + gfieldSum f (L1 x) = L1 <$> gfieldSum @name @s @path1 f x + gfieldSum f (R1 y) = R1 <$> gfieldSum @name @s @path2 f y + {-# INLINE gfieldSum #-} + +instance + ( path ~ FromMaybe + (TypeError + ('Text "Type " ':<>: Quoted ('ShowType s) ':<>: + 'Text " doesn't have a field named " ':<>: Quoted ('Text name))) + mpath + , GFieldProd name s path g a + ) => GFieldSum name s ('PathLeaf mpath) (M1 C m g) a where + gfieldSum f (M1 x) = M1 <$> gfieldProd @name @s @path f x + +class GFieldProd (name :: Symbol) s (path :: [Path]) g a | name g -> a where + gfieldProd :: LensVL' (g x) a + +instance + ( GFieldProd name s path g1 a + ) => GFieldProd name s ('PathLeft : path) (g1 :*: g2) a where + gfieldProd f (x :*: y) = (:*: y) <$> gfieldProd @name @s @path f x + +instance + ( GFieldProd name s path g2 a + ) => GFieldProd name s ('PathRight : path) (g1 :*: g2) a where + gfieldProd f (x :*: y) = (x :*:) <$> gfieldProd @name @s @path f y + +instance + ( a ~ b -- for better error message if types don't match + ) => GFieldProd name s '[] (M1 S ('MetaSel ('Just name) su ss ds) (Rec0 b)) a where + gfieldProd f (M1 (K1 x)) = M1 . K1 <$> f x + +---------------------------------------- +-- Helpers + +type family Quoted (s :: ErrorMessage) :: ErrorMessage where + Quoted s = 'Text "‘" ':<>: s ':<>: 'Text "’" + +data PathTree + = PathTree PathTree PathTree + | PathLeaf (Maybe [Path]) + | NoPath + +data Path = PathLeft | PathRight + +-- | Compute paths to a field for a generic representation of a data type. +type family GetPathTree (name :: Symbol) g :: PathTree where + GetPathTree name (M1 D _ g) = GetPathTree name g + GetPathTree name V1 = 'NoPath + GetPathTree name (g1 :+: g2) = 'PathTree (GetPathTree name g1) + (GetPathTree name g2) + GetPathTree name (M1 C _ g) = 'PathLeaf (GetPath name g '[]) + +-- | Compute path to a constructor in a sum or a field in a product. +type family GetPath (name :: Symbol) g (acc :: [Path]) :: Maybe [Path] where + GetPath name (M1 D _ g) acc = GetPath name g acc + + -- Find path to a constructor in a sum type + GetPath name (M1 C ('MetaCons name _ _) _) acc = 'Just (Reverse acc '[]) + GetPath name (g1 :+: g2) acc = Alt (GetPath name g1 ('PathLeft : acc)) + (GetPath name g2 ('PathRight : acc)) + + -- Find path to a field in a product type + GetPath name (M1 S ('MetaSel ('Just name) _ _ _) _) acc = 'Just (Reverse acc '[]) + GetPath name (g1 :*: g2) acc = Alt (GetPath name g1 ('PathLeft : acc)) + (GetPath name g2 ('PathRight : acc)) + + GetPath _ _ _ = 'Nothing + +-- | Reverse a type-level list. +type family Reverse (xs :: [k]) (acc :: [k]) :: [k] where + Reverse '[] acc = acc + Reverse (x : xs) acc = Reverse xs (x : acc) + +type family FromMaybe (def :: a) (m :: Maybe a) :: a where + FromMaybe _ ('Just a) = a + FromMaybe def 'Nothing = def + +-- | Type-level mplus for 'Maybe'. +type family Alt (m1 :: Maybe a) (m2 :: Maybe a) :: Maybe a where + Alt ('Just a) _ = 'Just a + Alt _ b = b ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -178,6 +178,8 @@ test('T10370', compile, ['']) +test('T11068', normal, makefile_test, ['T11068']) + test('T10547', [ collect_compiler_stats('bytes allocated', 4), ], View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/998803dc4dbceb36074644483e11e6183fa5355a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/998803dc4dbceb36074644483e11e6183fa5355a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 01:57:57 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 21:57:57 -0400 Subject: [Git][ghc/ghc][master] Extend mAX_TUPLE_SIZE to 64 Message-ID: <5f88fe255a358_28003fd4029ad45c5540da@gitlab.haskell.org.mail> Spam detection software, running on the system "mail.haskell.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. [...] Content analysis details: (5.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.1 URI_HEX URI: URI hostname has long hexadecimal sequence 5.0 UNWANTED_LANGUAGE_BODY BODY: Message written in an undesired language -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 HTML_MESSAGE BODY: HTML included in message 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid The original message was not completely plain text, and may be unsafe to open with some email clients; in particular, it may contain a virus, or confirm that your address can receive spam. If you wish to view it, it may be safer to save it to a file and open it with an editor. -------------- next part -------------- An embedded message was scrubbed... From: Marge Bot Subject: [Git][ghc/ghc][master] Extend mAX_TUPLE_SIZE to 64 Date: Thu, 15 Oct 2020 21:57:57 -0400 Size: 350443 URL: From gitlab at gitlab.haskell.org Fri Oct 16 01:58:36 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 21:58:36 -0400 Subject: [Git][ghc/ghc][master] 4 commits: rts: Clean-up whitespace in Interpreter Message-ID: <5f88fe4ced409_2800d10b17c56022f@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 4 changed files: - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs - rts/Interpreter.c Changes: ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -59,9 +59,9 @@ import Data.Array.Unsafe( castSTUArray ) import Foreign import Data.Char ( ord ) import Data.List ( genericLength ) -import Data.Map (Map) +import Data.Map.Strict (Map) import Data.Maybe (fromMaybe) -import qualified Data.Map as Map +import qualified Data.Map.Strict as Map -- ----------------------------------------------------------------------------- -- Unlinked BCOs @@ -179,10 +179,12 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm -- this BCO to be long. (n_insns0, lbl_map0) = inspectAsm platform False initial_offset asm ((n_insns, lbl_map), long_jumps) - | isLarge n_insns0 = (inspectAsm platform True initial_offset asm, True) + | isLarge (fromIntegral $ Map.size lbl_map0) + || isLarge n_insns0 + = (inspectAsm platform True initial_offset asm, True) | otherwise = ((n_insns0, lbl_map0), False) - env :: Word16 -> Word + env :: LocalLabel -> Word env lbl = fromMaybe (pprPanic "assembleBCO.findLabel" (ppr lbl)) (Map.lookup lbl lbl_map) @@ -222,13 +224,13 @@ type AsmState = (SizedSeq Word16, data Operand = Op Word | SmallOp Word16 - | LabelOp Word16 + | LabelOp LocalLabel -- (unused) | LargeOp Word data Assembler a = AllocPtr (IO BCOPtr) (Word -> Assembler a) | AllocLit [BCONPtr] (Word -> Assembler a) - | AllocLabel Word16 (Assembler a) + | AllocLabel LocalLabel (Assembler a) | Emit Word16 [Operand] (Assembler a) | NullAsm a deriving (Functor) @@ -253,13 +255,13 @@ ptr = ioptr . return lit :: [BCONPtr] -> Assembler Word lit l = AllocLit l return -label :: Word16 -> Assembler () +label :: LocalLabel -> Assembler () label w = AllocLabel w (return ()) emit :: Word16 -> [Operand] -> Assembler () emit w ops = Emit w ops (return ()) -type LabelEnv = Word16 -> Word +type LabelEnv = LocalLabel -> Word largeOp :: Bool -> Operand -> Bool largeOp long_jumps op = case op of @@ -299,7 +301,7 @@ runAsm platform long_jumps e = go in ((), (st_i1,st_l0,st_p0)) go k -type LabelEnvMap = Map Word16 Word +type LabelEnvMap = Map LocalLabel Word data InspectState = InspectState { instrCount :: !Word ===================================== compiler/GHC/ByteCode/Instr.hs ===================================== @@ -6,7 +6,7 @@ -- | Bytecode instruction definitions module GHC.ByteCode.Instr ( - BCInstr(..), ProtoBCO(..), bciStackUse, + BCInstr(..), ProtoBCO(..), bciStackUse, LocalLabel(..) ) where #include "HsVersions.h" @@ -50,7 +50,12 @@ data ProtoBCO a protoBCOFFIs :: [FFIInfo] } -type LocalLabel = Word16 +-- | A local block label (e.g. identifying a case alternative). +newtype LocalLabel = LocalLabel { getLocalLabel :: Word32 } + deriving (Eq, Ord) + +instance Outputable LocalLabel where + ppr (LocalLabel lbl) = text "lbl:" <> ppr lbl data BCInstr -- Messing with the stack ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -74,6 +74,7 @@ import GHC.Unit.Module import Control.Exception import Data.Array +import Data.Coerce (coerce) import Data.ByteString (ByteString) import Data.Map (Map) import Data.IntMap (IntMap) @@ -1967,7 +1968,7 @@ data BcM_State { bcm_hsc_env :: HscEnv , uniqSupply :: UniqSupply -- for generating fresh variable names , thisModule :: Module -- current module (for breakpoints) - , nextlabel :: Word16 -- for generating local labels + , nextlabel :: Word32 -- for generating local labels , ffis :: [FFIInfo] -- ffi info blocks, to free later -- Should be free()d when it is GCd , modBreaks :: Maybe ModBreaks -- info about breakpoints @@ -2032,17 +2033,17 @@ recordFFIBc :: RemotePtr C_ffi_cif -> BcM () recordFFIBc a = BcM $ \st -> return (st{ffis = FFIInfo a : ffis st}, ()) -getLabelBc :: BcM Word16 +getLabelBc :: BcM LocalLabel getLabelBc = BcM $ \st -> do let nl = nextlabel st when (nl == maxBound) $ panic "getLabelBc: Ran out of labels" - return (st{nextlabel = nl + 1}, nl) + return (st{nextlabel = nl + 1}, LocalLabel nl) -getLabelsBc :: Word16 -> BcM [Word16] +getLabelsBc :: Word32 -> BcM [LocalLabel] getLabelsBc n = BcM $ \st -> let ctr = nextlabel st - in return (st{nextlabel = ctr+n}, [ctr .. ctr+n-1]) + in return (st{nextlabel = ctr+n}, coerce [ctr .. ctr+n-1]) getCCArray :: BcM (Array BreakIndex (RemotePtr CostCentre)) getCCArray = BcM $ \st -> ===================================== rts/Interpreter.c ===================================== @@ -1478,11 +1478,11 @@ run_BCO: for (i = 0; i < n_payload; i++) ap->payload[i] = (StgClosure*)SpW(i+1); - Sp_addW(n_payload+1); - IF_DEBUG(interpreter, - debugBelch("\tBuilt "); - printObj((StgClosure*)ap); - ); + Sp_addW(n_payload+1); + IF_DEBUG(interpreter, + debugBelch("\tBuilt "); + printObj((StgClosure*)ap); + ); goto nextInsn; } @@ -1504,11 +1504,11 @@ run_BCO: for (i = 0; i < n_payload; i++) pap->payload[i] = (StgClosure*)SpW(i+1); - Sp_addW(n_payload+1); - IF_DEBUG(interpreter, - debugBelch("\tBuilt "); - printObj((StgClosure*)pap); - ); + Sp_addW(n_payload+1); + IF_DEBUG(interpreter, + debugBelch("\tBuilt "); + printObj((StgClosure*)pap); + ); goto nextInsn; } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b14c4185ca944295d5cfa60ebc6f7ab2a257fc9...cc536288c32df9c4b9f37020b76348f58a57b3cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b14c4185ca944295d5cfa60ebc6f7ab2a257fc9...cc536288c32df9c4b9f37020b76348f58a57b3cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 02:29:35 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 15 Oct 2020 22:29:35 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Extend mAX_TUPLE_SIZE to 64 Message-ID: <5f89058f477fe_2800d1807c4566062@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 321df97d by John Ericson at 2020-10-15T22:29:18-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - fb27b803 by Dylan Yudaken at 2020-10-15T22:29:22-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - e4595fb5 by DylanZA at 2020-10-15T22:29:22-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 73b41ff2 by Hécate at 2020-10-15T22:29:24-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - includes/RtsAPI.h - libraries/base/.hlint.yaml - libraries/base/GHC/Exts.hs - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Tuple.hs - rts/Interpreter.c - rts/RtsAPI.c - rts/RtsSymbols.c - testsuite/tests/backpack/should_compile/all.T - + testsuite/tests/backpack/should_compile/bkp57.bkp - + testsuite/tests/backpack/should_compile/bkp57.stderr - + testsuite/tests/backpack/should_compile/bkp58.bkp - + testsuite/tests/backpack/should_compile/bkp58.stderr - + testsuite/tests/backpack/should_compile/bkp59.bkp - + testsuite/tests/backpack/should_compile/bkp59.stderr - + testsuite/tests/backpack/should_compile/bkp60.bkp - + testsuite/tests/backpack/should_compile/bkp60.stderr - + testsuite/tests/ffi/should_run/IncallAffinity.hs - + testsuite/tests/ffi/should_run/IncallAffinity_c.c - testsuite/tests/ffi/should_run/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a7025172cc0322d3b1a4756e73c25e380723154...73b41ff250c6fdf00c0fe74308f9bdf3c2303e92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3a7025172cc0322d3b1a4756e73c25e380723154...73b41ff250c6fdf00c0fe74308f9bdf3c2303e92 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 04:16:11 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 16 Oct 2020 00:16:11 -0400 Subject: [Git][ghc/ghc][master] 7 commits: mingw: Extract zst toolchain archives Message-ID: <5f891e8b3689f_2800d304c1c572129@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 9 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - configure.ac - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - rts/RtsSymbols.c - testsuite/driver/runtests.py - testsuite/tests/ghci/scripts/T9293.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci057.stdout-mingw32 Changes: ===================================== .gitlab-ci.yml ===================================== @@ -5,8 +5,8 @@ variables: DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8 # Sequential version number capturing the versions of all tools fetched by - # .gitlab/ci.sh. - WINDOWS_TOOLCHAIN_VERSION: 3 + # .gitlab/ci.sh. Used for invalidation of GitLab CI cache. + WINDOWS_TOOLCHAIN_VERSION: 4 # Disable shallow clones; they break our linting rules GIT_DEPTH: 0 @@ -212,7 +212,7 @@ lint-release-changelogs: junit: junit.xml expire_in: 2 week paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .validate-linux-hadrian: @@ -220,6 +220,7 @@ lint-release-changelogs: image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" variables: TEST_ENV: "x86_64-linux-deb9-hadrian" + BIN_DIST_NAME: "ghc-x86_64-deb9-linux" before_script: # workaround for docker permissions - sudo chown ghc:ghc -R . @@ -399,7 +400,7 @@ release-x86_64-freebsd: HADRIAN_ARGS: "--docs=no-sphinx" GHC_VERSION: 8.6.3 CABAL_INSTALL_VERSION: 3.0.0.0 - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-portbld-freebsd.tar.xz" + BIN_DIST_NAME: "ghc-x86_64-portbld-freebsd" TEST_ENV: "x86_64-freebsd-hadrian" FLAVOUR: "validate" after_script: @@ -464,6 +465,7 @@ validate-x86_64-darwin: LANG: "en_US.UTF-8" CONFIGURE_ARGS: --with-intree-gmp TEST_ENV: "x86_64-darwin-hadrian" + BIN_DIST_NAME: "ghc-x86_64-apple-darwin" FLAVOUR: "validate" script: - .gitlab/ci.sh setup @@ -479,7 +481,7 @@ validate-x86_64-darwin: reports: junit: junit.xml paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .validate-linux: @@ -785,7 +787,7 @@ release-x86_64-linux-deb8: allow_failure: true variables: TEST_ENV: "x86_64-linux-alpine" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-alpine-linux.tar.xz" + BIN_DIST_NAME: "ghc-x86_64-alpine-linux" # Can't use ld.gold due to #13958. CONFIGURE_ARGS: "--disable-ld-override" HADRIAN_ARGS: "--docs=no-sphinx" @@ -856,9 +858,7 @@ validate-x86_64-linux-fedora27: ############################################################ .build-windows: - # For the reasons given in #17777 this build isn't reliable. needs: [validate-x86_64-linux-deb9-hadrian] - allow_failure: true before_script: - git clean -xdf @@ -903,7 +903,7 @@ validate-x86_64-linux-fedora27: expire_in: 2 week when: always paths: - - ghc.tar.xz + - "$BIN_DIST_NAME.tar.xz" - junit.xml .build-x86_64-windows-hadrian: @@ -911,6 +911,7 @@ validate-x86_64-linux-fedora27: variables: MSYSTEM: MINGW64 TEST_ENV: "x86_64-windows" + BIN_DIST_NAME: "ghc-x86_64-unknown-mingw32" cache: key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION" @@ -970,6 +971,7 @@ release-x86_64-windows-integer-simple: variables: BIGNUM_BACKEND: native BUILD_FLAVOUR: "perf" + BIN_DIST_NAME: "ghc-x86_64-mingw32-unknown-nogmp" ############################################################ @@ -987,9 +989,7 @@ doc-tarball: - validate-x86_64-windows-hadrian variables: LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz" - WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz" - # Due to Windows allow_failure - allow_failure: true + WINDOWS_BINDIST: "ghc-x86_64-unknown-mingw32.tar.xz" artifacts: paths: - haddock.html.tar.xz @@ -1155,8 +1155,6 @@ pages: dependencies: - doc-tarball image: ghcci/x86_64-linux-deb9:0.2 - # Due to Windows allow_failure - allow_failure: true tags: - x86_64-linux script: ===================================== .gitlab/ci.sh ===================================== @@ -377,10 +377,13 @@ function build_hadrian() { if [ -z "$FLAVOUR" ]; then fail "FLAVOUR not set" fi + if [ -z "$BIN_DIST_NAME" ]; then + fail "BIN_DIST_NAME not set" + fi run_hadrian binary-dist - mv _build/bindist/ghc*.tar.xz ghc.tar.xz + mv _build/bindist/ghc*.tar.xz $BIN_DIST_NAME.tar.xz } function test_hadrian() { ===================================== configure.ac ===================================== @@ -417,7 +417,8 @@ set_up_tarballs() { rm -rf inplace/mingw local base_dir="../ghc-tarballs/${tarball_dest_dir}" ( cd inplace && - find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; && + find "${base_dir}" -name "*.tar.xz" -exec tar --xz -xf {} \; && + find "${base_dir}" -name "*.tar.zst" -exec tar --zstd -xf {} \; && rm ".MTREE" && rm ".PKGINFO" && cd .. ) || AC_MSG_ERROR([Could not extract Windows toolchains.]) ===================================== libraries/base/GHC/IO/Handle/Lock/Windows.hsc ===================================== @@ -1,6 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} -- | File locking for Windows. module GHC.IO.Handle.Lock.Windows where ===================================== rts/RtsSymbols.c ===================================== @@ -151,7 +151,9 @@ __imp___acrt_iob_func, __rts_iob_func, true)) \ RTS_WIN32_ONLY(SymI_HasProto_redirect( \ __imp____acrt_iob_func, __rts_iob_func, true)) \ - SymI_HasProto(__mingw_vsnwprintf) + SymI_HasProto(__mingw_vsnwprintf) \ + /* ^^ Need to figure out why this is needed. */ \ + SymI_HasProto(__mingw_vfprintf) \ /* ^^ Need to figure out why this is needed. */ #define RTS_MINGW_COMPAT_SYMBOLS \ ===================================== testsuite/driver/runtests.py ===================================== @@ -457,7 +457,21 @@ else: if config.baseline_commit: print('Performance baseline: %s\n' % config.baseline_commit) if any(t.metrics): - tabulate_metrics(t.metrics) + # Group metrics by metric type + groups = {} # type: Dict[MetricName, List[PerfMetric]] + for m in t.metrics: + if m.stat.metric not in groups: + groups[m.stat.metric] = [] + + groups[m.stat.metric].append(m) + + for metric_name, stats in groups.items(): + heading = 'Metrics: %s' % metric_name + print() + print(heading) + print('-' * len(heading)) + print() + tabulate_metrics(stats) else: print("\nNone collected.") print("") ===================================== testsuite/tests/ghci/scripts/T9293.stdout-mingw32 ===================================== @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is not enabled @@ -35,7 +34,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should work, GADTs is in force from :set @@ -56,7 +54,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is now disabled @@ -79,7 +76,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is only enabled at the prompt ===================================== testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 ===================================== @@ -14,7 +14,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports ~~~~~~~~~~ Testing :set -a ===================================== testsuite/tests/ghci/scripts/ghci057.stdout-mingw32 ===================================== @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is not enabled @@ -35,7 +34,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should work, GADTs is in force from :set @@ -56,7 +54,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is now disabled @@ -79,7 +76,6 @@ other dynamic, non-language, flag settings: -fshow-warning-groups warning settings: -Wsemigroup - -Wnoncanonical-monoid-instances -Wstar-is-type -Wcompat-unqualified-imports Should fail, GADTs is only enabled at the prompt View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc536288c32df9c4b9f37020b76348f58a57b3cb...9a9679dbfc77c600e6c2a031ccab37d203a19cf9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cc536288c32df9c4b9f37020b76348f58a57b3cb...9a9679dbfc77c600e6c2a031ccab37d203a19cf9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 07:41:27 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 16 Oct 2020 03:41:27 -0400 Subject: [Git][ghc/ghc][wip/T18854] Update T5423_cmm.cmm Message-ID: <5f894ea73b74e_28003fd3845d06b45936a8@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: d0488819 by Moritz Angermann at 2020-10-16T03:41:25-04:00 Update T5423_cmm.cmm - - - - - 1 changed file: - testsuite/tests/rts/T5423_cmm.cmm Changes: ===================================== testsuite/tests/rts/T5423_cmm.cmm ===================================== @@ -10,6 +10,6 @@ test (W_ r1, W_ r9, W_ r10) { - foreign "C" test_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); + foreign "C" print_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); return (r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d04888192d18285cf2cdc4221a87b1ccd5894c55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d04888192d18285cf2cdc4221a87b1ccd5894c55 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 07:42:11 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 16 Oct 2020 03:42:11 -0400 Subject: [Git][ghc/ghc][wip/T18854] Update T5423_c.c Message-ID: <5f894ed3f1b5b_2800d303ad85942aa@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: 7c9b13ee by Moritz Angermann at 2020-10-16T03:42:10-04:00 Update T5423_c.c - - - - - 1 changed file: - testsuite/tests/rts/T5423_c.c Changes: ===================================== testsuite/tests/rts/T5423_c.c ===================================== @@ -12,13 +12,13 @@ void print_it( StgWord r3, StgWord r4, StgWord r5, - StgWord r5, + StgWord r6, StgWord r7, StgWord r8, StgWord r9, StgWord r10 ) { - printf("%d %d %d %d %d %d %d %d %d %d\n", + printf("%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n", r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c9b13ee70835352d6cf808aad8ef5efbdc7e2ec -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7c9b13ee70835352d6cf808aad8ef5efbdc7e2ec You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 08:10:06 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 16 Oct 2020 04:10:06 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: mingw: Extract zst toolchain archives Message-ID: <5f89555e190ee_28003fd3883160f06042df@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - d7c6d53f by John Ericson at 2020-10-16T04:09:50-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 4aba25a7 by Dylan Yudaken at 2020-10-16T04:09:55-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 1efe50a7 by DylanZA at 2020-10-16T04:09:55-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 23e05f11 by Hécate at 2020-10-16T04:09:58-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - configure.ac - includes/RtsAPI.h - libraries/base/.hlint.yaml - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - rts/RtsAPI.c - rts/RtsSymbols.c - testsuite/driver/runtests.py - testsuite/tests/backpack/should_compile/all.T - + testsuite/tests/backpack/should_compile/bkp57.bkp - + testsuite/tests/backpack/should_compile/bkp57.stderr - + testsuite/tests/backpack/should_compile/bkp58.bkp - + testsuite/tests/backpack/should_compile/bkp58.stderr - + testsuite/tests/backpack/should_compile/bkp59.bkp - + testsuite/tests/backpack/should_compile/bkp59.stderr - + testsuite/tests/backpack/should_compile/bkp60.bkp - + testsuite/tests/backpack/should_compile/bkp60.stderr - + testsuite/tests/ffi/should_run/IncallAffinity.hs - + testsuite/tests/ffi/should_run/IncallAffinity_c.c - testsuite/tests/ffi/should_run/all.T - testsuite/tests/ghci/scripts/T9293.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 - testsuite/tests/ghci/scripts/ghci057.stdout-mingw32 - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBoot.hs - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA1.hs - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA2.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/73b41ff250c6fdf00c0fe74308f9bdf3c2303e92...23e05f115e0f687a08252d579d63bf33d6662515 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/73b41ff250c6fdf00c0fe74308f9bdf3c2303e92...23e05f115e0f687a08252d579d63bf33d6662515 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 10:39:21 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 16 Oct 2020 06:39:21 -0400 Subject: [Git][ghc/ghc][wip/T18723] 151 commits: Remove unused ThBrackCtxt and ResSigCtxt Message-ID: <5f8978591eda0_280010e4991c620488@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18723 at Glasgow Haskell Compiler / GHC Commits: 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 89ffc584 by Ryan Scott at 2020-10-16T06:28:34-04:00 WIP: Check for large tuples more thoroughly in the typechecker This unifies the treatment of how GHC checks for constraint tuples and other tuples by: * Migrating the `checkTupSize` renamer check to the typechecker, * Moving the existing `bigConstraintTuple` typechecker validity check to `checkCTupSize` for consistency with `checkTupSize`, and * Consistently using `check(C)TupSize` when typechecking tuple names, expressions, patterns, and types. * Removing the unused `HsConstraintTuple` constructor of `HsTupleSort`. Fixes #18723. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f01bf042179e00c1884cffc4f2cf2b93f58821ef...89ffc584069c00fe674d312f5875fd2f5be42512 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f01bf042179e00c1884cffc4f2cf2b93f58821ef...89ffc584069c00fe674d312f5875fd2f5be42512 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 10:59:51 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 16 Oct 2020 06:59:51 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] 14 commits: Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Message-ID: <5f897d27e8de3_2800aeb3bec6266cc@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 1ce2d7b6 by Vladislav Zavialov at 2020-10-16T13:59:06+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - configure.ac - docs/users_guide/9.2.1-notes.rst - docs/users_guide/using-optimisation.rst - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/base/GHC/Exts.hs - libraries/base/GHC/IO/Handle/Lock/Windows.hsc - libraries/containers - libraries/ghc-prim/GHC/Classes.hs - libraries/ghc-prim/GHC/Tuple.hs - rts/Interpreter.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7137012d70ef861b9e4bb11b6c80923b26dfb310...1ce2d7b62f52d25075d05e8bbd88665c6d2e971c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7137012d70ef861b9e4bb11b6c80923b26dfb310...1ce2d7b62f52d25075d05e8bbd88665c6d2e971c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 11:18:17 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 16 Oct 2020 07:18:17 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] Implement -Woperator-whitespace (#18834) Message-ID: <5f8981792423b_28003fd409bcbc5063193@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: 2c8a97e2 by Vladislav Zavialov at 2020-10-16T14:16:19+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 18 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -501,6 +501,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4087,7 +4089,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnInaccessibleCode, Opt_WarnSpaceAfterBang, Opt_WarnNonCanonicalMonadInstances, - Opt_WarnNonCanonicalMonoidInstances + Opt_WarnNonCanonicalMonoidInstances, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,34 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax" + $$ text "by a future language extension." + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1853,6 +1854,7 @@ of ``-W(no-)*``. .. ghc-flag:: -Winvalid-haddock :shortdesc: warn when a Haddock comment occurs in an invalid position :type: dynamic + :reverse: -Wno-invalid-haddock :category: :since: 9.0 @@ -1869,6 +1871,56 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :reverse: -Wno-operator-whitespace-ext-conflict + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :reverse: -Wno-operator-whitespace + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c8a97e22787efce1ad2095783a63cba2e01ec05 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c8a97e22787efce1ad2095783a63cba2e01ec05 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 11:28:26 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Fri, 16 Oct 2020 07:28:26 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] Implement -Woperator-whitespace (#18834) Message-ID: <5f8983dadd090_28003fd3edc311c06325ba@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: e91aec18 by Vladislav Zavialov at 2020-10-16T14:27:47+03:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 18 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -501,6 +501,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4087,7 +4089,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnInaccessibleCode, Opt_WarnSpaceAfterBang, Opt_WarnNonCanonicalMonadInstances, - Opt_WarnNonCanonicalMonoidInstances + Opt_WarnNonCanonicalMonoidInstances, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,34 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax" + $$ nest 2 (text "by a future language extension.") + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1853,6 +1854,7 @@ of ``-W(no-)*``. .. ghc-flag:: -Winvalid-haddock :shortdesc: warn when a Haddock comment occurs in an invalid position :type: dynamic + :reverse: -Wno-invalid-haddock :category: :since: 9.0 @@ -1869,6 +1871,56 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :reverse: -Wno-operator-whitespace-ext-conflict + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :reverse: -Wno-operator-whitespace + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e91aec18c2b658dd747fa61f5fd398f13a31e484 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e91aec18c2b658dd747fa61f5fd398f13a31e484 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 14:10:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 16 Oct 2020 10:10:40 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Skip type family defaults with hs-boot and hsig files Message-ID: <5f89a9e015798_28003fd3ed525b106491ec@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 358aa7b1 by John Ericson at 2020-10-16T10:10:21-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - db04f938 by Sebastian Graf at 2020-10-16T10:10:22-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 49a8b754 by Sebastian Graf at 2020-10-16T10:10:22-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 5433b29f by Sebastian Graf at 2020-10-16T10:10:22-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 572af2ae by Dylan Yudaken at 2020-10-16T10:10:26-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 6475c1cb by DylanZA at 2020-10-16T10:10:26-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 7b3b2753 by Hécate at 2020-10-16T10:10:31-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - includes/RtsAPI.h - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23e05f115e0f687a08252d579d63bf33d6662515...7b3b2753a4e857e704af98ae52623bff1131da7a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23e05f115e0f687a08252d579d63bf33d6662515...7b3b2753a4e857e704af98ae52623bff1131da7a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 14:17:58 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 16 Oct 2020 10:17:58 -0400 Subject: [Git][ghc/ghc][master] Clarify Eq documentation #18713 Message-ID: <5f89ab96a2cfb_2800ce7c1406568aa@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - 1 changed file: - libraries/ghc-prim/GHC/Classes.hs Changes: ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -125,18 +125,13 @@ and @('>=')@ for the types in "GHC.Word" and "GHC.Int". -- and 'Eq' may be derived for any datatype whose constituents are also -- instances of 'Eq'. -- --- The Haskell Report defines no laws for 'Eq'. However, '==' is customarily --- expected to implement an equivalence relationship where two values comparing --- equal are indistinguishable by "public" functions, with a "public" function --- being one not allowing to see implementation details. For example, for a --- type representing non-normalised natural numbers modulo 100, a "public" --- function doesn't make the difference between 1 and 201. It is expected to --- have the following properties: +-- The Haskell Report defines no laws for 'Eq'. However, instances are +-- encouraged to follow these properties: -- -- [__Reflexivity__]: @x == x@ = 'True' -- [__Symmetry__]: @x == y@ = @y == x@ -- [__Transitivity__]: if @x == y && y == z@ = 'True', then @x == z@ = 'True' --- [__Substitutivity__]: if @x == y@ = 'True' and @f@ is a "public" function +-- [__Extensionality__]: if @x == y@ = 'True' and @f@ is a function -- whose return type is an instance of 'Eq', then @f x == f y@ = 'True' -- [__Negation__]: @x /= y@ = @not (x == y)@ -- @@ -234,7 +229,7 @@ eqChar, neChar :: Char -> Char -> Bool -- >>> 0/0 == (0/0 :: Float) -- False -- --- Also note that `Float`'s 'Eq' instance does not satisfy substitutivity: +-- Also note that `Float`'s 'Eq' instance does not satisfy extensionality: -- -- >>> 0 == (-0 :: Float) -- True View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07b0db86595890dfca6f624e554cdb8c9b86d0cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07b0db86595890dfca6f624e554cdb8c9b86d0cc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 14:19:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 16 Oct 2020 10:19:50 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 9 commits: Clarify Eq documentation #18713 Message-ID: <5f89ac06c0d7b_28003fd40971b2006647ab@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - f2d3939f by John Ericson at 2020-10-16T10:19:29-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 0c78c25c by Sebastian Graf at 2020-10-16T10:19:29-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 2f613025 by Sebastian Graf at 2020-10-16T10:19:29-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - ab35711e by Sebastian Graf at 2020-10-16T10:19:29-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - fc67410c by Dylan Yudaken at 2020-10-16T10:19:35-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - dea8e672 by DylanZA at 2020-10-16T10:19:35-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 26f2b342 by Sylvain Henry at 2020-10-16T10:19:41-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - 30ee2c12 by Hécate at 2020-10-16T10:19:43-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - libraries/ghc-prim/GHC/Classes.hs - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b3b2753a4e857e704af98ae52623bff1131da7a...30ee2c129cd80d95600033d60761ccfb600110fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7b3b2753a4e857e704af98ae52623bff1131da7a...30ee2c129cd80d95600033d60761ccfb600110fe You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 14:21:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 16 Oct 2020 10:21:50 -0400 Subject: [Git][ghc/ghc][ghc-9.0] winio: add release note Message-ID: <5f89ac7ee46ef_28003fd3885c2ccc67259a@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: b1a2c5e4 by Tamar Christina at 2020-10-16T10:21:20-04:00 winio: add release note - - - - - 1 changed file: - docs/users_guide/9.0.1-notes.rst Changes: ===================================== docs/users_guide/9.0.1-notes.rst ===================================== @@ -45,6 +45,13 @@ Highlights This improves runtime but causes increased memory usage on Windows versions older than Win 8.1/Server 2012. +* Windows: New IO Manager. + + A new I/O manager (WinIO) is now available as a community technical preview which is designed to allow experimentation and + bootstrapping of third-party packages such as Network. The new I/O manager is off by default and can be enabled with the + RTS flag ``--io-manager=native``. Currently the I/O manager is *unoptimized* and is focused more on correctness. There is also + no support for pipes and sockets. These will be added in the next release. `*see more* `__. + * Big-number support - GHC now relies on a new ``ghc-bignum`` package to provide Integer/Natural View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1a2c5e4508d61bc0bedc13c7240b6fbf674157e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1a2c5e4508d61bc0bedc13c7240b6fbf674157e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 14:50:21 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 16 Oct 2020 10:50:21 -0400 Subject: [Git][ghc/ghc][wip/T18723] WIP: Check for large tuples more thoroughly in the typechecker Message-ID: <5f89b32da1e48_28003fd3edaec74c6741dd@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18723 at Glasgow Haskell Compiler / GHC Commits: 36b1df64 by Ryan Scott at 2020-10-16T10:48:57-04:00 WIP: Check for large tuples more thoroughly in the typechecker This unifies the treatment of how GHC checks for constraint tuples and other tuples by: * Migrating the `checkTupSize` renamer check to the typechecker, * Moving the existing `bigConstraintTuple` typechecker validity check to `checkCTupSize` for consistency with `checkTupSize`, and * Consistently using `check(C)TupSize` when typechecking tuple names, expressions, patterns, and types. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This a `haddock` submodule bump. Fixes #18723. - - - - - 26 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - testsuite/tests/polykinds/T10451.stderr - − testsuite/tests/rename/should_fail/T6148.stderr - + testsuite/tests/rename/should_fail/T6148a.hs - + testsuite/tests/rename/should_fail/T6148a.stderr - + testsuite/tests/rename/should_fail/T6148b.hs - + testsuite/tests/rename/should_fail/T6148b.stderr - testsuite/tests/rename/should_fail/T6148.hs → testsuite/tests/rename/should_fail/T6148c.hs - + testsuite/tests/rename/should_fail/T6148c.stderr - testsuite/tests/rename/should_fail/all.T - + testsuite/tests/typecheck/should_fail/T18723a.hs - + testsuite/tests/typecheck/should_fail/T18723a.stderr - + testsuite/tests/typecheck/should_fail/T18723b.hs - + testsuite/tests/typecheck/should_fail/T18723b.stderr - + testsuite/tests/typecheck/should_fail/T18723c.hs - + testsuite/tests/typecheck/should_fail/T18723c.stderr - testsuite/tests/typecheck/should_fail/all.T - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1055,20 +1055,19 @@ namely HsTupleTy, but keep track of the tuple kind (in the first argument to HsTupleTy, a HsTupleSort). We can tell if a tuple is unboxed while parsing, because of the #. However, with -XConstraintKinds we can only distinguish between constraint and boxed tuples during type checking, in general. Hence the -four constructors of HsTupleSort: +two constructors of HsTupleSort: HsUnboxedTuple -> Produced by the parser - HsBoxedTuple -> Certainly a boxed tuple - HsConstraintTuple -> Certainly a constraint tuple HsBoxedOrConstraintTuple -> Could be a boxed or a constraint tuple. Produced by the parser only, disappears after type checking + +After typechecking, we use TupleSort (which clearly distinguishes between +constraint tuples and boxed tuples) rather than HsTupleSort. -} -- | Haskell Tuple Sort data HsTupleSort = HsUnboxedTuple - | HsBoxedTuple - | HsConstraintTuple | HsBoxedOrConstraintTuple deriving Data @@ -1986,11 +1985,9 @@ hsTypeNeedsParens p = go_hs_ty -- Special-case unary boxed tuple applications so that they are -- parenthesized as `Identity (Solo x)`, not `Identity Solo x` (#18612) -- See Note [One-tuples] in GHC.Builtin.Types - go_hs_ty (HsTupleTy _ con [L _ ty]) + go_hs_ty (HsTupleTy _ con [_]) = case con of - HsBoxedTuple -> p >= appPrec HsBoxedOrConstraintTuple -> p >= appPrec - HsConstraintTuple -> go_hs_ty ty HsUnboxedTuple -> False go_hs_ty (HsTupleTy{}) = False go_hs_ty (HsSumTy{}) = False ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -13,6 +13,7 @@ module GHC.Iface.Load ( -- Importing one thing tcLookupImported_maybe, importDecl, checkWiredInTyCon, ifCheckWiredInThing, + checkTupSize, checkCTupSize, -- RnM/TcM functions loadModuleInterface, loadModuleInterfaces, @@ -56,6 +57,8 @@ import GHC.Builtin.Names import GHC.Builtin.Utils import GHC.Builtin.PrimOps ( allThePrimOps, primOpFixity, primOpOcc ) import GHC.Types.Id.Make ( seqId, EnableBignumRules(..) ) +import GHC.Core.ConLike +import GHC.Core.DataCon import GHC.Core.Rules import GHC.Core.TyCon import GHC.Types.Annotations @@ -78,7 +81,6 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Fingerprint import GHC.Driver.Hooks -import GHC.Types.FieldLabel import GHC.Iface.Rename import GHC.Types.Unique.DSet import GHC.Driver.Plugins @@ -133,9 +135,30 @@ tcImportDecl_maybe name = do { when (needWiredInHomeIface thing) (initIfaceTcRn (loadWiredInHomeIface name)) -- See Note [Loading instances for wired-in things] + -- Error if attempting to use a prefix tuple name (,, ... ,,) that + -- exceeds mAX_TUPLE_SIZE. + ; whenIsJust (tuple_ty_thing_maybe thing) checkTupSize ; return (Succeeded thing) } | otherwise = initIfaceTcRn (importDecl name) + where + -- Returns @Just arity@ if the supplied TyThing corresponds to a tuple + -- type or data constructor. Returns @Nothing@ otherwise. + tuple_ty_thing_maybe :: TyThing -> Maybe Arity + tuple_ty_thing_maybe thing + | Just tycon <- case thing of + ATyCon tc -> Just tc + AConLike (RealDataCon dc) -> Just (dataConTyCon dc) + _ -> Nothing + , Just tupleSort <- tyConTuple_maybe tycon + = Just $ case tupleSort of + -- Unboxed tuples have twice as many arguments because of the + -- 'RuntimeRep's (#17837) + UnboxedTuple -> tyConArity tycon `div` 2 + _ -> tyConArity tycon + + | otherwise + = Nothing importDecl :: Name -> IfM lcl (MaybeErr MsgDoc TyThing) -- Get the TyThing for this Name from an interface file @@ -249,6 +272,27 @@ needWiredInHomeIface :: TyThing -> Bool needWiredInHomeIface (ATyCon {}) = True needWiredInHomeIface _ = False +-- | Ensure that a boxed or unboxed tuple has arity no larger than +-- 'mAX_TUPLE_SIZE'. +checkTupSize :: Int -> TcM () +checkTupSize tup_size + | tup_size <= mAX_TUPLE_SIZE + = return () + | otherwise + = addErr (sep [text "A" <+> int tup_size <> ptext (sLit "-tuple is too large for GHC"), + nest 2 (parens (text "max size is" <+> int mAX_TUPLE_SIZE)), + nest 2 (text "Workaround: use nested tuples or define a data type")]) + +-- | Ensure that a constraint tuple has arity no larger than 'mAX_CTUPLE_SIZE'. +checkCTupSize :: Int -> TcM () +checkCTupSize tup_size + | tup_size <= mAX_CTUPLE_SIZE + = return () + | otherwise + = addErr (hang (text "Constraint tuple arity too large:" <+> int tup_size + <+> parens (text "max arity =" <+> int mAX_CTUPLE_SIZE)) + 2 (text "Instead, use a nested tuple")) + {- ************************************************************************ ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -72,7 +72,7 @@ import GHC.Core.DataCon import GHC.Core.TyCon import GHC.Utils.Error ( MsgDoc ) import GHC.Builtin.Names( rOOT_MAIN ) -import GHC.Types.Basic ( pprWarningTxtForMsg, TopLevelFlag(..), TupleSort(..) ) +import GHC.Types.Basic ( pprWarningTxtForMsg, TopLevelFlag(..) ) import GHC.Types.SrcLoc as SrcLoc import GHC.Utils.Outputable as Outputable import GHC.Types.Unique.Set ( uniqSetAny ) @@ -280,20 +280,6 @@ lookupLocatedTopBndrRn = wrapLocM lookupTopBndrRn -- Note [Errors in lookup functions] lookupExactOcc_either :: Name -> RnM (Either MsgDoc Name) lookupExactOcc_either name - | Just thing <- wiredInNameTyThing_maybe name - , Just tycon <- case thing of - ATyCon tc -> Just tc - AConLike (RealDataCon dc) -> Just (dataConTyCon dc) - _ -> Nothing - , Just tupleSort <- tyConTuple_maybe tycon - = do { let tupArity = case tupleSort of - -- Unboxed tuples have twice as many arguments because of the - -- 'RuntimeRep's (#17837) - UnboxedTuple -> tyConArity tycon `div` 2 - _ -> tyConArity tycon - ; checkTupSize tupArity - ; return (Right name) } - | isExternalName name = return (Right name) ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -281,7 +281,6 @@ rnExpr (ExplicitList x _ exps) rnExpr (ExplicitTuple x tup_args boxity) = do { checkTupleSection tup_args - ; checkTupSize (length tup_args) ; (tup_args', fvs) <- mapAndUnzipM rnTupArg tup_args ; return (ExplicitTuple x tup_args' boxity, plusFVs fvs) } where ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -37,8 +37,8 @@ module GHC.Rename.Pat (-- main entry points -- Literals rnLit, rnOverLit, - -- Pattern Error messages that are also used elsewhere - checkTupSize, patSigErr + -- Pattern Error message that is also used elsewhere + patSigErr ) where -- ENH: thin imports to only what is necessary for patterns @@ -59,7 +59,7 @@ import GHC.Rename.Utils ( HsDocContext(..), newLocalBndrRn, bindLocalNames , warnUnusedMatches, newLocalBndrRn , checkUnusedRecordWildcard , checkDupNames, checkDupAndShadowedNames - , checkTupSize , unknownSubordinateErr ) + , unknownSubordinateErr ) import GHC.Rename.HsType import GHC.Builtin.Names import GHC.Types.Name @@ -497,8 +497,7 @@ rnPatAndThen mk (ListPat _ pats) False -> return (ListPat Nothing pats') } rnPatAndThen mk (TuplePat x pats boxed) - = do { liftCps $ checkTupSize (length pats) - ; pats' <- rnLPatsAndThen mk pats + = do { pats' <- rnLPatsAndThen mk pats ; return (TuplePat x pats' boxed) } rnPatAndThen mk (SumPat x pat alt arity) ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -11,7 +11,6 @@ This module contains miscellaneous functions related to renaming. module GHC.Rename.Utils ( checkDupRdrNames, checkShadowedRdrNames, checkDupNames, checkDupAndShadowedNames, dupNamesErr, - checkTupSize, addFvRn, mapFvRn, mapMaybeFvRn, warnUnusedMatches, warnUnusedTypePatterns, warnUnusedTopBinds, warnUnusedLocalBinds, @@ -57,7 +56,6 @@ import GHC.Driver.Session import GHC.Data.FastString import Control.Monad import Data.List -import GHC.Settings.Constants ( mAX_TUPLE_SIZE ) import qualified Data.List.NonEmpty as NE import qualified GHC.LanguageExtensions as LangExt @@ -572,15 +570,6 @@ typeAppErr what (L _ k) <+> quotes (char '@' <> ppr k)) 2 (text "Perhaps you intended to use TypeApplications") -checkTupSize :: Int -> RnM () -checkTupSize tup_size - | tup_size <= mAX_TUPLE_SIZE - = return () - | otherwise - = addErr (sep [text "A" <+> int tup_size <> ptext (sLit "-tuple is too large for GHC"), - nest 2 (parens (text "max size is" <+> int mAX_TUPLE_SIZE)), - nest 2 (text "Workaround: use nested tuples or define a data type")]) - {- ************************************************************************ ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Tc.Gen.Splice( tcSpliceExpr, tcTypedBracket, tcUntypedBracket ) import GHC.Hs +import GHC.Iface.Load import GHC.Tc.Utils.Zonk import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Unify @@ -1035,7 +1036,9 @@ arithSeqEltType (Just fl) res_ty ---------------- tcTupArgs :: [LHsTupArg GhcRn] -> [TcSigmaType] -> TcM [LHsTupArg GhcTc] tcTupArgs args tys - = ASSERT( equalLength args tys ) mapM go (args `zip` tys) + = do MASSERT( equalLength args tys ) + checkTupSize (length args) + mapM go (args `zip` tys) where go (L l (Missing {}), arg_ty) = do { mult <- newFlexiTyVarTy multiplicityTy ; return (L l (Missing (Scaled mult arg_ty))) } ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -81,6 +81,7 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Validity import GHC.Tc.Utils.Unify import GHC.IfaceToCore +import GHC.Iface.Load import GHC.Tc.Solver import GHC.Tc.Utils.Zonk import GHC.Core.TyCo.Rep @@ -103,8 +104,6 @@ import GHC.Types.Var.Env import GHC.Builtin.Types import GHC.Types.Basic import GHC.Types.SrcLoc -import GHC.Settings.Constants ( mAX_CTUPLE_SIZE ) -import GHC.Utils.Error( MsgDoc ) import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.Set @@ -1132,16 +1131,8 @@ tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } -tc_hs_type mode rn_ty@(HsTupleTy _ hs_tup_sort tys) exp_kind - = tc_tuple rn_ty mode tup_sort tys exp_kind - where - tup_sort = case hs_tup_sort of -- Fourth case dealt with above - HsUnboxedTuple -> UnboxedTuple - HsBoxedTuple -> BoxedTuple - HsConstraintTuple -> ConstraintTuple -#if __GLASGOW_HASKELL__ <= 810 - _ -> panic "tc_hs_type HsTupleTy" -#endif +tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind + = tc_tuple rn_ty mode UnboxedTuple tys exp_kind tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys @@ -1172,6 +1163,7 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks + ; checkTupSize arity ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys @@ -1326,33 +1318,28 @@ finish_tuple rn_ty tup_sort tau_tys tau_kinds exp_kind = do -- Drop any uses of 1-tuple constraints here. -- See Note [Ignore unary constraint tuples] -> check_expected_kind tau_ty constraintKind - | arity > mAX_CTUPLE_SIZE - -> failWith (bigConstraintTuple arity) | otherwise - -> let tycon = cTupleTyCon arity in - check_expected_kind (mkTyConApp tycon tau_tys) constraintKind + -> do let tycon = cTupleTyCon arity + checkCTupSize arity + check_expected_kind (mkTyConApp tycon tau_tys) constraintKind BoxedTuple -> do let tycon = tupleTyCon Boxed arity + checkTupSize arity checkWiredInTyCon tycon check_expected_kind (mkTyConApp tycon tau_tys) liftedTypeKind - UnboxedTuple -> + UnboxedTuple -> do let tycon = tupleTyCon Unboxed arity tau_reps = map kindRep tau_kinds -- See also Note [Unboxed tuple RuntimeRep vars] in GHC.Core.TyCon arg_tys = tau_reps ++ tau_tys - res_kind = unboxedTupleKind tau_reps in + res_kind = unboxedTupleKind tau_reps + checkTupSize arity check_expected_kind (mkTyConApp tycon arg_tys) res_kind where arity = length tau_tys check_expected_kind ty act_kind = checkExpectedKind rn_ty ty act_kind exp_kind -bigConstraintTuple :: Arity -> MsgDoc -bigConstraintTuple arity - = hang (text "Constraint tuple arity too large:" <+> int arity - <+> parens (text "max arity =" <+> int mAX_CTUPLE_SIZE)) - 2 (text "Instead, use a nested tuple") - {- Note [Ignore unary constraint tuples] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcSyntaxOp, tcSyntaxOpGen, tcInferRho ) import GHC.Hs +import GHC.Iface.Load import GHC.Tc.Utils.Zonk import GHC.Tc.Gen.Sig( TcPragEnv, lookupPragEnv, addInlinePrags ) import GHC.Tc.Utils.Monad @@ -509,6 +510,7 @@ Fortunately that's what matchExpectedFunTySigma returns anyway. tc = tupleTyCon boxity arity -- NB: tupleTyCon does not flatten 1-tuples -- See Note [Don't flatten tuples from HsSyn] in GHC.Core.Make + ; checkTupSize arity ; (coi, arg_tys) <- matchExpectedPatTy (matchExpectedTyConApp tc) penv (scaledThing pat_ty) -- Unboxed tuples have RuntimeRep vars, which we discard: ===================================== testsuite/tests/polykinds/T10451.stderr ===================================== @@ -10,3 +10,15 @@ T10451.hs:22:12: error: Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a)’ In the type declaration for ‘T’ + +T10451.hs:22:12: error: + • Constraint tuple arity too large: 66 (max arity = 64) + Instead, use a nested tuple + • In the type ‘(Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, Eq a, + Eq a, Eq a, Eq a)’ + In the type declaration for ‘T’ ===================================== testsuite/tests/rename/should_fail/T6148.stderr deleted ===================================== @@ -1,15 +0,0 @@ - -T6148.hs:3:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:7:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:11:6: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type ===================================== testsuite/tests/rename/should_fail/T6148a.hs ===================================== @@ -0,0 +1,4 @@ +module T6148a where + +a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) ===================================== testsuite/tests/rename/should_fail/T6148a.stderr ===================================== @@ -0,0 +1,14 @@ + +T6148a.hs:3:5: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the expression: + (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + In an equation for ‘a’: + a = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0) ===================================== testsuite/tests/rename/should_fail/T6148b.hs ===================================== @@ -0,0 +1,3 @@ +module T6148b where + +b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) ===================================== testsuite/tests/rename/should_fail/T6148b.stderr ===================================== @@ -0,0 +1,9 @@ + +T6148b.hs:3:5: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the expression: + (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + In an equation for ‘b’: + b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) ===================================== testsuite/tests/rename/should_fail/T6148.hs → testsuite/tests/rename/should_fail/T6148c.hs ===================================== @@ -1,10 +1,4 @@ -module T6148 where - -a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - - -b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +module T6148c where data T = T ===================================== testsuite/tests/rename/should_fail/T6148c.stderr ===================================== @@ -0,0 +1,7 @@ + +T6148c.hs:5:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type signature: + c :: (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -87,7 +87,9 @@ test('T5892b', normal, compile_fail, ['-package containers']) test('T5951', normal, compile_fail, ['']) test('T6018rnfail', normal, compile_fail, ['']) test('T6060', normal, compile_fail, ['']) -test('T6148', normal, compile_fail, ['']) +test('T6148a', normal, compile_fail, ['']) +test('T6148b', normal, compile_fail, ['']) +test('T6148c', normal, compile_fail, ['']) test('T7164', normal, compile_fail, ['']) test('T7338', normal, compile_fail, ['']) test('T7338a', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18723a.hs ===================================== @@ -0,0 +1,11 @@ +module T18723a where + +data T1 = MkT1 + ( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + ) ===================================== testsuite/tests/typecheck/should_fail/T18723a.stderr ===================================== @@ -0,0 +1,26 @@ + +T18723a.hs:4:3: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int)’ + In the definition of data constructor ‘MkT1’ + In the data declaration for ‘T1’ + +T18723a.hs:4:3: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int)’ + In the definition of data constructor ‘MkT1’ + In the data declaration for ‘T1’ ===================================== testsuite/tests/typecheck/should_fail/T18723b.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE DataKinds #-} +module T18723b where + +import Data.Proxy + +data T2 = MkT2 (Proxy + '( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + )) ===================================== testsuite/tests/typecheck/should_fail/T18723b.stderr ===================================== @@ -0,0 +1,274 @@ + +T18723b.hs:7:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the first argument of ‘Proxy’, namely + ‘'(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int)’ + In the type ‘(Proxy '(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int))’ + In the definition of data constructor ‘MkT2’ + +T18723b.hs:7:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the first argument of ‘Proxy’, namely + ‘'(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int)’ + In the type ‘(Proxy '(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int))’ + In the definition of data constructor ‘MkT2’ ===================================== testsuite/tests/typecheck/should_fail/T18723c.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE UnboxedTuples #-} +module T18723c where + +data T3 = MkT3 + (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + #) ===================================== testsuite/tests/typecheck/should_fail/T18723c.stderr ===================================== @@ -0,0 +1,26 @@ + +T18723c.hs:5:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int #)’ + In the definition of data constructor ‘MkT3’ + In the data declaration for ‘T3’ + +T18723c.hs:5:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int #)’ + In the definition of data constructor ‘MkT3’ + In the data declaration for ‘T3’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -580,6 +580,9 @@ test('T18357b', normal, compile_fail, ['']) test('T18455', normal, compile_fail, ['']) test('T18534', normal, compile_fail, ['']) test('T18714', normal, compile_fail, ['']) +test('T18723a', normal, compile_fail, ['']) +test('T18723b', normal, compile_fail, ['']) +test('T18723c', normal, compile_fail, ['']) test('too-many', normal, compile_fail, ['']) test('T18640a', normal, compile_fail, ['']) test('T18640b', normal, compile_fail, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit ff3145a5612f9cb8363aca79cb279a6080dc406b View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36b1df64308f7c2f2dce45ce1fbbfad813459b7f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36b1df64308f7c2f2dce45ce1fbbfad813459b7f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 15:16:50 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 16 Oct 2020 11:16:50 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 2 commits: Add ghc-debug funcitons to the RTS API Message-ID: <5f89b9625bcd5_28003fd3bc02304467622@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: aabdbc82 by David Eichmann at 2020-10-16T13:07:48+01:00 Add ghc-debug funcitons to the RTS API Four new functions added to RtsAPI.h: * rts_pause and rts_resume allow an external process to completely pause and resume the RTS. * rts_listThreads and rts_listMiscRoots are used to find the current roots of the garbage collector. These changes also mean that `Task.h` is exposed to the user. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - b8128dab by David Eichmann at 2020-10-16T16:14:23+01:00 ghc-heap: expose decoding from heap representation and support partial TSO/STACK decoding Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Runtime/Interpreter.hs - includes/Rts.h - includes/RtsAPI.h - + includes/rts/Task.h - includes/rts/storage/Closures.h - includes/rts/storage/Heap.h - includes/rts/storage/TSO.h - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs - libraries/ghc-heap/ghc-heap.cabal.in - + libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/all.T - + libraries/ghc-heap/tests/create_tso.c - + libraries/ghc-heap/tests/create_tso.h - + libraries/ghc-heap/tests/list_threads_and_misc_roots.hs - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.c - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.h - + libraries/ghc-heap/tests/parse_tso_flags.hs - + libraries/ghc-heap/tests/tso_and_stack_closures.hs - libraries/ghc-prim/changelog.md - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - rts/Capability.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e6e86177678664da6f2ea7f977412e38eabbad3...b8128dab18bf88b2700990e0d45f75b283fccb5b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e6e86177678664da6f2ea7f977412e38eabbad3...b8128dab18bf88b2700990e0d45f75b283fccb5b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 15:34:07 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 16 Oct 2020 11:34:07 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] ghc-heap: expose decoding from heap representation and support partial TSO/STACK decoding Message-ID: <5f89bd6fd54a9_2800a634f2068061d@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: 616060eb by David Eichmann at 2020-10-16T16:25:49+01:00 ghc-heap: expose decoding from heap representation and support partial TSO/STACK decoding Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 20 changed files: - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs - libraries/ghc-heap/ghc-heap.cabal.in - + libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/all.T - + libraries/ghc-heap/tests/create_tso.c - + libraries/ghc-heap/tests/create_tso.h - + libraries/ghc-heap/tests/list_threads_and_misc_roots.hs - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.c - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.h - + libraries/ghc-heap/tests/parse_tso_flags.hs - + libraries/ghc-heap/tests/tso_and_stack_closures.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/Heap.hs ===================================== @@ -7,6 +7,9 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ExplicitForAll #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE UnliftedFFITypes #-} {-| Module : GHC.Exts.Heap @@ -24,7 +27,11 @@ module GHC.Exts.Heap ( , GenClosure(..) , ClosureType(..) , PrimType(..) + , WhatNext(..) + , WhyBlocked(..) + , TsoFlags(..) , HasHeapRep(getClosureData) + , getClosureDataFromHeapRep -- * Info Table types , StgInfoTable(..) @@ -35,6 +42,12 @@ module GHC.Exts.Heap ( , peekItbl , pokeItbl + -- * Cost Centre (profiling) types + , StgTSOProfInfo(..) + , IndexTable(..) + , CostCentre(..) + , CostCentreStack(..) + -- * Closure inspection , getBoxedClosureData , allClosures @@ -49,16 +62,18 @@ import Prelude import GHC.Exts.Heap.Closures import GHC.Exts.Heap.ClosureTypes import GHC.Exts.Heap.Constants +import GHC.Exts.Heap.ProfInfo.Types #if defined(PROFILING) import GHC.Exts.Heap.InfoTableProf #else import GHC.Exts.Heap.InfoTable #endif import GHC.Exts.Heap.Utils +import qualified GHC.Exts.Heap.FFIClosures as FFIClosures import Control.Monad import Data.Bits -import GHC.Arr +import Foreign import GHC.Exts import GHC.Int import GHC.Word @@ -66,13 +81,19 @@ import GHC.Word #include "ghcconfig.h" class HasHeapRep (a :: TYPE rep) where - getClosureData :: a -> IO Closure + + -- | Decode a closure to it's heap representation ('GenClosure'). + getClosureData + :: a + -- ^ Closure to decode. + -> IO Closure + -- ^ Heap representation of the closure. instance HasHeapRep (a :: TYPE 'LiftedRep) where - getClosureData = getClosure + getClosureData = getClosureDataFromHeapObject instance HasHeapRep (a :: TYPE 'UnliftedRep) where - getClosureData x = getClosure (unsafeCoerce# x) + getClosureData x = getClosureDataFromHeapObject (unsafeCoerce# x) instance Int# ~ a => HasHeapRep (a :: TYPE 'IntRep) where getClosureData x = return $ @@ -102,49 +123,87 @@ instance Double# ~ a => HasHeapRep (a :: TYPE 'DoubleRep) where getClosureData x = return $ DoubleClosure { ptipe = PDouble, doubleVal = D# x } --- | This returns the raw representation of the given argument. The second --- component of the triple is the raw words of the closure on the heap, and the --- third component is those words that are actually pointers. Once back in the --- Haskell world, the raw words that hold pointers may be outdated after a --- garbage collector run, but the corresponding values in 'Box's will still --- point to the correct value. -getClosureRaw :: a -> IO (Ptr StgInfoTable, [Word], [Box]) -getClosureRaw x = do +-- | Get the heap representation of a closure _at this moment_, even if it is +-- unevaluated or an indirection or other exotic stuff. Beware when passing +-- something to this function, the same caveats as for +-- 'GHC.Exts.Heap.Closures.asBox' apply. +-- +-- For most use cases 'getClosureData' is an easier to use alternative. +-- +-- Currently TSO and STACK objects will return `UnsupportedClosure`. This is +-- because it is not memory safe to extract TSO and STACK objects (done via +-- `unpackClosure#`). Other threads may be mutating those objects and interleave +-- with reads in `unpackClosure#`. This is particularly problematic with STACKs +-- where pointer values may be overwritten by non-pointer values as the +-- corresponding haskell thread runs. +getClosureDataFromHeapObject + :: a + -- ^ Heap object to decode. + -> IO Closure + -- ^ Heap representation of the closure. +getClosureDataFromHeapObject x = do case unpackClosure# x of --- This is a hack to cover the bootstrap compiler using the old version of --- 'unpackClosure'. The new 'unpackClosure' return values are not merely --- a reordering, so using the old version would not work. - (# iptr, dat, pointers #) -> do - let nelems = (I# (sizeofByteArray# dat)) `div` wORD_SIZE - end = fromIntegral nelems - 1 - rawWds = [W# (indexWordArray# dat i) | I# i <- [0.. end] ] - pelems = I# (sizeofArray# pointers) - ptrList = amap' Box $ Array 0 (pelems - 1) pelems pointers - pure (Ptr iptr, rawWds, ptrList) - --- From GHC.Runtime.Heap.Inspect -amap' :: (t -> b) -> Array Int t -> [b] -amap' f (Array i0 i _ arr#) = map g [0 .. i - i0] - where g (I# i#) = case indexArray# arr# i# of - (# e #) -> f e - --- | This function returns a parsed heap representation of the argument _at --- this moment_, even if it is unevaluated or an indirection or other exotic --- stuff. Beware when passing something to this function, the same caveats as --- for 'asBox' apply. -getClosure :: a -> IO Closure -getClosure x = do - (iptr, wds, pts) <- getClosureRaw x - itbl <- peekItbl iptr - -- The remaining words after the header - let rawWds = drop (closureTypeHeaderSize (tipe itbl)) wds - -- For data args in a pointers then non-pointers closure - -- This is incorrect in non pointers-first setups - -- not sure if that happens - npts = drop (closureTypeHeaderSize (tipe itbl) + length pts) wds +#if MIN_VERSION_ghc_prim(0,5,3) + (# infoTableAddr, heapRep, pointersArray #) -> do +#else + -- This is a hack to cover the bootstrap compiler using the old version + -- of 'unpackClosure'. The new 'unpackClosure' return values are not + -- merely a reordering, so using the old version would not work. + (# infoTableAddr, pointersArray, heapRep #) -> do +#endif + let infoTablePtr = Ptr infoTableAddr + ptrList = [case indexArray# pointersArray i of + (# ptr #) -> Box ptr + | I# i <- [0..(I# (sizeofArray# pointersArray)) - 1] + ] + + infoTable <- peekItbl infoTablePtr + case tipe infoTable of + TSO -> pure $ UnsupportedClosure infoTable + STACK -> pure $ UnsupportedClosure infoTable + _ -> getClosureDataFromHeapRep False heapRep infoTablePtr ptrList + +-- | Convert an unpacked heap object, to a `GenClosure b`. The inputs to this +-- function can be generated from a heap object using `unpackClosure#`. +getClosureDataFromHeapRep + :: Bool + -- ^ True to support decoding of stack pointers. If False and the closure is + -- a STACK, then `UnsupportedClosure` is returned. + -> ByteArray# + -- ^ Heap representation of the closure as returned by `unpackClosure#`. + -- This includes all of the object including the header, info table + -- pointer, pointer data, and non-pointer data. The ByteArray# may be + -- pinned or unpinned. + -> Ptr StgInfoTable + -- ^ Pointer to the `StgInfoTable` of the closure, extracted from the heap + -- representation. The info table must not be movable by GC i.e. must be in + -- pinned or off-heap memory. + -> [b] + -- ^ Pointers in the payload of the closure, extracted from the heap + -- representation as returned by `collect_pointers()` in `Heap.c`. The type + -- `b` is some representation of a pointer e.g. `Any` or `Ptr Any`. + -> IO (GenClosure b) + -- ^ Heap representation of the closure. +getClosureDataFromHeapRep decodeStackClosures heapRep infoTablePtr pts = do + itbl <- peekItbl infoTablePtr + let -- heapRep as a list of words. + rawHeapWords :: [Word] + rawHeapWords = [W# (indexWordArray# heapRep i) | I# i <- [0.. end] ] + where + nelems = (I# (sizeofByteArray# heapRep)) `div` wORD_SIZE + end = fromIntegral nelems - 1 + + -- Just the payload of rawHeapWords (no header). + payloadWords :: [Word] + payloadWords = drop (closureTypeHeaderSize (tipe itbl)) rawHeapWords + + -- The non-pointer words in the payload. Only valid for closures with a + -- "pointers first" layout. Not valid for bit field layout. + npts :: [Word] + npts = drop (closureTypeHeaderSize (tipe itbl) + length pts) rawHeapWords case tipe itbl of t | t >= CONSTR && t <= CONSTR_NOCAF -> do - (p, m, n) <- dataConNames iptr + (p, m, n) <- dataConNames infoTablePtr if m == "GHC.ByteCode.Instr" && n == "BreakInfo" then pure $ UnsupportedClosure itbl else pure $ ConstrClosure itbl pts npts p m n @@ -164,9 +223,9 @@ getClosure x = do unless (length pts >= 1) $ fail "Expected at least 1 ptr argument to AP" -- We expect at least the arity, n_args, and fun fields - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail $ "Expected at least 2 raw words to AP" - let splitWord = rawWds !! 0 + let splitWord = payloadWords !! 0 pure $ APClosure itbl #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -181,9 +240,9 @@ getClosure x = do unless (length pts >= 1) $ fail "Expected at least 1 ptr argument to PAP" -- We expect at least the arity, n_args, and fun fields - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail "Expected at least 2 raw words to PAP" - let splitWord = rawWds !! 0 + let splitWord = payloadWords !! 0 pure $ PAPClosure itbl #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -218,10 +277,10 @@ getClosure x = do unless (length pts >= 3) $ fail $ "Expected at least 3 ptr argument to BCO, found " ++ show (length pts) - unless (length rawWds >= 4) $ + unless (length payloadWords >= 4) $ fail $ "Expected at least 4 words to BCO, found " - ++ show (length rawWds) - let splitWord = rawWds !! 3 + ++ show (length payloadWords) + let splitWord = payloadWords !! 3 pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) #if defined(WORDS_BIGENDIAN) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) @@ -230,27 +289,30 @@ getClosure x = do (fromIntegral splitWord) (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2)) #endif - (drop 4 rawWds) + (drop 4 payloadWords) ARR_WORDS -> do - unless (length rawWds >= 1) $ + unless (length payloadWords >= 1) $ fail $ "Expected at least 1 words to ARR_WORDS, found " - ++ show (length rawWds) - pure $ ArrWordsClosure itbl (head rawWds) (tail rawWds) + ++ show (length payloadWords) + pure $ ArrWordsClosure itbl (head payloadWords) (tail payloadWords) t | t >= MUT_ARR_PTRS_CLEAN && t <= MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length rawWds >= 2) $ + unless (length payloadWords >= 2) $ fail $ "Expected at least 2 words to MUT_ARR_PTRS_* " - ++ "found " ++ show (length rawWds) - pure $ MutArrClosure itbl (rawWds !! 0) (rawWds !! 1) pts + ++ "found " ++ show (length payloadWords) + pure $ MutArrClosure itbl (payloadWords !! 0) (payloadWords !! 1) pts t | t >= SMALL_MUT_ARR_PTRS_CLEAN && t <= SMALL_MUT_ARR_PTRS_FROZEN_CLEAN -> do - unless (length rawWds >= 1) $ + unless (length payloadWords >= 1) $ fail $ "Expected at least 1 word to SMALL_MUT_ARR_PTRS_* " - ++ "found " ++ show (length rawWds) - pure $ SmallMutArrClosure itbl (rawWds !! 0) pts + ++ "found " ++ show (length payloadWords) + pure $ SmallMutArrClosure itbl (payloadWords !! 0) pts - t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> + t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY -> do + unless (length pts >= 1) $ + fail $ "Expected at least 1 words to MUT_VAR, found " + ++ show (length pts) pure $ MutVarClosure itbl (head pts) t | t == MVAR_CLEAN || t == MVAR_DIRTY -> do @@ -260,13 +322,12 @@ getClosure x = do pure $ MVarClosure itbl (pts !! 0) (pts !! 1) (pts !! 2) BLOCKING_QUEUE -> - pure $ OtherClosure itbl pts wds + pure $ OtherClosure itbl pts rawHeapWords -- pure $ BlockingQueueClosure itbl -- (pts !! 0) (pts !! 1) (pts !! 2) (pts !! 3) - -- pure $ OtherClosure itbl pts wds + -- pure $ OtherClosure itbl pts rawHeapWords -- - WEAK -> pure $ WeakClosure { info = itbl @@ -276,6 +337,47 @@ getClosure x = do , finalizer = pts !! 3 , link = pts !! 4 } + TSO | [ u_lnk, u_gbl_lnk, tso_stack, u_trec, u_blk_ex, u_bq] <- pts + -> withArray rawHeapWords (\ptr -> do + fields <- FFIClosures.peekTSOFields ptr + pure $ TSOClosure + { info = itbl + , link = u_lnk + , global_link = u_gbl_lnk + , tsoStack = tso_stack + , trec = u_trec + , blocked_exceptions = u_blk_ex + , bq = u_bq + , what_next = FFIClosures.tso_what_next fields + , why_blocked = FFIClosures.tso_why_blocked fields + , flags = FFIClosures.tso_flags fields + , threadId = FFIClosures.tso_threadId fields + , saved_errno = FFIClosures.tso_saved_errno fields + , tso_dirty = FFIClosures.tso_dirty fields + , alloc_limit = FFIClosures.tso_alloc_limit fields + , tot_stack_size = FFIClosures.tso_tot_stack_size fields + , prof = FFIClosures.tso_prof fields + }) + | otherwise + -> fail $ "Expected 6 ptr arguments to TSO, found " + ++ show (length pts) + STACK + | [] <- pts + -> if decodeStackClosures + then withArray rawHeapWords (\ptr -> do + fields <- FFIClosures.peekStackFields ptr + pure $ StackClosure + { info = itbl + , stack_size = FFIClosures.stack_size fields + , stack_dirty = FFIClosures.stack_dirty fields +#if __GLASGOW_HASKELL__ >= 811 + , stack_marking = FFIClosures.stack_marking fields +#endif + }) + else pure $ UnsupportedClosure itbl + | otherwise + -> fail $ "Expected 0 ptr argument to STACK, found " + ++ show (length pts) _ -> pure $ UnsupportedClosure itbl ===================================== libraries/ghc-heap/GHC/Exts/Heap/Closures.hs ===================================== @@ -12,6 +12,9 @@ module GHC.Exts.Heap.Closures ( Closure , GenClosure(..) , PrimType(..) + , WhatNext(..) + , WhyBlocked(..) + , TsoFlags(..) , allClosures #if __GLASGOW_HASKELL__ >= 809 -- The closureSize# primop is unsupported on earlier GHC releases but we @@ -40,6 +43,8 @@ import GHC.Exts.Heap.InfoTable import GHC.Exts.Heap.InfoTableProf () #endif +import GHC.Exts.Heap.ProfInfo.Types + import Data.Bits import Data.Int import Data.Word @@ -100,11 +105,11 @@ type Closure = GenClosure Box -- | This is the representation of a Haskell value on the heap. It reflects -- -- --- The data type is parametrized by the type to store references in. Usually --- this is a 'Box' with the type synonym 'Closure'. +-- The data type is parametrized by `b`: the type to store references in. +-- Usually this is a 'Box' with the type synonym 'Closure'. -- --- All Heap objects have the same basic layout. A header containing a pointer --- to the info table and a payload with various fields. The @info@ field below +-- All Heap objects have the same basic layout. A header containing a pointer to +-- the info table and a payload with various fields. The @info@ field below -- always refers to the info table pointed to by the header. The remaining -- fields are the payload. -- @@ -268,6 +273,39 @@ data GenClosure b , link :: !b -- ^ next weak pointer for the capability, can be NULL. } + -- | Representation of StgTSO: A Thread State Object. The values for + -- 'what_next', 'why_blocked' and 'flags' are defined in @Constants.h at . + | TSOClosure + { info :: !StgInfoTable + -- pointers + , link :: !b + , global_link :: !b + , tsoStack :: !b -- ^ stackobj from StgTSO + , trec :: !b + , blocked_exceptions :: !b + , bq :: !b + -- values + , what_next :: !WhatNext + , why_blocked :: !WhyBlocked + , flags :: ![TsoFlags] + , threadId :: !Word64 + , saved_errno :: !Word32 + , tso_dirty :: !Word32 -- ^ non-zero => dirty + , alloc_limit :: !Int64 + , tot_stack_size :: !Word32 + , prof :: !(Maybe StgTSOProfInfo) + } + + -- | Representation of StgStack: The 'tsoStack ' of a 'TSOClosure'. + | StackClosure + { info :: !StgInfoTable + , stack_size :: !Word32 -- ^ stack size in *words* + , stack_dirty :: !Word8 -- ^ non-zero => dirty +#if __GLASGOW_HASKELL__ >= 810 + , stack_marking :: !Word8 +#endif + } + ------------------------------------------------------------ -- Unboxed unlifted closures @@ -332,6 +370,43 @@ data PrimType | PDouble deriving (Eq, Show, Generic) +data WhatNext + = ThreadRunGHC + | ThreadInterpret + | ThreadKilled + | ThreadComplete + | WhatNextUnknownValue Word16 -- ^ Please report this as a bug + deriving (Eq, Show, Generic) + +data WhyBlocked + = NotBlocked + | BlockedOnMVar + | BlockedOnMVarRead + | BlockedOnBlackHole + | BlockedOnRead + | BlockedOnWrite + | BlockedOnDelay + | BlockedOnSTM + | BlockedOnDoProc + | BlockedOnCCall + | BlockedOnCCall_Interruptible + | BlockedOnMsgThrowTo + | ThreadMigrating + | BlockedOnIOCompletion + | WhyBlockedUnknownValue Word16 -- ^ Please report this as a bug + deriving (Eq, Show, Generic) + +data TsoFlags + = TsoLocked + | TsoBlockx + | TsoInterruptible + | TsoStoppedOnBreakpoint + | TsoMarked + | TsoSqueezed + | TsoAllocLimit + | TsoFlagsUnknownValue Word32 -- ^ Please report this as a bug + deriving (Eq, Show, Generic) + -- | For generic code, this function returns all referenced closures. allClosures :: GenClosure b -> [b] allClosures (ConstrClosure {..}) = ptrArgs ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP #-} + +module GHC.Exts.Heap.FFIClosures (module Reexport) where + +#if defined(PROFILING) +import GHC.Exts.Heap.FFIClosures_ProfilingEnabled as Reexport +import GHC.Exts.Heap.FFIClosures_ProfilingDisabled () +#else +import GHC.Exts.Heap.FFIClosures_ProfilingDisabled as Reexport +import GHC.Exts.Heap.FFIClosures_ProfilingEnabled () +#endif ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc ===================================== @@ -0,0 +1,133 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} + +module GHC.Exts.Heap.FFIClosures_ProfilingDisabled where + +-- Manually undefining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.FFIClosures_ProfilingEnabled. +#undef PROFILING +#include "Rts.h" + +import Prelude +import Foreign +import GHC.Exts +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled +import GHC.Exts.Heap.ProfInfo.Types +import GHC.Exts.Heap.Closures(WhatNext(..), WhyBlocked(..), TsoFlags(..)) + +data TSOFields = TSOFields { + tso_what_next :: WhatNext, + tso_why_blocked :: WhyBlocked, + tso_flags :: [TsoFlags], +-- Unfortunately block_info is a union without clear discriminator. +-- block_info :: TDB, + tso_threadId :: Word64, + tso_saved_errno :: Word32, + tso_dirty:: Word32, + tso_alloc_limit :: Int64, + tso_tot_stack_size :: Word32, + tso_prof :: Maybe StgTSOProfInfo +} + +-- | Get non-pointer fields from @StgTSO_@ (@TSO.h@) +peekTSOFields :: Ptr tsoPtr -> IO TSOFields +peekTSOFields ptr = do + what_next' <- (#peek struct StgTSO_, what_next) ptr + why_blocked' <- (#peek struct StgTSO_, why_blocked) ptr + flags' <- (#peek struct StgTSO_, flags) ptr + threadId' <- (#peek struct StgTSO_, id) ptr + saved_errno' <- (#peek struct StgTSO_, saved_errno) ptr + dirty' <- (#peek struct StgTSO_, dirty) ptr + alloc_limit' <- (#peek struct StgTSO_, alloc_limit) ptr + tot_stack_size' <- (#peek struct StgTSO_, tot_stack_size) ptr + tso_prof' <- peekStgTSOProfInfo ptr + + return TSOFields { + tso_what_next = parseWhatNext what_next', + tso_why_blocked = parseWhyBlocked why_blocked', + tso_flags = parseTsoFlags flags', + tso_threadId = threadId', + tso_saved_errno = saved_errno', + tso_dirty = dirty', + tso_alloc_limit = alloc_limit', + tso_tot_stack_size = tot_stack_size', + tso_prof = tso_prof' + } + +parseWhatNext :: Word16 -> WhatNext +parseWhatNext w = case w of + (#const ThreadRunGHC) -> ThreadRunGHC + (#const ThreadInterpret) -> ThreadInterpret + (#const ThreadKilled) -> ThreadKilled + (#const ThreadComplete) -> ThreadComplete + _ -> WhatNextUnknownValue w + +parseWhyBlocked :: Word16 -> WhyBlocked +parseWhyBlocked w = case w of + (#const NotBlocked) -> NotBlocked + (#const BlockedOnMVar) -> BlockedOnMVar + (#const BlockedOnMVarRead) -> BlockedOnMVarRead + (#const BlockedOnBlackHole) -> BlockedOnBlackHole + (#const BlockedOnRead) -> BlockedOnRead + (#const BlockedOnWrite) -> BlockedOnWrite + (#const BlockedOnDelay) -> BlockedOnDelay + (#const BlockedOnSTM) -> BlockedOnSTM + (#const BlockedOnDoProc) -> BlockedOnDoProc + (#const BlockedOnCCall) -> BlockedOnCCall + (#const BlockedOnCCall_Interruptible) -> BlockedOnCCall_Interruptible + (#const BlockedOnMsgThrowTo) -> BlockedOnMsgThrowTo + (#const ThreadMigrating) -> ThreadMigrating +#if __GLASGOW_HASKELL__ >= 810 + (#const BlockedOnIOCompletion) -> BlockedOnIOCompletion +#endif + _ -> WhyBlockedUnknownValue w + +parseTsoFlags :: Word32 -> [TsoFlags] +parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset (#const TSO_LOCKED) w) + | isSet (#const TSO_BLOCKEX) w = TsoBlockx : parseTsoFlags (unset (#const TSO_BLOCKEX) w) + | isSet (#const TSO_INTERRUPTIBLE) w = TsoInterruptible : parseTsoFlags (unset (#const TSO_INTERRUPTIBLE) w) + | isSet (#const TSO_STOPPED_ON_BREAKPOINT) w = TsoStoppedOnBreakpoint : parseTsoFlags (unset (#const TSO_STOPPED_ON_BREAKPOINT) w) + | isSet (#const TSO_MARKED) w = TsoMarked : parseTsoFlags (unset (#const TSO_MARKED) w) + | isSet (#const TSO_SQUEEZED) w = TsoSqueezed : parseTsoFlags (unset (#const TSO_SQUEEZED) w) + | isSet (#const TSO_ALLOC_LIMIT) w = TsoAllocLimit : parseTsoFlags (unset (#const TSO_ALLOC_LIMIT) w) +parseTsoFlags 0 = [] +parseTsoFlags w = [TsoFlagsUnknownValue w] + +isSet :: Word32 -> Word32 -> Bool +isSet bitMask w = w .&. bitMask /= 0 + +unset :: Word32 -> Word32 -> Word32 +unset bitMask w = w `xor` bitMask + +data StackFields = StackFields { + stack_size :: Word32, + stack_dirty :: Word8, +#if __GLASGOW_HASKELL__ >= 810 + stack_marking :: Word8, +#endif + stack_sp :: Addr## +} + +-- | Get non-closure fields from @StgStack_@ (@TSO.h@) +peekStackFields :: Ptr a -> IO StackFields +peekStackFields ptr = do + stack_size' <- (#peek struct StgStack_, stack_size) ptr ::IO Word32 + dirty' <- (#peek struct StgStack_, dirty) ptr +#if __GLASGOW_HASKELL__ >= 810 + marking' <- (#peek struct StgStack_, marking) ptr +#endif + Ptr sp' <- (#peek struct StgStack_, sp) ptr + + -- TODO decode the stack. + + return StackFields { + stack_size = stack_size', + stack_dirty = dirty', +#if __GLASGOW_HASKELL__ >= 810 + stack_marking = marking', +#endif + stack_sp = sp' + } + ===================================== libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc ===================================== @@ -0,0 +1,132 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} + +module GHC.Exts.Heap.FFIClosures_ProfilingEnabled where + +-- Manually defining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.FFIClosures_ProfilingDisabled. +#define PROFILING +#include "Rts.h" + +import Prelude +import Foreign +import GHC.Exts +import GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled +import GHC.Exts.Heap.ProfInfo.Types +import GHC.Exts.Heap.Closures(WhatNext(..), WhyBlocked(..), TsoFlags(..)) + +data TSOFields = TSOFields { + tso_what_next :: WhatNext, + tso_why_blocked :: WhyBlocked, + tso_flags :: [TsoFlags], +-- Unfortunately block_info is a union without clear discriminator. +-- block_info :: TDB, + tso_threadId :: Word64, + tso_saved_errno :: Word32, + tso_dirty:: Word32, + tso_alloc_limit :: Int64, + tso_tot_stack_size :: Word32, + tso_prof :: Maybe StgTSOProfInfo +} + +-- | Get non-pointer fields from @StgTSO_@ (@TSO.h@) +peekTSOFields :: Ptr tsoPtr -> IO TSOFields +peekTSOFields ptr = do + what_next' <- (#peek struct StgTSO_, what_next) ptr + why_blocked' <- (#peek struct StgTSO_, why_blocked) ptr + flags' <- (#peek struct StgTSO_, flags) ptr + threadId' <- (#peek struct StgTSO_, id) ptr + saved_errno' <- (#peek struct StgTSO_, saved_errno) ptr + dirty' <- (#peek struct StgTSO_, dirty) ptr + alloc_limit' <- (#peek struct StgTSO_, alloc_limit) ptr + tot_stack_size' <- (#peek struct StgTSO_, tot_stack_size) ptr + tso_prof' <- peekStgTSOProfInfo ptr + + return TSOFields { + tso_what_next = parseWhatNext what_next', + tso_why_blocked = parseWhyBlocked why_blocked', + tso_flags = parseTsoFlags flags', + tso_threadId = threadId', + tso_saved_errno = saved_errno', + tso_dirty = dirty', + tso_alloc_limit = alloc_limit', + tso_tot_stack_size = tot_stack_size', + tso_prof = tso_prof' + } + +parseWhatNext :: Word16 -> WhatNext +parseWhatNext w = case w of + (#const ThreadRunGHC) -> ThreadRunGHC + (#const ThreadInterpret) -> ThreadInterpret + (#const ThreadKilled) -> ThreadKilled + (#const ThreadComplete) -> ThreadComplete + _ -> WhatNextUnknownValue w + +parseWhyBlocked :: Word16 -> WhyBlocked +parseWhyBlocked w = case w of + (#const NotBlocked) -> NotBlocked + (#const BlockedOnMVar) -> BlockedOnMVar + (#const BlockedOnMVarRead) -> BlockedOnMVarRead + (#const BlockedOnBlackHole) -> BlockedOnBlackHole + (#const BlockedOnRead) -> BlockedOnRead + (#const BlockedOnWrite) -> BlockedOnWrite + (#const BlockedOnDelay) -> BlockedOnDelay + (#const BlockedOnSTM) -> BlockedOnSTM + (#const BlockedOnDoProc) -> BlockedOnDoProc + (#const BlockedOnCCall) -> BlockedOnCCall + (#const BlockedOnCCall_Interruptible) -> BlockedOnCCall_Interruptible + (#const BlockedOnMsgThrowTo) -> BlockedOnMsgThrowTo + (#const ThreadMigrating) -> ThreadMigrating +#if __GLASGOW_HASKELL__ >= 810 + (#const BlockedOnIOCompletion) -> BlockedOnIOCompletion +#endif + _ -> WhyBlockedUnknownValue w + +parseTsoFlags :: Word32 -> [TsoFlags] +parseTsoFlags w | isSet (#const TSO_LOCKED) w = TsoLocked : parseTsoFlags (unset (#const TSO_LOCKED) w) + | isSet (#const TSO_BLOCKEX) w = TsoBlockx : parseTsoFlags (unset (#const TSO_BLOCKEX) w) + | isSet (#const TSO_INTERRUPTIBLE) w = TsoInterruptible : parseTsoFlags (unset (#const TSO_INTERRUPTIBLE) w) + | isSet (#const TSO_STOPPED_ON_BREAKPOINT) w = TsoStoppedOnBreakpoint : parseTsoFlags (unset (#const TSO_STOPPED_ON_BREAKPOINT) w) + | isSet (#const TSO_MARKED) w = TsoMarked : parseTsoFlags (unset (#const TSO_MARKED) w) + | isSet (#const TSO_SQUEEZED) w = TsoSqueezed : parseTsoFlags (unset (#const TSO_SQUEEZED) w) + | isSet (#const TSO_ALLOC_LIMIT) w = TsoAllocLimit : parseTsoFlags (unset (#const TSO_ALLOC_LIMIT) w) +parseTsoFlags 0 = [] +parseTsoFlags w = [TsoFlagsUnknownValue w] + +isSet :: Word32 -> Word32 -> Bool +isSet bitMask w = w .&. bitMask /= 0 + +unset :: Word32 -> Word32 -> Word32 +unset bitMask w = w `xor` bitMask + +data StackFields = StackFields { + stack_size :: Word32, + stack_dirty :: Word8, +#if __GLASGOW_HASKELL__ >= 810 + stack_marking :: Word8, +#endif + stack_sp :: Addr## +} + +-- | Get non-closure fields from @StgStack_@ (@TSO.h@) +peekStackFields :: Ptr a -> IO StackFields +peekStackFields ptr = do + stack_size' <- (#peek struct StgStack_, stack_size) ptr ::IO Word32 + dirty' <- (#peek struct StgStack_, dirty) ptr +#if __GLASGOW_HASKELL__ >= 810 + marking' <- (#peek struct StgStack_, marking) ptr +#endif + Ptr sp' <- (#peek struct StgStack_, sp) ptr + + -- TODO decode the stack. + + return StackFields { + stack_size = stack_size', + stack_dirty = dirty', +#if __GLASGOW_HASKELL__ >= 810 + stack_marking = marking', +#endif + stack_sp = sp' + } ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc ===================================== @@ -0,0 +1,12 @@ +module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled( + peekStgTSOProfInfo +) where + +import Prelude +import Foreign +import GHC.Exts.Heap.ProfInfo.Types + +-- | This implementation is used when PROFILING is undefined. +-- It always returns 'Nothing', because there is no profiling info available. +peekStgTSOProfInfo :: Ptr tsoPtr -> IO (Maybe StgTSOProfInfo) +peekStgTSOProfInfo _ = return Nothing ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc ===================================== @@ -0,0 +1,167 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE MagicHash #-} + +module GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled( + peekStgTSOProfInfo +) where + +#if __GLASGOW_HASKELL__ >= 811 + +-- Manually defining PROFILING gives the #peek and #poke macros an accurate +-- representation of the C structures when hsc2hs runs. This is valid because +-- a non-profiling build would use +-- GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled. +#define PROFILING + +#include "Rts.h" +#undef BLOCK_SIZE +#undef MBLOCK_SIZE +#undef BLOCKS_PER_MBLOCK +#include "DerivedConstants.h" + +import Data.IntSet (IntSet) +import qualified Data.IntSet as IntSet +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap +import Data.IORef (IORef, newIORef, readIORef, writeIORef) +import Foreign +import Foreign.C.String +import GHC.Exts +import GHC.Exts.Heap.ProfInfo.Types +import Prelude + +-- Use Int based containers for pointers (addresses) for better performance. +-- These will be queried a lot! +type AddressSet = IntSet +type AddressMap = IntMap + +peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) +peekStgTSOProfInfo tsoPtr = do + cccs_ptr <- peekByteOff tsoPtr cccsOffset + costCenterCacheRef <- newIORef IntMap.empty + cccs' <- peekCostCentreStack IntSet.empty costCenterCacheRef cccs_ptr + + return $ Just StgTSOProfInfo { + cccs = cccs' + } + +cccsOffset :: Int +cccsOffset = (#const OFFSET_StgTSO_cccs) + (#size StgHeader) + +peekCostCentreStack + :: AddressSet + -> IORef (AddressMap CostCentre) + -> Ptr costCentreStack + -> IO (Maybe CostCentreStack) +peekCostCentreStack _ _ ptr | ptr == nullPtr = return Nothing +peekCostCentreStack loopBreakers _ ptr | IntSet.member (ptrToInt ptr) loopBreakers = return Nothing +peekCostCentreStack loopBreakers costCenterCacheRef ptr = do + ccs_ccsID' <- (#peek struct CostCentreStack_, ccsID) ptr + ccs_cc_ptr <- (#peek struct CostCentreStack_, cc) ptr + ccs_cc' <- peekCostCentre costCenterCacheRef ccs_cc_ptr + ccs_prevStack_ptr <- (#peek struct CostCentreStack_, prevStack) ptr + let loopBreakers' = (IntSet.insert ptrAsInt loopBreakers) + ccs_prevStack' <- peekCostCentreStack loopBreakers' costCenterCacheRef ccs_prevStack_ptr + ccs_indexTable_ptr <- (#peek struct CostCentreStack_, indexTable) ptr + ccs_indexTable' <- peekIndexTable loopBreakers' costCenterCacheRef ccs_indexTable_ptr + ccs_root_ptr <- (#peek struct CostCentreStack_, root) ptr + ccs_root' <- peekCostCentreStack loopBreakers' costCenterCacheRef ccs_root_ptr + ccs_depth' <- (#peek struct CostCentreStack_, depth) ptr + ccs_scc_count' <- (#peek struct CostCentreStack_, scc_count) ptr + ccs_selected' <- (#peek struct CostCentreStack_, selected) ptr + ccs_time_ticks' <- (#peek struct CostCentreStack_, time_ticks) ptr + ccs_mem_alloc' <- (#peek struct CostCentreStack_, mem_alloc) ptr + ccs_inherited_alloc' <- (#peek struct CostCentreStack_, inherited_alloc) ptr + ccs_inherited_ticks' <- (#peek struct CostCentreStack_, inherited_ticks) ptr + + return $ Just CostCentreStack { + ccs_ccsID = ccs_ccsID', + ccs_cc = ccs_cc', + ccs_prevStack = ccs_prevStack', + ccs_indexTable = ccs_indexTable', + ccs_root = ccs_root', + ccs_depth = ccs_depth', + ccs_scc_count = ccs_scc_count', + ccs_selected = ccs_selected', + ccs_time_ticks = ccs_time_ticks', + ccs_mem_alloc = ccs_mem_alloc', + ccs_inherited_alloc = ccs_inherited_alloc', + ccs_inherited_ticks = ccs_inherited_ticks' + } + where + ptrAsInt = ptrToInt ptr + +peekCostCentre :: IORef (AddressMap CostCentre) -> Ptr costCentre -> IO CostCentre +peekCostCentre costCenterCacheRef ptr = do + costCenterCache <- readIORef costCenterCacheRef + case IntMap.lookup ptrAsInt costCenterCache of + (Just a) -> return a + Nothing -> do + cc_ccID' <- (#peek struct CostCentre_, ccID) ptr + cc_label_ptr <- (#peek struct CostCentre_, label) ptr + cc_label' <- peekCString cc_label_ptr + cc_module_ptr <- (#peek struct CostCentre_, module) ptr + cc_module' <- peekCString cc_module_ptr + cc_srcloc_ptr <- (#peek struct CostCentre_, srcloc) ptr + cc_srcloc' <- do + if cc_srcloc_ptr == nullPtr then + return Nothing + else + fmap Just (peekCString cc_srcloc_ptr) + cc_mem_alloc' <- (#peek struct CostCentre_, mem_alloc) ptr + cc_time_ticks' <- (#peek struct CostCentre_, time_ticks) ptr + cc_is_caf' <- (#peek struct CostCentre_, is_caf) ptr + cc_link_ptr <- (#peek struct CostCentre_, link) ptr + cc_link' <- if cc_link_ptr == nullPtr then + return Nothing + else + fmap Just (peekCostCentre costCenterCacheRef cc_link_ptr) + + let result = CostCentre { + cc_ccID = cc_ccID', + cc_label = cc_label', + cc_module = cc_module', + cc_srcloc = cc_srcloc', + cc_mem_alloc = cc_mem_alloc', + cc_time_ticks = cc_time_ticks', + cc_is_caf = cc_is_caf', + cc_link = cc_link' + } + + writeIORef costCenterCacheRef (IntMap.insert ptrAsInt result costCenterCache) + + return result + where + ptrAsInt = ptrToInt ptr + +peekIndexTable :: AddressSet -> IORef (AddressMap CostCentre) -> Ptr indexTable -> IO (Maybe IndexTable) +peekIndexTable _ _ ptr | ptr == nullPtr = return Nothing +peekIndexTable loopBreakers costCenterCacheRef ptr = do + it_cc_ptr <- (#peek struct IndexTable_, cc) ptr + it_cc' <- peekCostCentre costCenterCacheRef it_cc_ptr + it_ccs_ptr <- (#peek struct IndexTable_, ccs) ptr + it_ccs' <- peekCostCentreStack loopBreakers costCenterCacheRef it_ccs_ptr + it_next_ptr <- (#peek struct IndexTable_, next) ptr + it_next' <- peekIndexTable loopBreakers costCenterCacheRef it_next_ptr + it_back_edge' <- (#peek struct IndexTable_, back_edge) ptr + + return $ Just IndexTable { + it_cc = it_cc', + it_ccs = it_ccs', + it_next = it_next', + it_back_edge = it_back_edge' + } + +-- | casts a @Ptr@ to an @Int@ +ptrToInt :: Ptr a -> Int +ptrToInt (Ptr a##) = I## (addr2Int## a##) + +#else +import Prelude +import Foreign + +import GHC.Exts.Heap.ProfInfo.Types + +peekStgTSOProfInfo :: Ptr a -> IO (Maybe StgTSOProfInfo) +peekStgTSOProfInfo _ = return Nothing +#endif ===================================== libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs ===================================== @@ -0,0 +1,56 @@ +{-# LANGUAGE DeriveGeneric #-} + +module GHC.Exts.Heap.ProfInfo.Types where + +import Prelude +import Data.Word +import GHC.Generics + +-- | This is a somewhat faithful representation of StgTSOProfInfo. See +-- +-- for more details on this data structure. +data StgTSOProfInfo = StgTSOProfInfo { + cccs :: Maybe CostCentreStack +} deriving (Show, Generic) + +-- | This is a somewhat faithful representation of CostCentreStack. See +-- +-- for more details on this data structure. +data CostCentreStack = CostCentreStack { + ccs_ccsID :: Int, + ccs_cc :: CostCentre, + ccs_prevStack :: Maybe CostCentreStack, + ccs_indexTable :: Maybe IndexTable, + ccs_root :: Maybe CostCentreStack, + ccs_depth :: Word, + ccs_scc_count :: Word64, + ccs_selected :: Word, + ccs_time_ticks :: Word, + ccs_mem_alloc :: Word64, + ccs_inherited_alloc :: Word64, + ccs_inherited_ticks :: Word +} deriving (Show, Generic, Eq) + +-- | This is a somewhat faithful representation of CostCentre. See +-- +-- for more details on this data structure. +data CostCentre = CostCentre { + cc_ccID :: Int, + cc_label :: String, + cc_module :: String, + cc_srcloc :: Maybe String, + cc_mem_alloc :: Word64, + cc_time_ticks :: Word, + cc_is_caf :: Bool, + cc_link :: Maybe CostCentre +} deriving (Show, Generic, Eq) + +-- | This is a somewhat faithful representation of IndexTable. See +-- +-- for more details on this data structure. +data IndexTable = IndexTable { + it_cc :: CostCentre, + it_ccs :: Maybe CostCentreStack, + it_next :: Maybe IndexTable, + it_back_edge :: Bool +} deriving (Show, Generic, Eq) ===================================== libraries/ghc-heap/ghc-heap.cabal.in ===================================== @@ -25,6 +25,7 @@ library build-depends: base >= 4.9.0 && < 5.0 , ghc-prim > 0.2 && < 0.8 , rts == 1.0.* + , containers >= 0.6.2.1 && < 0.7 ghc-options: -Wall cmm-sources: cbits/HeapPrim.cmm @@ -39,3 +40,9 @@ library GHC.Exts.Heap.InfoTable.Types GHC.Exts.Heap.InfoTableProf GHC.Exts.Heap.Utils + GHC.Exts.Heap.FFIClosures + GHC.Exts.Heap.FFIClosures_ProfilingEnabled + GHC.Exts.Heap.FFIClosures_ProfilingDisabled + GHC.Exts.Heap.ProfInfo.Types + GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingEnabled + GHC.Exts.Heap.ProfInfo.PeekProfInfo_ProfilingDisabled ===================================== libraries/ghc-heap/tests/TestUtils.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash #-} +module TestUtils where + +import Foreign (Ptr) +import GHC.Exts (Addr#) +import GHC.Ptr (Ptr(Ptr)) + +assertEqual :: (Show a, Eq a) => a -> a -> IO () +assertEqual a b + | a /= b = error (show a ++ " /= " ++ show b) + | otherwise = return () + +unpackAddr# :: Ptr () -> Addr# +unpackAddr# (Ptr addr) = addr ===================================== libraries/ghc-heap/tests/all.T ===================================== @@ -36,3 +36,26 @@ test('closure_size_noopt', ], compile_and_run, ['']) +test('tso_and_stack_closures', + [extra_files(['create_tso.c','create_tso.h','TestUtils.hs']), + only_ways(['profthreaded']), + extra_ways(['profthreaded']), + ignore_stdout, + ignore_stderr + ], + multi_compile_and_run, ['tso_and_stack_closures', [('create_tso.c','')], '']) + +test('list_threads_and_misc_roots', + [extra_files(['list_threads_and_misc_roots_c.c','list_threads_and_misc_roots_c.h','TestUtils.hs']), + ignore_stdout, + ignore_stderr + ], + multi_compile_and_run, ['list_threads_and_misc_roots', [('list_threads_and_misc_roots_c.c','')], '-threaded']) + +test('parse_tso_flags', + [extra_files(['TestUtils.hs']), + only_ways(['normal']), + ignore_stdout, + ignore_stderr + ], + compile_and_run, ['']) ===================================== libraries/ghc-heap/tests/create_tso.c ===================================== @@ -0,0 +1,80 @@ +#include "Rts.h" +#include "RtsAPI.h" + +// Must be called from a safe FFI call. +void create_and_unpack_tso_and_stack + // TSO + ( StgTSO ** outTso + , StgInfoTable ** outTsoInfoTablePtr + , int * outTsoHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outTsoHeapRep // Array of words + , int * outTsoPointersSize // Size of outPointers (in words) + , StgClosure *** outTsoPointers // Array of all pointers of the TSO + // Stack + , StgTSO ** outStack + , StgInfoTable ** outStackInfoTablePtr + , int * outStackHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outStackHeapRep // Array of words + , int * outStackPointersSize // Size of outPointers (in words) + , StgClosure *** outStackPointers // Array of all pointers of the TSO + ) +{ + // Pause RTS + Capability * cap = rts_pause(); + + // Create TSO/Stack + HaskellObj trueClosure = rts_mkBool(cap, 1); + *outTso = createGenThread(cap, 500U, trueClosure); + + // Unpack TSO + unpack_closure( + (StgClosure*)(*outTso), + outTsoInfoTablePtr, + outTsoHeapRepSize, + outTsoHeapRep, + outTsoPointersSize, + outTsoPointers); + + // Unpack STACK + *outStack = (*outTsoPointers)[2]; + unpack_closure( + (StgClosure*)(*outStack), + outStackInfoTablePtr, + outStackHeapRepSize, + outStackHeapRep, + outStackPointersSize, + outStackPointers); + + // Resume RTS + rts_resume(cap); +} + +// Assumed the rts is paused +void unpack_closure + ( StgClosure * inClosure + , StgInfoTable ** outInfoTablePtr + , int * outHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outHeapRep // Array of words + , int * outPointersSize // Size of outPointers (in words) + , StgClosure *** outPointers // Array of all pointers of the TSO + ) +{ + *outInfoTablePtr = get_itbl(inClosure); + + // Copy TSO pointers. + StgWord closureSizeW = heap_view_closureSize(inClosure); + int closureSizeB = sizeof(StgWord) * closureSizeW; + StgClosure ** pointers = malloc(closureSizeB); + *outPointersSize = collect_pointers(inClosure, closureSizeW, pointers); + *outPointers = pointers; + + // Copy the heap rep. + StgWord * heapRep = malloc(closureSizeB); + for (int i = 0; i < closureSizeW; i++) + { + heapRep[i] = ((StgWord*)inClosure)[i]; + } + + *outHeapRepSize = closureSizeB; + *outHeapRep = heapRep; +} ===================================== libraries/ghc-heap/tests/create_tso.h ===================================== @@ -0,0 +1,19 @@ +#include "Rts.h" +#include "RtsAPI.h" + +void create_and_unpack_tso_and_stack + // TSO + ( StgTSO ** outTso + , StgInfoTable ** outTsoInfoTablePtr + , int * outTsoHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outTsoHeapRep // Array of words + , int * outTsoPointersSize // Size of outPointers (in words) + , StgClosure *** outTsoPointers // Array of all pointers of the TSO + // Stack + , StgTSO ** outStack + , StgInfoTable ** outStackInfoTablePtr + , int * outStackHeapRepSize // Size of outHeapRep (in bytes) + , StgWord ** outStackHeapRep // Array of words + , int * outStackPointersSize // Size of outPointers (in words) + , StgClosure *** outStackPointers // Array of all pointers of the TSO + ); ===================================== libraries/ghc-heap/tests/list_threads_and_misc_roots.hs ===================================== @@ -0,0 +1,6 @@ + +foreign import ccall safe "list_threads_and_misc_roots_c.h check_tso_and_misc_roots" + check_tso_and_misc_roots :: IO () + +main :: IO () +main = check_tso_and_misc_roots ===================================== libraries/ghc-heap/tests/list_threads_and_misc_roots_c.c ===================================== @@ -0,0 +1,52 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "list_threads_and_misc_roots_c.h" + +static int tsoCount = 0; +static StgTSO** tsos; + +static int miscRootsCount = 0; +static StgClosure** miscRoots; + +void collectTSOsCallback(void *user, StgTSO* tso){ + tsoCount++; + tsos = realloc(tsos, sizeof(StgTSO*) * tsoCount); + tsos[tsoCount - 1] = tso; +} + +void collectMiscRootsCallback(void *user, StgClosure* closure){ + miscRootsCount++; + miscRoots = realloc(miscRoots, sizeof(StgClosure*) * miscRootsCount); + miscRoots[miscRootsCount - 1] = closure; +} + +void check_tso_and_misc_roots(void) { + Capability * cap = rts_pause(); + rts_listThreads(&collectTSOsCallback, NULL); + rts_listMiscRoots(&collectMiscRootsCallback, NULL); + + for (int i = 0; i < tsoCount; i++) + { + StgTSO *tso = UNTAG_CLOSURE(tsos[i]); + if (get_itbl(tso)->type != TSO) + { + printf("tso returned a non-TSO type %zu at index %i\n", + tso->header.info->type, + i); + exit(1); + } + } + + for (int i = 0; i < miscRootsCount; i++) + { + StgClosure *root = UNTAG_CLOSURE(miscRoots[i]); + printf("get_itbl(root) = %p\n", get_itbl(root)); fflush(stdout); + if (get_itbl(root)->type == TSO) + { + printf("rts_listThreads returned a TSO type at index %i (TSO=%zu)\n", i, TSO); fflush(stdout); + exit(1); + } + } + + rts_resume(cap); +} ===================================== libraries/ghc-heap/tests/list_threads_and_misc_roots_c.h ===================================== @@ -0,0 +1,4 @@ +#include "Rts.h" +#include "RtsAPI.h" + +void check_tso_and_misc_roots(void); ===================================== libraries/ghc-heap/tests/parse_tso_flags.hs ===================================== @@ -0,0 +1,17 @@ +import GHC.Exts.Heap.Closures +import GHC.Exts.Heap.FFIClosures +import TestUtils + +main :: IO() +main = do + assertEqual (parseTsoFlags 0) [] + assertEqual (parseTsoFlags 1) [TsoFlagsUnknownValue 1] + assertEqual (parseTsoFlags 2) [TsoLocked] + assertEqual (parseTsoFlags 4) [TsoBlockx] + assertEqual (parseTsoFlags 8) [TsoInterruptible] + assertEqual (parseTsoFlags 16) [TsoStoppedOnBreakpoint] + assertEqual (parseTsoFlags 64) [TsoMarked] + assertEqual (parseTsoFlags 128) [TsoSqueezed] + assertEqual (parseTsoFlags 256) [TsoAllocLimit] + + assertEqual (parseTsoFlags 6) [TsoLocked, TsoBlockx] ===================================== libraries/ghc-heap/tests/tso_and_stack_closures.hs ===================================== @@ -0,0 +1,168 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} + +import Control.Monad (forM_, unless) +import Data.List (find) +import Data.Word +import Foreign +import Foreign.C.Types +import GHC.IO ( IO(..) ) +import GHC.Exts +import GHC.Exts.Heap +import qualified GHC.Exts.Heap.FFIClosures as FFIClosures +import GHC.Word + +import TestUtils + +main :: IO () +main = do + (tso, stack) <- {-# SCC "MyCostCentre" #-} createAndUnpackTSOAndSTACKClosure + assertEqual (getClosureType tso) TSO + assertEqual (what_next tso) ThreadRunGHC + assertEqual (why_blocked tso) NotBlocked + assertEqual (saved_errno tso) 0 + forM_ (flags tso) $ \flag -> case flag of + TsoFlagsUnknownValue _ -> error $ "Unknown flag: " ++ show flag + _ | flag `elem` + [ TsoLocked + , TsoBlockx + , TsoStoppedOnBreakpoint + , TsoSqueezed + ] -> error $ "Unexpected flag: " ++ show flag + _ -> return () + + assertEqual (getClosureType stack) STACK + +#if defined(PROFILING) + let costCentre = ccs_cc <$> (cccs =<< prof tso) + case costCentre of + Nothing -> error $ "No CostCentre found in TSO: " ++ show tso + Just _ -> case findMyCostCentre (linkedCostCentres costCentre) of + Just myCostCentre -> do + assertEqual (cc_label myCostCentre) "MyCostCentre" + assertEqual (cc_module myCostCentre) "Main" + assertEqual (cc_srcloc myCostCentre) (Just "tso_and_stack_closures.hs:23:48-80") + assertEqual (cc_is_caf myCostCentre) False + Nothing -> error $ "MyCostCentre not found in:\n" ++ unlines (cc_label <$> linkedCostCentres costCentre) +#endif + +linkedCostCentres :: Maybe CostCentre -> [CostCentre] +linkedCostCentres Nothing = [] +linkedCostCentres (Just cc) = cc : linkedCostCentres (cc_link cc) + +findMyCostCentre:: [CostCentre] -> Maybe CostCentre +findMyCostCentre ccs = find (\cc -> cc_label cc == "MyCostCentre") ccs + +getClosureType :: GenClosure b -> ClosureType +getClosureType = tipe . info + +type StgTso = Any +type StgStack = Any +data MBA a = MBA (MutableByteArray# a) +data BA = BA ByteArray# + +foreign import ccall safe "create_tso.h create_and_unpack_tso_and_stack" + c_create_and_unpack_tso_and_stack + :: Ptr (Ptr StgTso) + -> Ptr (Ptr StgInfoTable) + -> Ptr CInt + -> Ptr (Ptr Word8) + -> Ptr CInt + -> Ptr (Ptr (Ptr Any)) + -> Ptr (Ptr StgStack) + -> Ptr (Ptr StgInfoTable) + -> Ptr CInt + -> Ptr (Ptr Word8) + -> Ptr CInt + -> Ptr (Ptr (Ptr Any)) + -> IO () + +createAndUnpackTSOAndSTACKClosure + :: IO ( GenClosure (Ptr Any) + , GenClosure (Ptr Any) + ) +createAndUnpackTSOAndSTACKClosure = do + + alloca $ \ptrPtrTso -> do + alloca $ \ptrPtrTsoInfoTable -> do + alloca $ \ptrTsoHeapRepSize -> do + alloca $ \ptrPtrTsoHeapRep -> do + alloca $ \ptrTsoPointersSize -> do + alloca $ \ptrPtrPtrTsoPointers -> do + + alloca $ \ptrPtrStack -> do + alloca $ \ptrPtrStackInfoTable -> do + alloca $ \ptrStackHeapRepSize -> do + alloca $ \ptrPtrStackHeapRep -> do + alloca $ \ptrStackPointersSize -> do + alloca $ \ptrPtrPtrStackPointers -> do + + c_create_and_unpack_tso_and_stack + + ptrPtrTso + ptrPtrTsoInfoTable + ptrTsoHeapRepSize + ptrPtrTsoHeapRep + ptrTsoPointersSize + ptrPtrPtrTsoPointers + + ptrPtrStack + ptrPtrStackInfoTable + ptrStackHeapRepSize + ptrPtrStackHeapRep + ptrStackPointersSize + ptrPtrPtrStackPointers + + let fromHeapRep + ptrPtrClosureInfoTable + ptrClosureHeapRepSize + ptrPtrClosureHeapRep + ptrClosurePointersSize + ptrPtrPtrClosurePointers = do + ptrInfoTable :: Ptr StgInfoTable <- peek ptrPtrClosureInfoTable + + heapRepSize :: Int <- fromIntegral <$> peek ptrClosureHeapRepSize + let I# heapRepSize# = heapRepSize + ptrHeapRep :: Ptr Word8 <- peek ptrPtrClosureHeapRep + MBA mutHeapRepBA <- IO $ \s -> let + (# s', mba# #) = newByteArray# heapRepSize# s + in (# s', MBA mba# #) + forM_ [0..heapRepSize-1] $ \i@(I# i#) -> do + W8# w <- peekElemOff ptrHeapRep i + IO (\s -> (# writeWord8Array# mutHeapRepBA i# w s, () #)) + BA heapRep <- IO $ \s -> let + (# s', ba# #) = unsafeFreezeByteArray# mutHeapRepBA s + in (# s', BA ba# #) + + pointersSize :: Int <- fromIntegral <$> peek ptrClosurePointersSize + ptrPtrPointers :: Ptr (Ptr Any) <- peek ptrPtrPtrClosurePointers + ptrPtrPointers :: [Ptr Any] <- sequence + [ peekElemOff ptrPtrPointers i + | i <- [0..pointersSize-1] + ] + + getClosureDataFromHeapRep + True + heapRep + ptrInfoTable + ptrPtrPointers + + tso <- fromHeapRep + ptrPtrTsoInfoTable + ptrTsoHeapRepSize + ptrPtrTsoHeapRep + ptrTsoPointersSize + ptrPtrPtrTsoPointers + + stack <- fromHeapRep + ptrPtrStackInfoTable + ptrStackHeapRepSize + ptrPtrStackHeapRep + ptrStackPointersSize + ptrPtrPtrStackPointers + + return (tso, stack) ===================================== libraries/ghci/GHCi/Message.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE GADTs, DeriveGeneric, StandaloneDeriving, ScopedTypeVariables, - GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards #-} + GeneralizedNewtypeDeriving, ExistentialQuantification, RecordWildCards, + CPP #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-orphans #-} -- | @@ -29,7 +30,7 @@ import GHCi.TH.Binary () -- For Binary instances import GHCi.BreakArray import GHC.LanguageExtensions -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.ForeignSrcLang import GHC.Fingerprint import Control.Concurrent @@ -110,7 +111,7 @@ data Message a where -> Int -- constr tag -> Int -- pointer tag -> ByteString -- constructor desccription - -> Message (RemotePtr StgInfoTable) + -> Message (RemotePtr Heap.StgInfoTable) -- | Evaluate a statement EvalStmt @@ -211,7 +212,7 @@ data Message a where -- type reconstruction. GetClosure :: HValueRef - -> Message (GenClosure HValueRef) + -> Message (Heap.GenClosure HValueRef) -- | Evaluate something. This is used to support :force in GHCi. Seq @@ -449,10 +450,20 @@ instance Binary (FunPtr a) where get = castPtrToFunPtr <$> get -- Binary instances to support the GetClosure message -instance Binary StgInfoTable -instance Binary ClosureType -instance Binary PrimType -instance Binary a => Binary (GenClosure a) +#if MIN_VERSION_ghc_heap(8,11,0) +instance Binary Heap.StgTSOProfInfo +instance Binary Heap.CostCentreStack +instance Binary Heap.CostCentre +instance Binary Heap.IndexTable +instance Binary Heap.WhatNext +instance Binary Heap.WhyBlocked +instance Binary Heap.TsoFlags +#endif + +instance Binary Heap.StgInfoTable +instance Binary Heap.ClosureType +instance Binary Heap.PrimType +instance Binary a => Binary (Heap.GenClosure a) data Msg = forall a . (Binary a, Show a) => Msg (Message a) ===================================== libraries/ghci/GHCi/Run.hs ===================================== @@ -32,7 +32,7 @@ import Data.Binary.Get import Data.ByteString (ByteString) import qualified Data.ByteString.Unsafe as B import GHC.Exts -import GHC.Exts.Heap +import qualified GHC.Exts.Heap as Heap import GHC.Stack import Foreign hiding (void) import Foreign.C @@ -93,8 +93,8 @@ run m = case m of toRemotePtr <$> mkConInfoTable tc ptrs nptrs tag ptrtag desc StartTH -> startTH GetClosure ref -> do - clos <- getClosureData =<< localRef ref - mapM (\(Box x) -> mkRemoteRef (HValue x)) clos + clos <- Heap.getClosureData =<< localRef ref + mapM (\(Heap.Box x) -> mkRemoteRef (HValue x)) clos Seq ref -> doSeq ref ResumeSeq ref -> resumeSeq ref _other -> error "GHCi.Run.run" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/616060eb6f35a9de4aaf4ab43ba41fa661e3ab27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/616060eb6f35a9de4aaf4ab43ba41fa661e3ab27 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 16 15:43:23 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 16 Oct 2020 11:43:23 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug] 2 commits: Add ghc-debug funcitons to the RTS API Message-ID: <5f89bf9b437dd_28003fd384e54bdc6849c0@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug at Glasgow Haskell Compiler / GHC Commits: efdb4afa by David Eichmann at 2020-10-16T16:43:12+01:00 Add ghc-debug funcitons to the RTS API Four new functions added to RtsAPI.h: * rts_pause and rts_resume allow an external process to completely pause and resume the RTS. * rts_listThreads and rts_listMiscRoots are used to find the current roots of the garbage collector. These changes also mean that `Task.h` is exposed to the user. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 9966df61 by David Eichmann at 2020-10-16T16:43:12+01:00 ghc-heap: expose decoding from heap representation and support partial TSO/STACK decoding Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Runtime/Interpreter.hs - includes/Rts.h - includes/RtsAPI.h - + includes/rts/Task.h - includes/rts/storage/Closures.h - includes/rts/storage/Heap.h - includes/rts/storage/TSO.h - libraries/ghc-heap/GHC/Exts/Heap.hs - libraries/ghc-heap/GHC/Exts/Heap/Closures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures.hs - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingDisabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/PeekProfInfo_ProfilingEnabled.hsc - + libraries/ghc-heap/GHC/Exts/Heap/ProfInfo/Types.hs - libraries/ghc-heap/ghc-heap.cabal.in - + libraries/ghc-heap/tests/TestUtils.hs - libraries/ghc-heap/tests/all.T - + libraries/ghc-heap/tests/create_tso.c - + libraries/ghc-heap/tests/create_tso.h - + libraries/ghc-heap/tests/list_threads_and_misc_roots.hs - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.c - + libraries/ghc-heap/tests/list_threads_and_misc_roots_c.h - + libraries/ghc-heap/tests/parse_tso_flags.hs - + libraries/ghc-heap/tests/tso_and_stack_closures.hs - libraries/ghci/GHCi/Message.hs - libraries/ghci/GHCi/Run.hs - rts/Capability.c - rts/Heap.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/616060eb6f35a9de4aaf4ab43ba41fa661e3ab27...9966df61712b6488d13b366265186a7659dd8237 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/616060eb6f35a9de4aaf4ab43ba41fa661e3ab27...9966df61712b6488d13b366265186a7659dd8237 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 01:20:24 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 16 Oct 2020 21:20:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Skip type family defaults with hs-boot and hsig files Message-ID: <5f8a46d8cee77_2800e9ee8607450ad@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 117f2517 by John Ericson at 2020-10-16T21:20:04-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - c321d57b by Sebastian Graf at 2020-10-16T21:20:05-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 32b13955 by Sebastian Graf at 2020-10-16T21:20:05-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 15c68001 by Sebastian Graf at 2020-10-16T21:20:05-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 8526d4de by Dylan Yudaken at 2020-10-16T21:20:09-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - a07adfc3 by DylanZA at 2020-10-16T21:20:09-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 29948821 by Sylvain Henry at 2020-10-16T21:20:12-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - 29ec47e9 by Hécate at 2020-10-16T21:20:13-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30ee2c129cd80d95600033d60761ccfb600110fe...29ec47e914fe2469bfe5043b3a1b9569e584bf55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30ee2c129cd80d95600033d60761ccfb600110fe...29ec47e914fe2469bfe5043b3a1b9569e584bf55 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 06:50:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 02:50:42 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Skip type family defaults with hs-boot and hsig files Message-ID: <5f8a94429596a_28003fd3ee209cdc770682@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4612f4de by John Ericson at 2020-10-17T02:50:25-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 47429f56 by Sebastian Graf at 2020-10-17T02:50:26-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 8faa24df by Sebastian Graf at 2020-10-17T02:50:26-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 61feeaba by Sebastian Graf at 2020-10-17T02:50:26-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - f36636fd by Dylan Yudaken at 2020-10-17T02:50:30-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 12824eb7 by DylanZA at 2020-10-17T02:50:30-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - c64b474a by Sylvain Henry at 2020-10-17T02:50:34-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - b9920013 by Hécate at 2020-10-17T02:50:34-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/29ec47e914fe2469bfe5043b3a1b9569e584bf55...b992001344889f4080be22ae1aeb6fd28bb5dac8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/29ec47e914fe2469bfe5043b3a1b9569e584bf55...b992001344889f4080be22ae1aeb6fd28bb5dac8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 12:24:05 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sat, 17 Oct 2020 08:24:05 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] 36 commits: Move File Target parser to library #18596 Message-ID: <5f8ae2652e293_28003fd388bcd1a87806df@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - 7809741c by Alan Zimmerman at 2020-10-17T13:21:08+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88e6f7d6de778bfb68ddb8b7c20338dbae926275...7809741cc862325859eda18fc8aba4d82e8cad73 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/88e6f7d6de778bfb68ddb8b7c20338dbae926275...7809741cc862325859eda18fc8aba4d82e8cad73 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 13:11:15 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 09:11:15 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Skip type family defaults with hs-boot and hsig files Message-ID: <5f8aed73e9b8b_2800abfa888798953@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8fe5e26a by John Ericson at 2020-10-17T09:10:59-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 711a9178 by Sebastian Graf at 2020-10-17T09:10:59-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - c01b5e90 by Sebastian Graf at 2020-10-17T09:10:59-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - c9c53255 by Sebastian Graf at 2020-10-17T09:10:59-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 9c893c9d by Dylan Yudaken at 2020-10-17T09:11:03-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - df2661ec by DylanZA at 2020-10-17T09:11:03-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 61e307a5 by Sylvain Henry at 2020-10-17T09:11:07-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - 16e13a7b by Hécate at 2020-10-17T09:11:08-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b992001344889f4080be22ae1aeb6fd28bb5dac8...16e13a7b2d69b40b09264c820b6032e8dce716c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b992001344889f4080be22ae1aeb6fd28bb5dac8...16e13a7b2d69b40b09264c820b6032e8dce716c9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 14:20:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 10:20:37 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: Allow doc-tarball job to fail Message-ID: <5f8afdb556522_28003fd3dd5c569880971@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -981,6 +981,8 @@ release-x86_64-windows-integer-simple: doc-tarball: stage: packaging needs: [validate-x86_64-linux-deb9-debug, validate-x86_64-windows-hadrian, validate-x86_64-linux-deb9-unreg-hadrian] + # N.B. Documentation isn't correctly packaged in Hadrian bindists + allow_newer: true tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aca0e63bce4b29ac6e0cd06dbd169b0c06b53e25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aca0e63bce4b29ac6e0cd06dbd169b0c06b53e25 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 15:07:26 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 17 Oct 2020 11:07:26 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f8b08aef0d5c_28003fd3ee2eeb98812690@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 037ced55 by Ryan Scott at 2020-10-17T11:06:55-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Adding a third type parameter to `HsConDeclDetails` to represent the types in an `InfixCon`, separate from the type parameters for `PrefixCon` and `RecCon`, and * Creating `HsConDeclH98Details` and `HsConDeclGADTDetails` synonyms on top of the new `HsConDeclDetails`, which instantiate the `inf` type parameter to `HsScaled pass (LBangType pass)` and `Void`, respectively. Using `Void` allows functions that consume `HsConDeclGADTDetails` to simply call `absurd` instead of having to, say, `panic`. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{,H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon`. This is still possible since `RecCon`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. TODO: Say the magic words about T18844. Bumps the `haddock` submodule. [ci skip] (TODO: Remove this) - - - - - 18 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - utils/haddock Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -1227,7 +1227,10 @@ pprMinimalSig (L _ bf) = ppr (fmap unLoc bf) -} -- | Haskell Pattern Synonym Details -type HsPatSynDetails pass = HsConDetails (LIdP pass) [RecordPatSynField (LIdP pass)] +type HsPatSynDetails pass + = HsConDetails (LIdP pass) + [RecordPatSynField (LIdP pass)] + (LIdP pass) -- See Note [Record PatSyn Fields] -- | Record Pattern Synonym Field ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,9 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclDetails, HsConDeclH98Details, HsConDeclGADTDetails, + hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -126,6 +127,7 @@ import GHC.Core.Type import GHC.Data.Bag import GHC.Data.Maybe import Data.Data hiding (TyCon,Fixity, Infix) +import Data.Void {- ************************************************************************ @@ -1473,9 +1475,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1494,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1625,39 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass - = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a data constructor declaration. The @inf@ type parameter +-- represents the representation for infix data constructors, which is +-- different depending on whether the data constructor is Haskell98-style or +-- GADT-style. +type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + +-- | The arguments in a Haskell98 data constructor, which can be infix. +type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + +-- | The arguments in a GADT constructor, which cannot be infix. +type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon v _ -> absurd v hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,7 +1737,7 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -316,7 +316,7 @@ type instance ConLikeP GhcTc = ConLike -- | Haskell Constructor Pattern Details -type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) +type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) (LPat p) hsConPatArgs :: HsConPatDetails p -> [LPat p] hsConPatArgs (PrefixCon ps) = ps @@ -866,7 +866,7 @@ patNeedsParens p = go -- | @'conPatNeedsParens' p cp@ returns 'True' if the constructor patterns @cp@ -- needs parentheses under precedence @p at . -conPatNeedsParens :: PprPrec -> HsConDetails a b -> Bool +conPatNeedsParens :: PprPrec -> HsConDetails a b c -> Bool conPatNeedsParens p = go where go (PrefixCon args) = p >= appPrec && not (null args) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1101,14 +1101,14 @@ instance OutputableBndrId p -- HsConDetails is used for patterns/expressions *and* for data type -- declarations -- | Haskell Constructor Details -data HsConDetails arg rec +data HsConDetails arg rec inf = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } - | InfixCon arg arg -- p1 `C` p2 + | InfixCon inf inf -- p1 `C` p2 deriving Data -instance (Outputable arg, Outputable rec) - => Outputable (HsConDetails arg rec) where +instance (Outputable arg, Outputable rec, Outputable inf) + => Outputable (HsConDetails arg rec inf) where ppr (PrefixCon args) = text "PrefixCon" <+> ppr args ppr (RecCon rec) = text "RecCon:" <+> ppr rec ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1255,7 +1255,7 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where (remSeen', flds) = get_flds remSeen args @@ -1267,7 +1267,7 @@ hsConDeclsBinders cons (remSeen', flds) = get_flds remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds :: Seen p -> HsConDeclDetails (GhcPass p) inf -> (Seen p, [LFieldOcc (GhcPass p)]) get_flds remSeen (RecCon flds) = (remSeen', fld_names) ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -31,6 +31,7 @@ import Data.Map (Map) import qualified Data.Map as M import Data.Maybe import Data.Semigroup +import Data.Void -- | Extract docs from renamer output. extractDocs :: TcGblEnv @@ -189,7 +190,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +217,31 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + InfixCon v _ -> absurd v + RecCon _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -85,6 +85,7 @@ import Data.ByteString ( unpack ) import Control.Monad import Data.List import Data.Function +import Data.Void data MetaWrappers = MetaWrappers { -- Applies its argument to a type argument `m` and dictionary `Quote m` @@ -869,7 +870,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +878,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +890,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2582,52 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + InfixCon v _ -> absurd v + RecCon ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a PrefixCon. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a RecCon. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2636,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -68,6 +68,7 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Data ( Data, Typeable ) import Data.List ( foldl1' ) +import Data.Void import Control.Monad ( forM_ ) import Control.Monad.Trans.State.Strict import Control.Monad.Trans.Reader @@ -578,6 +579,9 @@ class ToHie a where class HasType a where getTypeNode :: a -> HieM [HieAST Type] +instance ToHie Void where + toHie = absurd + instance (ToHie a) => ToHie [a] where toHie = concatMapM toHie @@ -996,8 +1000,10 @@ instance HiePass p => ToHie (PScoped (Located (Pat (GhcPass p)))) where HieRn -> [] #endif where - contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) - -> HsConDetails (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a))) + contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) a + -> HsConDetails (PScoped a) + (RContext (HsRecFields (GhcPass p) (PScoped a))) + (PScoped a) contextify (PrefixCon args) = PrefixCon $ patScopes rsp scope pscope args contextify (InfixCon a b) = InfixCon a' b' where [a', b'] = patScopes rsp scope pscope [a,b] @@ -1314,7 +1320,7 @@ instance HiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p))) where , toHie $ PS Nothing sc NoScope pat ] -instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where +instance (ToHie arg, ToHie rec, ToHie inf) => ToHie (HsConDetails arg rec inf) where toHie (PrefixCon args) = toHie args toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] @@ -1530,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1545,6 +1551,12 @@ instance ToHie (Located (ConDecl GhcRn)) where tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars + + condecl_scope :: HsConDeclGADTDetails (GhcPass p) -> Scope + condecl_scope args = case args of + PrefixCon xs -> scaled_args_scope xs + InfixCon v _ -> absurd v + RecCon x -> mkLScope x ConDeclH98 { con_name = name, con_ex_tvs = qvars , con_mb_cxt = ctx, con_args = dets } -> [ toHie $ C (Decl ConDec $ getRealSpan span) name @@ -1556,12 +1568,14 @@ instance ToHie (Located (ConDecl GhcRn)) where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope + condecl_scope :: HsConDeclH98Details (GhcPass p) -> Scope condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled (GhcPass p) (LHsType (GhcPass p))] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) + instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -643,7 +643,7 @@ mkGadtDecl names ty = do , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -69,6 +69,7 @@ import Control.Monad.Trans.Writer import Data.Functor.Identity import Data.Coerce import qualified Data.Monoid +import Data.Void import GHC.Parser.Lexer import GHC.Parser.Errors @@ -690,22 +691,22 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of + con_g_args' <- + case con_g_args of PrefixCon ts -> PrefixCon <$> addHaddock ts RecCon (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + InfixCon v _ -> absurd v con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -67,6 +67,7 @@ import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt import Data.List ( nubBy, partition ) +import Data.Void import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -1747,9 +1748,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1785,16 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixCon args -> extract_scaled_ltys args + InfixCon v _ -> absurd v + RecCon (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1804,6 +1812,14 @@ extract_lctxt ctxt = extract_ltys (unLoc ctxt) extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_lty :: LHsType GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lty (L _ ty) acc = case ty of ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -75,6 +75,7 @@ import Data.List.NonEmpty ( NonEmpty(..) ) import Data.Maybe ( isNothing, isJust, fromMaybe, mapMaybe ) import qualified Data.Set as Set ( difference, fromList, toList, null ) import Data.Function ( on ) +import Data.Void {- | @rnSourceDecl@ "renames" declarations. It simultaneously performs dependency analysis and precedence parsing. @@ -2180,7 +2181,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2198,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2211,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2221,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2236,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,22 +2247,36 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name + -> HsDocContext + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details = rnConDeclDetails rnScaledLHsType + +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails = rnConDeclDetails (\_ -> absurd) + +rnConDeclDetails :: + (HsDocContext -> infPs -> RnM (infRn, FreeVars)) + -> Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclDetails GhcPs infPs + -> RnM (HsConDeclDetails GhcRn infRn, FreeVars) +rnConDeclDetails _ _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } -rnConDeclDetails _ doc (InfixCon ty1 ty2) - = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 - ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 +rnConDeclDetails rnInf _ doc (InfixCon ty1 ty2) + = do { (new_ty1, fvs1) <- rnInf doc ty1 + ; (new_ty2, fvs2) <- rnInf doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclDetails _ con doc (RecCon (L l fields)) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecCon flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -81,12 +81,14 @@ import GHC.Types.Basic import qualified GHC.LanguageExtensions as LangExt import Control.Monad +import Data.Foldable import Data.Function ( on ) import Data.Functor.Identity import Data.List import Data.List.NonEmpty ( NonEmpty(..) ) import qualified Data.Set as Set import Data.Tuple( swap ) +import Data.Void {- ************************************************************************ @@ -1563,18 +1565,33 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the type of an argument to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need --- the first two arguments. -kcConArgTys :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () -kcConArgTys new_or_data res_kind arg_tys = do - { let exp_kind = getArgExpKind new_or_data res_kind - ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind - tcMult mult) - +-- the ContextKind argument. +kcConArg :: ContextKind -> HsScaled GhcRn (LHsType GhcRn) -> TcM () +kcConArg exp_kind (HsScaled mult ty) = do + _ <- tcCheckLHsType (getBangType ty) exp_kind + _ <- tcMult mult + pure () -- See Note [Implementation of UnliftedNewtypes], STEP 2 - } + +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: ContextKind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args = kcConArgs kcConArg + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: ContextKind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs = kcConArgs (\_ -> absurd) + +-- Kind-check the types of argument to a data constructor. +kcConArgs :: (ContextKind -> infRn -> TcM ()) + -> ContextKind -> HsConDeclDetails GhcRn infRn -> TcM () +kcConArgs kc_inf exp_kind con_args = case con_args of + PrefixCon tys -> traverse_ (kcConArg exp_kind) tys + InfixCon ty1 ty2 -> traverse_ (kc_inf exp_kind) [ty1, ty2] + RecCon (L _ flds) -> traverse_ (kcConArg exp_kind) $ + map (hsLinear . cd_fld_type . unLoc) flds kcConDecls :: NewOrData -> Kind -- The result kind signature @@ -1604,14 +1621,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args (getArgExpKind new_or_data res_kind) args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1642,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs (getArgExpKind new_or_data res_kind) args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3213,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3283,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3300,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,19 +3379,20 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of InfixCon {} -> return True - _ -> return False + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True + InfixCon v _ -> absurd v RecCon {} -> return False PrefixCon arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) @@ -3383,18 +3401,31 @@ tcConIsInfixGADT con details ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args = tcConArgs tcConArg + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs = tcConArgs (\_ -> absurd) + +tcConArgs :: (ContextKind -> infRn -> TcM (Scaled TcType, HsSrcBang)) + -> ContextKind -- expected kind of arguments -- always OpenKind for datatypes, but unlifted newtypes -- might have a specific kind - -> HsConDeclDetails GhcRn + -> HsConDeclDetails GhcRn infRn -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConArgs _ exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) - = do { bty1' <- tcConArg exp_kind bty1 - ; bty2' <- tcConArg exp_kind bty2 - ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConArgs tc_inf exp_kind (InfixCon bty1 bty2) + = mapM (tc_inf exp_kind) [bty1, bty2] +tcConArgs _ exp_kind (RecCon fields) = mapM (tcConArg exp_kind) btys where -- We need a one-to-one mapping from field_names to btys ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -630,7 +630,7 @@ cvtConstr (RecGadtC c varstrtys ty) ; rec_flds <- mapM cvt_id_arg varstrtys ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -638,7 +638,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -37,14 +37,63 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon + , ... + } + + Where: :: + + -- New type synonym introduced in GHC 9.2; equivalent to `HsConDeclDetails` + -- in previous versions of GHC + type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + + -- New type synonym introduced in GHC 9.2 + type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + + -- The `inf` type parameter is new in GHC 9.2 + type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + + -- The `inf` type parameter is new in GHC 9.2 + data HsConDetails arg rec inf + = PrefixCon [arg] -- C p1 p2 p3 + | RecCon rec -- C { x = p1, y = p2 } + | InfixCon inf inf -- p1 `C` p2 + + The use of ``Void`` in ``HsConDeclGADTDetails`` reflects the fact that GADT + constructors cannot use infix syntax like Haskell98-style constructors can. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit e55b11af180271e4fdc3a548857342e182deec5c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/037ced558dc32302972b8ca8e06aac0a90851528 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/037ced558dc32302972b8ca8e06aac0a90851528 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 17:26:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 13:26:29 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: s/allow_newer/allow_failure Message-ID: <5f8b2945dccc5_28003fd41a5da7f48186cf@gitlab.haskell.org.mail> Ben Gamari pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -982,7 +982,7 @@ doc-tarball: stage: packaging needs: [validate-x86_64-linux-deb9-debug, validate-x86_64-windows-hadrian, validate-x86_64-linux-deb9-unreg-hadrian] # N.B. Documentation isn't correctly packaged in Hadrian bindists - allow_newer: true + allow_failure: true tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b02a9ea79dddd98f6bbb42e1652d7ea38db7d55e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b02a9ea79dddd98f6bbb42e1652d7ea38db7d55e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 17:35:02 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Sat, 17 Oct 2020 13:35:02 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-8.10 Message-ID: <5f8b2b46e99b_28003fd402815a40821229@gitlab.haskell.org.mail> Krzysztof Gogolewski deleted branch wip/backports-8.10 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 17:35:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 13:35:04 -0400 Subject: [Git][ghc/ghc][ghc-8.10] 10 commits: typecheck: Drop SPECIALISE pragmas when there is no unfolding Message-ID: <5f8b2b489a6a_28003fd402815a408214fe@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: da1b5345 by Ben Gamari at 2020-10-16T01:10:54+02:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. (cherry picked from commit 708e374a8bf108999c11b6cf59c7d27677ed24a8) - - - - - f3bc882d by Ben Gamari at 2020-10-16T01:13:02+02:00 testsuite: Add test for #18118 (cherry picked from commit 2cdb72a569f6049a390626bca0dd6e362045ed65) Conflicts: testsuite/tests/typecheck/should_compile/all.T - - - - - 7e6c6340 by Moritz Angermann at 2020-10-16T01:14:57+02:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 (cherry picked from commit 6189cc04ca6c3d79126744e988b487f75ccef9e2) - - - - - 1ac0a2aa by Ben Gamari at 2020-10-16T01:16:06+02:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. (cherry picked from commit ea1cbb8f2ac9e077ed19530911c3a35c5f46ee8a) - - - - - 1fdadd41 by Ben Gamari at 2020-10-16T01:16:38+02:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. (cherry picked from commit ce42e187ebfc81174ed477f247f023ae094c9b24) - - - - - ec6b31f0 by Ben Gamari at 2020-10-16T01:17:08+02:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. (cherry picked from commit 0799b3de3e3462224bddc0e4b6a3156d04a06361) - - - - - 7367ae91 by Ben Gamari at 2020-10-16T01:17:33+02:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. (cherry picked from commit 057db94ce038970b14df1599fe83097c284b9c1f) - - - - - 5b5dde18 by Benjamin Maurer at 2020-10-16T01:19:50+02:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. (cherry picked from commit 74c797f6b72c4d01f5e0092dfac1461f3f3dd7a2) - - - - - 8cb4fe24 by Krzysztof Gogolewski at 2020-10-16T01:20:55+02:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. (cherry picked from commit 587c3c514f05f97082952d613695f1186ff3174e) - - - - - 5a4d0c3d by Krzysztof Gogolewski at 2020-10-16T01:21:41+02:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. (cherry picked from commit fd302e938ebf48c73d9f715d67ce8cd990f972ff) - - - - - 13 changed files: - compiler/main/DynFlags.hs - compiler/typecheck/TcSigs.hs - docs/users_guide/phases.rst - rts/RtsMessages.c - rts/RtsSymbols.c - rts/STM.c - rts/linker/Elf.c - rts/posix/GetTime.c - rts/posix/OSMem.c - + testsuite/tests/rts/T18623/all.T - + testsuite/tests/typecheck/should_compile/T18118.hs - + testsuite/tests/typecheck/should_compile/T18118A.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/main/DynFlags.hs ===================================== @@ -3064,6 +3064,8 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lo = (f,[]) } , make_ord_flag defFlag "pgmlc" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lc = (f,[]) } + , make_ord_flag defFlag "pgmlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_lm = (f,[]) } , make_ord_flag defFlag "pgmi" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_i = f } , make_ord_flag defFlag "pgmL" @@ -3079,6 +3081,8 @@ dynamic_flags_deps = [ -- (see #15319) toolSettings_ccSupportsNoPie = False } + , make_ord_flag defFlag "pgmc-supports-no-pie" + $ noArg $ alterToolSettings $ \s -> s { toolSettings_ccSupportsNoPie = True } , make_ord_flag defFlag "pgms" (HasArg (\_ -> addWarn "Object splitting was removed in GHC 8.8")) , make_ord_flag defFlag "pgma" @@ -3102,6 +3106,8 @@ dynamic_flags_deps = [ -- need to appear before -optl/-opta to be parsed as LLVM flags. + , make_ord_flag defFlag "optlm" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lm = f : toolSettings_opt_lm s } , make_ord_flag defFlag "optlo" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_opt_lo = f : toolSettings_opt_lo s } , make_ord_flag defFlag "optlc" ===================================== compiler/typecheck/TcSigs.hs ===================================== @@ -818,9 +818,13 @@ tcImpPrags prags tcImpSpec :: (Name, Sig GhcRn) -> TcM [TcSpecPrag] tcImpSpec (name, prag) = do { id <- tcLookupId name - ; unless (isAnyInlinePragma (idInlinePragma id)) - (addWarnTc NoReason (impSpecErr name)) - ; tcSpecPrag id prag } + ; if isAnyInlinePragma (idInlinePragma id) + then tcSpecPrag id prag + else do { addWarnTc NoReason (impSpecErr name) + ; return [] } } + -- If there is no INLINE/INLINABLE pragma there will be no unfolding. In + -- that case, just delete the SPECIALISE pragma altogether, lest the + -- desugarer fall over because it can't find the unfolding. See #18118. impSpecErr :: Name -> SDoc impSpecErr name ===================================== docs/users_guide/phases.rst ===================================== @@ -180,6 +180,20 @@ the following flags: Pass ⟨option⟩ to the C compiler. +.. ghc-flag:: -pgmc-supports-no-pie + :shortdesc: Indicate that the C compiler supports ``-no-pie`` + :type: dynamic + :category: phase-options + + When ``-pgmc`` is used, GHC by default will never pass the ``-no-pie`` + command line flag. The rationale is that it is not known whether the + specified compiler will support it. This flag can be used to indicate + that ``-no-pie`` is supported. It has to be passed after ``-pgmc``. + + This flag is not neccessary when ``-pgmc`` is not used, since GHC + remembers whether the default C compiler supports ``-no-pie`` in + an internal settings file. + .. ghc-flag:: -optcxx ⟨option⟩ :shortdesc: pass ⟨option⟩ to the C++ compiler :type: dynamic ===================================== rts/RtsMessages.c ===================================== @@ -248,7 +248,7 @@ rtsSysErrorMsgFn(const char *s, va_list ap) r = vsnprintf(buf, BUFSIZE, s, ap); if (r > 0 && r < BUFSIZE) { - r = vsnprintf(buf+r, BUFSIZE-r, ": %s", syserr); + r = snprintf(buf+r, BUFSIZE-r, ": %s", syserr); MessageBox(NULL /* hWnd */, buf, prog_name, ===================================== rts/RtsSymbols.c ===================================== @@ -700,6 +700,7 @@ SymI_HasProto(stg_copySmallArrayzh) \ SymI_HasProto(stg_copySmallMutableArrayzh) \ SymI_HasProto(stg_casSmallArrayzh) \ + SymI_HasProto(stg_copyArray_barrier) \ SymI_HasProto(stg_newBCOzh) \ SymI_HasProto(stg_newByteArrayzh) \ SymI_HasProto(stg_casIntArrayzh) \ ===================================== rts/STM.c ===================================== @@ -1342,6 +1342,9 @@ void stmWriteTVar(Capability *cap, if (entry != NULL) { if (entry_in == trec) { // Entry found in our trec + IF_NONMOVING_WRITE_BARRIER_ENABLED { + updateRemembSetPushClosure(cap, (StgClosure *) entry->new_value); + } entry -> new_value = new_value; } else { // Entry found in another trec ===================================== rts/linker/Elf.c ===================================== @@ -903,8 +903,9 @@ ocGetNames_ELF ( ObjectCode* oc ) common_used += symbol->elf_sym->st_size; ASSERT(common_used <= common_size); - debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", - symbol->elf_sym->st_size, nm, symbol->addr); + IF_DEBUG(linker, + debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", + symbol->elf_sym->st_size, nm, symbol->addr)); /* Pointless to do addProddableBlock() for this area, since the linker should never poke around in it. */ ===================================== rts/posix/GetTime.c ===================================== @@ -71,7 +71,7 @@ Time getCurrentThreadCPUTime(void) // support clock_getcpuclockid. Hence we prefer to use the Darwin-specific // path on Darwin, even if clock_gettime is available. #if defined(darwin_HOST_OS) - thread_basic_info_data_t info = { 0 }; + thread_basic_info_data_t info = { }; mach_msg_type_number_t info_count = THREAD_BASIC_INFO_COUNT; kern_return_t kern_err = thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t) &info, &info_count); ===================================== rts/posix/OSMem.c ===================================== @@ -39,6 +39,7 @@ #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) #include #include +#include #endif #include @@ -545,13 +546,57 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len) } #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SYS_TIME_H) - struct rlimit limit; + struct rlimit asLimit; /* rlim_t is signed on some platforms, including FreeBSD; * explicitly cast to avoid sign compare error */ - if (!getrlimit(RLIMIT_AS, &limit) - && limit.rlim_cur > 0 - && *len > (W_) limit.rlim_cur) { - *len = (W_) limit.rlim_cur; + if (!getrlimit(RLIMIT_AS, &asLimit) + && asLimit.rlim_cur > 0 + && *len > (W_) asLimit.rlim_cur) { + + /* In case address space/virtual memory was limited by rlimit (ulimit), + we try to reserver 2/3 of that limit. If we take all, there'll be + nothing left for spawning system threads etc. and we'll crash + (See #18623) + */ + + pthread_attr_t threadAttr; + if (pthread_attr_init(&threadAttr)) { + // Never fails on Linux + sysErrorBelch("failed to initialize thread attributes"); + stg_exit(EXIT_FAILURE); + } + + size_t stacksz = 0; + if (pthread_attr_getstacksize(&threadAttr, &stacksz)) { + // Should never fail + sysErrorBelch("failed to read default thread stack size"); + stg_exit(EXIT_FAILURE); + } + + // Cleanup + if (pthread_attr_destroy(&threadAttr)) { + // Should never fail + sysErrorBelch("failed to destroy thread attributes"); + stg_exit(EXIT_FAILURE); + } + + size_t pageSize = getPageSize(); + // 2/3rds of limit, round down to multiple of PAGE_SIZE + *len = (W_) (asLimit.rlim_cur * 0.666) & ~(pageSize - 1); + + // debugBelch("New len: %zu, pageSize: %zu\n", *len, pageSize); + + /* Make sure we leave enough vmem for at least three threads. + This number was found through trial and error. We're at least launching + that many threads (e.g., itimer). We can't know for sure how much we need, + but at least we can fail early and give a useful error message in this case. */ + if (((W_) (asLimit.rlim_cur - *len )) < ((W_) (stacksz * 3))) { + // Three stacks is 1/3 of needed, then convert to Megabyte + size_t needed = (stacksz * 3 * 3) / (1024 * 1024); + errorBelch("the current resource limit for virtual memory ('ulimit -v' or RLIMIT_AS) is too low.\n" + "Please make sure that at least %zuMiB of virtual memory are available.", needed); + stg_exit(EXIT_FAILURE); + } } #endif @@ -577,9 +622,11 @@ void *osReserveHeapMemory(void *startAddressPtr, W_ *len) // of memory will be wasted (e.g. imagine a machine with 512GB of // physical memory but a 511GB ulimit). See #14492. *len -= *len / 8; + // debugBelch("Limit hit, reduced len: %zu\n", *len); } else if ((W_)at >= minimumAddress) { // Success! We were given a block of memory starting above the 8 GB // mark, which is what we were looking for. + break; } else { // We got addressing space but it wasn't above the 8GB mark. ===================================== testsuite/tests/rts/T18623/all.T ===================================== @@ -0,0 +1,6 @@ +# Starting GHC on *nix with vmem limit, RTS will reserve all available memory +# and crash when creating a thread. Fix reserves only 2/3rds of vmem_limit. +test('T18623', + [when(opsys('mingw32'), skip), cmd_prefix('ulimit -v ' + str(1024 ** 2) + ' && '), ignore_stdout], + run_command, + ['{compiler} --version']) \ No newline at end of file ===================================== testsuite/tests/typecheck/should_compile/T18118.hs ===================================== @@ -0,0 +1,5 @@ +module T18118 (myfun) where + +import T18118A + +{-# SPECIALISE myfun :: Double #-} ===================================== testsuite/tests/typecheck/should_compile/T18118A.hs ===================================== @@ -0,0 +1,5 @@ +module T18118A where + +myfun :: a +myfun = undefined + ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -696,3 +696,4 @@ test('T17343', exit_code(1), compile_and_run, ['']) test('T17792', normal, compile, ['']) test('T18185', normal, compile, ['']) test('T17566', [extra_files(['T17566a.hs'])], makefile_test, []) +test('T18118', normal, multimod_compile, ['T18118', '-v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43f970499d053098d1928ce3921176192ec07d7a...5a4d0c3dcd2d83744293ea82a7e5606ad2038109 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43f970499d053098d1928ce3921176192ec07d7a...5a4d0c3dcd2d83744293ea82a7e5606ad2038109 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 17:38:38 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sat, 17 Oct 2020 13:38:38 -0400 Subject: [Git][ghc/ghc][wip/warn-operator-whitespace] 4 commits: Clarify Eq documentation #18713 Message-ID: <5f8b2c1e2a398_28003fd3ec59be4c82167d@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/warn-operator-whitespace at Glasgow Haskell Compiler / GHC Commits: 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 02f5b644 by Vladislav Zavialov at 2020-10-17T13:38:35-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 20 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - libraries/ghc-prim/GHC/Classes.hs - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== .gitlab-ci.yml ===================================== @@ -981,6 +981,8 @@ release-x86_64-windows-integer-simple: doc-tarball: stage: packaging needs: [validate-x86_64-linux-deb9-debug, validate-x86_64-windows-hadrian, validate-x86_64-linux-deb9-unreg-hadrian] + # N.B. Documentation isn't correctly packaged in Hadrian bindists + allow_failure: true tags: - x86_64-linux image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV" ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -501,6 +501,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3330,7 +3330,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4087,7 +4089,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnInaccessibleCode, Opt_WarnSpaceAfterBang, Opt_WarnNonCanonicalMonadInstances, - Opt_WarnNonCanonicalMonoidInstances + Opt_WarnNonCanonicalMonoidInstances, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,34 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax" + $$ nest 2 (text "by a future language extension.") + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1853,6 +1854,7 @@ of ``-W(no-)*``. .. ghc-flag:: -Winvalid-haddock :shortdesc: warn when a Haddock comment occurs in an invalid position :type: dynamic + :reverse: -Wno-invalid-haddock :category: :since: 9.0 @@ -1869,6 +1871,56 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :reverse: -Wno-operator-whitespace-ext-conflict + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :reverse: -Wno-operator-whitespace + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== libraries/ghc-prim/GHC/Classes.hs ===================================== @@ -125,18 +125,13 @@ and @('>=')@ for the types in "GHC.Word" and "GHC.Int". -- and 'Eq' may be derived for any datatype whose constituents are also -- instances of 'Eq'. -- --- The Haskell Report defines no laws for 'Eq'. However, '==' is customarily --- expected to implement an equivalence relationship where two values comparing --- equal are indistinguishable by "public" functions, with a "public" function --- being one not allowing to see implementation details. For example, for a --- type representing non-normalised natural numbers modulo 100, a "public" --- function doesn't make the difference between 1 and 201. It is expected to --- have the following properties: +-- The Haskell Report defines no laws for 'Eq'. However, instances are +-- encouraged to follow these properties: -- -- [__Reflexivity__]: @x == x@ = 'True' -- [__Symmetry__]: @x == y@ = @y == x@ -- [__Transitivity__]: if @x == y && y == z@ = 'True', then @x == z@ = 'True' --- [__Substitutivity__]: if @x == y@ = 'True' and @f@ is a "public" function +-- [__Extensionality__]: if @x == y@ = 'True' and @f@ is a function -- whose return type is an instance of 'Eq', then @f x == f y@ = 'True' -- [__Negation__]: @x /= y@ = @not (x == y)@ -- @@ -234,7 +229,7 @@ eqChar, neChar :: Char -> Char -> Bool -- >>> 0/0 == (0/0 :: Float) -- False -- --- Also note that `Float`'s 'Eq' instance does not satisfy substitutivity: +-- Also note that `Float`'s 'Eq' instance does not satisfy extensionality: -- -- >>> 0 == (-0 :: Float) -- True ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e91aec18c2b658dd747fa61f5fd398f13a31e484...02f5b644d89eaf7b356eb6728200f948dfb32f1b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e91aec18c2b658dd747fa61f5fd398f13a31e484...02f5b644d89eaf7b356eb6728200f948dfb32f1b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 19:01:37 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 15:01:37 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: gitlab-ci: Allow doc-tarball job to fail Message-ID: <5f8b3f9133da7_28003fd3eca496388368c4@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 57fe48e0 by John Ericson at 2020-10-17T15:01:22-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 06659d46 by Sebastian Graf at 2020-10-17T15:01:22-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 612c37d3 by Sebastian Graf at 2020-10-17T15:01:22-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 7a41407e by Sebastian Graf at 2020-10-17T15:01:22-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 88a3ade3 by Dylan Yudaken at 2020-10-17T15:01:25-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 54fa9ab8 by DylanZA at 2020-10-17T15:01:25-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 070840fa by Sylvain Henry at 2020-10-17T15:01:29-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - 9a9e2273 by Hécate at 2020-10-17T15:01:30-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16e13a7b2d69b40b09264c820b6032e8dce716c9...9a9e2273860219501efc9423233d5eab5b49439b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16e13a7b2d69b40b09264c820b6032e8dce716c9...9a9e2273860219501efc9423233d5eab5b49439b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 19:22:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 15:22:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18857 Message-ID: <5f8b448bb80a7_28003fd3ee2277c8847986@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T18857 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18857 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 19:28:00 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 15:28:00 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T17945 Message-ID: <5f8b45c0836ba_28003fd3ee81ce308508df@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T17945 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T17945 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 20:06:43 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 17 Oct 2020 16:06:43 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/clean-ghc-tarballs Message-ID: <5f8b4ed3eb3b8_28003fd3edd277508667d9@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/clean-ghc-tarballs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/clean-ghc-tarballs You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 17 20:41:49 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sat, 17 Oct 2020 16:41:49 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f8b570d57898_28003fd3ec55ffc887676e@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: 2c0c88f1 by Alan Zimmerman at 2020-10-17T21:15:24+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -931,22 +931,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -961,20 +962,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1959,10 +1963,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -980,10 +980,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -624,11 +624,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -721,10 +721,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1847,7 +1847,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2453,7 +2453,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -1683,7 +1683,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1751,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 2fa32841b63dfae5e5faa764de9dd6929af646c7 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c0c88f14d653ce0a607b42911759761cd695fe8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2c0c88f14d653ce0a607b42911759761cd695fe8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 02:01:46 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 22:01:46 -0400 Subject: [Git][ghc/ghc][master] Skip type family defaults with hs-boot and hsig files Message-ID: <5f8ba20a8b6e9_2800d00087c8874d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 17 changed files: - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - testsuite/tests/backpack/should_compile/all.T - + testsuite/tests/backpack/should_compile/bkp57.bkp - + testsuite/tests/backpack/should_compile/bkp57.stderr - + testsuite/tests/backpack/should_compile/bkp58.bkp - + testsuite/tests/backpack/should_compile/bkp58.stderr - + testsuite/tests/backpack/should_compile/bkp59.bkp - + testsuite/tests/backpack/should_compile/bkp59.stderr - + testsuite/tests/backpack/should_compile/bkp60.bkp - + testsuite/tests/backpack/should_compile/bkp60.stderr - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBoot.hs - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA1.hs - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA2.hs - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA2.hs-boot - + testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA3.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Tc/TyCl/Class.hs ===================================== @@ -550,8 +550,10 @@ warnMissingAT name = do { warn <- woptM Opt_WarnMissingMethods ; traceTc "warn" (ppr name <+> ppr warn) ; hsc_src <- fmap tcg_src getGblEnv - -- Warn only if -Wmissing-methods AND not a signature - ; warnTc (Reason Opt_WarnMissingMethods) (warn && hsc_src /= HsigFile) + -- hs-boot and signatures never need to provide complete "definitions" + -- of any sort, as they aren't really defining anything, but just + -- constraining items which are defined elsewhere. + ; warnTc (Reason Opt_WarnMissingMethods) (warn && hsc_src == HsSrcFile) (text "No explicit" <+> text "associated type" <+> text "or default declaration for" <+> quotes (ppr name)) } ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -512,9 +512,18 @@ tcClsInstDecl (L loc (ClsInstDecl { cid_poly_ty = hs_ty, cid_binds = binds -- Check for missing associated types and build them -- from their defaults (if available) + ; is_boot <- tcIsHsBootOrSig + ; let atItems = classATItems clas ; tf_insts2 <- mapM (tcATDefault loc mini_subst defined_ats) - (classATItems clas) - + (if is_boot then [] else atItems) + -- Don't default type family instances, but rather omit, in hsig/hs-boot. + -- Since hsig/hs-boot files are essentially large binders we want omission + -- of the definition to result in no restriction, rather than for example + -- attempting to "pattern match" with the invisible defaults and generate + -- equalities. Without further handling, this would just result in a panic + -- anyway. + -- See https://github.com/ghc-proposals/ghc-proposals/pull/320 for + -- additional discussion. ; return (df_stuff, tf_insts1 ++ concat tf_insts2) } @@ -539,8 +548,8 @@ tcClsInstDecl (L loc (ClsInstDecl { cid_poly_ty = hs_ty, cid_binds = binds all_insts = tyfam_insts ++ datafam_insts -- In hs-boot files there should be no bindings - ; is_boot <- tcIsHsBootOrSig ; let no_binds = isEmptyLHsBinds binds && null uprags + ; is_boot <- tcIsHsBootOrSig ; failIfTc (is_boot && not no_binds) badBootDeclErr ; return ( [inst_info], all_insts, deriv_infos ) } ===================================== testsuite/tests/backpack/should_compile/all.T ===================================== @@ -48,6 +48,10 @@ test('bkp53', normal, backpack_compile, ['']) test('bkp54', normal, backpack_compile, ['']) test('bkp55', normal, backpack_compile, ['']) test('bkp56', normal, backpack_compile, ['']) +test('bkp57', normal, backpack_compile, ['']) +test('bkp58', normal, backpack_compile, ['']) +test('bkp59', normal, backpack_compile, ['']) +test('bkp60', normal, backpack_compile, ['']) test('T13140', normal, backpack_compile, ['']) test('T13149', expect_broken(13149), backpack_compile, ['']) ===================================== testsuite/tests/backpack/should_compile/bkp57.bkp ===================================== @@ -0,0 +1,37 @@ +-- no default method, backpack +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeApplications #-} +unit common where + module Class where + class Show (T x) => C x where + type T x + def :: T x + --type T x = () +unit consumer-abs where + dependency common + signature Instance where + import Class + data I = I Int + instance C I where + --type T I = () + module Downstream where + import Class + import Instance + asdf :: C I => String + asdf = show $ def @I +unit consumer-impl where + dependency common + module Impl where + import Class + data I = I Int + instance C I where + type T I = () + def = () +unit tie where + dependency consumer-impl + dependency consumer-abs[Instance=consumer-impl:Impl] + module Tie where + import Downstream + main = print asdf ===================================== testsuite/tests/backpack/should_compile/bkp57.stderr ===================================== @@ -0,0 +1,19 @@ +[1 of 4] Processing common + Instantiating common + [1 of 1] Compiling Class ( common/Class.hs, bkp57.out/common/Class.o ) +[2 of 4] Processing consumer-abs + [1 of 2] Compiling Instance[sig] ( consumer-abs/Instance.hsig, nothing ) + [2 of 2] Compiling Downstream ( consumer-abs/Downstream.hs, nothing ) +[3 of 4] Processing consumer-impl + Instantiating consumer-impl + [1 of 1] Including common + [1 of 1] Compiling Impl ( consumer-impl/Impl.hs, bkp57.out/consumer-impl/Impl.o ) +[4 of 4] Processing tie + Instantiating tie + [1 of 2] Including consumer-impl + [2 of 2] Including consumer-abs[Instance=consumer-impl:Impl] + Instantiating consumer-abs[Instance=consumer-impl:Impl] + [1 of 1] Including common + [1 of 2] Compiling Instance[sig] ( consumer-abs/Instance.hsig, bkp57.out/consumer-abs/consumer-abs-EtqPCpl4Hcf9otzJUe9fPM/Instance.o ) + [2 of 2] Compiling Downstream ( consumer-abs/Downstream.hs, bkp57.out/consumer-abs/consumer-abs-EtqPCpl4Hcf9otzJUe9fPM/Downstream.o ) + [1 of 1] Compiling Tie ( tie/Tie.hs, bkp57.out/tie/Tie.o ) ===================================== testsuite/tests/backpack/should_compile/bkp58.bkp ===================================== @@ -0,0 +1,35 @@ +-- no default method, hs-boot +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeApplications #-} +unit common where + module Class where + class Show (T x) => C x where + type T x + --type T x = () + def :: T x +unit consumer-impl where + dependency common + module {-# SOURCE #-} Impl where + import Class + data I = I Int + instance C I where + --type T I = () + module Downstream where + import Class + import {-# SOURCE #-} Impl + asdf :: C I => String + asdf = show $ def @I + module Impl where + import Class + data I = I Int + instance C I where + type T I = () + def = () +unit tie where + dependency consumer-impl + module Tie where + import Downstream + import Impl + main = print asdf ===================================== testsuite/tests/backpack/should_compile/bkp58.stderr ===================================== @@ -0,0 +1,13 @@ +[1 of 3] Processing common + Instantiating common + [1 of 1] Compiling Class ( common/Class.hs, bkp58.out/common/Class.o ) +[2 of 3] Processing consumer-impl + Instantiating consumer-impl + [1 of 1] Including common + [1 of 3] Compiling Impl[boot] ( consumer-impl/Impl.hs-boot, bkp58.out/consumer-impl/Impl.o-boot ) + [2 of 3] Compiling Downstream ( consumer-impl/Downstream.hs, bkp58.out/consumer-impl/Downstream.o ) + [3 of 3] Compiling Impl ( consumer-impl/Impl.hs, bkp58.out/consumer-impl/Impl.o ) +[3 of 3] Processing tie + Instantiating tie + [1 of 1] Including consumer-impl + [1 of 1] Compiling Tie ( tie/Tie.hs, bkp58.out/tie/Tie.o ) ===================================== testsuite/tests/backpack/should_compile/bkp59.bkp ===================================== @@ -0,0 +1,38 @@ +-- default method, backpack +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeApplications #-} +unit common where + module Class where + class Show (T x) => C x where + type T x + type T x = () + def :: T x + class D x where +unit consumer-abs where + dependency common + signature Instance where + import Class + data I = I Int + instance C I where + --type T I = () + module Downstream where + import Class + import Instance + asdf :: C I => String + asdf = show $ def @I +unit consumer-impl where + dependency common + module Impl where + import Class + data I = I Int + instance C I where + type T I = () + def = () +unit tie where + dependency consumer-impl + dependency consumer-abs[Instance=consumer-impl:Impl] + module Tie where + import Downstream + main = print asdf ===================================== testsuite/tests/backpack/should_compile/bkp59.stderr ===================================== @@ -0,0 +1,19 @@ +[1 of 4] Processing common + Instantiating common + [1 of 1] Compiling Class ( common/Class.hs, bkp59.out/common/Class.o ) +[2 of 4] Processing consumer-abs + [1 of 2] Compiling Instance[sig] ( consumer-abs/Instance.hsig, nothing ) + [2 of 2] Compiling Downstream ( consumer-abs/Downstream.hs, nothing ) +[3 of 4] Processing consumer-impl + Instantiating consumer-impl + [1 of 1] Including common + [1 of 1] Compiling Impl ( consumer-impl/Impl.hs, bkp59.out/consumer-impl/Impl.o ) +[4 of 4] Processing tie + Instantiating tie + [1 of 2] Including consumer-impl + [2 of 2] Including consumer-abs[Instance=consumer-impl:Impl] + Instantiating consumer-abs[Instance=consumer-impl:Impl] + [1 of 1] Including common + [1 of 2] Compiling Instance[sig] ( consumer-abs/Instance.hsig, bkp59.out/consumer-abs/consumer-abs-EtqPCpl4Hcf9otzJUe9fPM/Instance.o ) + [2 of 2] Compiling Downstream ( consumer-abs/Downstream.hs, bkp59.out/consumer-abs/consumer-abs-EtqPCpl4Hcf9otzJUe9fPM/Downstream.o ) + [1 of 1] Compiling Tie ( tie/Tie.hs, bkp59.out/tie/Tie.o ) ===================================== testsuite/tests/backpack/should_compile/bkp60.bkp ===================================== @@ -0,0 +1,35 @@ +-- default method, hs-boot +{-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeApplications #-} +unit common where + module Class where + class Show (T x) => C x where + type T x + type T x = () + def :: T x +unit consumer-impl where + dependency common + module {-# SOURCE #-} Impl where + import Class + data I = I Int + instance C I where + --type T I = () + module Downstream where + import Class + import {-# SOURCE #-} Impl + asdf :: C I => String + asdf = show $ def @I + module Impl where + import Class + data I = I Int + instance C I where + type T I = () + def = () +unit tie where + dependency consumer-impl + module Tie where + import Downstream + import Impl + main = print asdf ===================================== testsuite/tests/backpack/should_compile/bkp60.stderr ===================================== @@ -0,0 +1,13 @@ +[1 of 3] Processing common + Instantiating common + [1 of 1] Compiling Class ( common/Class.hs, bkp60.out/common/Class.o ) +[2 of 3] Processing consumer-impl + Instantiating consumer-impl + [1 of 1] Including common + [1 of 3] Compiling Impl[boot] ( consumer-impl/Impl.hs-boot, bkp60.out/consumer-impl/Impl.o-boot ) + [2 of 3] Compiling Downstream ( consumer-impl/Downstream.hs, bkp60.out/consumer-impl/Downstream.o ) + [3 of 3] Compiling Impl ( consumer-impl/Impl.hs, bkp60.out/consumer-impl/Impl.o ) +[3 of 3] Processing tie + Instantiating tie + [1 of 1] Including consumer-impl + [1 of 1] Compiling Tie ( tie/Tie.hs, bkp60.out/tie/Tie.o ) ===================================== testsuite/tests/typecheck/should_compile/ClassDefaultInHsBoot.hs ===================================== @@ -0,0 +1,4 @@ +import ClassDefaultInHsBootA3 +import ClassDefaultInHsBootA2 + +main = print asdf ===================================== testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA1.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE AllowAmbiguousTypes #-} +-- Analogous to module Class from tests/backpack/should_compile/bkp58.bkp +module ClassDefaultInHsBootA1 where + +class Show (T x) => C x where + type T x + type T x = Int + def :: T x ===================================== testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA2.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies #-} +module ClassDefaultInHsBootA2 where + +import ClassDefaultInHsBootA1 + +data I = I Int + +instance C I where + type T I = () + def = () ===================================== testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA2.hs-boot ===================================== @@ -0,0 +1,6 @@ +module ClassDefaultInHsBootA2 where + +import ClassDefaultInHsBootA1 + +data I = I Int +instance C I ===================================== testsuite/tests/typecheck/should_compile/ClassDefaultInHsBootA3.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE FlexibleContexts #-} +module ClassDefaultInHsBootA3 where + +import ClassDefaultInHsBootA1 +import ClassDefaultInHsBootA2 + +asdf :: String +asdf = show $ def @I ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -724,4 +724,5 @@ test('T18323', normal, compile, ['']) test('T18585', normal, compile, ['']) test('T18831', normal, compile, ['']) test('T15942', normal, compile, ['']) +test('ClassDefaultInHsBoot', [extra_files(['ClassDefaultInHsBootA1.hs','ClassDefaultInHsBootA2.hs','ClassDefaultInHsBootA2.hs-boot','ClassDefaultInHsBootA3.hs'])], multimod_compile, ['ClassDefaultInHsBoot', '-v0']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59d7c9f45b034809516703b57c84e3dac1834578 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59d7c9f45b034809516703b57c84e3dac1834578 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 02:02:21 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 22:02:21 -0400 Subject: [Git][ghc/ghc][master] 3 commits: Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Message-ID: <5f8ba22d8d7f0_2800ed664488915b8@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr - − testsuite/tests/arityanal/f4.stderr - − testsuite/tests/arityanal/f5.stderr - − testsuite/tests/arityanal/f6.stderr - − testsuite/tests/arityanal/f7.stderr - − testsuite/tests/arityanal/f8.stderr - − testsuite/tests/arityanal/f9.stderr - − testsuite/tests/arityanal/prim.stderr - testsuite/tests/arityanal/f0.hs → testsuite/tests/arityanal/should_compile/Arity00.hs - + testsuite/tests/arityanal/should_compile/Arity00.stderr - testsuite/tests/arityanal/f1.hs → testsuite/tests/arityanal/should_compile/Arity01.hs - + testsuite/tests/arityanal/should_compile/Arity01.stderr - testsuite/tests/arityanal/f2.hs → testsuite/tests/arityanal/should_compile/Arity02.hs - + testsuite/tests/arityanal/should_compile/Arity02.stderr - testsuite/tests/arityanal/f3.hs → testsuite/tests/arityanal/should_compile/Arity03.hs - + testsuite/tests/arityanal/should_compile/Arity03.stderr - testsuite/tests/arityanal/f4.hs → testsuite/tests/arityanal/should_compile/Arity04.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59d7c9f45b034809516703b57c84e3dac1834578...451455fd008500259f5d2207bdfdccf6dddb52c5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59d7c9f45b034809516703b57c84e3dac1834578...451455fd008500259f5d2207bdfdccf6dddb52c5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 02:02:58 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 22:02:58 -0400 Subject: [Git][ghc/ghc][master] 2 commits: When using rts_setInCallCapability, lock incall threads Message-ID: <5f8ba252c6f53_28003fd3ed215efc8946da@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - 7 changed files: - compiler/GHC/HsToCore/Foreign/Decl.hs - includes/RtsAPI.h - rts/RtsAPI.c - rts/RtsSymbols.c - + testsuite/tests/ffi/should_run/IncallAffinity.hs - + testsuite/tests/ffi/should_run/IncallAffinity_c.c - testsuite/tests/ffi/should_run/all.T Changes: ===================================== compiler/GHC/HsToCore/Foreign/Decl.hs ===================================== @@ -415,7 +415,7 @@ f_helper(StablePtr s, HsBool b, HsInt i) { Capability *cap; cap = rts_lock(); - rts_evalIO(&cap, + rts_inCall(&cap, rts_apply(rts_apply(deRefStablePtr(s), rts_mkBool(b)), rts_mkInt(i))); rts_unlock(cap); @@ -630,7 +630,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc | otherwise = cResType <+> pprCconv <+> ftext c_nm <> parens fun_args - -- the target which will form the root of what we ask rts_evalIO to run + -- the target which will form the root of what we ask rts_inCall to run the_cfun = case maybe_target of Nothing -> text "(StgClosure*)deRefStablePtr(the_stableptr)" @@ -638,7 +638,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc cap = text "cap" <> comma - -- the expression we give to rts_evalIO + -- the expression we give to rts_inCall expr_to_run = foldl' appArg the_cfun arg_info -- NOT aug_arg_info where @@ -674,7 +674,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc , declareCResult , text "cap = rts_lock();" -- create the application + perform it. - , text "rts_evalIO" <> parens ( + , text "rts_inCall" <> parens ( char '&' <> cap <> text "rts_apply" <> parens ( cap <> ===================================== includes/RtsAPI.h ===================================== @@ -374,10 +374,6 @@ Capability *rts_unsafeGetMyCapability (void); // into Haskell. The actual capability will be calculated as the supplied // value modulo the number of enabled Capabilities. // -// Note that the thread may still be migrated by the RTS scheduler, but that -// will only happen if there are multiple threads running on one Capability and -// another Capability is free. -// // If affinity is non-zero, the current thread will be bound to // specific CPUs according to the prevailing affinity policy for the // specified capability, set by either +RTS -qa or +RTS --numa. @@ -479,6 +475,10 @@ void rts_evalLazyIO_ (/* inout */ Capability **, /* in */ unsigned int stack_size, /* out */ HaskellObj *ret); +void rts_inCall (/* inout */ Capability **, + /* in */ HaskellObj p, + /* out */ HaskellObj *ret); + void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); ===================================== rts/RtsAPI.c ===================================== @@ -460,6 +460,26 @@ void rts_evalIO (/* inout */ Capability **cap, scheduleWaitThread(tso,ret,cap); } +/* + * rts_inCall() is similar to rts_evalIO, but expects to be called as an incall, + * and is not expected to be called by user code directly. + */ +void rts_inCall (/* inout */ Capability **cap, + /* in */ HaskellObj p, + /* out */ HaskellObj *ret) +{ + StgTSO* tso; + + tso = createStrictIOThread(*cap, RtsFlags.GcFlags.initialStkSize, p); + if ((*cap)->running_task->preferred_capability != -1) { + // enabled_capabilities should not change between here and waitCapability() + ASSERT((*cap)->no == ((*cap)->running_task->preferred_capability % enabled_capabilities)); + // we requested explicit affinity; don't move this thread from now on. + tso->flags |= TSO_LOCKED; + } + scheduleWaitThread(tso,ret,cap); +} + /* * rts_evalStableIOMain() is suitable for calling main Haskell thread * stored in (StablePtr (IO a)) it calls rts_evalStableIO but wraps ===================================== rts/RtsSymbols.c ===================================== @@ -763,6 +763,7 @@ SymI_HasProto(rts_evalStableIOMain) \ SymI_HasProto(rts_evalStableIO) \ SymI_HasProto(rts_eval_) \ + SymI_HasProto(rts_inCall) \ SymI_HasProto(rts_getBool) \ SymI_HasProto(rts_getChar) \ SymI_HasProto(rts_getDouble) \ ===================================== testsuite/tests/ffi/should_run/IncallAffinity.hs ===================================== @@ -0,0 +1,36 @@ +module Lib (capTest) where + +import Control.Concurrent +import Control.Exception +import Control.Concurrent.MVar +import Control.Monad (when) +import System.Exit + +foreign export ccall "capTest" capTest :: IO Int + +capTest :: IO Int +capTest = catch go handle + where + handle :: SomeException -> IO Int + handle e = do + putStrLn $ "Failed " ++ (show e) + return (-1) + getCap = fmap fst $ threadCapability =<< myThreadId + go = do + when (not rtsSupportsBoundThreads) $ + die "This test requires -threaded" + mvar <- newEmptyMVar + mvar2 <- newEmptyMVar + (cap, locked) <- threadCapability =<< myThreadId + forkOn cap $ do + putMVar mvar =<< getCap + takeMVar mvar2 + -- if cap is locked, then this would get scheduled on a different + -- capacity. + fCap <- takeMVar mvar + putMVar mvar2 () + cap2 <- getCap + when (fCap /= cap) (fail "expected cap to be the same") + when (cap2 /= cap) (fail "expected cap to be the same when returning") + when (not locked) (fail "expected to be locked") + return cap ===================================== testsuite/tests/ffi/should_run/IncallAffinity_c.c ===================================== @@ -0,0 +1,78 @@ +#include "HsFFI.h" + +#include +#include "Rts.h" +#include + +#define THREADS 6 +#define OK 9999 +static OSThreadId ids[THREADS]; +static int results[THREADS]; +static int waiters = 0; +static int done = 0; +static Condition cond; +static Mutex mutex; + +HsInt capTest(); + +void* OSThreadProcAttr go(void *info) +{ + int cap; + int res; + int threadNum = *(int*)(info); + + // divide everything onto two caps (if there are two) + cap = (threadNum % 2) % enabled_capabilities; + + OS_ACQUIRE_LOCK(&mutex); + waiters++; + if (waiters == THREADS) { + broadcastCondition(&cond); + } else { + while(waiters != THREADS) { + waitCondition(&cond, &mutex); + } + } + OS_RELEASE_LOCK(&mutex); + + rts_setInCallCapability(cap, 0); + res = capTest(); + *(int*)info = res == cap ? OK : res; + OS_ACQUIRE_LOCK(&mutex); + done++; + broadcastCondition(&cond); + OS_RELEASE_LOCK(&mutex); + return 0; +} + +int main(int argc, char *argv[]) +{ + int n; + bool ok; + hs_init(&argc, &argv); + initCondition(&cond); + initMutex(&mutex); + waiters = 0; + done = 0; + ok = true; + for (n=0; n < THREADS; n++) { + results[n] = n; + if (createOSThread(&ids[n], "test", go, (void*)&results[n])) { + printf("unable to create thread %d\n", n); + exit(1); + } + } + OS_ACQUIRE_LOCK(&mutex); + while(done != THREADS) { + waitCondition(&cond, &mutex); + } + OS_RELEASE_LOCK(&mutex); + for (n = 0; n < THREADS; n++) { + if (results[n] != OK) { + printf("%d: unexpected result was %d\n", n, results[n]); + ok = false; + } + } + hs_exit(); + return ok ? 0 : 1; +} ===================================== testsuite/tests/ffi/should_run/all.T ===================================== @@ -218,3 +218,10 @@ test('UnliftedNewtypesByteArrayOffset', [omit_ways(['ghci'])], compile_and_run, test('T17471', [omit_ways(['ghci'])], compile_and_run, ['T17471_c.c -optc-D -optcFOO']) + +test('IncallAffinity', + [req_smp, only_ways(['threaded1', 'threaded2']), + # Unregisterised build doesn't support + when(unregisterised(), skip)], + compile_and_run, + ['IncallAffinity_c.c -no-hs-main']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/451455fd008500259f5d2207bdfdccf6dddb52c5...0b995759ae2ba2161097a1c43efc650ccbce0276 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/451455fd008500259f5d2207bdfdccf6dddb52c5...0b995759ae2ba2161097a1c43efc650ccbce0276 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 02:04:12 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 22:04:12 -0400 Subject: [Git][ghc/ghc][master] Don't get host RTS ways via settings (#18651) Message-ID: <5f8ba29ca4fb_28003fd3ec591a50899634@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - 7 changed files: - compiler/GHC/Driver/Session.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - hadrian/src/Rules/Generate.hs - includes/ghc.mk Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -131,8 +131,6 @@ module GHC.Driver.Session ( sGhcWithSMP, sGhcRTSWays, sLibFFI, - sGhcThreaded, - sGhcDebugged, sGhcRtsWithLibdw, GhcNameVersion(..), FileSettings(..), ===================================== compiler/GHC/Platform.hs ===================================== @@ -209,8 +209,6 @@ data PlatformMisc = PlatformMisc , platformMisc_ghcWithSMP :: Bool , platformMisc_ghcRTSWays :: String , platformMisc_libFFI :: Bool - , platformMisc_ghcThreaded :: Bool - , platformMisc_ghcDebugged :: Bool , platformMisc_ghcRtsWithLibdw :: Bool , platformMisc_llvmTarget :: String } ===================================== compiler/GHC/Settings.hs ===================================== @@ -61,8 +61,6 @@ module GHC.Settings , sGhcWithSMP , sGhcRTSWays , sLibFFI - , sGhcThreaded - , sGhcDebugged , sGhcRtsWithLibdw ) where @@ -276,9 +274,5 @@ sGhcRTSWays :: Settings -> String sGhcRTSWays = platformMisc_ghcRTSWays . sPlatformMisc sLibFFI :: Settings -> Bool sLibFFI = platformMisc_libFFI . sPlatformMisc -sGhcThreaded :: Settings -> Bool -sGhcThreaded = platformMisc_ghcThreaded . sPlatformMisc -sGhcDebugged :: Settings -> Bool -sGhcDebugged = platformMisc_ghcDebugged . sPlatformMisc sGhcRtsWithLibdw :: Settings -> Bool sGhcRtsWithLibdw = platformMisc_ghcRtsWithLibdw . sPlatformMisc ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -155,8 +155,6 @@ initSettings top_dir = do ghcWithSMP <- getBooleanSetting "Support SMP" ghcRTSWays <- getSetting "RTS ways" useLibFFI <- getBooleanSetting "Use LibFFI" - ghcThreaded <- getBooleanSetting "Use Threads" - ghcDebugged <- getBooleanSetting "Use Debugging" ghcRtsWithLibdw <- getBooleanSetting "RTS expects libdw" return $ Settings @@ -225,8 +223,6 @@ initSettings top_dir = do , platformMisc_ghcWithSMP = ghcWithSMP , platformMisc_ghcRTSWays = ghcRTSWays , platformMisc_libFFI = useLibFFI - , platformMisc_ghcThreaded = ghcThreaded - , platformMisc_ghcDebugged = ghcDebugged , platformMisc_ghcRtsWithLibdw = ghcRtsWithLibdw , platformMisc_llvmTarget = llvmTarget } ===================================== compiler/GHC/SysTools.hs ===================================== @@ -244,15 +244,11 @@ linkDynLib dflags0 o_files dep_packages -- against libHSrts, then both end up getting loaded, -- and things go wrong. We therefore link the libraries -- with the same RTS flags that we link GHC with. - dflags1 = if platformMisc_ghcThreaded $ platformMisc dflags0 - then addWay' WayThreaded dflags0 - else dflags0 - win_dflags = if platformMisc_ghcDebugged $ platformMisc dflags1 - then addWay' WayDebug dflags1 - else dflags1 - - dflags | OSMinGW32 <- os = win_dflags - | otherwise = dflags0 + dflags | OSMinGW32 <- os + , hostWays `hasWay` WayDyn + = dflags0 { ways = hostWays } + | otherwise + = dflags0 verbFlags = getVerbFlags dflags o_file = outputFile dflags ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -9,7 +9,6 @@ import Data.Foldable (for_) import Base import qualified Context import Expression -import Flavour import Hadrian.Oracles.TextFile (lookupValueOrError) import Oracles.Flag import Oracles.ModuleFiles @@ -338,8 +337,6 @@ generateSettings = do , ("Tables next to code", expr $ yesNo <$> flag TablesNextToCode) , ("Leading underscore", expr $ yesNo <$> flag LeadingUnderscore) , ("Use LibFFI", expr $ yesNo <$> useLibFFIForAdjustors) - , ("Use Threads", expr $ yesNo . ghcThreaded <$> flavour) - , ("Use Debugging", expr $ yesNo . ghcDebugged <$> flavour) , ("RTS expects libdw", yesNo <$> getFlag WithLibdw) ] let showTuple (k, v) = "(" ++ show k ++ ", " ++ show v ++ ")" ===================================== includes/ghc.mk ===================================== @@ -263,12 +263,6 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/. @echo ',("Tables next to code", "$(TablesNextToCode)")' >> $@ @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@ @echo ',("Use LibFFI", "$(UseLibFFIForAdjustors)")' >> $@ -# Note that GhcThreaded just reflects the Makefile variable setting. In -# particular, the stage1 compiler is never actually compiled with -threaded, but -# it will nevertheless have cGhcThreaded = True. The "+RTS --info" output will -# show what RTS GHC is really using. - @echo ",(\"Use Threads\", \"$(GhcThreaded)\")" >> $@ - @echo ",(\"Use Debugging\", \"$(GhcDebugged)\")" >> $@ @echo ",(\"RTS expects libdw\", \"$(GhcRtsWithLibdw)\")" >> $@ @echo "]" >> $@ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a91dcb669b3b221c51e8ba8bb85b7ae9806bc4ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a91dcb669b3b221c51e8ba8bb85b7ae9806bc4ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 02:04:47 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 17 Oct 2020 22:04:47 -0400 Subject: [Git][ghc/ghc][master] Linting corrections Message-ID: <5f8ba2bf4dcbd_28003fd3ec591a5090254a@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 1 changed file: - libraries/base/.hlint.yaml Changes: ===================================== libraries/base/.hlint.yaml ===================================== @@ -23,7 +23,7 @@ # lints that we otherwise want applied elsewhere. Such exceptions are listed # below. -- ignore: {name: Unused LANGUAGE pragma, within: [GHC.IO.Encoding.CodePage]} +- ignore: {name: Unused LANGUAGE pragma, within: [GHC.IO.Encoding.CodePage, GHC.IO.Handle.Lock.Windows, GHC.Event.KQueue]} - ignore: {name: Redundant do, within: [GHC.IO.Handle.Text.commitBuffer]} - ignore: {name: Use fewer imports, within: [GHC.Windows]} - ignore: {name: Use fewer imports, within: [GHC.Event.Control]} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d858a3aebee5adc447556b668b65b6e46370d8c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d858a3aebee5adc447556b668b65b6e46370d8c0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 09:31:27 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 18 Oct 2020 05:31:27 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] 11 commits: gitlab-ci: Allow doc-tarball job to fail Message-ID: <5f8c0b6fe82b9_28003fd409543f909054f2@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 73b54b85 by Alan Zimmerman at 2020-10-18T10:28:57+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Platform.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c0c88f14d653ce0a607b42911759761cd695fe8...73b54b856f6b97f88424f59795abd2b3eba16e2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2c0c88f14d653ce0a607b42911759761cd695fe8...73b54b856f6b97f88424f59795abd2b3eba16e2d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 13:37:37 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 18 Oct 2020 09:37:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/eqtycon-rn Message-ID: <5f8c45211d649_28003fd41bf45270915514@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/eqtycon-rn at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/eqtycon-rn You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 13:38:12 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 18 Oct 2020 09:38:12 -0400 Subject: [Git][ghc/ghc][wip/eqtycon-rn] Export (~) from Data.Type.Equality (#18862) Message-ID: <5f8c4544f2c59_28003fd40956ff3c91574b@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/eqtycon-rn at Glasgow Haskell Compiler / GHC Commits: ebeb84bd by Vladislav Zavialov at 2020-10-18T16:38:00+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) - - - - - 11 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Env.hs - libraries/base/Data/Type/Equality.hs - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Types.hs - + testsuite/tests/rename/should_compile/T18862.hs - testsuite/tests/rename/should_compile/all.T - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -2600,4 +2600,5 @@ pretendNameIsInScope :: Name -> Bool pretendNameIsInScope n = any (n `hasKey`) [ liftedTypeKindTyConKey, tYPETyConKey - , runtimeRepTyConKey, liftedRepDataConKey ] + , runtimeRepTyConKey, liftedRepDataConKey + , eqTyConKey ] ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -295,18 +295,14 @@ eqSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "eq_sel") eqSCSelIdKey eqSCSelI The (~) type operator used in equality constraints (a~b) is considered built-in syntax. This has a few consequences: -* The user is not allowed to define their own type constructors with this name: - - ghci> class a ~ b - :1:1: error: Illegal binding of built-in syntax: ~ - * Writing (a ~ b) does not require enabling -XTypeOperators. It does, however, require -XGADTs or -XTypeFamilies. * The (~) type operator is always in scope. It doesn't need to be imported, and it cannot be hidden. -* We have a bunch of special cases in the compiler to arrange all of the above. +In the past, users also could not define their own (~), but this restriction +has been lifted. There's no particular reason for (~) to be special, but fixing this would be a breaking change. ===================================== compiler/GHC/Parser.y ===================================== @@ -87,7 +87,7 @@ import GHC.Parser.Errors import GHC.Builtin.Types ( unitTyCon, unitDataCon, tupleTyCon, tupleDataCon, nilDataCon, unboxedUnitTyCon, unboxedUnitDataCon, - listTyCon_RDR, consDataCon_RDR, eqTyCon_RDR) + listTyCon_RDR, consDataCon_RDR ) } %expect 0 -- shift/reduce conflicts @@ -3517,11 +3517,7 @@ qtyconsym :: { Located RdrName } tyconsym :: { Located RdrName } : CONSYM { sL1 $1 $! mkUnqual tcClsName (getCONSYM $1) } - | VARSYM { sL1 $1 $! - -- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types - if getVARSYM $1 == fsLit "~" - then eqTyCon_RDR - else mkUnqual tcClsName (getVARSYM $1) } + | VARSYM { sL1 $1 $! mkUnqual tcClsName (getVARSYM $1) } | ':' { sL1 $1 $! consDataCon_RDR } | '-' { sL1 $1 $! mkUnqual tcClsName (fsLit "-") } | '.' { sL1 $1 $! mkUnqual tcClsName (fsLit ".") } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -121,7 +121,7 @@ import GHC.Utils.Lexeme ( isLexCon ) import GHC.Core.Type ( TyThing(..), unrestrictedFunTyCon, Specificity(..) ) import GHC.Builtin.Types( cTupleTyConName, tupleTyCon, tupleDataCon, nilDataConName, nilDataConKey, - listTyConName, listTyConKey, eqTyCon_RDR ) + listTyConName, listTyConKey ) import GHC.Types.ForeignCall import GHC.Types.SrcLoc import GHC.Types.Unique ( hasKey ) @@ -2128,8 +2128,7 @@ checkPrecP (L l (_,i)) (L _ ol) | otherwise = addFatalError $ Error (ErrPrecedenceOutOfRange i) [] l where -- If you change this, consider updating Note [Fixity of (->)] in GHC/Types.hs - specialOp op = unLoc op `elem` [ eqTyCon_RDR - , getRdrName unrestrictedFunTyCon ] + specialOp op = unLoc op `elem` [ getRdrName unrestrictedFunTyCon ] mkRecConstrOrUpdate :: LHsExpr GhcPs ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -90,6 +90,7 @@ import qualified Data.Semigroup as Semi import Data.Either ( partitionEithers ) import Data.List ( find, sortBy ) import Control.Arrow ( first ) +import Control.Applicative ( (<|>) ) import Data.Function {- @@ -963,9 +964,15 @@ lookupTypeOccRn rdr_name = badVarInType rdr_name | otherwise = do { mb_name <- lookupOccRn_maybe rdr_name - ; case mb_name of + ; case mb_name <|> matchEqTyName rdr_name of Just name -> return name - Nothing -> lookup_demoted rdr_name } + Nothing -> lookup_demoted rdr_name } + +-- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types +matchEqTyName :: RdrName -> Maybe Name +matchEqTyName rdr_name + | occName rdr_name == occName eqTyCon_RDR = Just eqTyConName + | otherwise = Nothing lookup_demoted :: RdrName -> RnM Name lookup_demoted rdr_name @@ -1153,8 +1160,9 @@ lookupInfoOccRn rdr_name = lookupExactOrOrig rdr_name (:[]) $ do { rdr_env <- getGlobalRdrEnv ; let ns = map gre_name (lookupGRE_RdrName rdr_name rdr_env) + ; let eq_ns = maybeToList (matchEqTyName rdr_name) ; qual_ns <- lookupQualifiedNameGHCi rdr_name - ; return (ns ++ (qual_ns `minusList` ns)) } + ; return (ns ++ eq_ns ++ (qual_ns `minusList` ns)) } -- | Like 'lookupOccRn_maybe', but with a more informative result if -- the 'RdrName' happens to be a record selector: @@ -1655,13 +1663,7 @@ dataTcOccs rdr_name = [rdr_name] where occ = rdrNameOcc rdr_name - rdr_name_tc = - case rdr_name of - -- The (~) type operator is always in scope, so we need a special case - -- for it here, or else :info (~) fails in GHCi. - -- See Note [eqTyCon (~) is built-in syntax] - Unqual occ | occNameFS occ == fsLit "~" -> eqTyCon_RDR - _ -> setRdrNameSpace rdr_name tcName + rdr_name_tc = setRdrNameSpace rdr_name tcName {- Note [dataTcOccs and Exact Names] ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -31,7 +31,9 @@ module Data.Type.Equality ( -- * The equality types - (:~:)(..), type (~~), + type (~), + type (~~), + (:~:)(..), (:~~:)(..), -- * Working with equality ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -88,6 +88,7 @@ module GHC.Exts unsafeCoerce#, -- * Equality + type (~), type (~~), -- * Representation polymorphism ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types ( SPEC(..), Symbol, Any, - type (~~), Coercible, + type (~), type (~~), Coercible, TYPE, RuntimeRep(..), Type, Constraint, -- The historical type * should ideally be written as -- `type *`, without the parentheses. But that's a true @@ -225,7 +225,6 @@ newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) * * (~) and Coercible - NB: (~) is built-in syntax, and hence not explicitly exported * * ********************************************************************* -} ===================================== testsuite/tests/rename/should_compile/T18862.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies #-} + +module T18862 where + +import Data.Kind (Constraint) +import qualified Data.Type.Equality as E + +type family (a :: k) ~ (b :: k) :: result_kind + +type instance a ~ b = (a E.~ b :: Constraint) +type instance a ~ b = (a E.== b :: Bool) ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -177,3 +177,4 @@ test('T17837', normal, compile, ['']) test('T18497', [], makefile_test, ['T18497']) test('T18264', [], makefile_test, ['T18264']) test('T18302', expect_broken(18302), compile, ['']) +test('T18862', normal, compile, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 75226997a379981cf2e343e166094887bb3a8295 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebeb84bd7d6e76267d6c28144a992d1dfeead8ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ebeb84bd7d6e76267d6c28144a992d1dfeead8ac You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 13:48:12 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 18 Oct 2020 09:48:12 -0400 Subject: [Git][ghc/ghc][wip/eqtycon-rn] Export (~) from Data.Type.Equality (#18862) Message-ID: <5f8c479ce7aac_28003fd388bbc22c91771c@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/eqtycon-rn at Glasgow Haskell Compiler / GHC Commits: 051065e3 by Vladislav Zavialov at 2020-10-18T16:48:02+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) - - - - - 11 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Env.hs - libraries/base/Data/Type/Equality.hs - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Types.hs - + testsuite/tests/rename/should_compile/T18862.hs - testsuite/tests/rename/should_compile/all.T - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -2600,4 +2600,5 @@ pretendNameIsInScope :: Name -> Bool pretendNameIsInScope n = any (n `hasKey`) [ liftedTypeKindTyConKey, tYPETyConKey - , runtimeRepTyConKey, liftedRepDataConKey ] + , runtimeRepTyConKey, liftedRepDataConKey + , eqTyConKey ] ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -295,18 +295,14 @@ eqSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "eq_sel") eqSCSelIdKey eqSCSelI The (~) type operator used in equality constraints (a~b) is considered built-in syntax. This has a few consequences: -* The user is not allowed to define their own type constructors with this name: - - ghci> class a ~ b - :1:1: error: Illegal binding of built-in syntax: ~ - * Writing (a ~ b) does not require enabling -XTypeOperators. It does, however, require -XGADTs or -XTypeFamilies. * The (~) type operator is always in scope. It doesn't need to be imported, and it cannot be hidden. -* We have a bunch of special cases in the compiler to arrange all of the above. +In the past, users also could not define their own (~), but this restriction +has been lifted. There's no particular reason for (~) to be special, but fixing this would be a breaking change. ===================================== compiler/GHC/Parser.y ===================================== @@ -87,7 +87,7 @@ import GHC.Parser.Errors import GHC.Builtin.Types ( unitTyCon, unitDataCon, tupleTyCon, tupleDataCon, nilDataCon, unboxedUnitTyCon, unboxedUnitDataCon, - listTyCon_RDR, consDataCon_RDR, eqTyCon_RDR) + listTyCon_RDR, consDataCon_RDR ) } %expect 0 -- shift/reduce conflicts @@ -3517,11 +3517,7 @@ qtyconsym :: { Located RdrName } tyconsym :: { Located RdrName } : CONSYM { sL1 $1 $! mkUnqual tcClsName (getCONSYM $1) } - | VARSYM { sL1 $1 $! - -- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types - if getVARSYM $1 == fsLit "~" - then eqTyCon_RDR - else mkUnqual tcClsName (getVARSYM $1) } + | VARSYM { sL1 $1 $! mkUnqual tcClsName (getVARSYM $1) } | ':' { sL1 $1 $! consDataCon_RDR } | '-' { sL1 $1 $! mkUnqual tcClsName (fsLit "-") } | '.' { sL1 $1 $! mkUnqual tcClsName (fsLit ".") } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -121,7 +121,7 @@ import GHC.Utils.Lexeme ( isLexCon ) import GHC.Core.Type ( TyThing(..), unrestrictedFunTyCon, Specificity(..) ) import GHC.Builtin.Types( cTupleTyConName, tupleTyCon, tupleDataCon, nilDataConName, nilDataConKey, - listTyConName, listTyConKey, eqTyCon_RDR ) + listTyConName, listTyConKey ) import GHC.Types.ForeignCall import GHC.Types.SrcLoc import GHC.Types.Unique ( hasKey ) @@ -2128,8 +2128,7 @@ checkPrecP (L l (_,i)) (L _ ol) | otherwise = addFatalError $ Error (ErrPrecedenceOutOfRange i) [] l where -- If you change this, consider updating Note [Fixity of (->)] in GHC/Types.hs - specialOp op = unLoc op `elem` [ eqTyCon_RDR - , getRdrName unrestrictedFunTyCon ] + specialOp op = unLoc op `elem` [ getRdrName unrestrictedFunTyCon ] mkRecConstrOrUpdate :: LHsExpr GhcPs ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -90,6 +90,7 @@ import qualified Data.Semigroup as Semi import Data.Either ( partitionEithers ) import Data.List ( find, sortBy ) import Control.Arrow ( first ) +import Control.Applicative ( (<|>) ) import Data.Function {- @@ -963,10 +964,16 @@ lookupTypeOccRn rdr_name = badVarInType rdr_name | otherwise = do { mb_name <- lookupOccRn_maybe rdr_name - ; case mb_name of + ; case mb_name <|> matchEqTyName rdr_name of Just name -> return name Nothing -> lookup_demoted rdr_name } +-- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types +matchEqTyName :: RdrName -> Maybe Name +matchEqTyName rdr_name + | occName rdr_name == occName eqTyCon_RDR = Just eqTyConName + | otherwise = Nothing + lookup_demoted :: RdrName -> RnM Name lookup_demoted rdr_name | Just demoted_rdr <- demoteRdrName rdr_name @@ -1153,6 +1160,7 @@ lookupInfoOccRn rdr_name = lookupExactOrOrig rdr_name (:[]) $ do { rdr_env <- getGlobalRdrEnv ; let ns = map gre_name (lookupGRE_RdrName rdr_name rdr_env) + ++ maybeToList (matchEqTyName rdr_name) ; qual_ns <- lookupQualifiedNameGHCi rdr_name ; return (ns ++ (qual_ns `minusList` ns)) } @@ -1655,13 +1663,7 @@ dataTcOccs rdr_name = [rdr_name] where occ = rdrNameOcc rdr_name - rdr_name_tc = - case rdr_name of - -- The (~) type operator is always in scope, so we need a special case - -- for it here, or else :info (~) fails in GHCi. - -- See Note [eqTyCon (~) is built-in syntax] - Unqual occ | occNameFS occ == fsLit "~" -> eqTyCon_RDR - _ -> setRdrNameSpace rdr_name tcName + rdr_name_tc = setRdrNameSpace rdr_name tcName {- Note [dataTcOccs and Exact Names] ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -31,7 +31,9 @@ module Data.Type.Equality ( -- * The equality types - (:~:)(..), type (~~), + type (~), + type (~~), + (:~:)(..), (:~~:)(..), -- * Working with equality ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -88,6 +88,7 @@ module GHC.Exts unsafeCoerce#, -- * Equality + type (~), type (~~), -- * Representation polymorphism ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types ( SPEC(..), Symbol, Any, - type (~~), Coercible, + type (~), type (~~), Coercible, TYPE, RuntimeRep(..), Type, Constraint, -- The historical type * should ideally be written as -- `type *`, without the parentheses. But that's a true @@ -225,7 +225,6 @@ newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) * * (~) and Coercible - NB: (~) is built-in syntax, and hence not explicitly exported * * ********************************************************************* -} ===================================== testsuite/tests/rename/should_compile/T18862.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies #-} + +module T18862 where + +import Data.Kind (Constraint) +import qualified Data.Type.Equality as E + +type family (a :: k) ~ (b :: k) :: result_kind + +type instance a ~ b = (a E.~ b :: Constraint) +type instance a ~ b = (a E.== b :: Bool) ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -177,3 +177,4 @@ test('T17837', normal, compile, ['']) test('T18497', [], makefile_test, ['T18497']) test('T18264', [], makefile_test, ['T18264']) test('T18302', expect_broken(18302), compile, ['']) +test('T18862', normal, compile, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 75226997a379981cf2e343e166094887bb3a8295 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/051065e36ff051740bcbc21ad38408f4d6536d58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/051065e36ff051740bcbc21ad38408f4d6536d58 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 15:35:07 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 18 Oct 2020 11:35:07 -0400 Subject: [Git][ghc/ghc][wip/eqtycon-rn] Export (~) from Data.Type.Equality (#18862) Message-ID: <5f8c60abb2ae6_28003fd3ee4351289190ac@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/eqtycon-rn at Glasgow Haskell Compiler / GHC Commits: 8c1aa21f by Vladislav Zavialov at 2020-10-18T18:34:50+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) Updates the haddock submodule. - - - - - 14 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Env.hs - libraries/base/Data/Type/Equality.hs - libraries/base/GHC/Exts.hs - libraries/ghc-prim/GHC/Types.hs - testsuite/tests/rename/should_fail/T15214.hs → testsuite/tests/rename/should_compile/T15214.hs - + testsuite/tests/rename/should_compile/T18862.hs - testsuite/tests/rename/should_compile/all.T - − testsuite/tests/rename/should_fail/T15214.stderr - testsuite/tests/rename/should_fail/all.T - utils/haddock Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -2600,4 +2600,5 @@ pretendNameIsInScope :: Name -> Bool pretendNameIsInScope n = any (n `hasKey`) [ liftedTypeKindTyConKey, tYPETyConKey - , runtimeRepTyConKey, liftedRepDataConKey ] + , runtimeRepTyConKey, liftedRepDataConKey + , eqTyConKey ] ===================================== compiler/GHC/Builtin/Types.hs ===================================== @@ -295,18 +295,14 @@ eqSCSelIdName = mkWiredInIdName gHC_TYPES (fsLit "eq_sel") eqSCSelIdKey eqSCSelI The (~) type operator used in equality constraints (a~b) is considered built-in syntax. This has a few consequences: -* The user is not allowed to define their own type constructors with this name: - - ghci> class a ~ b - :1:1: error: Illegal binding of built-in syntax: ~ - * Writing (a ~ b) does not require enabling -XTypeOperators. It does, however, require -XGADTs or -XTypeFamilies. * The (~) type operator is always in scope. It doesn't need to be imported, and it cannot be hidden. -* We have a bunch of special cases in the compiler to arrange all of the above. +In the past, users also could not define their own (~), but this restriction +has been lifted. There's no particular reason for (~) to be special, but fixing this would be a breaking change. ===================================== compiler/GHC/Parser.y ===================================== @@ -87,7 +87,7 @@ import GHC.Parser.Errors import GHC.Builtin.Types ( unitTyCon, unitDataCon, tupleTyCon, tupleDataCon, nilDataCon, unboxedUnitTyCon, unboxedUnitDataCon, - listTyCon_RDR, consDataCon_RDR, eqTyCon_RDR) + listTyCon_RDR, consDataCon_RDR ) } %expect 0 -- shift/reduce conflicts @@ -3517,11 +3517,7 @@ qtyconsym :: { Located RdrName } tyconsym :: { Located RdrName } : CONSYM { sL1 $1 $! mkUnqual tcClsName (getCONSYM $1) } - | VARSYM { sL1 $1 $! - -- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types - if getVARSYM $1 == fsLit "~" - then eqTyCon_RDR - else mkUnqual tcClsName (getVARSYM $1) } + | VARSYM { sL1 $1 $! mkUnqual tcClsName (getVARSYM $1) } | ':' { sL1 $1 $! consDataCon_RDR } | '-' { sL1 $1 $! mkUnqual tcClsName (fsLit "-") } | '.' { sL1 $1 $! mkUnqual tcClsName (fsLit ".") } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -121,7 +121,7 @@ import GHC.Utils.Lexeme ( isLexCon ) import GHC.Core.Type ( TyThing(..), unrestrictedFunTyCon, Specificity(..) ) import GHC.Builtin.Types( cTupleTyConName, tupleTyCon, tupleDataCon, nilDataConName, nilDataConKey, - listTyConName, listTyConKey, eqTyCon_RDR ) + listTyConName, listTyConKey ) import GHC.Types.ForeignCall import GHC.Types.SrcLoc import GHC.Types.Unique ( hasKey ) @@ -2128,8 +2128,7 @@ checkPrecP (L l (_,i)) (L _ ol) | otherwise = addFatalError $ Error (ErrPrecedenceOutOfRange i) [] l where -- If you change this, consider updating Note [Fixity of (->)] in GHC/Types.hs - specialOp op = unLoc op `elem` [ eqTyCon_RDR - , getRdrName unrestrictedFunTyCon ] + specialOp op = unLoc op `elem` [ getRdrName unrestrictedFunTyCon ] mkRecConstrOrUpdate :: LHsExpr GhcPs ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -90,6 +90,7 @@ import qualified Data.Semigroup as Semi import Data.Either ( partitionEithers ) import Data.List ( find, sortBy ) import Control.Arrow ( first ) +import Control.Applicative ( (<|>) ) import Data.Function {- @@ -963,10 +964,16 @@ lookupTypeOccRn rdr_name = badVarInType rdr_name | otherwise = do { mb_name <- lookupOccRn_maybe rdr_name - ; case mb_name of + ; case mb_name <|> matchEqTyName rdr_name of Just name -> return name Nothing -> lookup_demoted rdr_name } +-- See Note [eqTyCon (~) is built-in syntax] in GHC.Builtin.Types +matchEqTyName :: RdrName -> Maybe Name +matchEqTyName rdr_name + | occName rdr_name == occName eqTyCon_RDR = Just eqTyConName + | otherwise = Nothing + lookup_demoted :: RdrName -> RnM Name lookup_demoted rdr_name | Just demoted_rdr <- demoteRdrName rdr_name @@ -1153,6 +1160,7 @@ lookupInfoOccRn rdr_name = lookupExactOrOrig rdr_name (:[]) $ do { rdr_env <- getGlobalRdrEnv ; let ns = map gre_name (lookupGRE_RdrName rdr_name rdr_env) + ++ maybeToList (matchEqTyName rdr_name) ; qual_ns <- lookupQualifiedNameGHCi rdr_name ; return (ns ++ (qual_ns `minusList` ns)) } @@ -1655,13 +1663,7 @@ dataTcOccs rdr_name = [rdr_name] where occ = rdrNameOcc rdr_name - rdr_name_tc = - case rdr_name of - -- The (~) type operator is always in scope, so we need a special case - -- for it here, or else :info (~) fails in GHCi. - -- See Note [eqTyCon (~) is built-in syntax] - Unqual occ | occNameFS occ == fsLit "~" -> eqTyCon_RDR - _ -> setRdrNameSpace rdr_name tcName + rdr_name_tc = setRdrNameSpace rdr_name tcName {- Note [dataTcOccs and Exact Names] ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -31,7 +31,9 @@ module Data.Type.Equality ( -- * The equality types - (:~:)(..), type (~~), + type (~), + type (~~), + (:~:)(..), (:~~:)(..), -- * Working with equality ===================================== libraries/base/GHC/Exts.hs ===================================== @@ -88,6 +88,7 @@ module GHC.Exts unsafeCoerce#, -- * Equality + type (~), type (~~), -- * Representation polymorphism ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -32,7 +32,7 @@ module GHC.Types ( SPEC(..), Symbol, Any, - type (~~), Coercible, + type (~), type (~~), Coercible, TYPE, RuntimeRep(..), Type, Constraint, -- The historical type * should ideally be written as -- `type *`, without the parentheses. But that's a true @@ -225,7 +225,6 @@ newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) * * (~) and Coercible - NB: (~) is built-in syntax, and hence not explicitly exported * * ********************************************************************* -} ===================================== testsuite/tests/rename/should_fail/T15214.hs → testsuite/tests/rename/should_compile/T15214.hs ===================================== ===================================== testsuite/tests/rename/should_compile/T18862.hs ===================================== @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies #-} + +module T18862 where + +import Data.Kind (Constraint) +import qualified Data.Type.Equality as E + +type family (a :: k) ~ (b :: k) :: result_kind + +type instance a ~ b = (a E.~ b :: Constraint) +type instance a ~ b = (a E.== b :: Bool) ===================================== testsuite/tests/rename/should_compile/all.T ===================================== @@ -162,6 +162,7 @@ test('T14881', [], multimod_compile, ['T14881', '-W']) test('T14487', [], multimod_compile, ['T14487', '-v0']) test('T14747', [], multimod_compile, ['T14747', '-v0']) test('T15149', [], multimod_compile, ['T15149', '-v0']) +test('T15214', normal, compile, ['']) test('T13064', normal, compile, ['']) test('T15994', [], makefile_test, ['T15994']) test('T15798a', normal, compile, ['']) @@ -177,3 +178,4 @@ test('T17837', normal, compile, ['']) test('T18497', [], makefile_test, ['T18497']) test('T18264', [], makefile_test, ['T18264']) test('T18302', expect_broken(18302), compile, ['']) +test('T18862', normal, compile, ['']) ===================================== testsuite/tests/rename/should_fail/T15214.stderr deleted ===================================== @@ -1,2 +0,0 @@ - -T15214.hs:4:1: error: Illegal binding of built-in syntax: ~ ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -135,7 +135,6 @@ test('T14307', normal, compile_fail, ['']) test('T14591', normal, compile_fail, ['']) test('T14907a', normal, compile_fail, ['']) test('T14907b', normal, compile_fail, ['']) -test('T15214', normal, compile_fail, ['']) test('T15539', normal, compile_fail, ['']) test('T15487', normal, multimod_compile_fail, ['T15487','-v0']) test('T15659', normal, compile_fail, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 75226997a379981cf2e343e166094887bb3a8295 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c1aa21f2dc3858e09e0432ee38bdb3f3c01bd5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c1aa21f2dc3858e09e0432ee38bdb3f3c01bd5a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 16:03:10 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Sun, 18 Oct 2020 12:03:10 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/parsing-tests-12446-12862 Message-ID: <5f8c673e56d88_28003fd3885b7124919563@gitlab.haskell.org.mail> Vladislav Zavialov pushed new branch wip/parsing-tests-12446-12862 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/parsing-tests-12446-12862 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 18 21:13:02 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 18 Oct 2020 17:13:02 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Skip type family defaults with hs-boot and hsig files Message-ID: <5f8cafde70390_28003fd385e1e6f89282e1@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 73b54b85 by Alan Zimmerman at 2020-10-18T10:28:57+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - bb5f801d by Vladislav Zavialov at 2020-10-18T17:12:55-04:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Platform.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a9e2273860219501efc9423233d5eab5b49439b...bb5f801d9540bae97265e82e45733753a750ef79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a9e2273860219501efc9423233d5eab5b49439b...bb5f801d9540bae97265e82e45733753a750ef79 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 02:43:15 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sun, 18 Oct 2020 22:43:15 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Parser regression tests, close #12862 #12446 Message-ID: <5f8cfd4359a73_28003fd40294dfac93866f@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 86a9f089 by Vladislav Zavialov at 2020-10-18T22:43:08-04:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 5 changed files: - + testsuite/tests/parser/should_compile/T12862.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_fail/T12446.hs - + testsuite/tests/parser/should_fail/T12446.stderr - testsuite/tests/parser/should_fail/all.T Changes: ===================================== testsuite/tests/parser/should_compile/T12862.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TypeFamilies, InstanceSigs #-} +{-# LANGUAGE BangPatterns #-} -- should parse even with BangPatterns enabled + +module T12862 where + +import Data.Kind (Type) + +class Key key where + data TotalMap key :: Type -> Type + (!) :: TotalMap key val -> (key -> val) + +instance Key Bool where + data TotalMap Bool val = BoolMap val val + (!) :: TotalMap Bool val -> (Bool -> val) + (BoolMap f _) ! False = f -- with parentheses + BoolMap f _ ! True = f -- without parentheses ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,4 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T12862', normal, compile, ['']) ===================================== testsuite/tests/parser/should_fail/T12446.hs ===================================== @@ -0,0 +1,3 @@ +module T12446 where + +x = undefined @(_ ~ _) ===================================== testsuite/tests/parser/should_fail/T12446.stderr ===================================== @@ -0,0 +1,4 @@ + +T12446.hs:3:5: error: + Illegal visible type application ‘@(_ ~ _)’ + Perhaps you intended to use TypeApplications ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -173,3 +173,4 @@ test('T18251c', normal, compile_fail, ['']) test('T18251d', normal, compile_fail, ['']) test('T18251e', normal, compile_fail, ['']) test('T18251f', normal, compile_fail, ['']) +test('T12446', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86a9f089a0c0aaa8d8d706415a4ae394b7924c79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86a9f089a0c0aaa8d8d706415a4ae394b7924c79 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 08:35:29 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Mon, 19 Oct 2020 04:35:29 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f8d4fd191dcd_28003fd409623dc09654aa@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: dde79eaf by Alan Zimmerman at 2020-10-19T08:59:19+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -931,22 +931,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -961,20 +962,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1959,10 +1963,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -537,12 +538,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -980,10 +980,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -624,11 +624,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -721,10 +721,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1847,7 +1847,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2453,7 +2453,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -1683,7 +1683,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1751,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde79eaffcb0fa2bbecc759c7aa3fc4d3de0cfd1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dde79eaffcb0fa2bbecc759c7aa3fc4d3de0cfd1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 09:00:37 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 19 Oct 2020 05:00:37 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 53 commits: Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Message-ID: <5f8d55b5c548d_28003fd3889ea7c896947d@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 578d1ede by Sebastian Graf at 2020-10-19T11:00:29+02:00 Nested CPR - - - - - a59c927a by Sebastian Graf at 2020-10-19T11:00:29+02:00 Move tests from stranal to cpranal - - - - - 6659cc6a by Sebastian Graf at 2020-10-19T11:00:29+02:00 Accept FacState - - - - - a419bdd6 by Sebastian Graf at 2020-10-19T11:00:29+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - 968e6b22 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - b516d73d by Sebastian Graf at 2020-10-19T11:00:30+02:00 stuff - - - - - 045dca07 by Sebastian Graf at 2020-10-19T11:00:30+02:00 A slew of testsuite changes - - - - - 6a9777c1 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix T1600 - - - - - 0a0014a0 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix primop termination - - - - - defe6b0b by Sebastian Graf at 2020-10-19T11:00:30+02:00 Test for DataCon wrapper CPR - - - - - ddd7673f by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix CPR of bottoming functions/primops - - - - - ac7287f3 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - 5502211a by Sebastian Graf at 2020-10-19T11:00:30+02:00 Accept two more changed test outputs - - - - - 730fbdf3 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Update CaseBinderCPR with a new function - - - - - 0bd1d50c by Sebastian Graf at 2020-10-19T11:00:30+02:00 Don't give the case binder the CPR property - - - - - eced6ada by Sebastian Graf at 2020-10-19T11:00:30+02:00 Prune CPR sigs to constant depth on all bindings - - - - - e0f0a8b2 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Use variable length coding for ConTags - - - - - 79d21e1f by Sebastian Graf at 2020-10-19T11:00:30+02:00 Accept testuite output - - - - - 93cd0067 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - ca438c7f by Sebastian Graf at 2020-10-19T11:00:30+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 91c284db by Sebastian Graf at 2020-10-19T11:00:30+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - 2a22de5b by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix T9291 - - - - - 7f2bd0a1 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - 0bb5e521 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Testsuite changes - - - - - bd38fb0b by Sebastian Graf at 2020-10-19T11:00:30+02:00 Refactoring around cprAnalBind - - - - - 418be2d3 by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - 2508ec0d by Sebastian Graf at 2020-10-19T11:00:30+02:00 Fix T16893 - - - - - 71553c53 by Sebastian Graf at 2020-10-19T11:00:31+02:00 Accept new test output for T17673 - - - - - 6f7b4017 by Sebastian Graf at 2020-10-19T11:00:31+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 Metric Increase ['max_bytes_used', 'peak_megabytes_allocated']: T10370 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/546788b5119e34f3f7313f01b56eaa7f437422b4...6f7b40177f693d748080a2c5e17dc2c4da3138a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/546788b5119e34f3f7313f01b56eaa7f437422b4...6f7b40177f693d748080a2c5e17dc2c4da3138a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 09:01:17 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 19 Oct 2020 05:01:17 -0400 Subject: [Git][ghc/ghc][wip/T5075] 25 commits: Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Message-ID: <5f8d55dd8fe93_28003fd3eca36b289704ad@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T5075 at Glasgow Haskell Compiler / GHC Commits: 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 4aaf4073 by Sebastian Graf at 2020-10-19T11:01:09+02:00 CprAnal: Activate Sum CPR for local bindings We've had Sum CPR (#5075) for top-level bindings for a couple of years now. That begs the question why we didn't also activate it for local bindings, and the reasons for that are described in `Note [CPR for sum types]`. Only that it didn't make sense! The Note said that Sum CPR would destroy let-no-escapes, but that should be a non-issue since we have syntactic join points in Core now and we don't WW for them (`Note [Don't w/w join points for CPR]`). So I simply activated CPR for all bindings of sum type, thus fixing #5075. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - configure.ac - docs/users_guide/9.2.1-notes.rst - docs/users_guide/using-optimisation.rst - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - libraries/base/GHC/Exts.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3951ac4fc0039ebef01eddb87738b28ec569a8d...4aaf407393c3715bdc0fcdf8cd475a6202205fa3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3951ac4fc0039ebef01eddb87738b28ec569a8d...4aaf407393c3715bdc0fcdf8cd475a6202205fa3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 09:28:20 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 19 Oct 2020 05:28:20 -0400 Subject: [Git][ghc/ghc][wip/andreask/strict_dicts] 79 commits: Document profiling flags, warning flags, and no-pie Message-ID: <5f8d5c3463a6d_28003fd402e5c5fc988999@gitlab.haskell.org.mail> Andreas Klebinger pushed to branch wip/andreask/strict_dicts at Glasgow Haskell Compiler / GHC Commits: 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 582ee524 by Andreas Klebinger at 2020-10-19T11:25:29+02:00 Enable strict dicts by default at -O2. In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. In terms of measured results this reduced instructions executed for nofib by 1%. However for some cases (e.g. Cabal) enabling this by default increases compile time by 2-3% so we enable it only at -O2 where it's clear that a user is willing to trade compile time for runtime. Most of the testsuite runs without -O2 so there are few perf changes. T12545: We perform more WW work because dicts are now treated strict. T14697: Compiling empty modules. Probably because of changes inside ghc. T9203: I can't reproduce this improvement locally. Might be spurious. ------------------------- Metric Decrease: T14697 T9203 Metric Increase: T12545 ------------------------- - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2468ca3cd7298d3c16009574f2e6d95490d136e...582ee524add052b3b98f4f9288c5cb1bb9b5c1d2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2468ca3cd7298d3c16009574f2e6d95490d136e...582ee524add052b3b98f4f9288c5cb1bb9b5c1d2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 09:45:21 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 19 Oct 2020 05:45:21 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports-8.8 Message-ID: <5f8d6031bb27c_28003fd3ee8af87099204d@gitlab.haskell.org.mail> Krzysztof Gogolewski pushed new branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports-8.8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 10:52:20 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 19 Oct 2020 06:52:20 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-281-proposal-visible-foralls-proto Message-ID: <5f8d6fe431ae3_2800cfc313499453e@gitlab.haskell.org.mail> Danya Rogozin pushed new branch wip/ghc-281-proposal-visible-foralls-proto at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-281-proposal-visible-foralls-proto You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 11:12:03 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 19 Oct 2020 07:12:03 -0400 Subject: [Git][ghc/ghc][wip/ghc-281-proposal-visible-foralls-proto] (proto) visible foralls in terms Message-ID: <5f8d74836847c_28003fd4027c4384998576@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-281-proposal-visible-foralls-proto at Glasgow Haskell Compiler / GHC Commits: 6f1489c6 by Daniel Rogozin at 2020-10-19T14:10:09+03:00 (proto) visible foralls in terms - - - - - 15 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Tc/Validity.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -72,7 +72,10 @@ module GHC.Core.TyCo.Rep ( typeSize, coercionSize, provSize, -- * Multiplicities - Scaled(..), scaledMult, scaledThing, mapScaledType, Mult + Scaled(..), scaledMult, scaledThing, mapScaledType, Mult, + + -- * visible foralls related definitions + ArgType(..), mkVisFunForallTys, normalArgTys ) where #include "HsVersions.h" @@ -2071,3 +2074,22 @@ So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these. -} type Mult = Type + +data ArgType + = NormalArgType (Scaled Type) + | ForallArgType ReqTVBinder + deriving Data.Data + +mkVisFunForallTy :: ArgType -> Type -> Type +mkVisFunForallTy (NormalArgType m) ty = mkScaledFunTy VisArg m ty +mkVisFunForallTy (ForallArgType (Bndr var _)) ty = ForAllTy (Bndr var Required) ty + +mkVisFunForallTys :: [ArgType] -> Type -> Type +mkVisFunForallTys tys ty = foldr mkVisFunForallTy ty tys + +normalArgTys :: [ArgType] -> [Scaled Type] +normalArgTys [] = [] +normalArgTys (arg_ty : arg_tys) + = case arg_ty of + NormalArgType ty -> ty : normalArgTys arg_tys + _ -> normalArgTys arg_tys ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Data.FastString import GHC.Core.Type +import GHC.Core.TyCo.Rep (ArgType) import GHC.Builtin.Types (mkTupleStr) import GHC.Tc.Utils.TcType (TcType) import {-# SOURCE #-} GHC.Tc.Types (TcLclEnv) @@ -1710,7 +1711,7 @@ data MatchGroup p body data MatchGroupTc = MatchGroupTc - { mg_arg_tys :: [Scaled Type] -- Types of the arguments, t1..tn + { mg_arg_tys :: [ArgType] -- Types of the arguments, t1..tn , mg_res_ty :: Type -- Type of the result, tr } deriving Data ===================================== compiler/GHC/HsToCore/Arrows.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Core import GHC.Core.FVs import GHC.Core.Utils import GHC.Core.Make +import GHC.Core.TyCo.Rep import GHC.HsToCore.Binds (dsHsWrapper) import GHC.Types.Id @@ -595,7 +596,7 @@ dsCmd ids local_vars stack_ty res_ty exprFreeIdsDSet core_body `uniqDSetIntersectUniqSet` local_vars) dsCmd ids local_vars stack_ty res_ty - (HsCmdLamCase _ mg at MG { mg_ext = MatchGroupTc [Scaled arg_mult arg_ty] _ }) env_ids = do + (HsCmdLamCase _ mg at MG { mg_ext = MatchGroupTc [NormalArgType (Scaled arg_mult arg_ty)] _ }) env_ids = do arg_id <- newSysLocalDs arg_mult arg_ty let case_cmd = noLoc $ HsCmdCase noExtField (nlHsVar arg_id) mg dsCmdLam ids local_vars stack_ty res_ty [nlVarPat arg_id] case_cmd env_ids ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -48,6 +48,7 @@ import GHC.Core.Coercion( Coercion ) import GHC.Core import GHC.Core.Utils import GHC.Core.Make +import GHC.Core.TyCo.Rep( ArgType (..) ) import GHC.Driver.Session import GHC.Types.CostCentre @@ -721,7 +722,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields ; ([discrim_var], matching_code) <- matchWrapper RecUpd (Just record_expr) -- See Note [Scrutinee in Record updates] (MG { mg_alts = noLoc alts - , mg_ext = MatchGroupTc [unrestricted in_ty] out_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted in_ty)] out_ty , mg_origin = FromSource }) -- FromSource is not strictly right, but we @@ -1119,7 +1120,7 @@ dsDo ctx stmts (MG { mg_alts = noLoc [mkSimpleMatch LambdaExpr [mfix_pat] body] - , mg_ext = MatchGroupTc [unrestricted tup_ty] body_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted tup_ty)] body_ty , mg_origin = Generated }) mfix_pat = noLoc $ LazyPat noExtField $ mkBigLHsPatTupId rec_tup_pats body = noLoc $ HsDo body_ty ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -36,6 +36,7 @@ import GHC.Tc.Utils.Monad import GHC.HsToCore.Pmc import GHC.HsToCore.Pmc.Types ( Nablas, initNablas ) import GHC.Core +import GHC.Core.TyCo.Rep (normalArgTys) import GHC.Types.Literal import GHC.Core.Utils import GHC.Core.Make @@ -757,11 +758,11 @@ matchWrapper ctxt mb_scr (MG { mg_alts = L _ matches ; locn <- getSrcSpanDs ; new_vars <- case matches of - [] -> newSysLocalsDsNoLP arg_tys + [] -> newSysLocalsDsNoLP (normalArgTys arg_tys) (m:_) -> selectMatchVars (zipWithEqual "matchWrapper" (\a b -> (scaledMult a, unLoc b)) - arg_tys + (normalArgTys arg_tys) (hsLMatchPats m)) -- Pattern match check warnings for /this match-group/. ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Core.ConLike ( conLikeName, ConLike(RealDataCon) ) import GHC.Core.TyCon ( TyCon, tyConClass_maybe ) import GHC.Core.FVs import GHC.Core.DataCon ( dataConNonlinearType ) +import GHC.Core.TyCo.Rep ( mkVisFunForallTys ) import GHC.HsToCore ( deSugarExpr ) import GHC.Types.FieldLabel import GHC.Hs @@ -45,7 +46,7 @@ import GHC.Types.Name ( Name, nameSrcSpan, nameUnique ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnv, lookupNameEnv ) import GHC.Types.SrcLoc import GHC.Tc.Utils.Zonk ( hsLitType, hsPatType ) -import GHC.Core.Type ( mkVisFunTys, Type ) +import GHC.Core.Type ( Type ) import GHC.Core.Predicate import GHC.Core.InstEnv import GHC.Builtin.Types ( mkListTy, mkSumTy ) @@ -747,7 +748,7 @@ instance HiePass p => HasType (Located (HsExpr (GhcPass p))) where fallback = makeNode e' spn matchGroupType :: MatchGroupTc -> Type - matchGroupType (MatchGroupTc args res) = mkVisFunTys args res + matchGroupType (MatchGroupTc args res) = mkVisFunForallTys args res -- | Skip desugaring of these expressions for performance reasons. -- ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -39,6 +39,7 @@ import GHC.Core.TyCo.Ppr import GHC.Core.TyCo.Subst (substTyWithInScope) import GHC.Core.TyCo.FVs( shallowTyCoVarsOfType ) import GHC.Core.Type +import GHC.Types.Basic ( PromotionFlag (..) ) import GHC.Tc.Types.Evidence import GHC.Types.Var.Set import GHC.Builtin.PrimOps( tagToEnumKey ) @@ -312,6 +313,16 @@ tcValArgs quick_look fun args tc_arg n (EWrap wrap) = return (n, EWrap wrap) tc_arg n (ETypeArg l hs_ty ty) = return (n+1, ETypeArg l hs_ty ty) + tc_arg n (EValArg { eva_loc = loc + , eva_arg = ValArg (L l (HsVar noExtField tvname@(L l' name))) + , eva_arg_ty = ty }) + = return (n + 1, (ETypeArg loc arg' (irrelevantMult ty))) + where + arg' = HsWC { hswc_body = (L l ty_arg) + , hswc_ext = [name] + } + ty_arg = HsTyVar NoExtField IsPromoted tvname + tc_arg n eva@(EValArg { eva_arg = arg, eva_arg_ty = Scaled mult arg_ty }) = do { -- Crucial step: expose QL results before checking arg_ty -- So far as the paper is concerned, this step applies @@ -579,6 +590,26 @@ tcVTA fun_ty hs_ty , debugPprType insted_ty ]) ; return (ty_arg, insted_ty) } + | (bndr : _, ty) <- splitForAllTysReq fun_ty + = do { let tv = binderVar bndr + kind = tyVarKind tv + ; ty_arg <- tcHsTypeApp hs_ty kind + ; traceTc "ty_arg is" (ppr ty_arg) + + ; inner_ty <- zonkTcType ty + -- See Note [Visible type application zonk] + + ; let in_scope = mkInScopeSet (tyCoVarsOfTypes [fun_ty, ty_arg]) + insted_ty = substTyWithInScope in_scope [tv] [ty_arg] inner_ty + -- NB: tv and ty_arg have the same kind, so this + -- substitution is kind-respecting + ; traceTc "VTA" (vcat [ppr tv, debugPprType kind + , debugPprType ty_arg + , debugPprType (tcTypeKind ty_arg) + , debugPprType inner_ty + , debugPprType insted_ty ]) + ; return (ty_arg, insted_ty) } + | otherwise = do { (_, fun_ty) <- zonkTidyTcType emptyTidyEnv fun_ty ; failWith $ @@ -1087,5 +1118,3 @@ tcTagToEnum expr fun args app_res_ty res_ty tcExprPrag :: HsPragE GhcRn -> HsPragE GhcTc tcExprPrag (HsPragSCC x1 src ann) = HsPragSCC x1 src ann - - ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Tc.Utils.Env import GHC.Tc.Types.Origin import GHC.Tc.Types.Evidence import GHC.Core.Multiplicity +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Types.Id( mkLocalId ) import GHC.Tc.Utils.Instantiate import GHC.Builtin.Types @@ -265,7 +266,7 @@ tc_cmd env , m_grhss = grhss' }) arg_tys = map (unrestricted . hsLPatType) pats' cmd' = HsCmdLam x (MG { mg_alts = L l [match'] - , mg_ext = MatchGroupTc arg_tys res_ty + , mg_ext = MatchGroupTc (NormalArgType <$> arg_tys) res_ty , mg_origin = origin }) ; return (mkHsCmdWrap (mkWpCastN co) cmd') } where ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -1124,7 +1124,7 @@ tcSynArgE orig sigma_ty syn_ty thing_inside , res_wrapper ) -- :: res_ty_out "->" res_ty , arg_wrapper1, [], arg_wrapper2 ) ) -- :: arg_ty "->" arg_ty_out <- matchExpectedFunTys herald GenSigCtxt 1 (mkCheckExpType rho_ty) $ - \ [arg_ty] res_ty -> + \ [NormalArgTy arg_ty] res_ty -> do { arg_tc_ty <- expTypeToType (scaledThing arg_ty) ; res_tc_ty <- expTypeToType res_ty ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Types.Name import GHC.Builtin.Types import GHC.Types.Id import GHC.Core.TyCon +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Builtin.Types.Prim import GHC.Tc.Types.Evidence import GHC.Utils.Outputable @@ -141,7 +142,7 @@ tcMatchesCase :: (Outputable (body GhcRn)) => -- wrapper goes from MatchGroup's ty to expected ty tcMatchesCase ctxt (Scaled scrut_mult scrut_ty) matches res_ty - = tcMatches ctxt [Scaled scrut_mult (mkCheckExpType scrut_ty)] res_ty matches + = tcMatches ctxt [NormalArgTy (Scaled scrut_mult (mkCheckExpType scrut_ty))] res_ty matches tcMatchLambda :: SDoc -- see Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify -> TcMatchCtxt HsExpr @@ -187,7 +188,7 @@ data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body - -> [Scaled ExpSigmaType] -- Expected pattern types + -> [ArgTy] -- Expected pattern types -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) @@ -199,7 +200,7 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches -- when in inference mode, so we must do it ourselves, -- here, using expTypeToType = do { tcEmitBindingUsage bottomUE - ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; pat_tys <- mapM argTyToArgType pat_tys ; rhs_ty <- expTypeToType rhs_ty ; return (MG { mg_alts = L l [] , mg_ext = MatchGroupTc pat_tys rhs_ty @@ -209,15 +210,20 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM readScaledExpType pat_tys + ; pat_tys <- mapM argTyToArgType pat_tys ; rhs_ty <- readExpType rhs_ty ; return (MG { mg_alts = L l matches' , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } + where + argTyToArgType (NormalArgTy (Scaled m t)) = fmap (NormalArgType . Scaled m) (readExpType t) + argTyToArgType (ForallArgTy p) = return (ForallArgType p) + + ------------- tcMatch :: (Outputable (body GhcRn)) => TcMatchCtxt body - -> [Scaled ExpSigmaType] -- Expected pattern types + -> [ArgTy] -- Expected pattern types -> ExpRhoType -- Expected result-type of the Match. -> LMatch GhcRn (Located (body GhcRn)) -> TcM (LMatch GhcTc (Located (body GhcTc))) @@ -228,7 +234,7 @@ tcMatch ctxt pat_tys rhs_ty match tc_match ctxt pat_tys rhs_ty match@(Match { m_pats = pats, m_grhss = grhss }) = add_match_ctxt match $ - do { (pats', grhss') <- tcPats (mc_what ctxt) pats pat_tys $ + do { (pats', grhss') <- tcPats (mc_what ctxt) pats (scaledExpTypes pat_tys) $ tcGRHSs ctxt grhss rhs_ty ; return (Match { m_ext = noExtField , m_ctxt = mc_what ctxt, m_pats = pats' ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Types.Basic import GHC.Tc.Solver import GHC.Tc.Utils.Unify import GHC.Core.Predicate +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Builtin.Types import GHC.Tc.Utils.TcType import GHC.Tc.Types.Evidence @@ -728,14 +729,14 @@ tcPatSynMatcher (L loc name) lpat L (getLoc lpat) $ HsCase noExtField (nlHsVar scrutinee) $ MG{ mg_alts = L (getLoc lpat) cases - , mg_ext = MatchGroupTc [unrestricted pat_ty] res_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted pat_ty)] res_ty , mg_origin = Generated } body' = noLoc $ HsLam noExtField $ MG{ mg_alts = noLoc [mkSimpleMatch LambdaExpr args body] - , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty + , mg_ext = MatchGroupTc (map (NormalArgType . unrestricted) [pat_ty, cont_ty, fail_ty]) res_ty , mg_origin = Generated } match = mkMatch (mkPrefixFunRhs (L loc name)) [] ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.TcType ( TcTyCon, KnotTied, ExpType(..), InferResult(..), ExpSigmaType, ExpRhoType, mkCheckExpType, + ArgTy(..), scaledExpTypes, SyntaxOpType(..), synKnownType, mkSynFunTys, @@ -398,6 +399,16 @@ instance Outputable InferResult where mkCheckExpType :: TcType -> ExpType mkCheckExpType = Check +data ArgTy + = NormalArgTy (Scaled ExpSigmaType) + | ForallArgTy ReqTVBinder + +scaledExpTypes :: [ArgTy] -> [Scaled ExpSigmaType] +scaledExpTypes [] = [] +scaledExpTypes (arg_ty : arg_tys) + = case arg_ty of + NormalArgTy ty -> ty : scaledExpTypes arg_tys + _ -> scaledExpTypes arg_tys {- ********************************************************************* * * @@ -1286,9 +1297,9 @@ tcSplitPhiTy ty -- | Split a sigma type into its parts. tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type) -tcSplitSigmaTy ty = case tcSplitForAllTys ty of +tcSplitSigmaTy ty = case tcSplitForAllTysInvis ty of (tvs, rho) -> case tcSplitPhiTy rho of - (theta, tau) -> (tvs, theta, tau) + (theta, tau) -> (binderVar <$> tvs, theta, tau) -- | Split a sigma type into its parts, going underneath as many @ForAllTy at s -- as possible. For example, given this type synonym: ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -156,7 +156,7 @@ matchActualFunTySigma herald mb_thing err_info fun_ty ------------ mk_ctxt :: TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) - mk_ctxt res_ty env = mkFunTysMsg env herald (reverse arg_tys_so_far) + mk_ctxt res_ty env = mkFunTysMsg env herald (reverse (NormalArgType <$> arg_tys_so_far)) res_ty n_val_args_in_call (n_val_args_in_call, arg_tys_so_far) = err_info @@ -290,7 +290,7 @@ matchExpectedFunTys :: forall a. -> UserTypeCtxt -> Arity -> ExpRhoType -- Skolemised - -> ([Scaled ExpSigmaType] -> ExpRhoType -> TcM a) + -> ([ArgTy] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) -- If matchExpectedFunTys n ty = (_, wrap) -- then wrap : (t1 -> ... -> tn -> ty_r) ~> ty, @@ -320,7 +320,7 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside go acc_arg_tys n (FunTy { ft_mult = mult, ft_af = af, ft_arg = arg_ty, ft_res = res_ty }) = ASSERT( af == VisArg ) - do { (wrap_res, result) <- go ((Scaled mult $ mkCheckExpType arg_ty) : acc_arg_tys) + do { (wrap_res, result) <- go ((NormalArgTy . Scaled mult $ mkCheckExpType arg_ty) : acc_arg_tys) (n-1) res_ty ; let fun_wrap = mkWpFun idHsWrapper wrap_res (Scaled mult arg_ty) res_ty doc ; return ( fun_wrap, result ) } @@ -328,6 +328,16 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside doc = text "When inferring the argument type of a function with type" <+> quotes (ppr orig_ty) + go acc_arg_tys n ty + | (bndrs, ty') <- tcSplitForAllTysReq ty + , not (null bndrs) + = do { let forall_args = ForallArgTy <$> bndrs + ; let req_arg_tys = forall_args ++ acc_arg_tys + ; let arg_num = n - (length forall_args) + ; (wrap_gen, (wrap_res, result)) <- tcSkolemise ctx ty' $ \ty' -> + go req_arg_tys arg_num ty' + ; return (wrap_gen <.> wrap_res, result) } + go acc_arg_tys n ty@(TyVarTy tv) | isMetaTyVar tv = do { cts <- readMetaTyVar tv @@ -354,11 +364,11 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside defer acc_arg_tys n (mkCheckExpType ty) ------------ - defer :: [Scaled ExpSigmaType] -> Arity -> ExpRhoType -> TcM (HsWrapper, a) + defer :: [ArgTy] -> Arity -> ExpRhoType -> TcM (HsWrapper, a) defer acc_arg_tys n fun_ty = do { more_arg_tys <- replicateM n newInferExpType ; res_ty <- newInferExpType - ; result <- thing_inside (reverse acc_arg_tys ++ (map unrestricted more_arg_tys)) res_ty + ; result <- thing_inside (reverse acc_arg_tys ++ (map (NormalArgTy . unrestricted) more_arg_tys)) res_ty ; more_arg_tys <- mapM readExpType more_arg_tys ; res_ty <- readExpType res_ty ; let unif_fun_ty = mkVisFunTysMany more_arg_tys res_ty @@ -367,19 +377,24 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside ; return (wrap, result) } ------------ - mk_ctxt :: [Scaled ExpSigmaType] -> TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) + mk_ctxt :: [ArgTy] -> TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) mk_ctxt arg_tys res_ty env = mkFunTysMsg env herald arg_tys' res_ty arity where - arg_tys' = map (\(Scaled u v) -> Scaled u (checkingExpType "matchExpectedFunTys" v)) $ - reverse arg_tys + arg_tys' = map toArgType (reverse arg_tys) + + toArgType (NormalArgTy (Scaled u v)) + = NormalArgType (Scaled u (checkingExpType "matchExpectedFunTys" v)) + toArgType (ForallArgTy bndr) + = ForallArgType bndr + -- this is safe b/c we're called from "go" -mkFunTysMsg :: TidyEnv -> SDoc -> [Scaled TcType] -> TcType -> Arity +mkFunTysMsg :: TidyEnv -> SDoc -> [ArgType] -> TcType -> Arity -> TcM (TidyEnv, MsgDoc) mkFunTysMsg env herald arg_tys res_ty n_val_args_in_call = do { (env', fun_rho) <- zonkTidyTcType env $ - mkVisFunTys arg_tys res_ty + mkVisFunForallTys arg_tys res_ty ; let (all_arg_tys, _) = splitFunTys fun_rho n_fun_args = length all_arg_tys ===================================== compiler/GHC/Tc/Utils/Zonk.hs ===================================== @@ -82,6 +82,7 @@ import GHC.Utils.Panic import GHC.Types.Unique.FM import GHC.Core.Multiplicity import GHC.Core +import GHC.Core.TyCo.Rep (ArgType(..), normalArgTys) import {-# SOURCE #-} GHC.Tc.Gen.Splice (runTopSplice) @@ -671,10 +672,10 @@ zonkMatchGroup env zBody (MG { mg_alts = L l ms , mg_ext = MatchGroupTc arg_tys res_ty , mg_origin = origin }) = do { ms' <- mapM (zonkMatch env zBody) ms - ; arg_tys' <- zonkScaledTcTypesToTypesX env arg_tys + ; arg_tys' <- zonkScaledTcTypesToTypesX env (normalArgTys arg_tys) ; res_ty' <- zonkTcTypeToTypeX env res_ty ; return (MG { mg_alts = L l ms' - , mg_ext = MatchGroupTc arg_tys' res_ty' + , mg_ext = MatchGroupTc (NormalArgType <$> arg_tys') res_ty' , mg_origin = origin }) } zonkMatch :: ZonkEnv ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -567,11 +567,6 @@ linearityAllowed = typeLevelUserTypeCtxt -- where VDQ is permitted) and -- @testsuite/tests/dependent/should_fail/T16326_Fail*.hs@ (for places where -- VDQ is disallowed). -vdqAllowed :: UserTypeCtxt -> Bool -vdqAllowed ctxt = case typeOrKindCtxt ctxt of - OnlyTypeCtxt -> False - OnlyKindCtxt -> True - BothTypeAndKindCtxt -> True {- Note [Correctness and performance of type synonym validity checking] @@ -724,7 +719,7 @@ check_type ve (CastTy ty _) = check_type ve ty -- -- Critically, this case must come *after* the case for TyConApp. -- See Note [Liberal type synonyms]. -check_type ve@(ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt +check_type ve@(ValidityEnv{ ve_tidy_env = env , ve_rank = rank, ve_expand = expand }) ty | not (null tvbs && null theta) = do { traceTc "check_type" (ppr ty $$ ppr rank) @@ -736,12 +731,6 @@ check_type ve@(ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt -- Reject forall (a :: Eq b => b). blah -- In a kind signature we don't allow constraints - ; checkTcM (all (isInvisibleArgFlag . binderArgFlag) tvbs - || vdqAllowed ctxt) - (illegalVDQTyErr env ty) - -- Reject visible, dependent quantification in the type of a - -- term (e.g., `f :: forall a -> a -> Maybe a`) - ; check_valid_theta env' SigmaCtxt expand theta -- Allow type T = ?x::Int => Int -> Int -- but not type T = ?x::Int @@ -999,15 +988,6 @@ constraintTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) constraintTyErr env ty = (env, text "Illegal constraint in a kind:" <+> ppr_tidy env ty) --- | Reject a use of visible, dependent quantification in the type of a term. -illegalVDQTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) -illegalVDQTyErr env ty = - (env, vcat - [ hang (text "Illegal visible, dependent quantification" <+> - text "in the type of a term:") - 2 (ppr_tidy env ty) - , text "(GHC does not yet support this)" ] ) - -- | Reject uses of linear function arrows in kinds. linearFunKindErr :: TidyEnv -> Type -> (TidyEnv, SDoc) linearFunKindErr env ty = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f1489c62741b56c252e571678becd407a906c6b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6f1489c62741b56c252e571678becd407a906c6b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 12:26:29 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 19 Oct 2020 08:26:29 -0400 Subject: [Git][ghc/ghc][wip/T18723] 12 commits: Clarify Eq documentation #18713 Message-ID: <5f8d85f575e38_28003fd3ee895524100457b@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18723 at Glasgow Haskell Compiler / GHC Commits: 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 82902c87 by Ryan Scott at 2020-10-19T08:25:58-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - libraries/ghc-prim/GHC/Classes.hs - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36b1df64308f7c2f2dce45ce1fbbfad813459b7f...82902c87c373e8a5cf1b15028e808cfe1537ced3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/36b1df64308f7c2f2dce45ce1fbbfad813459b7f...82902c87c373e8a5cf1b15028e808cfe1537ced3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 13:37:05 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Mon, 19 Oct 2020 09:37:05 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/ci_validate Message-ID: <5f8d96819a917_28003fd4095f8b84102405d@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/ci_validate at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/ci_validate You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 13:48:50 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 19 Oct 2020 09:48:50 -0400 Subject: [Git][ghc/ghc][wip/ghc-281-proposal-visible-foralls-proto] fix Message-ID: <5f8d9942c1da5_2800109a35481027387@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-281-proposal-visible-foralls-proto at Glasgow Haskell Compiler / GHC Commits: 3cd65784 by Daniel Rogozin at 2020-10-19T16:48:07+03:00 fix - - - - - 1 changed file: - compiler/GHC/Tc/Gen/App.hs Changes: ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -313,16 +313,6 @@ tcValArgs quick_look fun args tc_arg n (EWrap wrap) = return (n, EWrap wrap) tc_arg n (ETypeArg l hs_ty ty) = return (n+1, ETypeArg l hs_ty ty) - tc_arg n (EValArg { eva_loc = loc - , eva_arg = ValArg (L l (HsVar noExtField tvname@(L l' name))) - , eva_arg_ty = ty }) - = return (n + 1, (ETypeArg loc arg' (irrelevantMult ty))) - where - arg' = HsWC { hswc_body = (L l ty_arg) - , hswc_ext = [name] - } - ty_arg = HsTyVar NoExtField IsPromoted tvname - tc_arg n eva@(EValArg { eva_arg = arg, eva_arg_ty = Scaled mult arg_ty }) = do { -- Crucial step: expose QL results before checking arg_ty -- So far as the paper is concerned, this step applies View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cd657848f0fb70d530cefbd415ca07a7de9c0f8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3cd657848f0fb70d530cefbd415ca07a7de9c0f8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 14:30:11 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Mon, 19 Oct 2020 10:30:11 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-debug_pause_and_resume Message-ID: <5f8da2f3274ea_28007bc340810289b6@gitlab.haskell.org.mail> David Eichmann pushed new branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-debug_pause_and_resume You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 14:41:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 10:41:49 -0400 Subject: [Git][ghc/ghc][wip/T18857] 12 commits: gitlab-ci: Allow doc-tarball job to fail Message-ID: <5f8da5ad612d5_28003fd40908a99010339c2@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18857 at Glasgow Haskell Compiler / GHC Commits: aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 23fdc9a0 by Ben Gamari at 2020-10-19T10:41:42-04:00 CmmToLlvm: Declare signature for memcmp Otherwise `opt` fails with: error: use of undefined value '@memcmp$def' Fixes #18857. - - - - - e3d27b0d by Ben Gamari at 2020-10-19T10:41:42-04:00 gitlab-ci: Run LLVM job on appropriately-labelled MRs Namely, those marked with the ~"LLVM backend" label - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h - includes/ghc.mk - libraries/base/.hlint.yaml - rts/RtsAPI.c - rts/RtsSymbols.c - − testsuite/tests/arityanal/Main.hs - − testsuite/tests/arityanal/Main.stderr - testsuite/tests/arityanal/Makefile - − testsuite/tests/arityanal/f0.stderr - − testsuite/tests/arityanal/f1.stderr - − testsuite/tests/arityanal/f10.stderr - − testsuite/tests/arityanal/f11.stderr - − testsuite/tests/arityanal/f12.stderr - − testsuite/tests/arityanal/f13.stderr - − testsuite/tests/arityanal/f14.stderr - − testsuite/tests/arityanal/f15.stderr - − testsuite/tests/arityanal/f2.stderr - − testsuite/tests/arityanal/f3.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aeb6d056ab52547358c3036454c668b13179f021...e3d27b0dce777098aafd95f958a3b100b93dabf1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aeb6d056ab52547358c3036454c668b13179f021...e3d27b0dce777098aafd95f958a3b100b93dabf1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:05:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 11:05:50 -0400 Subject: [Git][ghc/ghc][wip/T18854] 28 commits: Remove Proxy# argument in Data.Typeable.Internal Message-ID: <5f8dab4e67f3e_28003fd405cc36d41039285@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - e898118a by Ben Gamari at 2020-10-19T11:05:45-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/Constants.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generics.hs - compiler/GHC/Tc/Deriv/Utils.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Types/Evidence.hs - configure.ac - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/ffi.rst - docs/users_guide/using-optimisation.rst - hadrian/src/Rules/Generate.hs - includes/RtsAPI.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c9b13ee70835352d6cf808aad8ef5efbdc7e2ec...e898118a90ab68dc9388d9643d282e8f0ebcbb0b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c9b13ee70835352d6cf808aad8ef5efbdc7e2ec...e898118a90ab68dc9388d9643d282e8f0ebcbb0b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:10:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 11:10:01 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/flavour Message-ID: <5f8dac494e81a_28003fd3850e77b410400cb@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/flavour at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/flavour You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:12:39 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 11:12:39 -0400 Subject: [Git][ghc/ghc][wip/T18854] Document that ccall convention doesn't support varargs Message-ID: <5f8dace7cc883_28003fd4093f13e01044823@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: 3d61ff71 by Ben Gamari at 2020-10-19T11:12:31-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 4 changed files: - docs/users_guide/exts/ffi.rst - testsuite/tests/rts/T5423.hs - testsuite/tests/rts/T5423_c.c - testsuite/tests/rts/T5423_cmm.cmm Changes: ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -83,6 +83,21 @@ For more details on the implementation see the Paper: Last known to be accessible `here `_. +Varargs not supported by ``ccall`` calling convention +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that functions requiring varargs arguments are unsupported by the ``ccall`` +calling convention. Foreign imports needing to call such functions should rather +use the ``capi`` convention, giving an explicit signature for the needed +call-pattern. For instance, one could write: :: + + foreign import "capi" "printf" + my_printf :: Ptr CChar -> CInt -> IO () + + printInt :: CInt -> IO () + printInt n = my_printf "printed number %d" n + + .. _ffi-ghcexts: GHC extensions to the FFI Chapter ===================================== testsuite/tests/rts/T5423.hs ===================================== @@ -1,3 +1,5 @@ +-- | Verify that @foreign import prim@ calls with more than 10 arguments +-- are lowered correctly. {-# LANGUAGE MagicHash, GHCForeignImportPrim, UnliftedFFITypes #-} ===================================== testsuite/tests/rts/T5423_c.c ===================================== @@ -1,6 +1,24 @@ +#include #include void flush_stdout(void) { fflush(stdout); } + +void print_it( + StgWord r1, + StgWord r2, + StgWord r3, + StgWord r4, + StgWord r5, + StgWord r5, + StgWord r7, + StgWord r8, + StgWord r9, + StgWord r10 + ) +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", + r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); +} ===================================== testsuite/tests/rts/T5423_cmm.cmm ===================================== @@ -10,7 +10,6 @@ test (W_ r1, W_ r9, W_ r10) { - foreign "C" printf("%d %d %d %d %d %d %d %d %d %d\n", - r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); + foreign "C" test_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); return (r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d61ff71dc24bfd6b6db4d7291e569f365a153b7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d61ff71dc24bfd6b6db4d7291e569f365a153b7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:14:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 11:14:37 -0400 Subject: [Git][ghc/ghc][ghc-8.8] Add a flag to indicate that gcc supports -no-pie Message-ID: <5f8dad5d86e76_28003fd3850e77b4105068b@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.8 at Glasgow Haskell Compiler / GHC Commits: 597df8cd by Krzysztof Gogolewski at 2020-10-19T11:40:42+02:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - 2 changed files: - compiler/main/DynFlags.hs - docs/users_guide/phases.rst Changes: ===================================== compiler/main/DynFlags.hs ===================================== @@ -3011,6 +3011,8 @@ dynamic_flags_deps = [ -- Don't pass -no-pie with -pgmc -- (see Trac #15319) sGccSupportsNoPie = False}))) + , make_ord_flag defFlag "pgmc-supports-no-pie" + (noArg $ alterSettings $ \s -> s { sGccSupportsNoPie = True }) , make_ord_flag defFlag "pgms" (hasArg (\f -> alterSettings (\s -> s { sPgm_s = (f,[])}))) , make_ord_flag defFlag "pgma" ===================================== docs/users_guide/phases.rst ===================================== @@ -172,6 +172,20 @@ the following flags: Pass ⟨option⟩ to the C compiler. +.. ghc-flag:: -pgmc-supports-no-pie + :shortdesc: Indicate that the C compiler supports ``-no-pie`` + :type: dynamic + :category: phase-options + + When ``-pgmc`` is used, GHC by default will never pass the ``-no-pie`` + command line flag. The rationale is that it is not known whether the + specified compiler will support it. This flag can be used to indicate + that ``-no-pie`` is supported. It has to be passed after ``-pgmc``. + + This flag is not neccessary when ``-pgmc`` is not used, since GHC + remembers whether the default C compiler supports ``-no-pie`` in + an internal settings file. + .. ghc-flag:: -optlo ⟨option⟩ :shortdesc: pass ⟨option⟩ to the LLVM optimiser :type: dynamic View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/597df8cd2ed72889c41049488e5b62168fef13f9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/597df8cd2ed72889c41049488e5b62168fef13f9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:14:41 2020 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski) Date: Mon, 19 Oct 2020 11:14:41 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backports-8.8 Message-ID: <5f8dad61431f0_28003fd3ee1cef241052028@gitlab.haskell.org.mail> Krzysztof Gogolewski deleted branch wip/backports-8.8 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:16:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 19 Oct 2020 11:16:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f8dadc99eaf4_28003fd3ee1cef241058477@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: efa68d22 by Vladislav Zavialov at 2020-10-19T11:16:09-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - cd32505c by Sylvain Henry at 2020-10-19T11:16:14-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - 20 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/Cmm/DebugBlock.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -520,18 +521,22 @@ data UnwindExpr = UwConst !Int -- ^ literal value deriving (Eq) instance OutputableP env CLabel => OutputableP env UnwindExpr where - pdocPrec _ _ (UwConst i) = ppr i - pdocPrec _ _ (UwReg g 0) = ppr g - pdocPrec p env (UwReg g x) = pdocPrec p env (UwPlus (UwReg g 0) (UwConst x)) - pdocPrec _ env (UwDeref e) = char '*' <> pdocPrec 3 env e - pdocPrec _ env (UwLabel l) = pdocPrec 3 env l - pdocPrec p env (UwPlus e0 e1) | p <= 0 - = pdocPrec 0 env e0 <> char '+' <> pdocPrec 0 env e1 - pdocPrec p env (UwMinus e0 e1) | p <= 0 - = pdocPrec 1 env e0 <> char '-' <> pdocPrec 1 env e1 - pdocPrec p env (UwTimes e0 e1) | p <= 1 - = pdocPrec 2 env e0 <> char '*' <> pdocPrec 2 env e1 - pdocPrec _ env other = parens (pdocPrec 0 env other) + pdoc = pprUnwindExpr 0 + +pprUnwindExpr :: OutputableP env CLabel => Rational -> env -> UnwindExpr -> SDoc +pprUnwindExpr p env = \case + UwConst i -> ppr i + UwReg g 0 -> ppr g + UwReg g x -> pprUnwindExpr p env (UwPlus (UwReg g 0) (UwConst x)) + UwDeref e -> char '*' <> pprUnwindExpr 3 env e + UwLabel l -> pdoc env l + UwPlus e0 e1 + | p <= 0 -> pprUnwindExpr 0 env e0 <> char '+' <> pprUnwindExpr 0 env e1 + UwMinus e0 e1 + | p <= 0 -> pprUnwindExpr 1 env e0 <> char '-' <> pprUnwindExpr 1 env e1 + UwTimes e0 e1 + | p <= 1 -> pprUnwindExpr 2 env e0 <> char '*' <> pprUnwindExpr 2 env e1 + other -> parens (pprUnwindExpr 0 env other) -- | Conversion of Cmm expressions to unwind expressions. We check for -- unsupported operator usages and simplify the expression as far as ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -501,6 +501,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3328,7 +3328,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4085,7 +4087,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnInaccessibleCode, Opt_WarnSpaceAfterBang, Opt_WarnNonCanonicalMonadInstances, - Opt_WarnNonCanonicalMonoidInstances + Opt_WarnNonCanonicalMonoidInstances, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,34 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax" + $$ nest 2 (text "by a future language extension.") + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -1045,12 +1045,6 @@ instance Outputable Extension where -- See Note [The OutputableP class] class OutputableP env a where pdoc :: env -> a -> SDoc - pdocPrec :: Rational -> env -> a -> SDoc - -- 0 binds least tightly - -- We use Rational because there is always a - -- Rational between any other two Rationals - pdoc = pdocPrec 0 - pdocPrec _ = pdoc -- | Wrapper for types having a Outputable instance when an OutputableP instance -- is required. ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1853,6 +1854,7 @@ of ``-W(no-)*``. .. ghc-flag:: -Winvalid-haddock :shortdesc: warn when a Haddock comment occurs in an invalid position :type: dynamic + :reverse: -Wno-invalid-haddock :category: :since: 9.0 @@ -1869,6 +1871,56 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :reverse: -Wno-operator-whitespace-ext-conflict + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :reverse: -Wno-operator-whitespace + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86a9f089a0c0aaa8d8d706415a4ae394b7924c79...cd32505ccbf6dc77575990833d0e82d8db512a5b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86a9f089a0c0aaa8d8d706415a4ae394b7924c79...cd32505ccbf6dc77575990833d0e82d8db512a5b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 15:29:58 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 11:29:58 -0400 Subject: [Git][ghc/ghc][wip/T18835] hadrian: Suppress xelatex output unless it fails Message-ID: <5f8db0f636871_28003fd388dd18dc1072497@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18835 at Glasgow Haskell Compiler / GHC Commits: 6abe51a1 by Ben Gamari at 2020-10-19T11:29:45-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 1 changed file: - hadrian/src/Builder.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -27,6 +27,8 @@ import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities +import qualified Data.ByteString.Lazy.Char8 as BSL + import Base import Context import Oracles.Flag @@ -286,7 +288,18 @@ instance H.Builder Builder where Makeinfo -> do cmd' echo [path] "--no-split" [ "-o", output] [input] - Xelatex -> unit $ cmd' [Cwd output] [path] buildArgs + Xelatex -> + -- xelatex produces an incredible amount of output, almost + -- all of which is useless. Suppress it unless user + -- requests a loud build. + if verbosity >= Loud + then cmd' [Cwd output] [path] buildArgs + else do (Stdouterr out, Exit code) <- cmd' [Cwd output] [path] buildArgs + when (code /= ExitSuccess) $ + BSL.hPutStrLn stderr out + putFailure "xelatex failed!" + fail "xelatex failed" + Makeindex -> unit $ cmd' [Cwd output] [path] (buildArgs ++ [input]) Tar _ -> cmd' buildOptions echo [path] buildArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6abe51a19efda90ff37b8311cc054713ce316ffb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6abe51a19efda90ff37b8311cc054713ce316ffb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 16:01:55 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Mon, 19 Oct 2020 12:01:55 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18855 Message-ID: <5f8db873824f4_28003fd40281194010810a0@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18855 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18855 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 17:46:01 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Mon, 19 Oct 2020 13:46:01 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f8dd0d9404e4_28003fd3e82b29f01101070@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: 18bf10eb by David Eichmann at 2020-10-19T18:43:31+01:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -330,14 +330,49 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. +/* Note [Locking and Pausing the RTS] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You have to surround all access to the RtsAPI with rts_lock/rts_unlock +or with rts_pause/rts_resume. + +# rts_pause / rts_resume + +Halt execution of all Haskell threads by acquiring all capabilities. +rts_resume must later be called on the same thread to resume the RTS. Returns +a token which may be used to create new objects and evaluate them (like +rts_lock). + +rts_pause does not pause threads running safe FFI calls. Only one thread at a +time can keep the rts paused. The rts_pause function will block until the +current thread is given exclusive permission to pause the RTS. It is an error +if the RTS is already paused by the current OS thread. rts_pause is different +to rts_lock which only pauses a single capability. Calling rts_pause in +between rts_lock/rts_unlock on the same thread will cause an error. Calling +rts_pause from an unsafe FFI call will also cause an error (safe FFI calls +are ok). + + + - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ -// acquires a token which may be used to create new objects and -// evaluate them. +TODO + * This note should give a good overview of the whole pause/lock mechanism. It + should first explain correct usage, then explaing implementation details + * Do we want to say why we chose to track rts_pausing_task + * If we just check that we own all caps then ??? Ugg I just tried this and gave up. + Why? I think somehow the error messages are nicer with rts_pausing_task + * explain that both lock/pause is implemented by acquiring a capability + + + + + +*/ + +// acquires a token which may be used to create new objects and evaluate them. +// Calling rts_lock in between rts_pause/rts_resume on the same thread will +// cause an error. Capability *rts_lock (void); // releases the token acquired with rts_lock(). @@ -483,6 +518,29 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads by acquiring all capabilities. +// rts_resume must later be called on the same thread to resume the RTS. Returns +// a token which may be used to create new objects and evaluate them (like +// rts_lock). +// +// rts_pause does not pause threads running safe FFI calls. Only one thread at a +// time can keep the rts paused. The rts_pause function will block until the +// current thread is given exclusive permission to pause the RTS. It is an error +// if the RTS is already paused by the current OS thread. rts_pause is different +// to rts_lock which only pauses a single capability. Calling rts_pause in +// between rts_lock/rts_unlock on the same thread will cause an error. Calling +// rts_pause from an unsafe FFI call will also cause an error (safe FFI calls +// are ok). +Capability * rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. All capabilities are +// released. Must be called on the same thread as rts_pause(). +// [in] cap: the token returned by rts_pause. +void rts_resume (Capability * cap); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,14 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,12 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +599,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already call rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +634,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +659,167 @@ rts_unlock (Capability *cap) } } +#if defined(THREADED_RTS) + +/* + * NOTE RtsAPI thread safety: + * + * Although it's likely sufficient for many use cases to call RtsAPI.h functions + * from a single thread, we still want to ensure that the API is thread safe. + * This is achieved almost entirely by the mechanism of acquiring and releasing + * Capabilities, resulting in a sort of mutex / critical section pattern. + * Correct usage of this API requires that you surround API calls in + * rts_lock/rts_unlock or rts_pause/rts_resume. This ensures that the thread + * owns a capability while calling other RtsAPI functions (in the case of + * rts_pause/rts_resume the thread owns *all* capabilities). + * + * With the capability(s) acquired, GC cannot run. That allows access to the + * heap without objects unexpectedly moving, which is important for many of the + * functions in RtsAPI. + * + * Other important consequences are: + * + * * There are at most `n_capabilities` threads currently in a + * rts_lock/rts_unlock section. + * * There is at most 1 threads in a rts_pause/rts_resume section. In that case + * there will be no threads in a rts_lock/rts_unlock section. + * * rts_pause and rts_lock may block in order to enforce the above 2 + * invariants. + */ + +// See RtsAPI.h +Capability * rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (at it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + return task->cap; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See RtsAPI.h The cap argument is here just for symmetry with rts_pause and to +// match the pattern of rts_lock/rts_unlock. +void rts_resume (Capability * cap STG_UNUSED) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +Capability * GNU_ATTRIBUTE(__noreturn__) +rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (Capability * cap STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +855,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,15 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1573,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2096,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2776,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2835,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,12 @@ +test('pause_resume_via_safe_ffi', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,250 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + Capability * cap = rts_pause(); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + Capability * cap2 = rts_pause(); // This should have no effect and return immediately. + if(cap != cap2) { + errorBelch("A second call to rts_pause() returned a different Capability."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(cap); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + Capability * cap = rts_pause(); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + + // TODO print out what funciton is running to give better debug output if one of these deadlocks + + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(cap); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + safe_pthread_join_c :: CULong -> IO () + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,20 @@ + +test('unsafe_rts_pause', [only_ways(threaded_ways), exit_code(1)], compile_and_run, ['']) +test('rts_lock_when_paused', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + poke donePtr 0 + forkOS $ safe_assertDoneAfterOneSecond_c donePtr + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + poke donePtr 0 +-- forkOS $ safe_assertDoneAfterOneSecond_c donePtr + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,79 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + Capability * pauseCapA = rts_pause(); + printf("Paused\n"); + + printf("Pausing..."); + Capability * pauseCapB = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_unlock(pauseCapA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(pauseCapB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,19 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + poke donePtr 0 +-- forkOS $ safe_assertDoneAfterOneSecond_c donePtr + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already call rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18bf10eb2938e5397f89b6190fc0700684b10572 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18bf10eb2938e5397f89b6190fc0700684b10572 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 20:45:40 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 16:45:40 -0400 Subject: [Git][ghc/ghc][wip/T18835] 46 commits: Move File Target parser to library #18596 Message-ID: <5f8dfaf4a09bb_28003fd3ed653de811281a7@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18835 at Glasgow Haskell Compiler / GHC Commits: 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - 350f0a39 by Ben Gamari at 2020-10-19T16:44:15-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs - compiler/GHC/CmmToAsm/Reg/Linear/PPC.hs - compiler/GHC/CmmToAsm/Reg/Linear/SPARC.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - compiler/GHC/Core/FamInstEnv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6abe51a19efda90ff37b8311cc054713ce316ffb...350f0a39e535182f2cfcbc05e11b232df13f6b88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6abe51a19efda90ff37b8311cc054713ce316ffb...350f0a39e535182f2cfcbc05e11b232df13f6b88 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 20:46:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 16:46:50 -0400 Subject: [Git][ghc/ghc][wip/T18854] Document that ccall convention doesn't support varargs Message-ID: <5f8dfb3a660b3_28003fd40d0e9e78112871f@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: 86380ed1 by Ben Gamari at 2020-10-19T16:46:42-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 4 changed files: - docs/users_guide/exts/ffi.rst - testsuite/tests/rts/T5423.hs - testsuite/tests/rts/T5423_c.c - testsuite/tests/rts/T5423_cmm.cmm Changes: ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -83,6 +83,21 @@ For more details on the implementation see the Paper: Last known to be accessible `here `_. +Varargs not supported by ``ccall`` calling convention +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Note that functions requiring varargs arguments are unsupported by the ``ccall`` +calling convention. Foreign imports needing to call such functions should rather +use the ``capi`` convention, giving an explicit signature for the needed +call-pattern. For instance, one could write: :: + + foreign import "capi" "printf" + my_printf :: Ptr CChar -> CInt -> IO () + + printInt :: CInt -> IO () + printInt n = my_printf "printed number %d" n + + .. _ffi-ghcexts: GHC extensions to the FFI Chapter ===================================== testsuite/tests/rts/T5423.hs ===================================== @@ -1,3 +1,5 @@ +-- | Verify that @foreign import prim@ calls with more than 10 arguments +-- are lowered correctly. {-# LANGUAGE MagicHash, GHCForeignImportPrim, UnliftedFFITypes #-} ===================================== testsuite/tests/rts/T5423_c.c ===================================== @@ -1,6 +1,24 @@ +#include #include void flush_stdout(void) { fflush(stdout); } + +void print_it( + StgWord r1, + StgWord r2, + StgWord r3, + StgWord r4, + StgWord r5, + StgWord r6, + StgWord r7, + StgWord r8, + StgWord r9, + StgWord r10 + ) +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", + r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); +} ===================================== testsuite/tests/rts/T5423_cmm.cmm ===================================== @@ -10,7 +10,6 @@ test (W_ r1, W_ r9, W_ r10) { - foreign "C" printf("%d %d %d %d %d %d %d %d %d %d\n", - r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); + foreign "C" test_it(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10); return (r10); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86380ed17f0d5b2bc0b9d40a9edd03c1c7bbde39 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/86380ed17f0d5b2bc0b9d40a9edd03c1c7bbde39 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 22:16:28 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 19 Oct 2020 18:16:28 -0400 Subject: [Git][ghc/ghc][master] Implement -Woperator-whitespace (#18834) Message-ID: <5f8e103c6cc31_2800a3d56f811386fa@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 18 changed files: - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T - testsuite/tests/typecheck/should_compile/T16312.hs - utils/haddock Changes: ===================================== compiler/GHC/Cmm/CallConv.hs ===================================== @@ -207,14 +207,14 @@ nodeOnly = ([VanillaReg 1], [], [], [], []) realArgRegsCover :: Platform -> [GlobalReg] realArgRegsCover platform | passFloatArgsInXmm platform - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realLongRegs platform ++ realDoubleRegs platform -- we only need to save the low Double part of XMM registers. -- Moreover, the NCG can't load/store full XMM -- registers for now... | otherwise - = map ($VGcPtr) (realVanillaRegs platform) ++ + = map ($ VGcPtr) (realVanillaRegs platform) ++ realFloatRegs platform ++ realDoubleRegs platform ++ realLongRegs platform ===================================== compiler/GHC/CmmToLlvm/Regs.hs ===================================== @@ -50,12 +50,12 @@ lmGlobalReg platform suf reg VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf SpLim -> wordGlobal $ "SpLim" ++ suf - FloatReg 1 -> floatGlobal $"F1" ++ suf - FloatReg 2 -> floatGlobal $"F2" ++ suf - FloatReg 3 -> floatGlobal $"F3" ++ suf - FloatReg 4 -> floatGlobal $"F4" ++ suf - FloatReg 5 -> floatGlobal $"F5" ++ suf - FloatReg 6 -> floatGlobal $"F6" ++ suf + FloatReg 1 -> floatGlobal $ "F1" ++ suf + FloatReg 2 -> floatGlobal $ "F2" ++ suf + FloatReg 3 -> floatGlobal $ "F3" ++ suf + FloatReg 4 -> floatGlobal $ "F4" ++ suf + FloatReg 5 -> floatGlobal $ "F5" ++ suf + FloatReg 6 -> floatGlobal $ "F6" ++ suf DoubleReg 1 -> doubleGlobal $ "D1" ++ suf DoubleReg 2 -> doubleGlobal $ "D2" ++ suf DoubleReg 3 -> doubleGlobal $ "D3" ++ suf ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -501,6 +501,8 @@ data WarningFlag = | Opt_WarnCompatUnqualifiedImports -- Since 8.10 | Opt_WarnDerivingDefaults | Opt_WarnInvalidHaddock -- Since 8.12 + | Opt_WarnOperatorWhitespaceExtConflict -- Since 9.2 + | Opt_WarnOperatorWhitespace -- Since 9.2 deriving (Eq, Show, Enum) -- | Used when outputting warnings: if a reason is given, it is ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3328,7 +3328,9 @@ wWarningFlagsDeps = [ Opt_WarnPrepositiveQualifiedModule, flagSpec "unused-packages" Opt_WarnUnusedPackages, flagSpec "compat-unqualified-imports" Opt_WarnCompatUnqualifiedImports, - flagSpec "invalid-haddock" Opt_WarnInvalidHaddock + flagSpec "invalid-haddock" Opt_WarnInvalidHaddock, + flagSpec "operator-whitespace-ext-conflict" Opt_WarnOperatorWhitespaceExtConflict, + flagSpec "operator-whitespace" Opt_WarnOperatorWhitespace ] -- | These @-\@ flags can all be reversed with @-no-\@ @@ -4085,7 +4087,8 @@ standardWarnings -- see Note [Documenting warning flags] Opt_WarnInaccessibleCode, Opt_WarnSpaceAfterBang, Opt_WarnNonCanonicalMonadInstances, - Opt_WarnNonCanonicalMonoidInstances + Opt_WarnNonCanonicalMonoidInstances, + Opt_WarnOperatorWhitespaceExtConflict ] -- | Things you get with -W ===================================== compiler/GHC/Parser/Errors.hs ===================================== @@ -1,6 +1,8 @@ module GHC.Parser.Errors ( Warning(..) , TransLayoutReason(..) + , OperatorWhitespaceSymbol(..) + , OperatorWhitespaceOccurrence(..) , NumUnderscoreReason(..) , Error(..) , ErrorDesc(..) @@ -57,6 +59,20 @@ data Warning | WarnImportPreQualified !SrcSpan -- ^ Pre qualified import with 'WarnPrepositiveQualifiedModule' enabled + | WarnOperatorWhitespaceExtConflict !SrcSpan !OperatorWhitespaceSymbol + | WarnOperatorWhitespace !SrcSpan !FastString !OperatorWhitespaceOccurrence + +-- | The operator symbol in the 'WarnOperatorWhitespaceExtConflict' warning. +data OperatorWhitespaceSymbol + = OperatorWhitespaceSymbol_PrefixPercent + | OperatorWhitespaceSymbol_PrefixDollar + | OperatorWhitespaceSymbol_PrefixDollarDollar + +-- | The operator occurrence type in the 'WarnOperatorWhitespace' warning. +data OperatorWhitespaceOccurrence + = OperatorWhitespaceOccurrence_Prefix + | OperatorWhitespaceOccurrence_Suffix + | OperatorWhitespaceOccurrence_TightInfix data TransLayoutReason = TransLayout_Where -- ^ "`where' clause at the same depth as implicit layout block" ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -102,6 +102,34 @@ pprWarning = \case <+> text "after the module name instead." $$ text "To allow this, enable language extension 'ImportQualifiedPost'" + WarnOperatorWhitespaceExtConflict loc sym + -> mkParserWarn Opt_WarnOperatorWhitespaceExtConflict loc $ + let mk_prefix_msg operator_symbol extension_name syntax_meaning = + text "The prefix use of a" <+> quotes (text operator_symbol) + <+> text "would denote" <+> text syntax_meaning + $$ nest 2 (text "were the" <+> text extension_name <+> text "extension enabled.") + $$ text "Suggested fix: add whitespace after the" + <+> quotes (text operator_symbol) <> char '.' + in + case sym of + OperatorWhitespaceSymbol_PrefixPercent -> mk_prefix_msg "%" "LinearTypes" "a multiplicity annotation" + OperatorWhitespaceSymbol_PrefixDollar -> mk_prefix_msg "$" "TemplateHaskell" "an untyped splice" + OperatorWhitespaceSymbol_PrefixDollarDollar -> mk_prefix_msg "$$" "TemplateHaskell" "a typed splice" + + + WarnOperatorWhitespace loc sym occ_type + -> mkParserWarn Opt_WarnOperatorWhitespace loc $ + let mk_msg occ_type_str = + text "The" <+> text occ_type_str <+> text "use of a" <+> quotes (ftext sym) + <+> text "might be repurposed as special syntax" + $$ nest 2 (text "by a future language extension.") + $$ text "Suggested fix: add whitespace around it." + in + case occ_type of + OperatorWhitespaceOccurrence_Prefix -> mk_msg "prefix" + OperatorWhitespaceOccurrence_Suffix -> mk_msg "suffix" + OperatorWhitespaceOccurrence_TightInfix -> mk_msg "tight infix" + pprError :: Error -> ErrMsg pprError err = mkParserErr (errLoc err) $ vcat (pp_err (errDesc err) : map pp_hint (errHints err)) ===================================== compiler/GHC/Parser/Lexer.x ===================================== @@ -1572,42 +1572,65 @@ qconsym buf len = ITqconsym $! splitQualName buf len False -- See Note [Whitespace-sensitive operator parsing] varsym_prefix :: Action -varsym_prefix = sym $ \exts s -> - if | s == fsLit "@" -- regardless of TypeApplications for better error messages - -> return ITtypeApp - | LinearTypesBit `xtest` exts, s == fsLit "%" - -> return ITpercent - | ThQuotesBit `xtest` exts, s == fsLit "$" - -> return ITdollar - | ThQuotesBit `xtest` exts, s == fsLit "$$" - -> return ITdollardollar - | s == fsLit "-" -- Only when LexicalNegation is on, otherwise we get ITminus and - -- don't hit this code path. See Note [Minus tokens] - -> return ITprefixminus +varsym_prefix = sym $ \span exts s -> + let warnExtConflict errtok = + do { addWarning Opt_WarnOperatorWhitespaceExtConflict $ + WarnOperatorWhitespaceExtConflict (mkSrcSpanPs span) errtok + ; return (ITvarsym s) } + in + if | s == fsLit "@" -> + return ITtypeApp -- regardless of TypeApplications for better error messages + | s == fsLit "%" -> + if xtest LinearTypesBit exts + then return ITpercent + else warnExtConflict OperatorWhitespaceSymbol_PrefixPercent + | s == fsLit "$" -> + if xtest ThQuotesBit exts + then return ITdollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollar + | s == fsLit "$$" -> + if xtest ThQuotesBit exts + then return ITdollardollar + else warnExtConflict OperatorWhitespaceSymbol_PrefixDollarDollar + | s == fsLit "-" -> + return ITprefixminus -- Only when LexicalNegation is on, otherwise we get ITminus + -- and don't hit this code path. See Note [Minus tokens] | s == fsLit "!" -> return ITbang | s == fsLit "~" -> return ITtilde - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Prefix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_suffix :: Action -varsym_suffix = sym $ \_ s -> +varsym_suffix = sym $ \span _ s -> if | s == fsLit "@" -> failMsgP (Error ErrSuffixAT []) - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_Suffix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_tight_infix :: Action -varsym_tight_infix = sym $ \_ s -> +varsym_tight_infix = sym $ \span _ s -> if | s == fsLit "@" -> return ITat - | otherwise -> return (ITvarsym s) + | otherwise -> + do { addWarning Opt_WarnOperatorWhitespace $ + WarnOperatorWhitespace (mkSrcSpanPs span) s + OperatorWhitespaceOccurrence_TightInfix + ; return (ITvarsym s) } -- See Note [Whitespace-sensitive operator parsing] varsym_loose_infix :: Action -varsym_loose_infix = sym (\_ s -> return $ ITvarsym s) +varsym_loose_infix = sym (\_ _ s -> return $ ITvarsym s) consym :: Action -consym = sym (\_exts s -> return $ ITconsym s) +consym = sym (\_span _exts s -> return $ ITconsym s) -sym :: (ExtsBitmap -> FastString -> P Token) -> Action +sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action sym con span buf len = case lookupUFM reservedSymsFM fs of Just (keyword, NormalSyntax, 0) -> @@ -1616,20 +1639,20 @@ sym con span buf len = exts <- getExts if exts .&. i /= 0 then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, 0) -> do exts <- getExts if xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Just (keyword, UnicodeSyntax, i) -> do exts <- getExts if exts .&. i /= 0 && xtest UnicodeSyntaxBit exts then return $ L span keyword - else L span <$!> con exts fs + else L span <$!> con span exts fs Nothing -> do exts <- getExts - L span <$!> con exts fs + L span <$!> con span exts fs where !fs = lexemeToFastString buf len ===================================== compiler/GHC/Runtime/Eval.hs ===================================== @@ -427,7 +427,7 @@ resumeExec canLogSpan step hist' = case mb_brkpt of Nothing -> prevHistoryLst Just bi - | not $canLogSpan span -> prevHistoryLst + | not $ canLogSpan span -> prevHistoryLst | otherwise -> mkHistory hsc_env apStack bi `consBL` fromListBL 50 hist handleRunStatus step expr bindings final_ids status hist' ===================================== docs/users_guide/using-warnings.rst ===================================== @@ -51,6 +51,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunrecognised-warning-flags` * :ghc-flag:`-Winaccessible-code` * :ghc-flag:`-Wstar-binder` + * :ghc-flag:`-Woperator-whitespace-ext-conflict` The following flags are simple ways to select standard "packages" of warnings: @@ -1853,6 +1854,7 @@ of ``-W(no-)*``. .. ghc-flag:: -Winvalid-haddock :shortdesc: warn when a Haddock comment occurs in an invalid position :type: dynamic + :reverse: -Wno-invalid-haddock :category: :since: 9.0 @@ -1869,6 +1871,56 @@ of ``-W(no-)*``. This warning informs you about discarded documentation comments. It has no effect when :ghc-flag:`-haddock` is disabled. +.. ghc-flag:: -Woperator-whitespace-ext-conflict + :shortdesc: warn on uses of infix operators that would be parsed differently + were a particular GHC extension enabled + :type: dynamic + :reverse: -Wno-operator-whitespace-ext-conflict + :category: + + :since: 9.2 + + When :extension:`TemplateHaskell` is enabled, ``f $x`` is parsed as ``f`` + applied to an untyped splice. But when the extension is disabled, the + expression is parsed as a use of the ``$`` infix operator. + + To make it easy to read ``f $x`` without checking the enabled extensions, + one could rewrite it as ``f $ x``, which is what this warning suggests. + + Currently, it detects the following cases: + + * ``$x`` could mean an untyped splice under :extension:`TemplateHaskell` + * ``$$x`` could mean a typed splice under :extension:`TemplateHaskell` + * ``%m`` could mean a multiplicity annotation under :extension:`LinearTypes` + + It only covers extensions that currently exist. If you want to enforce a + stricter policy and always require whitespace around all infix operators, + use :ghc-flag:`-Woperator-whitespace`. + +.. ghc-flag:: -Woperator-whitespace + :shortdesc: warn on prefix, suffix, and tight infix uses of infix operators + :type: dynamic + :reverse: -Wno-operator-whitespace + :category: + + :since: 9.2 + + There are four types of infix operator occurrences, as defined by + `GHC Proposal #229 `__:: + + a ! b -- a loose infix occurrence + a!b -- a tight infix occurrence + a !b -- a prefix occurrence + a! b -- a suffix occurrence + + A loose infix occurrence of any operator is always parsed as an infix + operator, but other occurrence types may be assigned a special meaning. + For example, a prefix ``!`` denotes a bang pattern, and a prefix ``$`` + denotes a :extension:`TemplateHaskell` splice. + + This warning encourages the use of loose infix occurrences of all infix + operators, to prevent possible conflicts with future language extensions. + .. ghc-flag:: -Wauto-orphans :shortdesc: *(deprecated)* Does nothing :type: dynamic ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -95,7 +95,7 @@ listModuleTags m = do dflags <- getDynFlags mb_print_unqual <- GHC.mkPrintUnqualifiedForModule mInfo let unqual = fromMaybe GHC.alwaysQualify mb_print_unqual - let names = fromMaybe [] $GHC.modInfoTopLevelScope mInfo + let names = fromMaybe [] $ GHC.modInfoTopLevelScope mInfo let localNames = filter ((m==) . nameModule) names mbTyThings <- mapM GHC.lookupName localNames return $! [ tagInfo dflags unqual exported kind name realLoc @@ -153,11 +153,11 @@ collateAndWriteTags CTagsWithLineNumbers file tagInfos = do -- ctags style with the Ex expression being a regex searching the line, Vim et al collateAndWriteTags CTagsWithRegExes file tagInfos = do -- ctags style, Vim et al tagInfoGroups <- makeTagGroupsWithSrcInfo tagInfos - let tags = unlines $ sort $ map showCTag $concat tagInfoGroups + let tags = unlines $ sort $ map showCTag $ concat tagInfoGroups tryIO (writeTagsSafely file tags) collateAndWriteTags ETags file tagInfos = do -- etags style, Emacs/XEmacs - tagInfoGroups <- makeTagGroupsWithSrcInfo $filter tagExported tagInfos + tagInfoGroups <- makeTagGroupsWithSrcInfo $ filter tagExported tagInfos let tagGroups = map processGroup tagInfoGroups tryIO (writeTagsSafely file $ concat tagGroups) @@ -176,7 +176,7 @@ makeTagGroupsWithSrcInfo tagInfos = do where addTagSrcInfo [] = throwGhcException (CmdLineError "empty tag file group??") addTagSrcInfo group@(tagInfo:_) = do - file <- readFile $tagFile tagInfo + file <- readFile $ tagFile tagInfo let sortedGroup = sortBy (comparing tagLine) group return $ perFile sortedGroup 1 0 $ lines file @@ -197,7 +197,7 @@ showCTag ti = where tagCmd = case tagSrcInfo ti of - Nothing -> show $tagLine ti + Nothing -> show $ tagLine ti Just (srcLine,_) -> "/^"++ foldr escapeSlashes [] srcLine ++"$/" where ===================================== libraries/containers ===================================== @@ -1 +1 @@ -Subproject commit 535384f5919eafb03856cf604b99cc94ce04e37a +Subproject commit 648fdb95cb4cf406ed7364533de6314069e3ffa5 ===================================== testsuite/tests/parser/should_compile/T18834a.hs ===================================== @@ -0,0 +1,8 @@ +module T18834a where + +(%) = ($) +($$) = ($) + +x = even $0 +y = even $$0 +z = even %0 ===================================== testsuite/tests/parser/should_compile/T18834a.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834a.hs:6:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$’ would denote an untyped splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$’. + +T18834a.hs:7:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘$$’ would denote a typed splice + were the TemplateHaskell extension enabled. + Suggested fix: add whitespace after the ‘$$’. + +T18834a.hs:8:10: warning: [-Woperator-whitespace-ext-conflict (in -Wdefault)] + The prefix use of a ‘%’ would denote a multiplicity annotation + were the LinearTypes extension enabled. + Suggested fix: add whitespace after the ‘%’. ===================================== testsuite/tests/parser/should_compile/T18834b.hs ===================================== @@ -0,0 +1,8 @@ +{-# OPTIONS -Woperator-whitespace #-} + +module T18834b where + +f a b = a+ b +g a b = a +b +h a b = a+b +k a b = a + b -- this one is OK, no warning ===================================== testsuite/tests/parser/should_compile/T18834b.stderr ===================================== @@ -0,0 +1,15 @@ + +T18834b.hs:5:10: warning: [-Woperator-whitespace] + The suffix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:6:11: warning: [-Woperator-whitespace] + The prefix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. + +T18834b.hs:7:10: warning: [-Woperator-whitespace] + The tight infix use of a ‘+’ might be repurposed as special syntax + by a future language extension. + Suggested fix: add whitespace around it. ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -170,3 +170,5 @@ test('proposal-229f', test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) +test('T18834a', normal, compile, ['']) +test('T18834b', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_compile/T16312.hs ===================================== @@ -9,6 +9,6 @@ instance Functor g => Functor (Curried g h) where fmap f (Curried g) = Curried (g . fmap (.f)) instance (Functor g, g ~ h) => Applicative (Curried g h) where - pure a = Curried (fmap ($a)) + pure a = Curried (fmap ($ a)) Curried mf <*> Curried ma = Curried (ma . mf . fmap (.)) {-# INLINE (<*>) #-} ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit f7d9e0bb987ca31c3b15cbe63198dafbeee3a395 +Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5b3e34ec39fc89a0bcd0b60cf9a4962c89ba72f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5b3e34ec39fc89a0bcd0b60cf9a4962c89ba72f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 22:17:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 19 Oct 2020 18:17:04 -0400 Subject: [Git][ghc/ghc][master] Remove pdocPrec Message-ID: <5f8e1060b228f_2800a3d56f81140425@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - 2 changed files: - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Utils/Outputable.hs Changes: ===================================== compiler/GHC/Cmm/DebugBlock.hs ===================================== @@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE LambdaCase #-} {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -520,18 +521,22 @@ data UnwindExpr = UwConst !Int -- ^ literal value deriving (Eq) instance OutputableP env CLabel => OutputableP env UnwindExpr where - pdocPrec _ _ (UwConst i) = ppr i - pdocPrec _ _ (UwReg g 0) = ppr g - pdocPrec p env (UwReg g x) = pdocPrec p env (UwPlus (UwReg g 0) (UwConst x)) - pdocPrec _ env (UwDeref e) = char '*' <> pdocPrec 3 env e - pdocPrec _ env (UwLabel l) = pdocPrec 3 env l - pdocPrec p env (UwPlus e0 e1) | p <= 0 - = pdocPrec 0 env e0 <> char '+' <> pdocPrec 0 env e1 - pdocPrec p env (UwMinus e0 e1) | p <= 0 - = pdocPrec 1 env e0 <> char '-' <> pdocPrec 1 env e1 - pdocPrec p env (UwTimes e0 e1) | p <= 1 - = pdocPrec 2 env e0 <> char '*' <> pdocPrec 2 env e1 - pdocPrec _ env other = parens (pdocPrec 0 env other) + pdoc = pprUnwindExpr 0 + +pprUnwindExpr :: OutputableP env CLabel => Rational -> env -> UnwindExpr -> SDoc +pprUnwindExpr p env = \case + UwConst i -> ppr i + UwReg g 0 -> ppr g + UwReg g x -> pprUnwindExpr p env (UwPlus (UwReg g 0) (UwConst x)) + UwDeref e -> char '*' <> pprUnwindExpr 3 env e + UwLabel l -> pdoc env l + UwPlus e0 e1 + | p <= 0 -> pprUnwindExpr 0 env e0 <> char '+' <> pprUnwindExpr 0 env e1 + UwMinus e0 e1 + | p <= 0 -> pprUnwindExpr 1 env e0 <> char '-' <> pprUnwindExpr 1 env e1 + UwTimes e0 e1 + | p <= 1 -> pprUnwindExpr 2 env e0 <> char '*' <> pprUnwindExpr 2 env e1 + other -> parens (pprUnwindExpr 0 env other) -- | Conversion of Cmm expressions to unwind expressions. We check for -- unsupported operator usages and simplify the expression as far as ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -1045,12 +1045,6 @@ instance Outputable Extension where -- See Note [The OutputableP class] class OutputableP env a where pdoc :: env -> a -> SDoc - pdocPrec :: Rational -> env -> a -> SDoc - -- 0 binds least tightly - -- We use Rational because there is always a - -- Rational between any other two Rationals - pdoc = pdocPrec 0 - pdocPrec _ = pdoc -- | Wrapper for types having a Outputable instance when an OutputableP instance -- is required. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9648d680b4b07d48cf8741e0847abf07b95c7c1d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9648d680b4b07d48cf8741e0847abf07b95c7c1d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 19 22:47:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 19 Oct 2020 18:47:56 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f8e179c47b48_28003fd3bdfc9f60114777e@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - 08067a5a by Ben Gamari at 2020-10-19T18:47:42-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 8ecdd88f by Krzysztof Gogolewski at 2020-10-19T18:47:45-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 379b8a49 by nineonine at 2020-10-19T18:47:48-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - f7749a52 by Ben Gamari at 2020-10-19T18:47:48-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - libraries/containers - + testsuite/tests/ghci/scripts/T8042.script - + testsuite/tests/ghci/scripts/T8042.stdout - testsuite/tests/ghci/scripts/all.T - + testsuite/tests/parser/should_compile/T18834a.hs - + testsuite/tests/parser/should_compile/T18834a.stderr - + testsuite/tests/parser/should_compile/T18834b.hs - + testsuite/tests/parser/should_compile/T18834b.stderr - testsuite/tests/parser/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd32505ccbf6dc77575990833d0e82d8db512a5b...f7749a5250d79165becdf838e8e621e22a6996ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd32505ccbf6dc77575990833d0e82d8db512a5b...f7749a5250d79165becdf838e8e621e22a6996ba You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 03:16:33 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 19 Oct 2020 23:16:33 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backport-MR3949 Message-ID: <5f8e56911b858_28006e2b7c81160130@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/backport-MR3949 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backport-MR3949 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 04:47:59 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 00:47:59 -0400 Subject: [Git][ghc/ghc][master] testsuite: Add test for #18346 Message-ID: <5f8e6bff60497_2800cd471d011656f3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 3 changed files: - + testsuite/tests/simplCore/should_compile/T18346/MiniLens.hs - + testsuite/tests/simplCore/should_compile/T18346/T18346.hs - + testsuite/tests/simplCore/should_compile/T18346/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T18346/MiniLens.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE RankNTypes #-} + +module MiniLens ((^.), Getting, Lens', lens, view) where + +import Data.Functor.Const (Const(..)) + +type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t + +type Lens' s a = Lens s s a a + +lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b +lens sa sbt afb s = sbt s <$> afb (sa s) +{-# INLINE lens #-} + +type Getting r s a = (a -> Const r a) -> s -> Const r s + +view :: Getting a s a -> s -> a +view l = getConst . l Const +{-# INLINE view #-} + +(^.) :: s -> Getting a s a -> a +s ^. l = getConst (l Const s) +{-# INLINE (^.) #-} ===================================== testsuite/tests/simplCore/should_compile/T18346/T18346.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE RankNTypes #-} + +module GHCBug (field) where + +import MiniLens ((^.), Getting, Lens', lens, view) + +t' :: Getting () () () +t' = lens id const +{-# NOINLINE t' #-} + +mlift :: Functor f => Getting b a b -> Lens' (f a) (f b) +mlift l = lens (fmap (^. l)) const +{-# INLINE mlift #-} + +newtype Field = F (Maybe () -> Maybe ()) + +field :: Field +field = F (view (mlift t')) ===================================== testsuite/tests/simplCore/should_compile/T18346/all.T ===================================== @@ -0,0 +1,2 @@ +test('T18346', [extra_files(['MiniLens.hs'])], multimod_compile, ['T18346.hs', '-v0']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee5dcdf95a7c408e9c339aacebf89a007a735f8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ee5dcdf95a7c408e9c339aacebf89a007a735f8f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 04:48:36 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 00:48:36 -0400 Subject: [Git][ghc/ghc][master] Minor comments, update linear types docs Message-ID: <5f8e6c2439c92_28003fd3e5a31b5c11706d4@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 5 changed files: - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Tc/Utils/TcMType.hs - docs/users_guide/exts/linear_types.rst Changes: ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -423,7 +423,7 @@ funTyConName = mkPrimTyConName (fsLit "FUN") funTyConKey funTyCon -- @ -- type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). -- TYPE rep1 -> TYPE rep2 -> Type --- type Arr = FUN +-- type Arr = FUN 'Many -- @ -- funTyCon :: TyCon ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1119,14 +1119,14 @@ In the compiler we maintain the invariant that all saturated applications of See #11714. -} -splitFunTy :: Type -> (Type, Type, Type) --- ^ Attempts to extract the argument and result types from a type, and --- panics if that is not possible. See also 'splitFunTy_maybe' +splitFunTy :: Type -> (Mult, Type, Type) +-- ^ Attempts to extract the multiplicity, argument and result types from a type, +-- and panics if that is not possible. See also 'splitFunTy_maybe' splitFunTy = expectJust "splitFunTy" . splitFunTy_maybe {-# INLINE splitFunTy_maybe #-} -splitFunTy_maybe :: Type -> Maybe (Type, Type, Type) --- ^ Attempts to extract the argument and result types from a type +splitFunTy_maybe :: Type -> Maybe (Mult, Type, Type) +-- ^ Attempts to extract the multiplicity, argument and result types from a type splitFunTy_maybe ty | FunTy _ w arg res <- coreFullView ty = Just (w, arg, res) | otherwise = Nothing ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -351,9 +351,10 @@ mkPsBindStmt pat body = BindStmt noExtField pat body mkRnBindStmt pat body = BindStmt (XBindStmtRn { xbsrn_bindOp = noSyntaxExpr, xbsrn_failOp = Nothing }) pat body mkTcBindStmt pat body = BindStmt (XBindStmtTc { xbstc_bindOp = noSyntaxExpr, xbstc_boundResultType = unitTy, + -- unitTy is a dummy value + -- can't panic here: it's forced during zonking xbstc_boundResultMult = Many, xbstc_failOp = Nothing }) pat body - -- don't use placeHolderTypeTc above, because that panics during zonking emptyRecStmt' :: forall idL idR body. IsPass idR => XRecStmt (GhcPass idL) (GhcPass idR) body ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -999,7 +999,6 @@ writeMetaTyVarRef tyvar ref ty -- Check for level OK -- See Note [Level check when unifying] ; MASSERT2( level_check_ok, level_check_msg ) - -- another level check problem, see #97 -- Check Kinds ok ; MASSERT2( kind_check_ok, kind_msg ) ===================================== docs/users_guide/exts/linear_types.rst ===================================== @@ -101,13 +101,23 @@ Whether a data constructor field is linear or not can be customized using the GA :: data T2 a b c where - MkT2 :: a -> b %1 -> c %1 -> T2 a b -- Note unrestricted arrow in the first argument + MkT2 :: a -> b %1 -> c %1 -> T2 a b c -- Note unrestricted arrow in the first argument the value ``MkT2 x y z`` can be constructed only if ``x`` is unrestricted. On the other hand, a linear function which is matching on ``MkT2 x y z`` must consume ``y`` and ``z`` exactly once, but there is no restriction on ``x``. +It is also possible to define a multiplicity-polymorphic field: + +:: + data T3 a m where + MkT3 :: a %m -> T3 a m + +While linear fields are generalized (``MkT1 :: forall {m} a. a %m -> T1 a`` +in the previous example), multiplicity-polymorphic fields are not; +it is not possible to directly use ``MkT3`` as a function ``a -> T3 a 'One``. + If :extension:`LinearTypes` is disabled, all fields are considered to be linear fields, including GADT fields defined with the ``->`` arrow. @@ -143,9 +153,9 @@ missing pieces. have success using it, or you may not. Expect it to be really unreliable. - There is currently no support for multiplicity annotations such as ``x :: a %p``, ``\(x :: a %p) -> ...``. -- All ``case``, ``let`` and ``where`` statements consume their - right-hand side, or scrutiny, ``Many`` times. That is, the following - will not type check: +- All ``case`` expressions consume their scrutinee ``Many`` times. + All ``let`` and ``where`` statements consume their right hand side + ``Many`` times. That is, the following will not type check: :: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c7a5c0ca07085f31a3e2f8286bb57a0f35961cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6c7a5c0ca07085f31a3e2f8286bb57a0f35961cb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 04:49:13 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 00:49:13 -0400 Subject: [Git][ghc/ghc][master] Compile modules with `-fobject-code` enabled to byte-code when loaded with `*`... Message-ID: <5f8e6c49a3713_28003fd3ece1f69011737e3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 5 changed files: - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Types.hs - + testsuite/tests/ghci/scripts/T8042.script - + testsuite/tests/ghci/scripts/T8042.stdout - testsuite/tests/ghci/scripts/all.T Changes: ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -316,8 +316,19 @@ compileOne' m_tc_result mHscMessage current_dir = takeDirectory basename old_paths = includePaths dflags2 !prevailing_dflags = hsc_dflags hsc_env0 + -- Figure out which backend we're using + (bcknd, dflags3) + -- #8042: When module was loaded with `*` prefix in ghci, but DynFlags + -- suggest to generate object code (which may happen in case -fobject-code + -- was set), force it to generate byte-code. This is NOT transitive and + -- only applies to direct targets. + | Just (Target _ obj _) <- findTarget summary (hsc_targets hsc_env0) + , not obj + = (Interpreter, dflags2 { backend = Interpreter }) + | otherwise + = (backend dflags, dflags2) dflags = - dflags2 { includePaths = addQuoteInclude old_paths [current_dir] + dflags3 { includePaths = addQuoteInclude old_paths [current_dir] , log_action = log_action prevailing_dflags } -- use the prevailing log_action / log_finaliser, -- not the one cached in the summary. This is so @@ -325,9 +336,6 @@ compileOne' m_tc_result mHscMessage -- to re-summarize all the source files. hsc_env = hsc_env0 {hsc_dflags = dflags} - -- Figure out which backend we're using - bcknd = backend dflags - -- -fforce-recomp should also work with --make force_recomp = gopt Opt_ForceRecomp dflags source_modified ===================================== compiler/GHC/Driver/Types.hs ===================================== @@ -19,7 +19,7 @@ module GHC.Driver.Types ( -- * compilation state HscEnv(..), hscEPS, FinderCache, FindResult(..), InstalledFindResult(..), - Target(..), TargetId(..), InputFileBuffer, pprTarget, pprTargetId, + Target(..), TargetId(..), InputFileBuffer, pprTarget, pprTargetId, findTarget, HscStatus(..), -- * ModuleGraph @@ -605,7 +605,7 @@ type InputFileBuffer = StringBuffer pprTarget :: Target -> SDoc pprTarget (Target id obj _) = - (if obj then char '*' else empty) <> pprTargetId id + (if obj then empty else char '*') <> pprTargetId id instance Outputable Target where ppr = pprTarget @@ -617,6 +617,20 @@ pprTargetId (TargetFile f _) = text f instance Outputable TargetId where ppr = pprTargetId +findTarget :: ModSummary -> [Target] -> Maybe Target +findTarget ms ts = + case filter (matches ms) ts of + [] -> Nothing + (t:_) -> Just t + where + summary `matches` Target (TargetModule m) _ _ + = ms_mod_name summary == m + summary `matches` Target (TargetFile f _) _ _ + | Just f' <- ml_hs_file (ms_location summary) + = f == f' + _ `matches` _ + = False + {- ************************************************************************ * * ===================================== testsuite/tests/ghci/scripts/T8042.script ===================================== @@ -0,0 +1,11 @@ +:set -v1 +System.IO.writeFile "T8042B.hs" "{-# OPTIONS_GHC -fobject-code #-} module T8042B where { type I = Int; }" +System.IO.writeFile "T8042C.hs" "module T8042C where { type B = Bool; }" +System.IO.writeFile "T8042A.hs" "module T8042A where { import T8042B; import T8042C }" +-- no `*` prefix so should compile object-code for B only +:load T8042A +System.IO.writeFile "T8042A.hs" "{-# OPTIONS_GHC -fobject-code #-} module T8042A where { import T8042B; import T8042C }" +-- should compile object-code for A now +:reload +-- with `*` prefix should compile byte-code for A +:load *T8042A ===================================== testsuite/tests/ghci/scripts/T8042.stdout ===================================== @@ -0,0 +1,9 @@ +[1 of 3] Compiling T8042B ( T8042B.hs, T8042B.o ) +[2 of 3] Compiling T8042C ( T8042C.hs, interpreted ) +[3 of 3] Compiling T8042A ( T8042A.hs, interpreted ) +Ok, three modules loaded. +[3 of 3] Compiling T8042A ( T8042A.hs, T8042A.o ) +Ok, three modules loaded. +[2 of 3] Compiling T8042C ( T8042C.hs, interpreted ) +[3 of 3] Compiling T8042A ( T8042A.hs, interpreted ) +Ok, three modules loaded. ===================================== testsuite/tests/ghci/scripts/all.T ===================================== @@ -174,6 +174,7 @@ test('T7872', normal, ghci_script, ['T7872.script']) test('T7873', normal, ghci_script, ['T7873.script']) test('T7939', normal, ghci_script, ['T7939.script']) test('T7894', normal, ghci_script, ['T7894.script']) +test('T8042', normal, ghci_script, ['T8042.script']) test('T8116', normal, ghci_script, ['T8116.script']) test('T8113', normal, ghci_script, ['T8113.script']) test('T8172', when(opsys('mingw32'), normalise_drive_letter), View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58a1ca3886b00630937d7f5073b2d7961f8e80ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58a1ca3886b00630937d7f5073b2d7961f8e80ca You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 04:49:50 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 00:49:50 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Message-ID: <5f8e6c6e1b088_28003fd3ece1f69011764ec@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - 2 changed files: - .gitlab-ci.yml - .gitlab/ci.sh Changes: ===================================== .gitlab-ci.yml ===================================== @@ -62,7 +62,6 @@ workflow: .release: &release variables: BUILD_FLAVOUR: "perf" - FLAVOUR: "perf" artifacts: when: always expire_in: 1 year @@ -196,7 +195,7 @@ lint-release-changelogs: .validate-hadrian: variables: - FLAVOUR: "validate" + BUILD_FLAVOUR: "validate" script: - .gitlab/ci.sh setup - .gitlab/ci.sh configure @@ -402,7 +401,7 @@ release-x86_64-freebsd: CABAL_INSTALL_VERSION: 3.0.0.0 BIN_DIST_NAME: "ghc-x86_64-portbld-freebsd" TEST_ENV: "x86_64-freebsd-hadrian" - FLAVOUR: "validate" + BUILD_FLAVOUR: "validate" after_script: - cp -Rf $HOME/.cabal cabal-cache - .gitlab/ci.sh clean @@ -466,7 +465,7 @@ validate-x86_64-darwin: CONFIGURE_ARGS: --with-intree-gmp TEST_ENV: "x86_64-darwin-hadrian" BIN_DIST_NAME: "ghc-x86_64-apple-darwin" - FLAVOUR: "validate" + BUILD_FLAVOUR: "validate" script: - .gitlab/ci.sh setup - .gitlab/ci.sh configure @@ -885,7 +884,7 @@ validate-x86_64-linux-fedora27: extends: .build-windows stage: full-build variables: - FLAVOUR: "validate" + BUILD_FLAVOUR: "validate" # skipping perf tests for now since we build a quick-flavoured GHC, # which might result in some broken perf tests? HADRIAN_ARGS: "--docs=no-sphinx --skip-perf" ===================================== .gitlab/ci.sh ===================================== @@ -374,8 +374,8 @@ function test_make() { } function build_hadrian() { - if [ -z "$FLAVOUR" ]; then - fail "FLAVOUR not set" + if [ -z "$BUILD_FLAVOUR" ]; then + fail "BUILD_FLAVOUR not set" fi if [ -z "$BIN_DIST_NAME" ]; then fail "BIN_DIST_NAME not set" @@ -435,7 +435,7 @@ function clean() { function run_hadrian() { if [ -z "$BIGNUM_BACKEND" ]; then BIGNUM_BACKEND="gmp"; fi run hadrian/build-cabal \ - --flavour="$FLAVOUR" \ + --flavour="$BUILD_FLAVOUR" \ -j"$cores" \ --broken-test="$BROKEN_TESTS" \ --bignum=$BIGNUM_BACKEND \ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59b08a5d192e102f66a6d9260cc8466d7428cffe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/59b08a5d192e102f66a6d9260cc8466d7428cffe You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 08:11:07 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Tue, 20 Oct 2020 04:11:07 -0400 Subject: [Git][ghc/ghc][wip/az/unicode-hsscaled] 7 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f8e9b9b81f69_28001001ed2411817b@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/unicode-hsscaled at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dde79eaffcb0fa2bbecc759c7aa3fc4d3de0cfd1...ea736839d85594c95490dcf02d3325c2bbc68f33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dde79eaffcb0fa2bbecc759c7aa3fc4d3de0cfd1...ea736839d85594c95490dcf02d3325c2bbc68f33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 10:18:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 06:18:20 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/backport-MR3949 Message-ID: <5f8eb96c787e_28003fd4120742f411892be@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/backport-MR3949 at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 10:18:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 06:18:21 -0400 Subject: [Git][ghc/ghc][ghc-8.10] rts: fix race condition in StgCRun Message-ID: <5f8eb96d5e364_28003fd3ec2bc1901189467@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-8.10 at Glasgow Haskell Compiler / GHC Commits: 658362c6 by Tamar Christina at 2020-10-19T23:16:22-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. (cherry picked from commit fd984d68e5ec4b04bc79395c099434e653eb1060) - - - - - 5 changed files: - compiler/nativeGen/X86/Instr.hs - rts/RtsSymbols.c - rts/Schedule.c - rts/StgCRun.c - rts/StgRun.h Changes: ===================================== compiler/nativeGen/X86/Instr.hs ===================================== @@ -819,13 +819,14 @@ x86_mkJumpInstr id -- In essense each allocation larger than a page size needs to be chunked and -- a probe emitted after each page allocation. You have to hit the guard -- page so the kernel can map in the next page, otherwise you'll segfault. +-- See Note [Windows stack allocations]. -- needs_probe_call :: Platform -> Int -> Bool needs_probe_call platform amount = case platformOS platform of OSMinGW32 -> case platformArch platform of ArchX86 -> amount > (4 * 1024) - ArchX86_64 -> amount > (8 * 1024) + ArchX86_64 -> amount > (4 * 1024) _ -> False _ -> False @@ -849,7 +850,7 @@ x86_mkStackAllocInstr platform amount -- -- We emit a call because the stack probes are quite involved and -- would bloat code size a lot. GHC doesn't really have an -Os. - -- __chkstk is guaranteed to leave all nonvolatile registers and AX + -- ___chkstk is guaranteed to leave all nonvolatile registers and AX -- untouched. It's part of the standard prologue code for any Windows -- function dropping the stack more than a page. -- See Note [Windows stack layout] ===================================== rts/RtsSymbols.c ===================================== @@ -134,7 +134,7 @@ SymI_HasProto(rts_InstallConsoleEvent) \ SymI_HasProto(rts_ConsoleHandlerDone) \ SymI_HasProto(atexit) \ - RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \ + RTS_WIN32_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \ RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \ RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \ ===================================== rts/Schedule.c ===================================== @@ -136,7 +136,6 @@ static Capability *schedule (Capability *initialCapability, Task *task); // abstracted only to make the structure and control flow of the // scheduler clearer. // -static void schedulePreLoop (void); static void scheduleFindWork (Capability **pcap); #if defined(THREADED_RTS) static void scheduleYield (Capability **pcap, Task *task); @@ -205,8 +204,6 @@ schedule (Capability *initialCapability, Task *task) debugTrace (DEBUG_sched, "cap %d: schedule()", initialCapability->no); - schedulePreLoop(); - // ----------------------------------------------------------- // Scheduler loop starts here: @@ -599,20 +596,6 @@ promoteInRunQueue (Capability *cap, StgTSO *tso) pushOnRunQueue(cap, tso); } -/* ---------------------------------------------------------------------------- - * Setting up the scheduler loop - * ------------------------------------------------------------------------- */ - -static void -schedulePreLoop(void) -{ - // initialisation for scheduler - what cannot go into initScheduler() - -#if defined(mingw32_HOST_OS) && !defined(USE_MINIINTERPRETER) - win32AllocStack(); -#endif -} - /* ----------------------------------------------------------------------------- * scheduleFindWork() * ===================================== rts/StgCRun.c ===================================== @@ -89,25 +89,6 @@ StgFunPtr StgReturn(void) } #else /* !USE_MINIINTERPRETER */ - -#if defined(mingw32_HOST_OS) -/* - * Note [Windows Stack allocations] - * - * On windows the stack has to be allocated 4k at a time, otherwise - * we get a segfault. The C compiler knows how to do this (it calls - * _alloca()), so we make sure that we can allocate as much stack as - * we need. However since we are doing a local stack allocation and the value - * isn't valid outside the frame, compilers are free to optimize this allocation - * and the corresponding stack check away. So to prevent that we request that - * this function never be optimized (See #14669). */ -STG_NO_OPTIMIZE StgWord8 *win32AllocStack(void) -{ - StgWord8 stack[RESERVED_C_STACK_BYTES + 16 + 12]; - return stack; -} -#endif - /* ----------------------------------------------------------------------------- x86 architecture -------------------------------------------------------------------------- */ @@ -159,7 +140,21 @@ STG_NO_OPTIMIZE StgWord8 *win32AllocStack(void) * * If you edit the sequence below be sure to update the unwinding information * for stg_stop_thread in StgStartup.cmm. - */ + * + * Note [Windows Stack allocations] + * + * On windows the stack has to be allocated 4k at a time, otherwise + * we get a segfault. This is done by using a helper ___chkstk_ms that is + * provided by libgcc. The Haskell side already knows how to handle this +(see GHC.CmmToAsm.X86.Instr.needs_probe_call) + * but we need to do the same from STG. Previously we would drop the stack + * in StgRun but would only make it valid whenever the scheduler loop ran. + * + * This approach was fundamentally broken in that it falls apart when you + * take a signal from the OS (See #14669, #18601, #18548 and #18496). + * Concretely this means we must always keep the stack valid. + * */ + static void GNUC3_ATTRIBUTE(used) StgRunIsImplementedInAssembler(void) @@ -179,7 +174,13 @@ StgRunIsImplementedInAssembler(void) * bytes from here - this is a requirement of the C ABI, so * that C code can assign SSE2 registers directly to/from * stack locations. + * + * See Note [Windows Stack allocations] */ +#if defined(mingw32_HOST_OS) + "movl %0, %%eax\n\t" + "call ___chkstk_ms\n\t" +#endif "subl %0, %%esp\n\t" /* @@ -376,6 +377,14 @@ StgRunIsImplementedInAssembler(void) STG_HIDDEN STG_RUN "\n" #endif STG_RUN ":\n\t" + /* + * See Note [Windows Stack allocations] + */ +#if defined(mingw32_HOST_OS) + "movq %1, %%rax\n\t" + "addq %0, %%rax\n\t" + "callq ___chkstk_ms\n\t" +#endif "subq %1, %%rsp\n\t" "movq %%rsp, %%rax\n\t" "subq %0, %%rsp\n\t" ===================================== rts/StgRun.h ===================================== @@ -9,7 +9,3 @@ #pragma once RTS_PRIVATE StgRegTable * StgRun (StgFunPtr f, StgRegTable *basereg); - -#if defined(mingw32_HOST_OS) -StgWord8 *win32AllocStack(void); -#endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/658362c68a64f9b999367875ae7d75db07eb2620 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/658362c68a64f9b999367875ae7d75db07eb2620 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 10:37:29 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 20 Oct 2020 06:37:29 -0400 Subject: [Git][ghc/ghc][wip/T18855] Fix two constraint solving problems Message-ID: <5f8ebde9b8c18_28003fd40dd8dee01192461@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18855 at Glasgow Haskell Compiler / GHC Commits: 53beedaf by Simon Peyton Jones at 2020-10-20T11:36:10+01:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - + testsuite/tests/polykinds/T18855.hs - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_fail/T10709b.stderr - testsuite/tests/typecheck/should_fail/T12589.stderr Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -42,7 +42,8 @@ module GHC.Core.Coercion ( mkAxiomInstCo, mkProofIrrelCo, downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, - mkKindCo, castCoercionKind, castCoercionKindI, + mkKindCo, + castCoercionKind, castCoercionKind1, castCoercionKind2, mkFamilyTyConAppCo, mkHeteroCoercionType, @@ -1513,24 +1514,47 @@ instCoercions g ws ; return (piResultTy <$> g_tys <*> w_tys, g') } -- | Creates a new coercion with both of its types casted by different casts --- @castCoercionKind g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, +-- @castCoercionKind2 g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -castCoercionKind :: Coercion -> Role -> Type -> Type +castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -castCoercionKind g r t1 t2 h1 h2 +castCoercionKind2 g r t1 t2 h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) +-- | @castCoercionKind1 g r t1 t2 h@ = @coercionKind g r t1 t2 h h@ +-- That is, it's a specialised form of castCoercionKind, where the two +-- kind coercions are identical +-- @castCoercionKind1 g r t1 t2 h@, where @g :: t1 ~r t2@, +-- has type @(t1 |> h) ~r (t2 |> h)@. +-- @h@ must be nominal. +-- See Note [castCoercionKind1] +castCoercionKind1 :: Coercion -> Role -> Type -> Type + -> CoercionN -> Coercion +castCoercionKind1 g r t1 t2 h + = case g of + Refl t -> refl_shortcut t + GRefl _ t MRefl -> refl_shortcut t + GRefl _ _ (MCo kind_co) + -> GRefl r (mkCastTy t1 h) + (MCo (mkSymCo h `mkTransCo` kind_co `mkTransCo` h)) + _ -> castCoercionKind2 g r t1 t2 h h + where + refl_shortcut t = ASSERT2 (t1 `eqType` t2 && t1 `eqType` t + , ppr t $$ ppr t1 $$ ppr t2 ) + mkReflCo r (mkCastTy t1 h) + -- | Creates a new coercion with both of its types casted by different casts -- @castCoercionKind g h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -- It calls @coercionKindRole@, so it's quite inefficient (which 'I' stands for) --- Use @castCoercionKind@ instead if @t1@, @t2@, and @r@ are known beforehand. -castCoercionKindI :: Coercion -> CoercionN -> CoercionN -> Coercion -castCoercionKindI g h1 h2 - = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) - where (Pair t1 t2, r) = coercionKindRole g +-- Use @castCoercionKind2@ instead if @t1@, @t2@, and @r@ are known beforehand. +castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion +castCoercionKind g h1 h2 + = castCoercionKind2 g r t1 t2 h1 h2 + where + (Pair t1 t2, r) = coercionKindRole g mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the @@ -1592,6 +1616,23 @@ mkCoCast c g (tc, _) = splitTyConApp (coercionLKind g) co_list = decomposeCo (tyConArity tc) g (tyConRolesRepresentational tc) +{- Note [castCoercionKind1] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +castCoercionKind1 deals with the very important special case of castCoercionKind2 +where the two kind coercions are identical. In that case we can exploit the +situation where the main coercion is reflexive, via the special cases for Refl +and GRefl. + +This is important when flattening (ty |> co). We flatten ty, yielding + fco :: ty ~ ty' +and now we want a coercion xco between + xco :: (ty |> co) ~ (ty' |> co) +That's exactly what castCoercionKind1 does. And it's very very common for +fco to be Refl. In that case we do NOT want to get some terrible composition +of mkLeftCoherenceCo and mkRightCoherenceCo, which is what castCoercionKind2 +has to do in its full generality. See #18413. +-} + {- %************************************************************************ %* * @@ -1967,8 +2008,8 @@ ty_co_subst !lc role ty else pprPanic "ty_co_subst: covar is not almost devoid" (ppr t) go r ty@(LitTy {}) = ASSERT( r == Nominal ) mkNomReflCo ty - go r (CastTy ty co) = castCoercionKindI (go r ty) (substLeftCo lc co) - (substRightCo lc co) + go r (CastTy ty co) = castCoercionKind (go r ty) (substLeftCo lc co) + (substRightCo lc co) go r (CoercionTy co) = mkProofIrrelCo r kco (substLeftCo lc co) (substRightCo lc co) where kco = go Nominal (coercionType co) ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1447,7 +1447,7 @@ normalise_type ty = do { (nco, nty) <- go ty ; lc <- getLC ; let co' = substRightCo lc co - ; return (castCoercionKind nco Nominal ty nty co co' + ; return (castCoercionKind2 nco Nominal ty nty co co' , mkCastTy nty co') } go (CoercionTy co) = do { lc <- getLC ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1454,7 +1454,7 @@ ty_co_match menv subst (TyVarTy tv1) co lkco rkco = if any (inRnEnvR rn_env) (tyCoVarsOfCoList co) then Nothing -- occurs check failed else Just $ extendVarEnv subst tv1' $ - castCoercionKindI co (mkSymCo lkco) (mkSymCo rkco) + castCoercionKind co (mkSymCo lkco) (mkSymCo rkco) | otherwise = Nothing ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -2542,6 +2542,9 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs is_float_eq_candidate ct | pred <- ctPred ct , EqPred NomEq ty1 ty2 <- classifyPredType pred + , case ct of + CIrredCan {} -> False -- See Note [Do not float blocked constraints] + _ -> True -- See #18855 = float_eq ty1 ty2 || float_eq ty2 ty1 | otherwise = False @@ -2552,7 +2555,26 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs && (not (isTyVarTyVar tv1) || isTyVarTy ty2) Nothing -> False -{- Note [Float equalities from under a skolem binding] +{- Note [Do not float blocked constraints] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As #18855 showed, we must not float an equality that is blocked. +Consider + forall a[4]. [W] co1: alpha[4] ~ Maybe (a[4] |> bco) + [W] co2: alpha[4] ~ Maybe (beta[4] |> bco]) + [W] bco: kappa[2] ~ Type + +Now co1, co2 are blocked by bco. We will eventually float out bco +and solve it at level 2. But the danger is that we will *also* +float out co2, and that is bad bad bad. Because we'll promote alpha +and beta to level 2, and then fail to unify the promoted beta +with the skolem a[4]. + +Solution: don't float out blocked equalities. Remember: we only want +to float out if we can solve; see Note [Which equalities to float]. + +(Future plan: kill floating altogether.) + +Note [Float equalities from under a skolem binding] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which of the simple equalities can we float out? Obviously, only ones that don't mention the skolem-bound variables. But that is ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1206,9 +1206,11 @@ flatten_one ty@(ForAllTy {}) flatten_one (CastTy ty g) = do { (xi, co) <- flatten_one ty ; (g', _) <- flatten_co g - ; role <- getRole - ; return (mkCastTy xi g', castCoercionKind co role xi ty g' g) } + ; return (mkCastTy xi g', castCoercionKind1 co role xi ty g') } + -- It makes a /big/ difference to call castCoercionKind1 not + -- the more general castCoercionKind2. + -- See Note [castCoercionKind1] in GHC.Core.Coercion flatten_one (CoercionTy co) = first mkCoercionTy <$> flatten_co co ===================================== testsuite/tests/polykinds/T18855.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind + +type family Apply (f :: a -> b) (x :: a) :: b + +type F :: forall a. + forall (p :: forall bOne. Either a bOne -> Type) + -> forall bTwo. + forall (e :: Either a bTwo) + -> Apply p e + +type family F ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -225,3 +225,4 @@ test('T18451', normal, compile_fail, ['']) test('T18451a', normal, compile_fail, ['']) test('T18451b', normal, compile_fail, ['']) test('T18522-ppr', normal, ghci_script, ['T18522-ppr.script']) +test('T18855', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10709b.stderr ===================================== @@ -11,44 +11,44 @@ T10709b.hs:6:22: error: x4 = (replicateM 2 . mask) (\ _ -> return ()) T10709b.hs:7:22: error: - • Couldn't match type ‘t0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘t0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (t0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘t0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (\ x -> undefined x) In an equation for ‘x5’: x5 = (replicateM 2 . mask) (\ x -> undefined x) T10709b.hs:8:22: error: - • Couldn't match type ‘p0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘p0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (p0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘p0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (id (\ _ -> undefined)) In an equation for ‘x6’: x6 = (replicateM 2 . mask) (id (\ _ -> undefined)) T10709b.hs:9:22: error: - • Couldn't match type ‘b0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘b0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (b0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘b0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (const undefined) In an equation for ‘x7’: x7 = (replicateM 2 . mask) (const undefined) T10709b.hs:10:22: error: - • Couldn't match type ‘a0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘a0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (a0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘a0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) ((\ x -> undefined x) :: a -> b) ===================================== testsuite/tests/typecheck/should_fail/T12589.stderr ===================================== @@ -1,12 +1,2 @@ T12589.hs:13:3: error: Variable not in scope: (&) :: t0 -> t1 -> t - -T12589.hs:13:5: error: - • Couldn't match expected type ‘t1’ - with actual type ‘(forall a. Bounded a => f0 a) -> h0 f0 xs0’ - Cannot instantiate unification variable ‘t1’ - with a type involving polytypes: - (forall a. Bounded a => f0 a) -> h0 f0 xs0 - • In the second argument of ‘(&)’, namely ‘hcpure (Proxy @Bounded)’ - In the expression: minBound & hcpure (Proxy @Bounded) - In an equation for ‘a’: a = minBound & hcpure (Proxy @Bounded) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53beedaf2bdd9b9cd3d396b6fe8b92a0e7f69ca2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53beedaf2bdd9b9cd3d396b6fe8b92a0e7f69ca2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 11:44:38 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 20 Oct 2020 07:44:38 -0400 Subject: [Git][ghc/ghc][wip/T18855] Fix two constraint solving problems Message-ID: <5f8ecda686af1_28003fd40d4fd3d411981da@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18855 at Glasgow Haskell Compiler / GHC Commits: c3854ecf by Simon Peyton Jones at 2020-10-20T12:43:52+01:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - + testsuite/tests/polykinds/T18855.hs - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_fail/T10709b.stderr - testsuite/tests/typecheck/should_fail/T12589.stderr Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -42,7 +42,8 @@ module GHC.Core.Coercion ( mkAxiomInstCo, mkProofIrrelCo, downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, - mkKindCo, castCoercionKind, castCoercionKindI, + mkKindCo, + castCoercionKind, castCoercionKind1, castCoercionKind2, mkFamilyTyConAppCo, mkHeteroCoercionType, @@ -1513,24 +1514,45 @@ instCoercions g ws ; return (piResultTy <$> g_tys <*> w_tys, g') } -- | Creates a new coercion with both of its types casted by different casts --- @castCoercionKind g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, +-- @castCoercionKind2 g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -castCoercionKind :: Coercion -> Role -> Type -> Type +castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -castCoercionKind g r t1 t2 h1 h2 +castCoercionKind2 g r t1 t2 h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) +-- | @castCoercionKind1 g r t1 t2 h@ = @coercionKind g r t1 t2 h h@ +-- That is, it's a specialised form of castCoercionKind, where the two +-- kind coercions are identical +-- @castCoercionKind1 g r t1 t2 h@, where @g :: t1 ~r t2@, +-- has type @(t1 |> h) ~r (t2 |> h)@. +-- @h@ must be nominal. +-- See Note [castCoercionKind1] +castCoercionKind1 :: Coercion -> Role -> Type -> Type + -> CoercionN -> Coercion +castCoercionKind1 g r t1 t2 h + = case g of + Refl t -> refl_shortcut t + GRefl _ t MRefl -> refl_shortcut t + GRefl _ _ (MCo kind_co) + -> GRefl r (mkCastTy t1 h) + (MCo (mkSymCo h `mkTransCo` kind_co `mkTransCo` h)) + _ -> castCoercionKind2 g r t1 t2 h h + where + refl_shortcut t = mkReflCo r (mkCastTy t1 h) + -- | Creates a new coercion with both of its types casted by different casts -- @castCoercionKind g h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -- It calls @coercionKindRole@, so it's quite inefficient (which 'I' stands for) --- Use @castCoercionKind@ instead if @t1@, @t2@, and @r@ are known beforehand. -castCoercionKindI :: Coercion -> CoercionN -> CoercionN -> Coercion -castCoercionKindI g h1 h2 - = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) - where (Pair t1 t2, r) = coercionKindRole g +-- Use @castCoercionKind2@ instead if @t1@, @t2@, and @r@ are known beforehand. +castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion +castCoercionKind g h1 h2 + = castCoercionKind2 g r t1 t2 h1 h2 + where + (Pair t1 t2, r) = coercionKindRole g mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the @@ -1592,6 +1614,23 @@ mkCoCast c g (tc, _) = splitTyConApp (coercionLKind g) co_list = decomposeCo (tyConArity tc) g (tyConRolesRepresentational tc) +{- Note [castCoercionKind1] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +castCoercionKind1 deals with the very important special case of castCoercionKind2 +where the two kind coercions are identical. In that case we can exploit the +situation where the main coercion is reflexive, via the special cases for Refl +and GRefl. + +This is important when flattening (ty |> co). We flatten ty, yielding + fco :: ty ~ ty' +and now we want a coercion xco between + xco :: (ty |> co) ~ (ty' |> co) +That's exactly what castCoercionKind1 does. And it's very very common for +fco to be Refl. In that case we do NOT want to get some terrible composition +of mkLeftCoherenceCo and mkRightCoherenceCo, which is what castCoercionKind2 +has to do in its full generality. See #18413. +-} + {- %************************************************************************ %* * @@ -1967,8 +2006,8 @@ ty_co_subst !lc role ty else pprPanic "ty_co_subst: covar is not almost devoid" (ppr t) go r ty@(LitTy {}) = ASSERT( r == Nominal ) mkNomReflCo ty - go r (CastTy ty co) = castCoercionKindI (go r ty) (substLeftCo lc co) - (substRightCo lc co) + go r (CastTy ty co) = castCoercionKind (go r ty) (substLeftCo lc co) + (substRightCo lc co) go r (CoercionTy co) = mkProofIrrelCo r kco (substLeftCo lc co) (substRightCo lc co) where kco = go Nominal (coercionType co) ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1447,7 +1447,7 @@ normalise_type ty = do { (nco, nty) <- go ty ; lc <- getLC ; let co' = substRightCo lc co - ; return (castCoercionKind nco Nominal ty nty co co' + ; return (castCoercionKind2 nco Nominal ty nty co co' , mkCastTy nty co') } go (CoercionTy co) = do { lc <- getLC ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1454,7 +1454,7 @@ ty_co_match menv subst (TyVarTy tv1) co lkco rkco = if any (inRnEnvR rn_env) (tyCoVarsOfCoList co) then Nothing -- occurs check failed else Just $ extendVarEnv subst tv1' $ - castCoercionKindI co (mkSymCo lkco) (mkSymCo rkco) + castCoercionKind co (mkSymCo lkco) (mkSymCo rkco) | otherwise = Nothing ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -2542,6 +2542,9 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs is_float_eq_candidate ct | pred <- ctPred ct , EqPred NomEq ty1 ty2 <- classifyPredType pred + , case ct of + CIrredCan {} -> False -- See Note [Do not float blocked constraints] + _ -> True -- See #18855 = float_eq ty1 ty2 || float_eq ty2 ty1 | otherwise = False @@ -2552,7 +2555,26 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs && (not (isTyVarTyVar tv1) || isTyVarTy ty2) Nothing -> False -{- Note [Float equalities from under a skolem binding] +{- Note [Do not float blocked constraints] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As #18855 showed, we must not float an equality that is blocked. +Consider + forall a[4]. [W] co1: alpha[4] ~ Maybe (a[4] |> bco) + [W] co2: alpha[4] ~ Maybe (beta[4] |> bco]) + [W] bco: kappa[2] ~ Type + +Now co1, co2 are blocked by bco. We will eventually float out bco +and solve it at level 2. But the danger is that we will *also* +float out co2, and that is bad bad bad. Because we'll promote alpha +and beta to level 2, and then fail to unify the promoted beta +with the skolem a[4]. + +Solution: don't float out blocked equalities. Remember: we only want +to float out if we can solve; see Note [Which equalities to float]. + +(Future plan: kill floating altogether.) + +Note [Float equalities from under a skolem binding] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which of the simple equalities can we float out? Obviously, only ones that don't mention the skolem-bound variables. But that is ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1206,9 +1206,11 @@ flatten_one ty@(ForAllTy {}) flatten_one (CastTy ty g) = do { (xi, co) <- flatten_one ty ; (g', _) <- flatten_co g - ; role <- getRole - ; return (mkCastTy xi g', castCoercionKind co role xi ty g' g) } + ; return (mkCastTy xi g', castCoercionKind1 co role xi ty g') } + -- It makes a /big/ difference to call castCoercionKind1 not + -- the more general castCoercionKind2. + -- See Note [castCoercionKind1] in GHC.Core.Coercion flatten_one (CoercionTy co) = first mkCoercionTy <$> flatten_co co ===================================== testsuite/tests/polykinds/T18855.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind + +type family Apply (f :: a -> b) (x :: a) :: b + +type F :: forall a. + forall (p :: forall bOne. Either a bOne -> Type) + -> forall bTwo. + forall (e :: Either a bTwo) + -> Apply p e + +type family F ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -225,3 +225,4 @@ test('T18451', normal, compile_fail, ['']) test('T18451a', normal, compile_fail, ['']) test('T18451b', normal, compile_fail, ['']) test('T18522-ppr', normal, ghci_script, ['T18522-ppr.script']) +test('T18855', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10709b.stderr ===================================== @@ -11,44 +11,44 @@ T10709b.hs:6:22: error: x4 = (replicateM 2 . mask) (\ _ -> return ()) T10709b.hs:7:22: error: - • Couldn't match type ‘t0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘t0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (t0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘t0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (\ x -> undefined x) In an equation for ‘x5’: x5 = (replicateM 2 . mask) (\ x -> undefined x) T10709b.hs:8:22: error: - • Couldn't match type ‘p0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘p0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (p0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘p0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (id (\ _ -> undefined)) In an equation for ‘x6’: x6 = (replicateM 2 . mask) (id (\ _ -> undefined)) T10709b.hs:9:22: error: - • Couldn't match type ‘b0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘b0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (b0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘b0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (const undefined) In an equation for ‘x7’: x7 = (replicateM 2 . mask) (const undefined) T10709b.hs:10:22: error: - • Couldn't match type ‘a0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘a0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (a0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘a0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) ((\ x -> undefined x) :: a -> b) ===================================== testsuite/tests/typecheck/should_fail/T12589.stderr ===================================== @@ -1,12 +1,2 @@ T12589.hs:13:3: error: Variable not in scope: (&) :: t0 -> t1 -> t - -T12589.hs:13:5: error: - • Couldn't match expected type ‘t1’ - with actual type ‘(forall a. Bounded a => f0 a) -> h0 f0 xs0’ - Cannot instantiate unification variable ‘t1’ - with a type involving polytypes: - (forall a. Bounded a => f0 a) -> h0 f0 xs0 - • In the second argument of ‘(&)’, namely ‘hcpure (Proxy @Bounded)’ - In the expression: minBound & hcpure (Proxy @Bounded) - In an equation for ‘a’: a = minBound & hcpure (Proxy @Bounded) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3854ecf284de79304018c75cbdf986bd5486342 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c3854ecf284de79304018c75cbdf986bd5486342 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 12:28:32 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 20 Oct 2020 08:28:32 -0400 Subject: [Git][ghc/ghc][wip/T18855] Fix two constraint solving problems Message-ID: <5f8ed7f0c48bc_28003fd40c6a9cb012021eb@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18855 at Glasgow Haskell Compiler / GHC Commits: 88ae0de6 by Simon Peyton Jones at 2020-10-20T13:27:59+01:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 9 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - + testsuite/tests/polykinds/T18855.hs - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_fail/T10709b.stderr - testsuite/tests/typecheck/should_fail/T12589.stderr Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -42,7 +42,8 @@ module GHC.Core.Coercion ( mkAxiomInstCo, mkProofIrrelCo, downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, - mkKindCo, castCoercionKind, castCoercionKindI, + mkKindCo, + castCoercionKind, castCoercionKind1, castCoercionKind2, mkFamilyTyConAppCo, mkHeteroCoercionType, @@ -1513,24 +1514,45 @@ instCoercions g ws ; return (piResultTy <$> g_tys <*> w_tys, g') } -- | Creates a new coercion with both of its types casted by different casts --- @castCoercionKind g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, +-- @castCoercionKind2 g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -castCoercionKind :: Coercion -> Role -> Type -> Type +castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -castCoercionKind g r t1 t2 h1 h2 +castCoercionKind2 g r t1 t2 h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) +-- | @castCoercionKind1 g r t1 t2 h@ = @coercionKind g r t1 t2 h h@ +-- That is, it's a specialised form of castCoercionKind, where the two +-- kind coercions are identical +-- @castCoercionKind1 g r t1 t2 h@, where @g :: t1 ~r t2@, +-- has type @(t1 |> h) ~r (t2 |> h)@. +-- @h@ must be nominal. +-- See Note [castCoercionKind1] +castCoercionKind1 :: Coercion -> Role -> Type -> Type + -> CoercionN -> Coercion +castCoercionKind1 g r t1 t2 h + = case g of + Refl {} -> refl_shortcut + GRefl _ _ MRefl -> refl_shortcut + GRefl _ _ (MCo kind_co) + -> GRefl r (mkCastTy t1 h) + (MCo (mkSymCo h `mkTransCo` kind_co `mkTransCo` h)) + _ -> castCoercionKind2 g r t1 t2 h h + where + refl_shortcut = mkReflCo r (mkCastTy t2 h) + -- | Creates a new coercion with both of its types casted by different casts -- @castCoercionKind g h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -- It calls @coercionKindRole@, so it's quite inefficient (which 'I' stands for) --- Use @castCoercionKind@ instead if @t1@, @t2@, and @r@ are known beforehand. -castCoercionKindI :: Coercion -> CoercionN -> CoercionN -> Coercion -castCoercionKindI g h1 h2 - = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) - where (Pair t1 t2, r) = coercionKindRole g +-- Use @castCoercionKind2@ instead if @t1@, @t2@, and @r@ are known beforehand. +castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion +castCoercionKind g h1 h2 + = castCoercionKind2 g r t1 t2 h1 h2 + where + (Pair t1 t2, r) = coercionKindRole g mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the @@ -1592,6 +1614,23 @@ mkCoCast c g (tc, _) = splitTyConApp (coercionLKind g) co_list = decomposeCo (tyConArity tc) g (tyConRolesRepresentational tc) +{- Note [castCoercionKind1] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +castCoercionKind1 deals with the very important special case of castCoercionKind2 +where the two kind coercions are identical. In that case we can exploit the +situation where the main coercion is reflexive, via the special cases for Refl +and GRefl. + +This is important when flattening (ty |> co). We flatten ty, yielding + fco :: ty ~ ty' +and now we want a coercion xco between + xco :: (ty |> co) ~ (ty' |> co) +That's exactly what castCoercionKind1 does. And it's very very common for +fco to be Refl. In that case we do NOT want to get some terrible composition +of mkLeftCoherenceCo and mkRightCoherenceCo, which is what castCoercionKind2 +has to do in its full generality. See #18413. +-} + {- %************************************************************************ %* * @@ -1967,8 +2006,8 @@ ty_co_subst !lc role ty else pprPanic "ty_co_subst: covar is not almost devoid" (ppr t) go r ty@(LitTy {}) = ASSERT( r == Nominal ) mkNomReflCo ty - go r (CastTy ty co) = castCoercionKindI (go r ty) (substLeftCo lc co) - (substRightCo lc co) + go r (CastTy ty co) = castCoercionKind (go r ty) (substLeftCo lc co) + (substRightCo lc co) go r (CoercionTy co) = mkProofIrrelCo r kco (substLeftCo lc co) (substRightCo lc co) where kco = go Nominal (coercionType co) ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1447,7 +1447,7 @@ normalise_type ty = do { (nco, nty) <- go ty ; lc <- getLC ; let co' = substRightCo lc co - ; return (castCoercionKind nco Nominal ty nty co co' + ; return (castCoercionKind2 nco Nominal ty nty co co' , mkCastTy nty co') } go (CoercionTy co) = do { lc <- getLC ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1454,7 +1454,7 @@ ty_co_match menv subst (TyVarTy tv1) co lkco rkco = if any (inRnEnvR rn_env) (tyCoVarsOfCoList co) then Nothing -- occurs check failed else Just $ extendVarEnv subst tv1' $ - castCoercionKindI co (mkSymCo lkco) (mkSymCo rkco) + castCoercionKind co (mkSymCo lkco) (mkSymCo rkco) | otherwise = Nothing ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -2542,6 +2542,9 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs is_float_eq_candidate ct | pred <- ctPred ct , EqPred NomEq ty1 ty2 <- classifyPredType pred + , case ct of + CIrredCan {} -> False -- See Note [Do not float blocked constraints] + _ -> True -- See #18855 = float_eq ty1 ty2 || float_eq ty2 ty1 | otherwise = False @@ -2552,7 +2555,26 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs && (not (isTyVarTyVar tv1) || isTyVarTy ty2) Nothing -> False -{- Note [Float equalities from under a skolem binding] +{- Note [Do not float blocked constraints] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As #18855 showed, we must not float an equality that is blocked. +Consider + forall a[4]. [W] co1: alpha[4] ~ Maybe (a[4] |> bco) + [W] co2: alpha[4] ~ Maybe (beta[4] |> bco]) + [W] bco: kappa[2] ~ Type + +Now co1, co2 are blocked by bco. We will eventually float out bco +and solve it at level 2. But the danger is that we will *also* +float out co2, and that is bad bad bad. Because we'll promote alpha +and beta to level 2, and then fail to unify the promoted beta +with the skolem a[4]. + +Solution: don't float out blocked equalities. Remember: we only want +to float out if we can solve; see Note [Which equalities to float]. + +(Future plan: kill floating altogether.) + +Note [Float equalities from under a skolem binding] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which of the simple equalities can we float out? Obviously, only ones that don't mention the skolem-bound variables. But that is ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1206,9 +1206,11 @@ flatten_one ty@(ForAllTy {}) flatten_one (CastTy ty g) = do { (xi, co) <- flatten_one ty ; (g', _) <- flatten_co g - ; role <- getRole - ; return (mkCastTy xi g', castCoercionKind co role xi ty g' g) } + ; return (mkCastTy xi g', castCoercionKind1 co role xi ty g') } + -- It makes a /big/ difference to call castCoercionKind1 not + -- the more general castCoercionKind2. + -- See Note [castCoercionKind1] in GHC.Core.Coercion flatten_one (CoercionTy co) = first mkCoercionTy <$> flatten_co co ===================================== testsuite/tests/polykinds/T18855.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind + +type family Apply (f :: a -> b) (x :: a) :: b + +type F :: forall a. + forall (p :: forall bOne. Either a bOne -> Type) + -> forall bTwo. + forall (e :: Either a bTwo) + -> Apply p e + +type family F ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -225,3 +225,4 @@ test('T18451', normal, compile_fail, ['']) test('T18451a', normal, compile_fail, ['']) test('T18451b', normal, compile_fail, ['']) test('T18522-ppr', normal, ghci_script, ['T18522-ppr.script']) +test('T18855', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10709b.stderr ===================================== @@ -11,44 +11,44 @@ T10709b.hs:6:22: error: x4 = (replicateM 2 . mask) (\ _ -> return ()) T10709b.hs:7:22: error: - • Couldn't match type ‘t0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘t0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (t0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘t0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (\ x -> undefined x) In an equation for ‘x5’: x5 = (replicateM 2 . mask) (\ x -> undefined x) T10709b.hs:8:22: error: - • Couldn't match type ‘p0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘p0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (p0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘p0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (id (\ _ -> undefined)) In an equation for ‘x6’: x6 = (replicateM 2 . mask) (id (\ _ -> undefined)) T10709b.hs:9:22: error: - • Couldn't match type ‘b0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘b0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (b0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘b0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (const undefined) In an equation for ‘x7’: x7 = (replicateM 2 . mask) (const undefined) T10709b.hs:10:22: error: - • Couldn't match type ‘a0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘a0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (a0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘a0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) ((\ x -> undefined x) :: a -> b) ===================================== testsuite/tests/typecheck/should_fail/T12589.stderr ===================================== @@ -1,12 +1,2 @@ T12589.hs:13:3: error: Variable not in scope: (&) :: t0 -> t1 -> t - -T12589.hs:13:5: error: - • Couldn't match expected type ‘t1’ - with actual type ‘(forall a. Bounded a => f0 a) -> h0 f0 xs0’ - Cannot instantiate unification variable ‘t1’ - with a type involving polytypes: - (forall a. Bounded a => f0 a) -> h0 f0 xs0 - • In the second argument of ‘(&)’, namely ‘hcpure (Proxy @Bounded)’ - In the expression: minBound & hcpure (Proxy @Bounded) - In an equation for ‘a’: a = minBound & hcpure (Proxy @Bounded) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88ae0de68ee54f28fc62c8edc3d0b0dc89525494 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/88ae0de68ee54f28fc62c8edc3d0b0dc89525494 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 12:33:42 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Tue, 20 Oct 2020 08:33:42 -0400 Subject: [Git][ghc/ghc][wip/ghc-281-proposal-visible-foralls-proto] (proto) visible foralls in terms Message-ID: <5f8ed9266dec2_28006fc16c8120398d@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-281-proposal-visible-foralls-proto at Glasgow Haskell Compiler / GHC Commits: ea1d5fb5 by Daniel Rogozin at 2020-10-20T15:33:17+03:00 (proto) visible foralls in terms - - - - - 15 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Match.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Tc/Utils/Zonk.hs - compiler/GHC/Tc/Validity.hs Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -72,7 +72,10 @@ module GHC.Core.TyCo.Rep ( typeSize, coercionSize, provSize, -- * Multiplicities - Scaled(..), scaledMult, scaledThing, mapScaledType, Mult + Scaled(..), scaledMult, scaledThing, mapScaledType, Mult, + + -- * visible foralls related definitions + ArgType(..), mkVisFunForallTys, normalArgTys ) where #include "HsVersions.h" @@ -2071,3 +2074,22 @@ So that Mult feels a bit more structured, we provide pattern synonyms and smart constructors for these. -} type Mult = Type + +data ArgType + = NormalArgType (Scaled Type) + | ForallArgType ReqTVBinder + deriving Data.Data + +mkVisFunForallTy :: ArgType -> Type -> Type +mkVisFunForallTy (NormalArgType m) ty = mkScaledFunTy VisArg m ty +mkVisFunForallTy (ForallArgType (Bndr var _)) ty = ForAllTy (Bndr var Required) ty + +mkVisFunForallTys :: [ArgType] -> Type -> Type +mkVisFunForallTys tys ty = foldr mkVisFunForallTy ty tys + +normalArgTys :: [ArgType] -> [Scaled Type] +normalArgTys [] = [] +normalArgTys (arg_ty : arg_tys) + = case arg_ty of + NormalArgType ty -> ty : normalArgTys arg_tys + _ -> normalArgTys arg_tys ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Data.FastString import GHC.Core.Type +import GHC.Core.TyCo.Rep (ArgType) import GHC.Builtin.Types (mkTupleStr) import GHC.Tc.Utils.TcType (TcType) import {-# SOURCE #-} GHC.Tc.Types (TcLclEnv) @@ -1710,7 +1711,7 @@ data MatchGroup p body data MatchGroupTc = MatchGroupTc - { mg_arg_tys :: [Scaled Type] -- Types of the arguments, t1..tn + { mg_arg_tys :: [ArgType] -- Types of the arguments, t1..tn , mg_res_ty :: Type -- Type of the result, tr } deriving Data ===================================== compiler/GHC/HsToCore/Arrows.hs ===================================== @@ -43,6 +43,7 @@ import GHC.Core import GHC.Core.FVs import GHC.Core.Utils import GHC.Core.Make +import GHC.Core.TyCo.Rep import GHC.HsToCore.Binds (dsHsWrapper) import GHC.Types.Id @@ -595,7 +596,7 @@ dsCmd ids local_vars stack_ty res_ty exprFreeIdsDSet core_body `uniqDSetIntersectUniqSet` local_vars) dsCmd ids local_vars stack_ty res_ty - (HsCmdLamCase _ mg at MG { mg_ext = MatchGroupTc [Scaled arg_mult arg_ty] _ }) env_ids = do + (HsCmdLamCase _ mg at MG { mg_ext = MatchGroupTc [NormalArgType (Scaled arg_mult arg_ty)] _ }) env_ids = do arg_id <- newSysLocalDs arg_mult arg_ty let case_cmd = noLoc $ HsCmdCase noExtField (nlHsVar arg_id) mg dsCmdLam ids local_vars stack_ty res_ty [nlVarPat arg_id] case_cmd env_ids ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -48,6 +48,7 @@ import GHC.Core.Coercion( Coercion ) import GHC.Core import GHC.Core.Utils import GHC.Core.Make +import GHC.Core.TyCo.Rep( ArgType (..) ) import GHC.Driver.Session import GHC.Types.CostCentre @@ -721,7 +722,7 @@ dsExpr expr@(RecordUpd { rupd_expr = record_expr, rupd_flds = fields ; ([discrim_var], matching_code) <- matchWrapper RecUpd (Just record_expr) -- See Note [Scrutinee in Record updates] (MG { mg_alts = noLoc alts - , mg_ext = MatchGroupTc [unrestricted in_ty] out_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted in_ty)] out_ty , mg_origin = FromSource }) -- FromSource is not strictly right, but we @@ -1119,7 +1120,7 @@ dsDo ctx stmts (MG { mg_alts = noLoc [mkSimpleMatch LambdaExpr [mfix_pat] body] - , mg_ext = MatchGroupTc [unrestricted tup_ty] body_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted tup_ty)] body_ty , mg_origin = Generated }) mfix_pat = noLoc $ LazyPat noExtField $ mkBigLHsPatTupId rec_tup_pats body = noLoc $ HsDo body_ty ===================================== compiler/GHC/HsToCore/Match.hs ===================================== @@ -36,6 +36,7 @@ import GHC.Tc.Utils.Monad import GHC.HsToCore.Pmc import GHC.HsToCore.Pmc.Types ( Nablas, initNablas ) import GHC.Core +import GHC.Core.TyCo.Rep (normalArgTys) import GHC.Types.Literal import GHC.Core.Utils import GHC.Core.Make @@ -757,11 +758,11 @@ matchWrapper ctxt mb_scr (MG { mg_alts = L _ matches ; locn <- getSrcSpanDs ; new_vars <- case matches of - [] -> newSysLocalsDsNoLP arg_tys + [] -> newSysLocalsDsNoLP (normalArgTys arg_tys) (m:_) -> selectMatchVars (zipWithEqual "matchWrapper" (\a b -> (scaledMult a, unLoc b)) - arg_tys + (normalArgTys arg_tys) (hsLMatchPats m)) -- Pattern match check warnings for /this match-group/. ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -34,6 +34,7 @@ import GHC.Core.ConLike ( conLikeName, ConLike(RealDataCon) ) import GHC.Core.TyCon ( TyCon, tyConClass_maybe ) import GHC.Core.FVs import GHC.Core.DataCon ( dataConNonlinearType ) +import GHC.Core.TyCo.Rep ( mkVisFunForallTys ) import GHC.HsToCore ( deSugarExpr ) import GHC.Types.FieldLabel import GHC.Hs @@ -45,7 +46,7 @@ import GHC.Types.Name ( Name, nameSrcSpan, nameUnique ) import GHC.Types.Name.Env ( NameEnv, emptyNameEnv, extendNameEnv, lookupNameEnv ) import GHC.Types.SrcLoc import GHC.Tc.Utils.Zonk ( hsLitType, hsPatType ) -import GHC.Core.Type ( mkVisFunTys, Type ) +import GHC.Core.Type ( Type ) import GHC.Core.Predicate import GHC.Core.InstEnv import GHC.Builtin.Types ( mkListTy, mkSumTy ) @@ -747,7 +748,7 @@ instance HiePass p => HasType (Located (HsExpr (GhcPass p))) where fallback = makeNode e' spn matchGroupType :: MatchGroupTc -> Type - matchGroupType (MatchGroupTc args res) = mkVisFunTys args res + matchGroupType (MatchGroupTc args res) = mkVisFunForallTys args res -- | Skip desugaring of these expressions for performance reasons. -- ===================================== compiler/GHC/Tc/Gen/App.hs ===================================== @@ -39,6 +39,7 @@ import GHC.Core.TyCo.Ppr import GHC.Core.TyCo.Subst (substTyWithInScope) import GHC.Core.TyCo.FVs( shallowTyCoVarsOfType ) import GHC.Core.Type +import GHC.Types.Basic ( PromotionFlag (..) ) import GHC.Tc.Types.Evidence import GHC.Types.Var.Set import GHC.Builtin.PrimOps( tagToEnumKey ) @@ -442,6 +443,9 @@ tcInstFun do_ql inst_final rn_fun fun_sigma rn_args ; case cts of Indirect fun_ty' -> go delta acc so_far fun_ty' args Flexi -> go1 delta acc so_far fun_ty args } + | (bndrs, _) <- splitForAllTysReq fun_ty + , not (null bndrs) + = go1 delta acc so_far fun_ty args | otherwise = go1 delta acc so_far fun_ty args @@ -556,6 +560,25 @@ tcVTA :: TcType -- Function type -- Deal with a visible type application -- The function type has already had its Inferred binders instantiated tcVTA fun_ty hs_ty + | (bndr : _, ty) <- splitForAllTysReq fun_ty + = do { let tv = binderVar bndr + kind = tyVarKind tv + ; ty_arg <- tcHsTypeApp hs_ty kind + ; traceTc "ty_arg is" (ppr ty_arg) + + ; inner_ty <- zonkTcType ty + -- See Note [Visible type application zonk] + + ; let in_scope = mkInScopeSet (tyCoVarsOfTypes [fun_ty, ty_arg]) + insted_ty = substTyWithInScope in_scope [tv] [ty_arg] inner_ty + -- NB: tv and ty_arg have the same kind, so this + -- substitution is kind-respecting + ; traceTc "VTA" (vcat [ppr tv, debugPprType kind + , debugPprType ty_arg + , debugPprType (tcTypeKind ty_arg) + , debugPprType inner_ty + , debugPprType insted_ty ]) + ; return (ty_arg, insted_ty) } | Just (tvb, inner_ty) <- tcSplitForAllTy_maybe fun_ty , binderArgFlag tvb == Specified -- It really can't be Inferred, because we've just @@ -1087,5 +1110,3 @@ tcTagToEnum expr fun args app_res_ty res_ty tcExprPrag :: HsPragE GhcRn -> HsPragE GhcTc tcExprPrag (HsPragSCC x1 src ann) = HsPragSCC x1 src ann - - ===================================== compiler/GHC/Tc/Gen/Arrow.hs ===================================== @@ -31,6 +31,7 @@ import GHC.Tc.Utils.Env import GHC.Tc.Types.Origin import GHC.Tc.Types.Evidence import GHC.Core.Multiplicity +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Types.Id( mkLocalId ) import GHC.Tc.Utils.Instantiate import GHC.Builtin.Types @@ -265,7 +266,7 @@ tc_cmd env , m_grhss = grhss' }) arg_tys = map (unrestricted . hsLPatType) pats' cmd' = HsCmdLam x (MG { mg_alts = L l [match'] - , mg_ext = MatchGroupTc arg_tys res_ty + , mg_ext = MatchGroupTc (NormalArgType <$> arg_tys) res_ty , mg_origin = origin }) ; return (mkHsCmdWrap (mkWpCastN co) cmd') } where ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -1124,7 +1124,7 @@ tcSynArgE orig sigma_ty syn_ty thing_inside , res_wrapper ) -- :: res_ty_out "->" res_ty , arg_wrapper1, [], arg_wrapper2 ) ) -- :: arg_ty "->" arg_ty_out <- matchExpectedFunTys herald GenSigCtxt 1 (mkCheckExpType rho_ty) $ - \ [arg_ty] res_ty -> + \ [NormalArgTy arg_ty] res_ty -> do { arg_tc_ty <- expTypeToType (scaledThing arg_ty) ; res_tc_ty <- expTypeToType res_ty ===================================== compiler/GHC/Tc/Gen/Match.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Types.Name import GHC.Builtin.Types import GHC.Types.Id import GHC.Core.TyCon +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Builtin.Types.Prim import GHC.Tc.Types.Evidence import GHC.Utils.Outputable @@ -141,7 +142,7 @@ tcMatchesCase :: (Outputable (body GhcRn)) => -- wrapper goes from MatchGroup's ty to expected ty tcMatchesCase ctxt (Scaled scrut_mult scrut_ty) matches res_ty - = tcMatches ctxt [Scaled scrut_mult (mkCheckExpType scrut_ty)] res_ty matches + = tcMatches ctxt [NormalArgTy (Scaled scrut_mult (mkCheckExpType scrut_ty))] res_ty matches tcMatchLambda :: SDoc -- see Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify -> TcMatchCtxt HsExpr @@ -187,7 +188,7 @@ data TcMatchCtxt body -- c.f. TcStmtCtxt, also in this module -- | Type-check a MatchGroup. tcMatches :: (Outputable (body GhcRn)) => TcMatchCtxt body - -> [Scaled ExpSigmaType] -- Expected pattern types + -> [ArgTy] -- Expected pattern types -> ExpRhoType -- Expected result-type of the Match. -> MatchGroup GhcRn (Located (body GhcRn)) -> TcM (MatchGroup GhcTc (Located (body GhcTc))) @@ -199,7 +200,7 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches -- when in inference mode, so we must do it ourselves, -- here, using expTypeToType = do { tcEmitBindingUsage bottomUE - ; pat_tys <- mapM scaledExpTypeToType pat_tys + ; pat_tys <- mapM argTyToArgType pat_tys ; rhs_ty <- expTypeToType rhs_ty ; return (MG { mg_alts = L l [] , mg_ext = MatchGroupTc pat_tys rhs_ty @@ -209,15 +210,20 @@ tcMatches ctxt pat_tys rhs_ty (MG { mg_alts = L l matches = do { umatches <- mapM (tcCollectingUsage . tcMatch ctxt pat_tys rhs_ty) matches ; let (usages,matches') = unzip umatches ; tcEmitBindingUsage $ supUEs usages - ; pat_tys <- mapM readScaledExpType pat_tys + ; pat_tys <- mapM argTyToArgType pat_tys ; rhs_ty <- readExpType rhs_ty ; return (MG { mg_alts = L l matches' , mg_ext = MatchGroupTc pat_tys rhs_ty , mg_origin = origin }) } + where + argTyToArgType (NormalArgTy (Scaled m t)) = fmap (NormalArgType . Scaled m) (readExpType t) + argTyToArgType (ForallArgTy p) = return (ForallArgType p) + + ------------- tcMatch :: (Outputable (body GhcRn)) => TcMatchCtxt body - -> [Scaled ExpSigmaType] -- Expected pattern types + -> [ArgTy] -- Expected pattern types -> ExpRhoType -- Expected result-type of the Match. -> LMatch GhcRn (Located (body GhcRn)) -> TcM (LMatch GhcTc (Located (body GhcTc))) @@ -228,7 +234,7 @@ tcMatch ctxt pat_tys rhs_ty match tc_match ctxt pat_tys rhs_ty match@(Match { m_pats = pats, m_grhss = grhss }) = add_match_ctxt match $ - do { (pats', grhss') <- tcPats (mc_what ctxt) pats pat_tys $ + do { (pats', grhss') <- tcPats (mc_what ctxt) pats (scaledExpTypes pat_tys) $ tcGRHSs ctxt grhss rhs_ty ; return (Match { m_ext = noExtField , m_ctxt = mc_what ctxt, m_pats = pats' ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Types.Basic import GHC.Tc.Solver import GHC.Tc.Utils.Unify import GHC.Core.Predicate +import GHC.Core.TyCo.Rep ( ArgType(..) ) import GHC.Builtin.Types import GHC.Tc.Utils.TcType import GHC.Tc.Types.Evidence @@ -728,14 +729,14 @@ tcPatSynMatcher (L loc name) lpat L (getLoc lpat) $ HsCase noExtField (nlHsVar scrutinee) $ MG{ mg_alts = L (getLoc lpat) cases - , mg_ext = MatchGroupTc [unrestricted pat_ty] res_ty + , mg_ext = MatchGroupTc [NormalArgType (unrestricted pat_ty)] res_ty , mg_origin = Generated } body' = noLoc $ HsLam noExtField $ MG{ mg_alts = noLoc [mkSimpleMatch LambdaExpr args body] - , mg_ext = MatchGroupTc (map unrestricted [pat_ty, cont_ty, fail_ty]) res_ty + , mg_ext = MatchGroupTc (map (NormalArgType . unrestricted) [pat_ty, cont_ty, fail_ty]) res_ty , mg_origin = Generated } match = mkMatch (mkPrefixFunRhs (L loc name)) [] ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -28,6 +28,7 @@ module GHC.Tc.Utils.TcType ( TcTyCon, KnotTied, ExpType(..), InferResult(..), ExpSigmaType, ExpRhoType, mkCheckExpType, + ArgTy(..), scaledExpTypes, SyntaxOpType(..), synKnownType, mkSynFunTys, @@ -398,6 +399,16 @@ instance Outputable InferResult where mkCheckExpType :: TcType -> ExpType mkCheckExpType = Check +data ArgTy + = NormalArgTy (Scaled ExpSigmaType) + | ForallArgTy ReqTVBinder + +scaledExpTypes :: [ArgTy] -> [Scaled ExpSigmaType] +scaledExpTypes [] = [] +scaledExpTypes (arg_ty : arg_tys) + = case arg_ty of + NormalArgTy ty -> ty : scaledExpTypes arg_tys + _ -> scaledExpTypes arg_tys {- ********************************************************************* * * @@ -1286,9 +1297,9 @@ tcSplitPhiTy ty -- | Split a sigma type into its parts. tcSplitSigmaTy :: Type -> ([TyVar], ThetaType, Type) -tcSplitSigmaTy ty = case tcSplitForAllTys ty of +tcSplitSigmaTy ty = case tcSplitForAllTysInvis ty of (tvs, rho) -> case tcSplitPhiTy rho of - (theta, tau) -> (tvs, theta, tau) + (theta, tau) -> (binderVar <$> tvs, theta, tau) -- | Split a sigma type into its parts, going underneath as many @ForAllTy at s -- as possible. For example, given this type synonym: ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -156,7 +156,7 @@ matchActualFunTySigma herald mb_thing err_info fun_ty ------------ mk_ctxt :: TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) - mk_ctxt res_ty env = mkFunTysMsg env herald (reverse arg_tys_so_far) + mk_ctxt res_ty env = mkFunTysMsg env herald (reverse (NormalArgType <$> arg_tys_so_far)) res_ty n_val_args_in_call (n_val_args_in_call, arg_tys_so_far) = err_info @@ -290,7 +290,7 @@ matchExpectedFunTys :: forall a. -> UserTypeCtxt -> Arity -> ExpRhoType -- Skolemised - -> ([Scaled ExpSigmaType] -> ExpRhoType -> TcM a) + -> ([ArgTy] -> ExpRhoType -> TcM a) -> TcM (HsWrapper, a) -- If matchExpectedFunTys n ty = (_, wrap) -- then wrap : (t1 -> ... -> tn -> ty_r) ~> ty, @@ -320,7 +320,7 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside go acc_arg_tys n (FunTy { ft_mult = mult, ft_af = af, ft_arg = arg_ty, ft_res = res_ty }) = ASSERT( af == VisArg ) - do { (wrap_res, result) <- go ((Scaled mult $ mkCheckExpType arg_ty) : acc_arg_tys) + do { (wrap_res, result) <- go ((NormalArgTy . Scaled mult $ mkCheckExpType arg_ty) : acc_arg_tys) (n-1) res_ty ; let fun_wrap = mkWpFun idHsWrapper wrap_res (Scaled mult arg_ty) res_ty doc ; return ( fun_wrap, result ) } @@ -328,6 +328,16 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside doc = text "When inferring the argument type of a function with type" <+> quotes (ppr orig_ty) + go acc_arg_tys n ty + | (bndrs, ty') <- tcSplitForAllTysReq ty + , not (null bndrs) + = do { let forall_args = ForallArgTy <$> bndrs + ; let req_arg_tys = forall_args ++ acc_arg_tys + ; let arg_num = n - (length forall_args) + ; (wrap_gen, (wrap_res, result)) <- tcSkolemise ctx ty' $ \ty' -> + go req_arg_tys arg_num ty' + ; return (wrap_gen <.> wrap_res, result) } + go acc_arg_tys n ty@(TyVarTy tv) | isMetaTyVar tv = do { cts <- readMetaTyVar tv @@ -354,11 +364,11 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside defer acc_arg_tys n (mkCheckExpType ty) ------------ - defer :: [Scaled ExpSigmaType] -> Arity -> ExpRhoType -> TcM (HsWrapper, a) + defer :: [ArgTy] -> Arity -> ExpRhoType -> TcM (HsWrapper, a) defer acc_arg_tys n fun_ty = do { more_arg_tys <- replicateM n newInferExpType ; res_ty <- newInferExpType - ; result <- thing_inside (reverse acc_arg_tys ++ (map unrestricted more_arg_tys)) res_ty + ; result <- thing_inside (reverse acc_arg_tys ++ (map (NormalArgTy . unrestricted) more_arg_tys)) res_ty ; more_arg_tys <- mapM readExpType more_arg_tys ; res_ty <- readExpType res_ty ; let unif_fun_ty = mkVisFunTysMany more_arg_tys res_ty @@ -367,19 +377,24 @@ matchExpectedFunTys herald ctx arity orig_ty thing_inside ; return (wrap, result) } ------------ - mk_ctxt :: [Scaled ExpSigmaType] -> TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) + mk_ctxt :: [ArgTy] -> TcType -> TidyEnv -> TcM (TidyEnv, MsgDoc) mk_ctxt arg_tys res_ty env = mkFunTysMsg env herald arg_tys' res_ty arity where - arg_tys' = map (\(Scaled u v) -> Scaled u (checkingExpType "matchExpectedFunTys" v)) $ - reverse arg_tys + arg_tys' = map toArgType (reverse arg_tys) + + toArgType (NormalArgTy (Scaled u v)) + = NormalArgType (Scaled u (checkingExpType "matchExpectedFunTys" v)) + toArgType (ForallArgTy bndr) + = ForallArgType bndr + -- this is safe b/c we're called from "go" -mkFunTysMsg :: TidyEnv -> SDoc -> [Scaled TcType] -> TcType -> Arity +mkFunTysMsg :: TidyEnv -> SDoc -> [ArgType] -> TcType -> Arity -> TcM (TidyEnv, MsgDoc) mkFunTysMsg env herald arg_tys res_ty n_val_args_in_call = do { (env', fun_rho) <- zonkTidyTcType env $ - mkVisFunTys arg_tys res_ty + mkVisFunForallTys arg_tys res_ty ; let (all_arg_tys, _) = splitFunTys fun_rho n_fun_args = length all_arg_tys ===================================== compiler/GHC/Tc/Utils/Zonk.hs ===================================== @@ -82,6 +82,7 @@ import GHC.Utils.Panic import GHC.Types.Unique.FM import GHC.Core.Multiplicity import GHC.Core +import GHC.Core.TyCo.Rep (ArgType(..), normalArgTys) import {-# SOURCE #-} GHC.Tc.Gen.Splice (runTopSplice) @@ -671,10 +672,10 @@ zonkMatchGroup env zBody (MG { mg_alts = L l ms , mg_ext = MatchGroupTc arg_tys res_ty , mg_origin = origin }) = do { ms' <- mapM (zonkMatch env zBody) ms - ; arg_tys' <- zonkScaledTcTypesToTypesX env arg_tys + ; arg_tys' <- zonkScaledTcTypesToTypesX env (normalArgTys arg_tys) ; res_ty' <- zonkTcTypeToTypeX env res_ty ; return (MG { mg_alts = L l ms' - , mg_ext = MatchGroupTc arg_tys' res_ty' + , mg_ext = MatchGroupTc (NormalArgType <$> arg_tys') res_ty' , mg_origin = origin }) } zonkMatch :: ZonkEnv ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -567,11 +567,6 @@ linearityAllowed = typeLevelUserTypeCtxt -- where VDQ is permitted) and -- @testsuite/tests/dependent/should_fail/T16326_Fail*.hs@ (for places where -- VDQ is disallowed). -vdqAllowed :: UserTypeCtxt -> Bool -vdqAllowed ctxt = case typeOrKindCtxt ctxt of - OnlyTypeCtxt -> False - OnlyKindCtxt -> True - BothTypeAndKindCtxt -> True {- Note [Correctness and performance of type synonym validity checking] @@ -724,7 +719,7 @@ check_type ve (CastTy ty _) = check_type ve ty -- -- Critically, this case must come *after* the case for TyConApp. -- See Note [Liberal type synonyms]. -check_type ve@(ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt +check_type ve@(ValidityEnv{ ve_tidy_env = env , ve_rank = rank, ve_expand = expand }) ty | not (null tvbs && null theta) = do { traceTc "check_type" (ppr ty $$ ppr rank) @@ -736,12 +731,6 @@ check_type ve@(ValidityEnv{ ve_tidy_env = env, ve_ctxt = ctxt -- Reject forall (a :: Eq b => b). blah -- In a kind signature we don't allow constraints - ; checkTcM (all (isInvisibleArgFlag . binderArgFlag) tvbs - || vdqAllowed ctxt) - (illegalVDQTyErr env ty) - -- Reject visible, dependent quantification in the type of a - -- term (e.g., `f :: forall a -> a -> Maybe a`) - ; check_valid_theta env' SigmaCtxt expand theta -- Allow type T = ?x::Int => Int -> Int -- but not type T = ?x::Int @@ -999,15 +988,6 @@ constraintTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) constraintTyErr env ty = (env, text "Illegal constraint in a kind:" <+> ppr_tidy env ty) --- | Reject a use of visible, dependent quantification in the type of a term. -illegalVDQTyErr :: TidyEnv -> Type -> (TidyEnv, SDoc) -illegalVDQTyErr env ty = - (env, vcat - [ hang (text "Illegal visible, dependent quantification" <+> - text "in the type of a term:") - 2 (ppr_tidy env ty) - , text "(GHC does not yet support this)" ] ) - -- | Reject uses of linear function arrows in kinds. linearFunKindErr :: TidyEnv -> Type -> (TidyEnv, SDoc) linearFunKindErr env ty = View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea1d5fb5512dcc7cbd7ee385f6bb51320875bc16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea1d5fb5512dcc7cbd7ee385f6bb51320875bc16 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 13:50:28 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 09:50:28 -0400 Subject: [Git][ghc/ghc][wip/T17945] 17 commits: gitlab-ci: Allow doc-tarball job to fail Message-ID: <5f8eeb24939b9_2800a071d1812195b3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17945 at Glasgow Haskell Compiler / GHC Commits: aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - c34bfe2a by Ben Gamari at 2020-10-20T09:50:26-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Platform.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/Tc/TyCl/Class.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst - ghc/GHCi/UI/Tags.hs - hadrian/src/Rules/Generate.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab149653ab02cb3221f8a408c01e3a5f67c6fafd...c34bfe2acd05c352794de79fd0f113799f4e7fa8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab149653ab02cb3221f8a408c01e3a5f67c6fafd...c34bfe2acd05c352794de79fd0f113799f4e7fa8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 14:38:12 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 20 Oct 2020 10:38:12 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 13 commits: [configure] fix LLVMTarget when native Message-ID: <5f8ef654515d6_28003fd38864ea4c1227546@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 13b5bca7 by Moritz Angermann at 2020-10-09T19:05:53+08:00 [configure] fix LLVMTarget when native uname -p return "arm", hence we can't work with target_cpu, but need to match on the target triple. - - - - - 5cbcd9c1 by Moritz Angermann at 2020-10-09T21:28:09+08:00 [testsuite] fix subsections_via_symbols test - - - - - b1f7b653 by Moritz Angermann at 2020-10-09T21:32:47+08:00 [testsuite] FixT11649 - - - - - bd8d997c by Moritz Angermann at 2020-10-15T00:31:47+08:00 Fix conc059 test - - - - - 5f1ce1fe by Moritz Angermann at 2020-10-15T00:32:38+08:00 WIP: fix ghci adjustors on aarch64/arm (infotables) - - - - - e9f7e561 by Moritz Angermann at 2020-10-16T16:23:03+08:00 [DWARF] Enable only on elf platforms - - - - - d7027d10 by Moritz Angermann at 2020-10-16T16:35:13+08:00 [Testsuite/LLVM] Fix T5681, T7571, T8131b - - - - - 688e9317 by Moritz Angermann at 2020-10-16T21:46:46+08:00 [testsuite/darwin] fix tests ghcilink003, ghcilink006 - - - - - 0a13e364 by Moritz Angermann at 2020-10-16T23:05:47+08:00 Fix linker_error2 - - - - - f7564af6 by Moritz Angermann at 2020-10-20T09:37:58+08:00 Sized Hints - - - - - d625eab0 by Moritz Angermann at 2020-10-20T15:50:29+08:00 [Testsuite/arm64] Fix test derefnull - - - - - 21a3f846 by Moritz Angermann at 2020-10-20T15:50:56+08:00 [testsuite/arm64] fix section_alignment - - - - - cb9372fd by Moritz Angermann at 2020-10-20T15:57:33+08:00 [macOS/arm64] darwinpcs :facepalm: - - - - - 28 changed files: - aclocal.m4 - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Ppr/Decl.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Utils.hs - libraries/ghci/GHCi/InfoTable.hsc - rts/Interpreter.c - rts/linker/MachO.c - rts/sm/Storage.c - testsuite/tests/concurrent/should_run/conc059_c.c - testsuite/tests/ghci/linking/all.T - testsuite/tests/llvm/should_compile/all.T - testsuite/tests/llvm/should_run/subsections_via_symbols/all.T - testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m - testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout - testsuite/tests/rts/all.T - testsuite/tests/rts/linker/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -118,7 +118,7 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS], GHC_CONVERT_OS([$target_os], [$TargetArch], [TargetOS]) fi - GHC_LLVM_TARGET([$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) + GHC_LLVM_TARGET([$target],[$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) GHC_SELECT_FILE_EXTENSIONS([$host], [exeext_host], [soext_host]) GHC_SELECT_FILE_EXTENSIONS([$target], [exeext_target], [soext_target]) @@ -2063,19 +2063,19 @@ case "$1" in esac ]) -# GHC_LLVM_TARGET(target_cpu, target_vendor, target_os, llvm_target_var) +# GHC_LLVM_TARGET(target, target_cpu, target_vendor, target_os, llvm_target_var) # -------------------------------- # converts the canonicalized target into something llvm can understand AC_DEFUN([GHC_LLVM_TARGET], [ - llvm_target_cpu=$1 - case "$1-$2-$3" in + llvm_target_cpu=$2 + case "$1" in *-freebsd*-gnueabihf) llvm_target_vendor="unknown" llvm_target_os="freebsd-gnueabihf" ;; *-hardfloat-*eabi) llvm_target_vendor="unknown" - llvm_target_os="$3""hf" + llvm_target_os="$4""hf" ;; *-mingw32|*-mingw64|*-msys) llvm_target_vendor="unknown" @@ -2086,25 +2086,25 @@ AC_DEFUN([GHC_LLVM_TARGET], [ # turned into just `-linux` and fail to be found # in the `llvm-targets` file. *-android*|*-gnueabi*|*-musleabi*) - GHC_CONVERT_VENDOR([$2],[llvm_target_vendor]) - llvm_target_os="$3" + GHC_CONVERT_VENDOR([$3],[llvm_target_vendor]) + llvm_target_os="$4" ;; # apple is a bit about their naming scheme for # aarch64; and clang on macOS doesn't know that # aarch64 would be arm64. So for LLVM we'll need # to call it arm64; while we'll refer to it internally # as aarch64 for consistency and sanity. - aarch64-apple-*) + aarch64-apple-*|arm64-apple-*) llvm_target_cpu="arm64" - GHC_CONVERT_VENDOR([$2],[llvm_target_vendor]) - GHC_CONVERT_OS([$3],[$1],[llvm_target_os]) + GHC_CONVERT_VENDOR([$3],[llvm_target_vendor]) + GHC_CONVERT_OS([$4],[$2],[llvm_target_os]) ;; *) - GHC_CONVERT_VENDOR([$2],[llvm_target_vendor]) - GHC_CONVERT_OS([$3],[$1],[llvm_target_os]) + GHC_CONVERT_VENDOR([$3],[llvm_target_vendor]) + GHC_CONVERT_OS([$4],[$2],[llvm_target_os]) ;; esac - $4="$llvm_target_cpu-$llvm_target_vendor-$llvm_target_os" + $5="$llvm_target_cpu-$llvm_target_vendor-$llvm_target_os" ]) ===================================== compiler/GHC/Cmm/LayoutStack.hs ===================================== @@ -1194,13 +1194,15 @@ lowerSafeForeignCall profile block foreignLbl :: FastString -> CmmExpr foreignLbl name = CmmLit (CmmLabel (mkForeignLabel name Nothing ForeignLabelInExternalPackage IsFunction)) +-- void * suspendThread (StgRegTable *, bool interruptible); callSuspendThread :: Platform -> LocalReg -> Bool -> CmmNode O O callSuspendThread platform id intrbl = CmmUnsafeForeignCall (ForeignTarget (foreignLbl (fsLit "suspendThread")) - (ForeignConvention CCallConv [AddrHint, NoHint] [AddrHint] CmmMayReturn)) + (ForeignConvention CCallConv [AddrHint, NoHint W32] [AddrHint] CmmMayReturn)) [id] [baseExpr, mkIntExpr platform (fromEnum intrbl)] +-- StgRegTable * resumeThread (void *); callResumeThread :: LocalReg -> LocalReg -> CmmNode O O callResumeThread new_base id = CmmUnsafeForeignCall ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -655,10 +655,14 @@ pprCallishMachOp mo = text (show mo) callishMachOpHints :: CallishMachOp -> ([ForeignHint], [ForeignHint]) callishMachOpHints op = case op of - MO_Memcpy _ -> ([], [AddrHint,AddrHint,NoHint]) - MO_Memset _ -> ([], [AddrHint,NoHint,NoHint]) - MO_Memmove _ -> ([], [AddrHint,AddrHint,NoHint]) - MO_Memcmp _ -> ([], [AddrHint, AddrHint, NoHint]) + -- void * memcpy(void *restrict dst, const void *restrict src, size_t n); + MO_Memcpy _ -> ([], [AddrHint, AddrHint, NoHint W64]) + -- void * memset(void *b, int c, size_t len); + MO_Memset _ -> ([], [AddrHint, SignedHint W32, NoHint W64]) + -- void * memmove(void *dst, const void *src, size_t len); + MO_Memmove _ -> ([], [AddrHint, AddrHint, NoHint W64]) + -- int memcmp(const void *s1, const void *s2, size_t n); + MO_Memcmp _ -> ([], [AddrHint, AddrHint, NoHint W64]) _ -> ([],[]) -- empty lists indicate NoHint ===================================== compiler/GHC/Cmm/Node.hs ===================================== @@ -306,8 +306,8 @@ data ForeignTarget -- The target of a foreign call foreignTargetHints :: ForeignTarget -> ([ForeignHint], [ForeignHint]) foreignTargetHints target - = ( res_hints ++ repeat NoHint - , arg_hints ++ repeat NoHint ) + = ( res_hints ++ repeat undefined + , arg_hints ++ repeat undefined ) where (res_hints, arg_hints) = case target of ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -1101,14 +1101,14 @@ parseSafety str = failMsgPD ("unrecognised safety: " ++ str) parseCmmHint :: String -> PD ForeignHint parseCmmHint "ptr" = return AddrHint -parseCmmHint "signed" = return SignedHint +parseCmmHint "signed" = return $ SignedHint W64 parseCmmHint str = failMsgPD ("unrecognised hint: " ++ str) -- labels are always pointers, so we might as well infer the hint inferCmmHint :: CmmExpr -> ForeignHint inferCmmHint (CmmLit (CmmLabel _)) = AddrHint inferCmmHint (CmmReg (CmmGlobal g)) | isPtrGlobalReg g = AddrHint -inferCmmHint _ = NoHint +inferCmmHint _ = NoHint W64 isPtrGlobalReg Sp = True isPtrGlobalReg SpLim = True ===================================== compiler/GHC/Cmm/Ppr/Decl.hs ===================================== @@ -130,8 +130,8 @@ pprInfoTable (CmmInfoTable { cit_lbl = lbl, cit_rep = rep , text "srt: " <> ppr srt ] instance Outputable ForeignHint where - ppr NoHint = empty - ppr SignedHint = quotes(text "signed") + ppr (NoHint sz) = quotes(text "unsigned" <+> ppr sz) + ppr (SignedHint sz) = quotes(text "signed" <+> ppr sz) -- ppr AddrHint = quotes(text "address") -- Temp Jan08 ppr AddrHint = (text "PtrHint") ===================================== compiler/GHC/Cmm/Type.hs ===================================== @@ -18,6 +18,7 @@ module GHC.Cmm.Type , rEP_StgEntCounter_allocd , ForeignHint(..) + , hintToWidth , Length , vec, vec2, vec4, vec8, vec16 @@ -314,11 +315,15 @@ isVecType _ = False -- needed by the ABI to make the correct kind of call. data ForeignHint - = NoHint | AddrHint | SignedHint - deriving( Eq ) + = NoHint Width | AddrHint | SignedHint Width + deriving( Eq, Show ) -- Used to give extra per-argument or per-result -- information needed by foreign calling conventions +hintToWidth :: ForeignHint -> Width +hintToWidth (NoHint w) = w +hintToWidth AddrHint = W64 -- XXX: this should be ptr size. +hintToWidth (SignedHint w) = w ------------------------------------------------------------------------- -- These don't really belong here, but I don't know where is best to ===================================== compiler/GHC/Cmm/Utils.hs ===================================== @@ -14,7 +14,7 @@ module GHC.Cmm.Utils( -- CmmType - primRepCmmType, slotCmmType, slotForeignHint, + primRepCmmType, slotCmmType, typeCmmType, typeForeignHint, primRepForeignHint, -- CmmLit @@ -140,34 +140,27 @@ primElemRepCmmType DoubleElemRep = f64 typeCmmType :: Platform -> UnaryType -> CmmType typeCmmType platform ty = primRepCmmType platform (typePrimRep1 ty) -primRepForeignHint :: PrimRep -> ForeignHint -primRepForeignHint VoidRep = panic "primRepForeignHint:VoidRep" -primRepForeignHint LiftedRep = AddrHint -primRepForeignHint UnliftedRep = AddrHint -primRepForeignHint IntRep = SignedHint -primRepForeignHint Int8Rep = SignedHint -primRepForeignHint Int16Rep = SignedHint -primRepForeignHint Int32Rep = SignedHint -primRepForeignHint Int64Rep = SignedHint -primRepForeignHint WordRep = NoHint -primRepForeignHint Word8Rep = NoHint -primRepForeignHint Word16Rep = NoHint -primRepForeignHint Word32Rep = NoHint -primRepForeignHint Word64Rep = NoHint -primRepForeignHint AddrRep = AddrHint -- NB! AddrHint, but NonPtrArg -primRepForeignHint FloatRep = NoHint -primRepForeignHint DoubleRep = NoHint -primRepForeignHint (VecRep {}) = NoHint - -slotForeignHint :: SlotTy -> ForeignHint -slotForeignHint PtrSlot = AddrHint -slotForeignHint WordSlot = NoHint -slotForeignHint Word64Slot = NoHint -slotForeignHint FloatSlot = NoHint -slotForeignHint DoubleSlot = NoHint - -typeForeignHint :: UnaryType -> ForeignHint -typeForeignHint = primRepForeignHint . typePrimRep1 +primRepForeignHint :: Platform -> PrimRep -> ForeignHint +primRepForeignHint _platform VoidRep = panic "primRepForeignHint:VoidRep" +primRepForeignHint _platform LiftedRep = AddrHint +primRepForeignHint _platform UnliftedRep = AddrHint +primRepForeignHint platform IntRep = SignedHint (cIntWidth platform) +primRepForeignHint _platform Int8Rep = SignedHint W8 +primRepForeignHint _platform Int16Rep = SignedHint W16 +primRepForeignHint _platform Int32Rep = SignedHint W32 +primRepForeignHint _platform Int64Rep = SignedHint W64 +primRepForeignHint platform WordRep = NoHint (wordWidth platform) +primRepForeignHint _platform Word8Rep = NoHint W8 +primRepForeignHint _platform Word16Rep = NoHint W16 +primRepForeignHint _platform Word32Rep = NoHint W32 +primRepForeignHint _platform Word64Rep = NoHint W64 +primRepForeignHint _platform AddrRep = AddrHint -- NB! AddrHint, but NonPtrArg +primRepForeignHint _platform FloatRep = NoHint W32 +primRepForeignHint _platform DoubleRep = NoHint W64 +primRepForeignHint _platform (VecRep {}) = NoHint W64 + +typeForeignHint :: Platform -> UnaryType -> ForeignHint +typeForeignHint platform = primRepForeignHint platform . typePrimRep1 --------------------------------------------------- -- ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -1184,7 +1184,7 @@ initNCGConfig dflags = NCGConfig ArchX86 -> v _ -> Nothing - , ncgDwarfEnabled = debugLevel dflags > 0 - , ncgDwarfUnwindings = debugLevel dflags >= 1 - , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. + , ncgDwarfEnabled = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags > 0 + , ncgDwarfUnwindings = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags >= 1 + , ncgDwarfStripBlockInfo = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. } ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1092,10 +1092,20 @@ genCCall target dest_regs arg_regs bid = do -- this will give us the format information to match on. arg_regs' <- mapM getSomeReg arg_regs + -- Now this is stupid. Our Cmm expressions doesn't carry the proper sizes + -- so while in Cmm we might get W64 incorrectly for an int, that is W32 in + -- STG; this thenn breaks packing of stack arguments, if we need to pack + -- for the pcs, e.g. darwinpcs. Option one would be to fix the Int type + -- in Cmm proper. Option two, which we choose here is to use extended Hint + -- information to contain the size information and use that when packing + -- arguments, spilled onto the stack. + let (_res_hints, arg_hints) = foreignTargetHints target + arg_regs'' = zipWith (\(r, f, c) h -> (r,f,h,c)) arg_regs' arg_hints + platform <- getPlatform let packStack = platformOS platform == OSDarwin - (stackSpace', passRegs, passArgumentsCode) <- passArguments packStack allGpArgRegs allFpArgRegs arg_regs' 0 [] nilOL + (stackSpace', passRegs, passArgumentsCode) <- passArguments packStack allGpArgRegs allFpArgRegs arg_regs'' 0 [] nilOL -- if we pack the stack, we may need to adjust to multiple of 8byte. -- if we don't pack the stack, it will always be multiple of 8. @@ -1242,11 +1252,11 @@ genCCall target dest_regs arg_regs bid = do config <- getConfig target <- cmmMakeDynamicReference config CallReference $ mkForeignLabel (fsLit name) Nothing ForeignLabelInThisPackage IsFunction - let cconv = ForeignConvention CCallConv [NoHint] [NoHint] CmmMayReturn + let cconv = ForeignConvention CCallConv [NoHint W64] [NoHint W64] CmmMayReturn genCCall (ForeignTarget target cconv) dest_regs arg_regs bid -- XXX: Optimize using paired load LDP - passArguments :: Bool -> [Reg] -> [Reg] -> [(Reg, Format, InstrBlock)] -> Int -> [Reg] -> InstrBlock -> NatM (Int, [Reg], InstrBlock) + passArguments :: Bool -> [Reg] -> [Reg] -> [(Reg, Format, ForeignHint, InstrBlock)] -> Int -> [Reg] -> InstrBlock -> NatM (Int, [Reg], InstrBlock) passArguments _packStack _ _ [] stackSpace accumRegs accumCode = return (stackSpace, accumRegs, accumCode) -- passArguments _ _ [] accumCode stackSpace | isEven stackSpace = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * stackSpace)) -- passArguments _ _ [] accumCode stackSpace = return $ SUM (OpReg W64 x31) (OpReg W64 x31) OpImm (ImmInt (-8 * (stackSpace + 1))) @@ -1285,34 +1295,37 @@ genCCall target dest_regs arg_regs bid = do -- For AArch64 specificies see: https://developer.arm.com/docs/ihi0055/latest/procedure-call-standard-for-the-arm-64-bit-architecture -- -- Still have GP regs, and we want to pass an GP argument. - passArguments pack (gpReg:gpRegs) fpRegs ((r, format, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do + passArguments pack (gpReg:gpRegs) fpRegs ((r, format, _hint, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do let w = formatToWidth format passArguments pack gpRegs fpRegs args stackSpace (gpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass gp argument: " ++ show r) $ MOV (OpReg w gpReg) (OpReg w r))) -- Still have FP regs, and we want to pass an FP argument. - passArguments pack gpRegs (fpReg:fpRegs) ((r, format, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do + passArguments pack gpRegs (fpReg:fpRegs) ((r, format, _hint, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do let w = formatToWidth format passArguments pack gpRegs fpRegs args stackSpace (fpReg:accumRegs) (accumCode `appOL` code_r `snocOL` (ANN (text $ "Pass fp argument: " ++ show r) $ MOV (OpReg w fpReg) (OpReg w r))) -- No mor regs left to pass. Must pass on stack. - passArguments pack [] [] ((r, format, code_r):args) stackSpace accumRegs accumCode = do - let w = formatToWidth format + passArguments pack [] [] ((r, format, hint, code_r):args) stackSpace accumRegs accumCode = do + let -- w = formatToWidth format + w = hintToWidth hint bytes = widthInBits w `div` 8 space = if pack then bytes else 8 stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) passArguments pack [] [] args (stackSpace+space) accumRegs (stackCode `appOL` accumCode) -- Still have fpRegs left, but want to pass a GP argument. Must be passed on the stack then. - passArguments pack [] fpRegs ((r, format, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do - let w = formatToWidth format + passArguments pack [] fpRegs ((r, format, hint, code_r):args) stackSpace accumRegs accumCode | isIntFormat format = do + let -- w = formatToWidth format + w = hintToWidth hint bytes = widthInBits w `div` 8 space = if pack then bytes else 8 stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) passArguments pack [] fpRegs args (stackSpace+space) accumRegs (stackCode `appOL` accumCode) -- Still have gpRegs left, but want to pass a FP argument. Must be passed on the stack then. - passArguments pack gpRegs [] ((r, format, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do - let w = formatToWidth format + passArguments pack gpRegs [] ((r, format, hint, code_r):args) stackSpace accumRegs accumCode | isFloatFormat format = do + let -- w = formatToWidth format + w = hintToWidth hint bytes = widthInBits w `div` 8 space = if pack then bytes else 8 stackCode = code_r `snocOL` (ANN (text $ "Pass argument (size " ++ show w ++ ") on the stack: " ++ show r) $ STR format (OpReg w r) (OpAddr (AddrRegImm (regSingle 31) (ImmInt stackSpace)))) ===================================== compiler/GHC/CmmToAsm/PPC/CodeGen.hs ===================================== @@ -1863,8 +1863,8 @@ genCCall' config gcp target dest_regs args | isBitsType rep = intFormat (wordWidth platform) | otherwise = cmmTypeFormat rep conv_op = case hint of - SignedHint -> MO_SS_Conv - _ -> MO_UU_Conv + SignedHint _ -> MO_SS_Conv + _ -> MO_UU_Conv stackOffset' = case gcp of GCPAIX -> ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2389,7 +2389,7 @@ genCCall' config is32Bit (PrimTarget (MO_PopCnt width)) dest_regs@[dst] targetExpr <- cmmMakeDynamicReference config CallReference lbl let target = ForeignTarget targetExpr (ForeignConvention CCallConv - [NoHint] [NoHint] + [NoHint W64] [NoHint W64] CmmMayReturn) genCCall' config is32Bit target dest_regs args bid where @@ -2422,7 +2422,7 @@ genCCall' config is32Bit (PrimTarget (MO_Pdep width)) dest_regs@[dst] targetExpr <- cmmMakeDynamicReference config CallReference lbl let target = ForeignTarget targetExpr (ForeignConvention CCallConv - [NoHint] [NoHint] + [NoHint W64] [NoHint W64] CmmMayReturn) genCCall' config is32Bit target dest_regs args bid where @@ -2455,7 +2455,7 @@ genCCall' config is32Bit (PrimTarget (MO_Pext width)) dest_regs@[dst] targetExpr <- cmmMakeDynamicReference config CallReference lbl let target = ForeignTarget targetExpr (ForeignConvention CCallConv - [NoHint] [NoHint] + [NoHint W64] [NoHint W64] CmmMayReturn) genCCall' config is32Bit target dest_regs args bid where @@ -2467,7 +2467,7 @@ genCCall' config is32Bit (PrimTarget (MO_Clz width)) dest_regs@[dst] args@[src] -- Fallback to `hs_clz64` on i386 targetExpr <- cmmMakeDynamicReference config CallReference lbl let target = ForeignTarget targetExpr (ForeignConvention CCallConv - [NoHint] [NoHint] + [NoHint W64] [NoHint W64] CmmMayReturn) genCCall' config is32Bit target dest_regs args bid @@ -2511,7 +2511,7 @@ genCCall' config is32Bit (PrimTarget (MO_UF_Conv width)) dest_regs args bid = do targetExpr <- cmmMakeDynamicReference config CallReference lbl let target = ForeignTarget targetExpr (ForeignConvention CCallConv - [NoHint] [NoHint] + [NoHint W64] [NoHint W64] CmmMayReturn) genCCall' config is32Bit target dest_regs args bid where ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -1004,13 +1004,13 @@ pprCall platform ppr_fn cconv results args pprArg (expr, AddrHint) = cCast platform (text "void *") expr -- see comment by machRepHintCType below - pprArg (expr, SignedHint) + pprArg (expr, SignedHint _) = cCast platform (machRep_S_CType platform $ typeWidth $ cmmExprType platform expr) expr pprArg (expr, _other) = pprExpr platform expr - pprUnHint AddrHint rep = parens (machRepCType platform rep) - pprUnHint SignedHint rep = parens (machRepCType platform rep) + pprUnHint AddrHint rep = parens (machRepCType platform rep) + pprUnHint (SignedHint _) rep = parens (machRepCType platform rep) pprUnHint _ _ = empty -- Currently we only have these two calling conventions, but this might @@ -1174,9 +1174,9 @@ isCmmWordType platform ty = not (isFloatType ty) -- the C compiler. machRepHintCType :: Platform -> CmmType -> ForeignHint -> SDoc machRepHintCType platform rep = \case - AddrHint -> text "void *" - SignedHint -> machRep_S_CType platform (typeWidth rep) - _other -> machRepCType platform rep + AddrHint -> text "void *" + (SignedHint _) -> machRep_S_CType platform (typeWidth rep) + _other -> machRepCType platform rep machRepPtrCType :: Platform -> CmmType -> SDoc machRepPtrCType platform r ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -606,11 +606,12 @@ getFCallArgs args typ | otherwise = do { cmm <- getArgAmode (NonVoid arg) ; profile <- getProfile - ; return (Just (add_shim profile typ cmm, hint)) } + ; platform <- getPlatform + ; return (Just (add_shim profile typ cmm, hint platform)) } where - arg_ty = stgArgType arg - arg_reps = typePrimRep arg_ty - hint = typeForeignHint arg_ty + arg_ty = stgArgType arg + arg_reps = typePrimRep arg_ty + hint plat = typeForeignHint plat arg_ty -- The minimum amount of information needed to determine -- the offset to apply to an argument to a foreign call. ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -265,12 +265,12 @@ emitPrimOp dflags primop = case primop of _ -> PrimopCmmEmit_External -- First we handle various awkward cases specially. - +-- Note: StgInt newSpark (StgRegTable *reg, StgClosure *p) ParOp -> \[arg] -> opIntoRegs $ \[res] -> do -- for now, just implement this in a C function -- later, we might want to inline it. emitCCall - [(res,NoHint)] + [(res,NoHint W32)] (CmmLit (CmmLabel (mkForeignLabel (fsLit "newSpark") Nothing ForeignLabelInExternalPackage IsFunction))) [(baseExpr, AddrHint), (arg,AddrHint)] @@ -281,7 +281,7 @@ emitPrimOp dflags primop = case primop of tmp <- assignTemp arg tmp2 <- newTemp (bWord platform) emitCCall - [(tmp2,NoHint)] + [(tmp2,NoHint W32)] (CmmLit (CmmLabel (mkForeignLabel (fsLit "newSpark") Nothing ForeignLabelInExternalPackage IsFunction))) [(baseExpr, AddrHint), ((CmmReg (CmmLocal tmp)), AddrHint)] emitAssign (CmmLocal res) (CmmReg (CmmLocal tmp)) ===================================== compiler/GHC/StgToCmm/Utils.hs ===================================== @@ -333,7 +333,7 @@ newUnboxedTupleRegs res_ty ; sequel <- getSequel ; regs <- choose_regs platform sequel ; ASSERT( regs `equalLength` reps ) - return (regs, map primRepForeignHint reps) } + return (regs, map (primRepForeignHint platform) reps) } where reps = typePrimRep res_ty choose_regs _ (AssignTo regs _) = return regs ===================================== libraries/ghci/GHCi/InfoTable.hsc ===================================== @@ -359,7 +359,8 @@ sizeOfEntryCode tables_next_to_code -- Note: Must return proper pointer for use in a closure newExecConItbl :: Bool -> StgInfoTable -> ByteString -> IO (FunPtr ()) newExecConItbl tables_next_to_code obj con_desc - = alloca $ \pcode -> do + = -- alloca $ \pcode -> + do sz0 <- sizeOfEntryCode tables_next_to_code let lcon_desc = BS.length con_desc + 1{- null terminator -} -- SCARY @@ -369,8 +370,10 @@ newExecConItbl tables_next_to_code obj con_desc -- table, because on a 64-bit platform we reference this string -- with a 32-bit offset relative to the info table, so if we -- allocated the string separately it might be out of range. - wr_ptr <- _allocateExec (sz + fromIntegral lcon_desc) pcode - ex_ptr <- peek pcode + wr_ptr <- _allocateWrite (sz + fromIntegral lcon_desc) + let ex_ptr = wr_ptr + -- wr_ptr <- _allocateExec (sz + fromIntegral lcon_desc) pcode + -- ex_ptr <- peek pcode let cinfo = StgConInfoTable { conDesc = ex_ptr `plusPtr` fromIntegral sz , infoTable = obj } pokeConItbl tables_next_to_code wr_ptr ex_ptr cinfo @@ -379,6 +382,7 @@ newExecConItbl tables_next_to_code obj con_desc let null_off = fromIntegral sz + fromIntegral (BS.length con_desc) poke (castPtr wr_ptr `plusPtr` null_off) (0 :: Word8) _flushExec sz ex_ptr -- Cache flush (if needed) + _markExec (sz + fromIntegral lcon_desc) ex_ptr pure $ if tables_next_to_code then castPtrToFunPtr $ ex_ptr `plusPtr` conInfoTableSizeB else castPtrToFunPtr ex_ptr @@ -389,6 +393,15 @@ foreign import ccall unsafe "allocateExec" foreign import ccall unsafe "flushExec" _flushExec :: CUInt -> Ptr a -> IO () +foreign import ccall unsafe "allocateWrite" + _allocateWrite :: CUInt -> IO (Ptr a) + +foreign import ccall unsafe "markExec" + _markExec :: CUInt -> Ptr a -> IO () + +foreign import ccall unsafe "freeWrite" + _freeWrite :: CUInt -> Ptr a -> IO () + -- ----------------------------------------------------------------------------- -- Constants and config ===================================== rts/Interpreter.c ===================================== @@ -979,7 +979,7 @@ run_BCO: bcoSize = bco->instrs->bytes / sizeof(StgWord16); #endif IF_DEBUG(interpreter,debugBelch("bcoSize = %d\n", bcoSize)); - + IF_DEBUG(interpreter,disassemble( bco )); #if defined(INTERP_STATS) it_lastopc = 0; /* no opcode */ #endif ===================================== rts/linker/MachO.c ===================================== @@ -1505,8 +1505,10 @@ ocResolve_MachO(ObjectCode* oc) */ if(NULL == symbol->addr) { symbol->addr = lookupSymbol_((char*)symbol->name); - if(NULL == symbol->addr) - barf("Failed to lookup symbol: %s", symbol->name); + if(NULL == symbol->addr) { + errorBelch("Failed to lookup symbol: %s", symbol->name); + return 0; + } } else { // we already have the address. } @@ -1515,10 +1517,12 @@ ocResolve_MachO(ObjectCode* oc) * the address as well already */ if(NULL == symbol->addr) { - barf("Something went wrong!"); + errorBelch("Something went wrong!"); + return 0; } if(NULL == symbol->got_addr) { - barf("Not good either!"); + errorBelch("Not good either!"); + return 0; } *(uint64_t*)symbol->got_addr = (uint64_t)symbol->addr; } ===================================== rts/sm/Storage.c ===================================== @@ -34,6 +34,10 @@ #include "Hash.h" #endif +#if RTS_LINKER_USE_MMAP +#include "LinkerInternals.h" +#endif + #include #include "ffi.h" @@ -1745,6 +1749,20 @@ AdjustorWritable allocateExec(W_ bytes, AdjustorExecutable *exec_ret) return writ; } +#if RTS_LINKER_USE_MMAP +AdjustorWritable allocateWrite(W_ bytes) { + return mmapForLinker(bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); +} + +void markExec(W_ bytes, AdjustorWritable writ) { + mmapForLinkerMarkExecutable(writ, bytes); +} + +void freeWrite(W_ bytes, AdjustorWritable writ) { + munmap(writ, bytes); +} +#endif + AdjustorWritable execToWritable(AdjustorExecutable exec) { AdjustorWritable writ; ===================================== testsuite/tests/concurrent/should_run/conc059_c.c ===================================== @@ -2,6 +2,7 @@ #include "conc059_stub.h" #include #include +#include #if mingw32_HOST_OS #include #endif ===================================== testsuite/tests/ghci/linking/all.T ===================================== @@ -13,7 +13,11 @@ test('ghcilink002', [extra_files(['TestLink.hs', 'f.c']), test('ghcilink003', [unless(doing_ghci, skip), # libstdc++ is named differently on FreeBSD - when(opsys('freebsd'), expect_broken(17739))], + when(opsys('freebsd'), expect_broken(17739)), + # from Big Sur onwards, we can't dlopen libstdc++.dylib + # anymore. Will produce: + # dlopen(libstdc++.dylib, 5): image not found + when(opsys('darwin'), expect_broken(17739))], makefile_test, ['ghcilink003']) @@ -33,7 +37,11 @@ test('ghcilink005', test('ghcilink006', [unless(doing_ghci, skip), # libstdc++ is named differently on FreeBSD - when(opsys('freebsd'), expect_broken(17739))], + when(opsys('freebsd'), expect_broken(17739)), + # from Big Sur onwards, we can't dlopen libstdc++.dylib + # anymore. Will produce: + # dlopen(libstdc++.dylib, 5): image not found + when(opsys('darwin'), expect_broken(17739))], makefile_test, ['ghcilink006']) ===================================== testsuite/tests/llvm/should_compile/all.T ===================================== @@ -5,11 +5,17 @@ def f( name, opts ): setTestOpts(f) +def ignore_llvm_and_vortex( msg ): + return re.sub(r"You are using an unsupported version of LLVM!.*\n",r"", + re.sub(r"Currently only [^ ]* is supported. System LLVM version: .*\n", r"", + re.sub(r"We will try though.*\n",r"", + re.sub(r".* is not a recognized processor for this target.*\n",r"",msg)))) + # test('T5486', normal, compile, ['']) -test('T5681', normal, compile, ['']) +test('T5681', [normal, normalise_errmsg_fun(ignore_llvm_and_vortex)], compile, ['']) test('T6158', [reqlib('vector'), reqlib('primitive')], compile, ['-package vector -package primitive']) -test('T7571', cmm_src, compile, ['-no-hs-main']) +test('T7571', [cmm_src, normalise_errmsg_fun(ignore_llvm_and_vortex)], compile, ['-no-hs-main']) test('T7575', unless(wordsize(32), skip), compile, ['']) -test('T8131b', normal, compile, ['']) -test('T11649', normal, compile, ['']) +test('T8131b', [normal, normalise_errmsg_fun(ignore_llvm_and_vortex)], compile, ['']) +test('T11649', [normal, normalise_errmsg_fun(ignore_llvm_and_vortex)], compile, ['']) test('T17920fail', cmm_src, compile_fail, ['-no-hs-main']) ===================================== testsuite/tests/llvm/should_run/subsections_via_symbols/all.T ===================================== @@ -3,9 +3,15 @@ # # Please refer to https://gitlab.haskell.org/ghc/ghc/issues/5019 # for the subsections_via_symbols.stderr +def ignore_llvm_and_vortex( msg ): + return re.sub(r"You are using an unsupported version of LLVM!.*\n",r"", + re.sub(r"Currently only [^ ]* is supported. System LLVM version: .*\n", r"", + re.sub(r"We will try though.*\n",r"", + re.sub(r".* is not a recognized processor for this target.*\n",r"",msg)))) test('subsections_via_symbols', [when(not opsys('darwin'), skip), only_ways(['optllvm', 'llvm', 'debugllvm']), - extra_files(['SubsectionsViaSymbols.hs'])], + extra_files(['SubsectionsViaSymbols.hs']), + normalise_errmsg_fun(ignore_llvm_and_vortex)], makefile_test, []) ===================================== testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m ===================================== @@ -1,6 +1,6 @@ #import #import "HsFFI.h" -#import "SymbolsViaSections_stub.h" +#import "SubsectionsViaSymbols_stub.h" int main(int argc, char * argv[]) { ===================================== testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout ===================================== @@ -1,2 +1,3 @@ +[1 of 1] Compiling SymbolsViaSections ( SubsectionsViaSymbols.hs, SubsectionsViaSymbols.o ) Linking subsections_via_symbols ... .......... ===================================== testsuite/tests/rts/all.T ===================================== @@ -37,6 +37,7 @@ test('derefnull', # The output under OS X is too unstable to readily compare when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(139)]), when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(139)]), + when(platform('aarch64-apple-darwin'), [ignore_stderr, exit_code(139)]), when(opsys('mingw32'), [ignore_stderr, exit_code(11)]), # since these test are supposed to crash the # profile report will be empty always. ===================================== testsuite/tests/rts/linker/all.T ===================================== @@ -12,7 +12,7 @@ test('unsigned_reloc_macho_x64', test('section_alignment', [ extra_files(['runner.c', 'section_alignment.c']), - unless(opsys('darwin') and arch('x86_64'), expect_broken(13624)) + unless(opsys('darwin') and have_ncg(), expect_broken(13624)) ], run_command, ['$MAKE -s --no-print-directory section_alignment']) @@ -104,8 +104,8 @@ test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip) compile_and_run, ['-rdynamic -package ghc']) -test('T7072', - [extra_files(['T7072-main.c', 'T7072-obj.c']), - unless(opsys('linux'), skip), - req_rts_linker], +test('T7072', + [extra_files(['T7072-main.c', 'T7072-obj.c']), + unless(opsys('linux'), skip), + req_rts_linker], makefile_test, ['T7072']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/046365b34996756242037e8f62c1ac8c6e4687ff...cb9372fd94af0ff2a0c247306e450c7467d410be -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/046365b34996756242037e8f62c1ac8c6e4687ff...cb9372fd94af0ff2a0c247306e450c7467d410be You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 15:44:10 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Tue, 20 Oct 2020 11:44:10 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f8f05caa99f2_280010a26a24123791c@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: 12aec424 by David Eichmann at 2020-10-20T16:43:25+01:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -330,14 +330,72 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. - - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ +/* Note [Locking and Pausing the RTS] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * You have to surround all access to the RtsAPI with rts_lock/rts_unlock or + * with rts_pause/rts_resume. + * + * + * # rts_lock / rts_unlock + * + * Use `rts_lock` to acquire a token which may be used to call other RtsAPI + * functions. This is achieved by acquiring a capability. Hence, at most n locks + * can be held simultaneously, where n is the number of capabilities. It is an + * error to call `rts_lock` when the rts is already paused by the current OS + * thread (see rts_pause/rts_resume below). + * + * + * # rts_pause / rts_resume + * + * Use `rts_pause` to halt execution of all Haskell threads and `rts_resume` to + * continue them. This is achieved by acquiring all capabilities. `rts_resume` + * must be called on the same thread as `rts_pause`. `rts_pause`, much like + * rts_lock, Returns a token which may be used to call other RtsAPI functions. + * + * * With the RTS paused, garbage collections will not occur and haskell threads + * will not execute, allocate nor mutate their stack. + * * Non-Haskell (i.e. non-worker) threads such as those running safe FFI calls + * will NOT be paused and can still mutate pinned mutable data such as pinned + * `MuttableByteArray#`s. + * * You may call `rts_pause` from within a non-worker OS thread. + * * You may call `rts_pause` from within a safe FFI call. In this case, make + * sure to call `rts_resume` within the same FFI call, or the RTS will likely + * deadlock. + * * Calling `rts_pause` from an unsafe FFI call will cause an error. + * * `rts_pause` does not pause threads running safe FFI calls. + * * On return, the rts will be fully paused: all haskell threads are stopped + * and all capabilities are acquired by the current thread. + * * `rts_pause` is different to rts_lock which only pauses a single capability. + * * Calling `rts_pause` in between rts_lock/rts_unlock on the same thread will + * cause an error. + * * Calling `rts_pause` results in an error if the RTS is already paused by the + * current OS thread. + * * Only one OS thread at a time can keep the rts paused. + * * `rts_pause` will block while another thread is pausing the RTS, and + * continue when the current thread is given exclusive permission to pause the + * RTS. + * + * + * ## Note on implementation. + * + * Although it's likely sufficient for many use cases to call RtsAPI.h functions + * from a single thread, we still want to ensure that the API is thread safe. + * This is achieved almost entirely by the mechanism of acquiring and releasing + * Capabilities, resulting in a sort of mutex / critical section pattern. + * This has the following consequences: + * + * * There are at most `n_capabilities` threads currently in a + * rts_lock/rts_unlock section. + * * There is at most 1 threads in a rts_pause/rts_resume section. In that case + * there will be no threads in a rts_lock/rts_unlock section. + * * rts_pause and rts_lock may block in order to enforce the above 2 + * invariants. + */ -// acquires a token which may be used to create new objects and -// evaluate them. +// acquires a token which may be used to create new objects and evaluate them. +// Calling rts_lock in between rts_pause/rts_resume on the same thread will +// cause an error. Capability *rts_lock (void); // releases the token acquired with rts_lock(). @@ -483,6 +541,18 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads. +// See Note [Locking and Pausing the RTS] for correct usage. +Capability * rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. +// See Note [Locking and Pausing the RTS] for correct usage. +// [in] cap: the token returned by rts_pause. +void rts_resume (Capability * cap); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,14 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,12 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +599,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already called rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +634,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +659,141 @@ rts_unlock (Capability *cap) } } +#if defined(THREADED_RTS) + +// See Note [Locking and Pausing the RTS] +Capability * rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (at it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + return task->cap; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See Note [Locking and Pausing the RTS]. The cap argument is here just for +// symmetry with rts_pause and to match the pattern of rts_lock/rts_unlock. +void rts_resume (Capability * cap STG_UNUSED) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +Capability * GNU_ATTRIBUTE(__noreturn__) +rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (Capability * cap STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +829,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,15 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1573,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2096,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2776,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2835,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,12 @@ +test('pause_resume_via_safe_ffi', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,250 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + Capability * cap = rts_pause(); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + Capability * cap2 = rts_pause(); // This should have no effect and return immediately. + if(cap != cap2) { + errorBelch("A second call to rts_pause() returned a different Capability."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(cap); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + Capability * cap = rts_pause(); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + + // TODO print out what funciton is running to give better debug output if one of these deadlocks + + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(cap); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + safe_pthread_join_c :: CULong -> IO () + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,20 @@ + +test('unsafe_rts_pause', [only_ways(threaded_ways), exit_code(1)], compile_and_run, ['']) +test('rts_lock_when_paused', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,79 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + Capability * pauseCapA = rts_pause(); + printf("Paused\n"); + + printf("Pausing..."); + Capability * pauseCapB = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_unlock(pauseCapA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(pauseCapB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already call rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12aec424f9f89ea2ff1dbd330686bd51240df92f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/12aec424f9f89ea2ff1dbd330686bd51240df92f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 16:44:19 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Tue, 20 Oct 2020 12:44:19 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f8f13e385b61_28003fd3ed29637c12465dd@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: 69b0dda7 by David Eichmann at 2020-10-20T17:44:08+01:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -330,17 +330,75 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. - - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ - -// acquires a token which may be used to create new objects and -// evaluate them. +/* Note [Locking and Pausing the RTS] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You have to surround all access to the RtsAPI with rts_lock/rts_unlock or +with rts_pause/rts_resume. + + +# rts_lock / rts_unlock + +Use `rts_lock` to acquire a token which may be used to call other RtsAPI +functions and call `rts_unlock` to return the token. When locked, garbage +collection will not occur. As long as 1 or more capabilities are not locked, +haskell threads will continue to execute. If you want to pause execution of +all haskell threads then use rts_pause/rts_resume instead. + +The implementation of `rts_lock` acquires a capability on this thread. Hence, +at most n locks can be held simultaneously, where n is the number of +capabilities. It is an error to call `rts_lock` when the rts is already +paused by the current OS thread (see rts_pause/rts_resume below). + + +# rts_pause / rts_resume + +Use `rts_pause` to pause execution of all Haskell threads and `rts_resume` to +resume them. The implementation acquires all capabilities. `rts_resume` +must be called on the same thread as `rts_pause`. `rts_pause`, much like +rts_lock, Returns a token which may be used to call other RtsAPI functions. + +* With the RTS paused, garbage collections will not occur and haskell threads + will not execute, allocate, nor mutate their stacks. +* Non-Haskell (i.e. non-worker) threads such as those running safe FFI calls + will NOT be paused and can still mutate pinned mutable data such as pinned + `MutableByteArray#`s. +* You may call `rts_pause` from within a non-worker OS thread. +* You may call `rts_pause` from within a *safe* FFI call. In this case, make + sure to call `rts_resume` within the same FFI call or the RTS will deadlock. +* Calling `rts_pause` from an *unsafe* FFI call will cause an error. +* On return, the rts will be fully paused: all haskell threads are stopped + and all capabilities are acquired by the current OS thread. +* Calling `rts_pause` in between rts_lock/rts_unlock on the same thread will + cause an error. +* Calling `rts_pause` results in an error if the RTS is already paused by the + current OS thread. +* Only one OS thread at a time can keep the rts paused. +* `rts_pause` will block while another thread is pausing the RTS, and + continue when the current thread is given exclusive permission to pause the + RTS. + +## Note on implementation. + +Thread safety is achieved almost entirely by the mechanism of acquiring and +releasing Capabilities, resulting in a sort of mutex / critical section pattern. +This has the following consequences: + +* There are at most `n_capabilities` threads currently in a + rts_lock/rts_unlock section. +* There is at most 1 threads in a rts_pause/rts_resume section. In that case + there will be no threads in a rts_lock/rts_unlock section. +* rts_pause and rts_lock may block in order to enforce the above 2 + invariants. + +*/ + +// Acquires a token which may be used to create new objects and evaluate them. +// See Note [Locking and Pausing the RTS] for correct usage. Capability *rts_lock (void); // releases the token acquired with rts_lock(). +// See Note [Locking and Pausing the RTS] for correct usage. void rts_unlock (Capability *token); // If you are in a context where you know you have a current capability but @@ -483,6 +541,18 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads. +// See Note [Locking and Pausing the RTS] for correct usage. +Capability * rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. +// See Note [Locking and Pausing the RTS] for correct usage. +// [in] cap: the token returned by rts_pause. +void rts_resume (Capability * cap); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,14 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,16 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +// +// It's possible to remove this and instead define the pausing task as whichever +// task owns all capabilities, but using `rts_pausing_task` leads to marginally +// cleaner code/API and better error messages. +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +603,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already called rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +638,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +663,141 @@ rts_unlock (Capability *cap) } } +#if defined(THREADED_RTS) + +// See Note [Locking and Pausing the RTS] +Capability * rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (at it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + return task->cap; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See Note [Locking and Pausing the RTS]. The cap argument is here just for +// symmetry with rts_pause and to match the pattern of rts_lock/rts_unlock. +void rts_resume (Capability * cap STG_UNUSED) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +Capability * GNU_ATTRIBUTE(__noreturn__) +rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (Capability * cap STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +833,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,15 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1573,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2096,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2776,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2835,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,12 @@ +test('pause_resume_via_safe_ffi', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,247 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + Capability * cap = rts_pause(); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + Capability * cap2 = rts_pause(); // This should have no effect and return immediately. + if(cap != cap2) { + errorBelch("A second call to rts_pause() returned a different Capability."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(cap); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + Capability * cap = rts_pause(); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(cap); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + safe_pthread_join_c :: CULong -> IO () + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,20 @@ + +test('unsafe_rts_pause', [only_ways(threaded_ways), exit_code(1)], compile_and_run, ['']) +test('rts_lock_when_paused', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,79 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + Capability * pauseCapA = rts_pause(); + printf("Paused\n"); + + printf("Pausing..."); + Capability * pauseCapB = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_unlock(pauseCapA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(pauseCapB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already call rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69b0dda793ef47f541a84a3788508d72ee6682ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69b0dda793ef47f541a84a3788508d72ee6682ed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 18:45:58 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 14:45:58 -0400 Subject: [Git][ghc/ghc][wip/tsan/timer] 6 commits: rts: Accept benign races in Proftimer Message-ID: <5f8f306618ae_28003fd3e89770381277174@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/timer at Glasgow Haskell Compiler / GHC Commits: 1ce9c5c7 by Ben Gamari at 2020-10-20T14:45:50-04:00 rts: Accept benign races in Proftimer - - - - - 03b5dc44 by Ben Gamari at 2020-10-20T14:45:50-04:00 rts: Pause timer while changing capability count This avoids #17289. - - - - - f8257342 by Ben Gamari at 2020-10-20T14:45:51-04:00 Fix #17289 - - - - - 60aeb584 by Ben Gamari at 2020-10-20T14:45:51-04:00 suppress #17289 (ticker) race - - - - - d7885a85 by Ben Gamari at 2020-10-20T14:45:51-04:00 rts: Fix timer initialization Previously `initScheduler` would attempt to pause the ticker and in so doing acquire the ticker mutex. However, initTicker, which is responsible for initializing said mutex, hadn't been called yet. - - - - - c5da3791 by Ben Gamari at 2020-10-20T14:45:51-04:00 rts: Annotate benign race in ticker shutdown logic We are guaranteed to see the change in the `stopped` flag at some point so the race is harmless. - - - - - 7 changed files: - rts/.tsan-suppressions - rts/Capability.c - rts/Proftimer.c - rts/RtsStartup.c - rts/Schedule.c - rts/Timer.c - rts/posix/itimer/Pthread.c Changes: ===================================== rts/.tsan-suppressions ===================================== @@ -7,3 +7,7 @@ race:capability_is_busy # This is a benign race during IO manager shutdown (between ioManagerWakeup # and GHC.Event.Control.closeControl). race:ioManagerWakeup + +# This is a potentially problematic race which I have yet to work out +# (#17289) +race:handle_tick ===================================== rts/Capability.c ===================================== @@ -410,36 +410,44 @@ void moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - uint32_t i; - Capability **old_capabilities = capabilities; + Capability **new_capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities"); - capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities"); + // We must disable the timer while we do this since the tick handler may + // call contextSwitchAllCapabilities, which may see the capabilities array + // as we free it. The alternative would be to protect the capabilities + // array with a lock but this seems more expensive than necessary. + // See #17289. + stopTimer(); if (to == 1) { // THREADED_RTS must work on builds that don't have a mutable // BaseReg (eg. unregisterised), so in this case // capabilities[0] must coincide with &MainCapability. - capabilities[0] = &MainCapability; + new_capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); } else { - for (i = 0; i < to; i++) { + for (uint32_t i = 0; i < to; i++) { if (i < from) { - capabilities[i] = old_capabilities[i]; + new_capabilities[i] = capabilities[i]; } else { - capabilities[i] = stgMallocBytes(sizeof(Capability), - "moreCapabilities"); - initCapability(capabilities[i], i); + new_capabilities[i] = stgMallocBytes(sizeof(Capability), + "moreCapabilities"); + initCapability(new_capabilities[i], i); } } } debugTrace(DEBUG_sched, "allocated %d more capabilities", to - from); + Capability **old_capabilities = ACQUIRE_LOAD(&capabilities); + RELEASE_STORE(&capabilities, new_capabilities); if (old_capabilities != NULL) { stgFree(old_capabilities); } + + startTimer(); #endif } ===================================== rts/Proftimer.c ===================================== @@ -30,7 +30,7 @@ void stopProfTimer( void ) { #if defined(PROFILING) - do_prof_ticks = false; + RELAXED_STORE(&do_prof_ticks, false); #endif } @@ -38,14 +38,14 @@ void startProfTimer( void ) { #if defined(PROFILING) - do_prof_ticks = true; + RELAXED_STORE(&do_prof_ticks, true); #endif } void stopHeapProfTimer( void ) { - do_heap_prof_ticks = false; + RELAXED_STORE(&do_heap_prof_ticks, false); } void @@ -74,7 +74,7 @@ handleProfTick(void) { #if defined(PROFILING) total_ticks++; - if (do_prof_ticks) { + if (RELAXED_LOAD(&do_prof_ticks)) { uint32_t n; for (n=0; n < n_capabilities; n++) { capabilities[n]->r.rCCCS->time_ticks++; @@ -83,7 +83,7 @@ handleProfTick(void) } #endif - if (do_heap_prof_ticks) { + if (RELAXED_LOAD(&do_heap_prof_ticks)) { ticks_to_heap_profile--; if (ticks_to_heap_profile <= 0) { ticks_to_heap_profile = RtsFlags.ProfFlags.heapProfileIntervalTicks; ===================================== rts/RtsStartup.c ===================================== @@ -284,6 +284,13 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) /* Initialise libdw session pool */ libdwPoolInit(); + /* Start the "ticker" and profiling timer but don't start until the + * scheduler is up. However, the ticker itself needs to be initialized + * before the scheduler to ensure that the ticker mutex is initialized as + * moreCapabilities will attempt to acquire it. + */ + initTimer(); + /* initialise scheduler data structures (needs to be done before * initStorage()). */ @@ -359,7 +366,6 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) initHeapProfiling(); /* start the virtual timer 'subsystem'. */ - initTimer(); startTimer(); #if defined(RTS_USER_SIGNALS) ===================================== rts/Schedule.c ===================================== @@ -2253,6 +2253,12 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) cap = rts_lock(); task = cap->running_task; + + // N.B. We must stop the interval timer while we are changing the + // capabilities array lest handle_tick may try to context switch + // an old capability. See #17289. + stopTimer(); + stopAllCapabilities(&cap, task); if (new_n_capabilities < enabled_capabilities) @@ -2335,6 +2341,8 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) // Notify IO manager that the number of capabilities has changed. rts_evalIO(&cap, ioManagerCapabilitiesChanged_closure, NULL); + startTimer(); + rts_unlock(cap); #endif // THREADED_RTS ===================================== rts/Timer.c ===================================== @@ -25,6 +25,15 @@ #include "Capability.h" #include "RtsSignals.h" +// This global counter is used to allow multiple threads to stop the +// timer temporarily with a stopTimer()/startTimer() pair. If +// timer_enabled == 0 timer is enabled +// timer_disabled == N, N > 0 timer is disabled by N threads +// When timer_enabled makes a transition to 0, we enable the timer, +// and when it makes a transition to non-0 we disable it. + +static StgWord timer_disabled; + /* ticks left before next pre-emptive context switch */ static int ticks_to_ctxt_switch = 0; @@ -92,7 +101,9 @@ void handle_tick(int unused STG_UNUSED) { handleProfTick(); - if (RtsFlags.ConcFlags.ctxtSwitchTicks > 0) { + if (RtsFlags.ConcFlags.ctxtSwitchTicks > 0 + && SEQ_CST_LOAD(&timer_disabled) == 0) + { ticks_to_ctxt_switch--; if (ticks_to_ctxt_switch <= 0) { ticks_to_ctxt_switch = RtsFlags.ConcFlags.ctxtSwitchTicks; @@ -148,15 +159,6 @@ handle_tick(int unused STG_UNUSED) } } -// This global counter is used to allow multiple threads to stop the -// timer temporarily with a stopTimer()/startTimer() pair. If -// timer_enabled == 0 timer is enabled -// timer_disabled == N, N > 0 timer is disabled by N threads -// When timer_enabled makes a transition to 0, we enable the timer, -// and when it makes a transition to non-0 we disable it. - -static StgWord timer_disabled; - void initTimer(void) { @@ -164,7 +166,7 @@ initTimer(void) if (RtsFlags.MiscFlags.tickInterval != 0) { initTicker(RtsFlags.MiscFlags.tickInterval, handle_tick); } - timer_disabled = 1; + SEQ_CST_STORE(&timer_disabled, 1); } void ===================================== rts/posix/itimer/Pthread.c ===================================== @@ -85,11 +85,11 @@ static Time itimer_interval = DEFAULT_TICK_INTERVAL; // Should we be firing ticks? // Writers to this must hold the mutex below. -static volatile bool stopped = false; +static bool stopped = false; // should the ticker thread exit? // This can be set without holding the mutex. -static volatile bool exited = true; +static bool exited = true; // Signaled when we want to (re)start the timer static Condition start_cond; @@ -120,7 +120,9 @@ static void *itimer_thread_func(void *_handle_tick) } #endif - while (!exited) { + // Relaxed is sufficient: If we don't see that exited was set in one iteration we will + // see it next time. + while (!RELAXED_LOAD(&exited)) { if (USE_TIMERFD_FOR_ITIMER) { ssize_t r = read(timerfd, &nticks, sizeof(nticks)); if ((r == 0) && (errno == 0)) { @@ -142,7 +144,8 @@ static void *itimer_thread_func(void *_handle_tick) } // first try a cheap test - if (stopped) { + TSAN_ANNOTATE_BENIGN_RACE(&stopped, "itimer_thread_func"); + if (RELAXED_LOAD(&stopped)) { OS_ACQUIRE_LOCK(&mutex); // should we really stop? if (stopped) { @@ -186,7 +189,7 @@ void startTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 0; + RELAXED_STORE(&stopped, false); signalCondition(&start_cond); OS_RELEASE_LOCK(&mutex); } @@ -196,7 +199,7 @@ void stopTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 1; + RELAXED_STORE(&stopped, true): OS_RELEASE_LOCK(&mutex); } @@ -204,8 +207,8 @@ stopTicker(void) void exitTicker (bool wait) { - ASSERT(!exited); - exited = true; + ASSERT(!SEQ_CST_LOAD(&exited)); + SEQ_CST_STORE(&exited, true); // ensure that ticker wakes up if stopped startTicker(); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7341c75fc3b3abde26062d600533ee6ea6d576fe...c5da3791f9a4ba6bdf91c231c7bbaed0ee1a6b2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7341c75fc3b3abde26062d600533ee6ea6d576fe...c5da3791f9a4ba6bdf91c231c7bbaed0ee1a6b2e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 18:46:17 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 14:46:17 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 7 commits: rts: Accept benign races in Proftimer Message-ID: <5f8f30791ec71_28003fd41631de841277745@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 1ce9c5c7 by Ben Gamari at 2020-10-20T14:45:50-04:00 rts: Accept benign races in Proftimer - - - - - 03b5dc44 by Ben Gamari at 2020-10-20T14:45:50-04:00 rts: Pause timer while changing capability count This avoids #17289. - - - - - f8257342 by Ben Gamari at 2020-10-20T14:45:51-04:00 Fix #17289 - - - - - 60aeb584 by Ben Gamari at 2020-10-20T14:45:51-04:00 suppress #17289 (ticker) race - - - - - d7885a85 by Ben Gamari at 2020-10-20T14:45:51-04:00 rts: Fix timer initialization Previously `initScheduler` would attempt to pause the ticker and in so doing acquire the ticker mutex. However, initTicker, which is responsible for initializing said mutex, hadn't been called yet. - - - - - c5da3791 by Ben Gamari at 2020-10-20T14:45:51-04:00 rts: Annotate benign race in ticker shutdown logic We are guaranteed to see the change in the `stopped` flag at some point so the race is harmless. - - - - - ca66a680 by Ben Gamari at 2020-10-20T14:46:09-04:00 Merge branch 'wip/tsan/timer' into wip/tsan/all - - - - - 1 changed file: - rts/posix/itimer/Pthread.c Changes: ===================================== rts/posix/itimer/Pthread.c ===================================== @@ -189,7 +189,7 @@ void startTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 0; + RELAXED_STORE(&stopped, false); signalCondition(&start_cond); OS_RELEASE_LOCK(&mutex); } @@ -199,7 +199,7 @@ void stopTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 1; + RELAXED_STORE(&stopped, true): OS_RELEASE_LOCK(&mutex); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e93ed3e60a09f1083dbd697562d2063f783ba5e3...ca66a68098773586d5c8c565964cf421df5a57c0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e93ed3e60a09f1083dbd697562d2063f783ba5e3...ca66a68098773586d5c8c565964cf421df5a57c0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 19:20:32 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 15:20:32 -0400 Subject: [Git][ghc/ghc][wip/tsan/timer] rts: Fix races in Pthread timer backend shudown Message-ID: <5f8f3880aa5ac_28003fd3e8b9f81012844c8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/timer at Glasgow Haskell Compiler / GHC Commits: 5745baad by Ben Gamari at 2020-10-20T15:19:59-04:00 rts: Fix races in Pthread timer backend shudown We can generally be pretty relaxed in the barriers here since the timer thread is a loop. - - - - - 1 changed file: - rts/posix/itimer/Pthread.c Changes: ===================================== rts/posix/itimer/Pthread.c ===================================== @@ -85,11 +85,11 @@ static Time itimer_interval = DEFAULT_TICK_INTERVAL; // Should we be firing ticks? // Writers to this must hold the mutex below. -static volatile bool stopped = false; +static bool stopped = false; // should the ticker thread exit? // This can be set without holding the mutex. -static volatile bool exited = true; +static bool exited = true; // Signaled when we want to (re)start the timer static Condition start_cond; @@ -120,7 +120,9 @@ static void *itimer_thread_func(void *_handle_tick) } #endif - while (!exited) { + // Relaxed is sufficient: If we don't see that exited was set in one iteration we will + // see it next time. + while (!RELAXED_LOAD(&exited)) { if (USE_TIMERFD_FOR_ITIMER) { ssize_t r = read(timerfd, &nticks, sizeof(nticks)); if ((r == 0) && (errno == 0)) { @@ -142,7 +144,8 @@ static void *itimer_thread_func(void *_handle_tick) } // first try a cheap test - if (stopped) { + TSAN_ANNOTATE_BENIGN_RACE(&stopped, "itimer_thread_func"); + if (RELAXED_LOAD(&stopped)) { OS_ACQUIRE_LOCK(&mutex); // should we really stop? if (stopped) { @@ -186,7 +189,7 @@ void startTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 0; + RELAXED_STORE(&stopped, false); signalCondition(&start_cond); OS_RELEASE_LOCK(&mutex); } @@ -196,7 +199,7 @@ void stopTicker(void) { OS_ACQUIRE_LOCK(&mutex); - stopped = 1; + RELAXED_STORE(&stopped, true); OS_RELEASE_LOCK(&mutex); } @@ -204,8 +207,8 @@ stopTicker(void) void exitTicker (bool wait) { - ASSERT(!exited); - exited = true; + ASSERT(!SEQ_CST_LOAD(&exited)); + SEQ_CST_STORE(&exited, true); // ensure that ticker wakes up if stopped startTicker(); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5745baadf8f5aa837c8c640cd6852a5b7f31b435 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5745baadf8f5aa837c8c640cd6852a5b7f31b435 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 19:21:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 15:21:27 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 2 commits: rts: Fix races in Pthread timer backend shudown Message-ID: <5f8f38b713a89_28003fd40950f43412850c9@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 5745baad by Ben Gamari at 2020-10-20T15:19:59-04:00 rts: Fix races in Pthread timer backend shudown We can generally be pretty relaxed in the barriers here since the timer thread is a loop. - - - - - 89608e64 by Ben Gamari at 2020-10-20T15:21:19-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr' and 'wip/tsan/timer' into wip/tsan/all - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - hadrian/src/Flavour.hs - includes/rts/OSThreads.h - includes/rts/StablePtr.h - includes/rts/storage/Closures.h - includes/rts/storage/GC.h - includes/stg/SMP.h - libraries/base/GHC/Event/Control.hs - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/RaiseAsync.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.c - rts/StablePtr.c - rts/Stats.c - rts/Task.c - rts/ThreadPaused.c - rts/Threads.c - rts/Timer.c - rts/Updates.h - rts/WSDeque.c - rts/WSDeque.h - rts/Weak.c - rts/posix/GetTime.c - rts/posix/OSThreads.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca66a68098773586d5c8c565964cf421df5a57c0...89608e64c1a0a8f568786340ca1ff0e5e747292c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca66a68098773586d5c8c565964cf421df5a57c0...89608e64c1a0a8f568786340ca1ff0e5e747292c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 19:55:55 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 15:55:55 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: testsuite: Add test for #18346 Message-ID: <5f8f40cb14f48_28003fd3ee0bfbb012894e0@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - ca99d7bb by Ben Gamari at 2020-10-20T15:55:48-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - docs/users_guide/exts/linear_types.rst - ghc/GHCi/UI.hs - testsuite/tests/driver/all.T - + testsuite/tests/ghci/scripts/T8042.script - + testsuite/tests/ghci/scripts/T8042.stdout - testsuite/tests/ghci/scripts/all.T - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7749a5250d79165becdf838e8e621e22a6996ba...ca99d7bb38d7069c2706853f8bd28697c5c01c91 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f7749a5250d79165becdf838e8e621e22a6996ba...ca99d7bb38d7069c2706853f8bd28697c5c01c91 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 20 19:58:40 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 20 Oct 2020 15:58:40 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] testing Message-ID: <5f8f41702194_28003fd409687f281290617@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: e01af0b9 by Ben Gamari at 2020-10-20T15:58:36-04:00 testing - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -649,7 +649,7 @@ nightly-x86_64-linux-deb9-tsan: validate-x86_64-linux-deb9-tsan: extends: .build-x86_64-linux-deb9-tsan - when: manual + stage: lint validate-x86_64-linux-deb9-dwarf: extends: .build-x86_64-linux-deb9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e01af0b9a44f7b21fa8ec17b388f2751ec9bbd53 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e01af0b9a44f7b21fa8ec17b388f2751ec9bbd53 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 02:56:05 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 22:56:05 -0400 Subject: [Git][ghc/ghc][master] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f8fa345a15fa_28003fd40960c558131814@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -931,22 +931,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -961,20 +962,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1959,10 +1963,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -133,6 +133,7 @@ import GHC.Types.SrcLoc import GHC.Data.FastString import GHC.Data.Bag import GHC.Settings.Constants +import GHC.Parser.Annotation import GHC.Utils.Misc import GHC.Utils.Outputable @@ -538,12 +539,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -2051,22 +2051,22 @@ is connected to the first type too. type :: { LHsType GhcPs } -- See Note [%shift: type -> btype] : btype %shift { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } @@ -3999,6 +3999,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,6 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -980,10 +980,10 @@ instance HasHaddock (Located (HsType GhcPs)) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -624,11 +624,11 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; (mult', w_fvs) <- rnHsArrow env mult - ; return (HsFunTy noExtField mult' ty1' ty2' + ; return (HsFunTy u mult' ty1' ty2' , plusFVs [fvs1, fvs2, w_fvs]) } rnHsTyKi env listTy@(HsListTy _ ty) @@ -721,10 +721,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1847,7 +1847,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -116,6 +116,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -1046,7 +1047,7 @@ tc_hs_type mode (HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2453,7 +2453,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,7 +3416,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -51,6 +51,7 @@ import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic +import GHC.Parser.Annotation import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1471,7 +1472,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1623,9 +1624,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -1683,7 +1683,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1751,7 +1751,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 77261e89c31b41eb5d7f1d16bb1de5b14b4296f4 +Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea736839d85594c95490dcf02d3325c2bbc68f33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea736839d85594c95490dcf02d3325c2bbc68f33 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 02:56:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 20 Oct 2020 22:56:38 -0400 Subject: [Git][ghc/ghc][master] testsuite: Mark T12971 as fragile on Windows Message-ID: <5f8fa366c909c_28003fd40960c5581320878@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - 1 changed file: - testsuite/tests/driver/all.T Changes: ===================================== testsuite/tests/driver/all.T ===================================== @@ -258,7 +258,7 @@ test('T12752pass', normal, compile, ['-DSHOULD_PASS=1 -Wcpp-undef']) test('T12955', normal, makefile_test, []) -test('T12971', [when(opsys('mingw32'), expect_broken(17945)), ignore_stdout], makefile_test, []) +test('T12971', [when(opsys('mingw32'), fragile(17945)), ignore_stdout], makefile_test, []) test('json', normal, compile_fail, ['-ddump-json']) test('json2', normalise_version('base','ghc-prim'), compile, ['-ddump-types -ddump-json']) test('T16167', exit_code(1), run_command, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf3c3bcd93b3a515f3c2db81b5a7c42af480c9b6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cf3c3bcd93b3a515f3c2db81b5a7c42af480c9b6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 06:47:42 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 02:47:42 -0400 Subject: [Git][ghc/ghc][wip/nested-cpr-2019] 29 commits: Nested CPR Message-ID: <5f8fd98ee432d_28006789e38132231c@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/nested-cpr-2019 at Glasgow Haskell Compiler / GHC Commits: b3b4b505 by Sebastian Graf at 2020-10-21T08:47:29+02:00 Nested CPR - - - - - da503e33 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Move tests from stranal to cpranal - - - - - aeffe9f1 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Accept FacState - - - - - cadbe986 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Factor Cpr and Termination into a joint lattice As a result, we don't even have to export Termination from Cpr. Neat! Also I realised there is a simpler and more sound way to generate and unleash CPR signatures. - - - - - e603eec2 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Consider unboxing effects of WW better and get rid of hack - - - - - da7fb664 by Sebastian Graf at 2020-10-21T08:47:35+02:00 stuff - - - - - c4f11732 by Sebastian Graf at 2020-10-21T08:47:35+02:00 A slew of testsuite changes - - - - - dcb0d297 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Fix T1600 - - - - - d9f34cfc by Sebastian Graf at 2020-10-21T08:47:35+02:00 Fix primop termination - - - - - d905fbe5 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Test for DataCon wrapper CPR - - - - - ed4779b6 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Fix CPR of bottoming functions/primops - - - - - d038b30e by Sebastian Graf at 2020-10-21T08:47:35+02:00 Fix DataConWrapperCpr and accept other test outputs - - - - - fc138815 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Accept two more changed test outputs - - - - - 25bd8b59 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Update CaseBinderCPR with a new function - - - - - a500eb47 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Don't give the case binder the CPR property - - - - - fac12896 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Prune CPR sigs to constant depth on all bindings - - - - - a197f416 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Use variable length coding for ConTags - - - - - deaae105 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Accept testuite output - - - - - b393fc78 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Don't attach CPR sigs to expandable bindings; transform their unfoldings instead - - - - - e9ed08ed by Sebastian Graf at 2020-10-21T08:47:35+02:00 Revert "Don't give the case binder the CPR property" This reverts commit 910edd76d5fe68b58c74f3805112f9faef4f2788. It seems we broke too much with this change. We lost our big win in `fish`. - - - - - 2f0f2e2c by Sebastian Graf at 2020-10-21T08:47:35+02:00 A more modular and configurable approach to optimistic case binder CPR - - - - - 70500c7f by Sebastian Graf at 2020-10-21T08:47:35+02:00 Fix T9291 - - - - - 1b3206ff by Sebastian Graf at 2020-10-21T08:47:35+02:00 Document -fcase-binder-cpr-depth in the user's guide - - - - - 70975b23 by Sebastian Graf at 2020-10-21T08:47:35+02:00 Testsuite changes - - - - - 68bb4fea by Sebastian Graf at 2020-10-21T08:47:35+02:00 Refactoring around cprAnalBind - - - - - 196f86e6 by Sebastian Graf at 2020-10-21T08:47:36+02:00 Fix case binder CPR by not looking into unfoldings of case binders - - - - - dc2778bb by Sebastian Graf at 2020-10-21T08:47:36+02:00 Fix T16893 - - - - - 436312b2 by Sebastian Graf at 2020-10-21T08:47:36+02:00 Accept new test output for T17673 - - - - - 9a0484cc by Sebastian Graf at 2020-10-21T08:47:36+02:00 Accepting metric changes to advance CI There are two ghc/alloc increases, which we might want to investigate later on. Metric Decrease: T1969 T9233 T9872a T9872b T9872c T9872d T12425 Metric Increase: T13253 T13701 T15164 Metric Increase ['max_bytes_used'] (test_env='x86_64-darwin'): T9675 Metric Increase ['max_bytes_used', 'peak_megabytes_allocated']: T10370 - - - - - 30 changed files: - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/Maybe.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Tidy.hs - compiler/GHC/Types/Cpr.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Info.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/using-optimisation.rst - testsuite/tests/stranal/sigs/CaseBinderCPR.hs → testsuite/tests/cpranal/sigs/CaseBinderCPR.hs - + testsuite/tests/cpranal/sigs/CaseBinderCPR.stderr - testsuite/tests/stranal/sigs/FacState.hs → testsuite/tests/cpranal/sigs/FacState.hs - + testsuite/tests/cpranal/sigs/FacState.stderr - + testsuite/tests/cpranal/sigs/Makefile - testsuite/tests/stranal/should_compile/T10694.hs → testsuite/tests/cpranal/sigs/T10694.hs - + testsuite/tests/cpranal/sigs/T10694.stderr - + testsuite/tests/cpranal/sigs/T1600.hs - + testsuite/tests/cpranal/sigs/T1600.stderr - testsuite/tests/stranal/sigs/T5075.hs → testsuite/tests/cpranal/sigs/T5075.hs - + testsuite/tests/cpranal/sigs/T5075.stderr - + testsuite/tests/cpranal/sigs/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f7b40177f693d748080a2c5e17dc2c4da3138a8...9a0484ccd4c5afb63cc2200a15050f9289be1b2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f7b40177f693d748080a2c5e17dc2c4da3138a8...9a0484ccd4c5afb63cc2200a15050f9289be1b2e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 09:39:17 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 21 Oct 2020 05:39:17 -0400 Subject: [Git][ghc/ghc][wip/T18723] 9 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f9001c5de2b3_2800d3e0c08134838b@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18723 at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - d54abe25 by Ryan Scott at 2020-10-21T05:37:57-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82902c87c373e8a5cf1b15028e808cfe1537ced3...d54abe257241a73a86c39cff98ad39ef339f3714 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/82902c87c373e8a5cf1b15028e808cfe1537ced3...d54abe257241a73a86c39cff98ad39ef339f3714 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 09:49:41 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 21 Oct 2020 05:49:41 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18856 Message-ID: <5f900435d6c0f_28003fd40d722df81349080@gitlab.haskell.org.mail> Simon Peyton Jones pushed new branch wip/T18856 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18856 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 10:11:16 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 21 Oct 2020 06:11:16 -0400 Subject: [Git][ghc/ghc][wip/T18844] 39 commits: Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings Message-ID: <5f90094469cdc_28003fd40950cd2413532e4@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - 14c75f86 by Ryan Scott at 2020-10-21T06:10:25-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Adding a third type parameter to `HsConDeclDetails` to represent the types in an `InfixCon`, separate from the type parameters for `PrefixCon` and `RecCon`, and * Creating `HsConDeclH98Details` and `HsConDeclGADTDetails` synonyms on top of the new `HsConDeclDetails`, which instantiate the `inf` type parameter to `HsScaled pass (LBangType pass)` and `Void`, respectively. Using `Void` allows functions that consume `HsConDeclGADTDetails` to simply call `absurd` instead of having to, say, `panic`. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{,H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon`. This is still possible since `RecCon`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/HsToCore/Quote.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/037ced558dc32302972b8ca8e06aac0a90851528...14c75f860af360dd0f860c6253c0f81823c6fabc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/037ced558dc32302972b8ca8e06aac0a90851528...14c75f860af360dd0f860c6253c0f81823c6fabc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 12:11:26 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 21 Oct 2020 08:11:26 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f90256e1ea59_2800a377da01364839@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 2d28ba57 by Ryan Scott at 2020-10-21T08:09:04-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Adding a third type parameter to `HsConDeclDetails` to represent the types in an `InfixCon`, separate from the type parameters for `PrefixCon` and `RecCon`, and * Creating `HsConDeclH98Details` and `HsConDeclGADTDetails` synonyms on top of the new `HsConDeclDetails`, which instantiate the `inf` type parameter to `HsScaled pass (LBangType pass)` and `Void`, respectively. Using `Void` allows functions that consume `HsConDeclGADTDetails` to simply call `absurd` instead of having to, say, `panic`. See also `Note [GADT syntax can't be infix]` in `GHC.Hs.Decls`. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{,H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon`. This is still possible since `RecCon`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 18 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - utils/haddock Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -1227,7 +1227,10 @@ pprMinimalSig (L _ bf) = ppr (fmap unLoc bf) -} -- | Haskell Pattern Synonym Details -type HsPatSynDetails pass = HsConDetails (LIdP pass) [RecordPatSynField (LIdP pass)] +type HsPatSynDetails pass + = HsConDetails (LIdP pass) + [RecordPatSynField (LIdP pass)] + (LIdP pass) -- See Note [Record PatSyn Fields] -- | Record Pattern Synonym Field ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,9 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclDetails, HsConDeclH98Details, HsConDeclGADTDetails, + hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -126,6 +127,7 @@ import GHC.Core.Type import GHC.Data.Bag import GHC.Data.Maybe import Data.Data hiding (TyCon,Fixity, Infix) +import Data.Void {- ************************************************************************ @@ -1473,9 +1475,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1494,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1625,86 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass - = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a data constructor declaration. The @inf@ type parameter +-- represents the representation for infix data constructors, which is +-- different depending on whether the data constructor is Haskell98-style or +-- GADT-style. +type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + +-- | The arguments in a Haskell98 data constructor, which can be infix. +type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + +-- | The arguments in a GADT constructor, which cannot be infix. +-- See @Note [GADT syntax can't be infix]@. +type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + +{- +Note [GADT syntax can't be infix] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The overall shape of Haskell98-style data constructors and GADT constructors +are very similar, which allows us to use the HsConDetails data type to +represent both forms of data constructors: + + data HsConDetails arg rec inf + = PrefixCon [arg] + | RecCon rec + | InfixCon inf inf + +But there is a key difference between the syntaxes of each form of data +constructor, however. Haskell98-style data constructors can use all three +varieties of HsConDetails above: + + data C p1 p2 + = C1 p1 p2 -- PrefixCon + | C2 { x :: p1, y :: p2 } -- InfixCon + | p1 `C2` p2 -- RecCon + +GADT constructors, on the other hand, can only use two HsConDetails varieties: + + data G p1 p2 where + G1 :: p1 -> p2 -> G p1 p2 -- PrefixCon + G2 :: { x :: p1, y :: p2 } -> G p1 p2 -- RecCon + +In other words, InfixCon is an unrepresentable state for GADT constructor +syntax (#18844). We encode this knowledge as a Haskell type by using separate +HsConDeclH98Details and HsConDeclGADTDetails type synonyms, which instantiate +the `inf` parameter of `HsConDetails pre rec inf` to different things. In +particular, HsConDeclGADTDetails instantiates `inf` to Void. This means that +when you match on an argument of type HsConDeclGADTDetails, you can "forget" +about the unrepresentable InfixCon case by using `absurd`: + + f :: HsConDeclGADTDetails pass -> blah + f (PrefixCon _) = ... + f (RecCon _) = ... + f (InfixCon v _) = absurd v + +Note that this Note only applies to the *surface syntax* of GADT constructors. +There is a notion of infix GADT constructors for the purposes of derived Show +instances (see Note [Infix GADT constructors]), but that is an orthogonal +concern. +-} getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon v _ -> absurd v hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,7 +1784,7 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, @@ -1731,7 +1792,7 @@ pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars where get_args (PrefixCon args) = map ppr args get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (InfixCon v _) = absurd v cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -316,7 +316,7 @@ type instance ConLikeP GhcTc = ConLike -- | Haskell Constructor Pattern Details -type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) +type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) (LPat p) hsConPatArgs :: HsConPatDetails p -> [LPat p] hsConPatArgs (PrefixCon ps) = ps @@ -866,7 +866,7 @@ patNeedsParens p = go -- | @'conPatNeedsParens' p cp@ returns 'True' if the constructor patterns @cp@ -- needs parentheses under precedence @p at . -conPatNeedsParens :: PprPrec -> HsConDetails a b -> Bool +conPatNeedsParens :: PprPrec -> HsConDetails a b c -> Bool conPatNeedsParens p = go where go (PrefixCon args) = p >= appPrec && not (null args) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1104,15 +1104,19 @@ instance OutputableBndrId p -- HsConDetails is used for patterns/expressions *and* for data type -- declarations --- | Haskell Constructor Details -data HsConDetails arg rec +-- | Haskell Constructor Details. +-- +-- The @arg@ and @inf@ type parameters are kept separate so that GADT +-- constructors (which cannot be declared with infix syntax) can instantiate +-- @inf@ to @Void at . See @Note [GADT syntax can't be infix]@ in "GHC.Hs.Decls". +data HsConDetails arg rec inf = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } - | InfixCon arg arg -- p1 `C` p2 + | InfixCon inf inf -- p1 `C` p2 deriving Data -instance (Outputable arg, Outputable rec) - => Outputable (HsConDetails arg rec) where +instance (Outputable arg, Outputable rec, Outputable inf) + => Outputable (HsConDetails arg rec inf) where ppr (PrefixCon args) = text "PrefixCon" <+> ppr args ppr (RecCon rec) = text "RecCon:" <+> ppr rec ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,7 +1257,7 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where (remSeen', flds) = get_flds remSeen args @@ -1269,7 +1269,7 @@ hsConDeclsBinders cons (remSeen', flds) = get_flds remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds :: Seen p -> HsConDeclDetails (GhcPass p) inf -> (Seen p, [LFieldOcc (GhcPass p)]) get_flds remSeen (RecCon flds) = (remSeen', fld_names) ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -31,6 +31,7 @@ import Data.Map (Map) import qualified Data.Map as M import Data.Maybe import Data.Semigroup +import Data.Void -- | Extract docs from renamer output. extractDocs :: TcGblEnv @@ -189,7 +190,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +217,31 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + InfixCon v _ -> absurd v + RecCon _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -85,6 +85,7 @@ import Data.ByteString ( unpack ) import Control.Monad import Data.List import Data.Function +import Data.Void data MetaWrappers = MetaWrappers { -- Applies its argument to a type argument `m` and dictionary `Quote m` @@ -869,7 +870,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +878,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +890,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2582,52 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + InfixCon v _ -> absurd v + RecCon ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a PrefixCon. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a RecCon. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2636,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -68,6 +68,7 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Data ( Data, Typeable ) import Data.List ( foldl1' ) +import Data.Void import Control.Monad ( forM_ ) import Control.Monad.Trans.State.Strict import Control.Monad.Trans.Reader @@ -578,6 +579,9 @@ class ToHie a where class HasType a where getTypeNode :: a -> HieM [HieAST Type] +instance ToHie Void where + toHie = absurd + instance (ToHie a) => ToHie [a] where toHie = concatMapM toHie @@ -996,8 +1000,10 @@ instance HiePass p => ToHie (PScoped (Located (Pat (GhcPass p)))) where HieRn -> [] #endif where - contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) - -> HsConDetails (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a))) + contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) a + -> HsConDetails (PScoped a) + (RContext (HsRecFields (GhcPass p) (PScoped a))) + (PScoped a) contextify (PrefixCon args) = PrefixCon $ patScopes rsp scope pscope args contextify (InfixCon a b) = InfixCon a' b' where [a', b'] = patScopes rsp scope pscope [a,b] @@ -1314,7 +1320,7 @@ instance HiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p))) where , toHie $ PS Nothing sc NoScope pat ] -instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where +instance (ToHie arg, ToHie rec, ToHie inf) => ToHie (HsConDetails arg rec inf) where toHie (PrefixCon args) = toHie args toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] @@ -1530,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1545,6 +1551,12 @@ instance ToHie (Located (ConDecl GhcRn)) where tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars + + condecl_scope :: HsConDeclGADTDetails (GhcPass p) -> Scope + condecl_scope args = case args of + PrefixCon xs -> scaled_args_scope xs + InfixCon v _ -> absurd v + RecCon x -> mkLScope x ConDeclH98 { con_name = name, con_ex_tvs = qvars , con_mb_cxt = ctx, con_args = dets } -> [ toHie $ C (Decl ConDec $ getRealSpan span) name @@ -1556,12 +1568,14 @@ instance ToHie (Located (ConDecl GhcRn)) where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope + condecl_scope :: HsConDeclH98Details (GhcPass p) -> Scope condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled (GhcPass p) (LHsType (GhcPass p))] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) + instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -643,7 +643,7 @@ mkGadtDecl names ty = do , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -69,6 +69,7 @@ import Control.Monad.Trans.Writer import Data.Functor.Identity import Data.Coerce import qualified Data.Monoid +import Data.Void import GHC.Parser.Lexer import GHC.Parser.Errors @@ -690,22 +691,22 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of + con_g_args' <- + case con_g_args of PrefixCon ts -> PrefixCon <$> addHaddock ts RecCon (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + InfixCon v _ -> absurd v con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -67,6 +67,7 @@ import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt import Data.List ( nubBy, partition ) +import Data.Void import Control.Monad ( unless, when ) #include "HsVersions.h" @@ -1747,9 +1748,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1785,16 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixCon args -> extract_scaled_ltys args + InfixCon v _ -> absurd v + RecCon (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1804,6 +1812,14 @@ extract_lctxt ctxt = extract_ltys (unLoc ctxt) extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_lty :: LHsType GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lty (L _ ty) acc = case ty of ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -75,6 +75,7 @@ import Data.List.NonEmpty ( NonEmpty(..) ) import Data.Maybe ( isNothing, isJust, fromMaybe, mapMaybe ) import qualified Data.Set as Set ( difference, fromList, toList, null ) import Data.Function ( on ) +import Data.Void {- | @rnSourceDecl@ "renames" declarations. It simultaneously performs dependency analysis and precedence parsing. @@ -2180,7 +2181,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2198,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2211,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2221,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2236,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,22 +2247,36 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name + -> HsDocContext + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details = rnConDeclDetails rnScaledLHsType + +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails = rnConDeclDetails (\_ -> absurd) + +rnConDeclDetails :: + (HsDocContext -> infPs -> RnM (infRn, FreeVars)) + -> Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclDetails GhcPs infPs + -> RnM (HsConDeclDetails GhcRn infRn, FreeVars) +rnConDeclDetails _ _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } -rnConDeclDetails _ doc (InfixCon ty1 ty2) - = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 - ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 +rnConDeclDetails rnInf _ doc (InfixCon ty1 ty2) + = do { (new_ty1, fvs1) <- rnInf doc ty1 + ; (new_ty2, fvs2) <- rnInf doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclDetails _ con doc (RecCon (L l fields)) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecCon flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -81,12 +81,14 @@ import GHC.Types.Basic import qualified GHC.LanguageExtensions as LangExt import Control.Monad +import Data.Foldable import Data.Function ( on ) import Data.Functor.Identity import Data.List import Data.List.NonEmpty ( NonEmpty(..) ) import qualified Data.Set as Set import Data.Tuple( swap ) +import Data.Void {- ************************************************************************ @@ -1563,18 +1565,33 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the type of an argument to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need --- the first two arguments. -kcConArgTys :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () -kcConArgTys new_or_data res_kind arg_tys = do - { let exp_kind = getArgExpKind new_or_data res_kind - ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind - tcMult mult) - +-- the ContextKind argument. +kcConArg :: ContextKind -> HsScaled GhcRn (LHsType GhcRn) -> TcM () +kcConArg exp_kind (HsScaled mult ty) = do + _ <- tcCheckLHsType (getBangType ty) exp_kind + _ <- tcMult mult + pure () -- See Note [Implementation of UnliftedNewtypes], STEP 2 - } + +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: ContextKind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args = kcConArgs kcConArg + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: ContextKind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs = kcConArgs (\_ -> absurd) + +-- Kind-check the types of argument to a data constructor. +kcConArgs :: (ContextKind -> infRn -> TcM ()) + -> ContextKind -> HsConDeclDetails GhcRn infRn -> TcM () +kcConArgs kc_inf exp_kind con_args = case con_args of + PrefixCon tys -> traverse_ (kcConArg exp_kind) tys + InfixCon ty1 ty2 -> traverse_ (kc_inf exp_kind) [ty1, ty2] + RecCon (L _ flds) -> traverse_ (kcConArg exp_kind) $ + map (hsLinear . cd_fld_type . unLoc) flds kcConDecls :: NewOrData -> Kind -- The result kind signature @@ -1604,14 +1621,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args (getArgExpKind new_or_data res_kind) args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1642,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs (getArgExpKind new_or_data res_kind) args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3213,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3283,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3300,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,19 +3379,20 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of InfixCon {} -> return True - _ -> return False + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True + InfixCon v _ -> absurd v RecCon {} -> return False PrefixCon arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) @@ -3383,18 +3401,31 @@ tcConIsInfixGADT con details ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args = tcConArgs tcConArg + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs = tcConArgs (\_ -> absurd) + +tcConArgs :: (ContextKind -> infRn -> TcM (Scaled TcType, HsSrcBang)) + -> ContextKind -- expected kind of arguments -- always OpenKind for datatypes, but unlifted newtypes -- might have a specific kind - -> HsConDeclDetails GhcRn + -> HsConDeclDetails GhcRn infRn -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConArgs _ exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) - = do { bty1' <- tcConArg exp_kind bty1 - ; bty2' <- tcConArg exp_kind bty2 - ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConArgs tc_inf exp_kind (InfixCon bty1 bty2) + = mapM (tc_inf exp_kind) [bty1, bty2] +tcConArgs _ exp_kind (RecCon fields) = mapM (tcConArg exp_kind) btys where -- We need a one-to-one mapping from field_names to btys @@ -3434,7 +3465,8 @@ matches what the user wrote (#18791). Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We do not currently have syntax to declare an infix constructor in GADT syntax, +We do not currently have syntax to declare an infix constructor in GADT syntax +(see Note [GADT syntax can't be infix] in GHC.Hs.Decls), but it makes a (small) difference to the Show instance. So as a slightly ad-hoc solution, we regard a GADT data constructor as infix if a) it is an operator symbol ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -631,7 +631,7 @@ cvtConstr (RecGadtC c varstrtys ty) ; rec_flds <- mapM cvt_id_arg varstrtys ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,63 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon + , ... + } + + Where: :: + + -- New type synonym introduced in GHC 9.2; equivalent to `HsConDeclDetails` + -- in previous versions of GHC + type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + + -- New type synonym introduced in GHC 9.2 + type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + + -- The `inf` type parameter is new in GHC 9.2 + type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + + -- The `inf` type parameter is new in GHC 9.2 + data HsConDetails arg rec inf + = PrefixCon [arg] -- C p1 p2 p3 + | RecCon rec -- C { x = p1, y = p2 } + | InfixCon inf inf -- p1 `C` p2 + + The use of ``Void`` in ``HsConDeclGADTDetails`` reflects the fact that GADT + constructors cannot use infix syntax like Haskell98-style constructors can. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 20cbbbf04fec215e19aad306ae89851dd2eba080 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2d28ba57c0345f22393fd1e38a3c71c058f46516 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2d28ba57c0345f22393fd1e38a3c71c058f46516 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 12:22:26 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 21 Oct 2020 08:22:26 -0400 Subject: [Git][ghc/ghc][wip/T18856] Fix error message location in tcCheckPatSynDecl Message-ID: <5f9028028193f_28003fd388a22d6c13677bc@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T18856 at Glasgow Haskell Compiler / GHC Commits: f3d70111 by Simon Peyton Jones at 2020-10-21T13:20:40+01:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 5 changed files: - compiler/GHC/Tc/TyCl/PatSyn.hs - testsuite/tests/patsyn/should_fail/T11010.stderr - + testsuite/tests/patsyn/should_fail/T18856.hs - + testsuite/tests/patsyn/should_fail/T18856.stderr - testsuite/tests/patsyn/should_fail/all.T Changes: ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -31,9 +31,9 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Builtin.Types.Prim import GHC.Types.Name +import GHC.Types.Name.Set import GHC.Types.SrcLoc import GHC.Core.PatSyn -import GHC.Types.Name.Set import GHC.Utils.Panic import GHC.Utils.Outputable import GHC.Data.FastString @@ -422,14 +422,22 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details ; tc_patsyn_finish lname dir is_infix lpat' (univ_bndrs, req_theta, ev_binds, req_dicts) (ex_bndrs, mkTyVarTys ex_tvs', prov_theta, prov_dicts) - (args', (map scaledThing arg_tys)) + (args', map scaledThing arg_tys) pat_ty rec_fields } where tc_arg :: TCvSubst -> Name -> Type -> TcM (LHsExpr GhcTc) + -- Look up the variable actually bound by lpat + -- and check that it has the expected type tc_arg subst arg_name arg_ty - = do { -- Look up the variable actually bound by lpat - -- and check that it has the expected type - arg_id <- tcLookupId arg_name + = setSrcSpan (nameSrcSpan arg_name) $ + -- Set the SrcSpan to be the binding site of the Id (#18856) + -- e.g. pattern P :: Int -> Maybe (Int,Bool) + -- pattern P x = Just (x,True) + -- Before unifying x's actual type with its expected type, in tc_arg, set + -- location to x's binding site in lpat, namely the 'x' in Just (x,True). + -- Else the error message location is wherever tcCheckPat finished, + -- namely the right-hand corner of the pattern + do { arg_id <- tcLookupId arg_name ; wrap <- tcSubTypeSigma GenSigCtxt (idType arg_id) (substTyUnchecked subst arg_ty) ===================================== testsuite/tests/patsyn/should_fail/T11010.stderr ===================================== @@ -1,5 +1,5 @@ -T11010.hs:9:36: error: +T11010.hs:9:34: error: • Couldn't match type ‘a1’ with ‘Int’ Expected: a -> b Actual: a1 -> b @@ -12,3 +12,6 @@ T11010.hs:9:36: error: • Relevant bindings include x :: Expr a1 (bound at T11010.hs:9:36) f :: a1 -> b (bound at T11010.hs:9:34) + | +9 | pattern IntFun str f x = Fun str f x + | ^ ===================================== testsuite/tests/patsyn/should_fail/T18856.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE PatternSynonyms, ViewPatterns #-} + +module T18856 where + +pattern P :: Int -> Bool -> (Int, Bool, [(Bool,Bool)]) +pattern P p q <- (q, p, [(True,False)]) + ===================================== testsuite/tests/patsyn/should_fail/T18856.stderr ===================================== @@ -0,0 +1,14 @@ + +T18856.hs:6:19: error: + • Couldn't match expected type ‘Bool’ with actual type ‘Int’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ + +T18856.hs:6:22: error: + • Couldn't match expected type ‘Int’ with actual type ‘Bool’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ ===================================== testsuite/tests/patsyn/should_fail/all.T ===================================== @@ -9,7 +9,7 @@ test('T9705-2', normal, compile_fail, ['']) test('unboxed-bind', normal, compile_fail, ['']) test('unboxed-wrapper-naked', normal, compile_fail, ['']) test('T10873', normal, compile_fail, ['']) -test('T11010', normal, compile_fail, ['']) +test('T11010', normal, compile_fail, ['-fdiagnostics-show-caret']) test('records-check-sels', normal, compile_fail, ['']) test('records-no-uni-update', normal, compile_fail, ['']) test('records-no-uni-update2', normal, compile_fail, ['']) @@ -47,3 +47,4 @@ test('T15692', normal, compile, ['']) # It has -fdefer-type-errors inside test('T15694', normal, compile_fail, ['']) test('T16900', normal, compile_fail, ['-fdiagnostics-show-caret']) test('T14552', normal, compile_fail, ['']) +test('T18856', normal, compile_fail, ['-fdiagnostics-show-caret']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d70111d1d69bf11ac374f4071cbd21a29b9d06 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d70111d1d69bf11ac374f4071cbd21a29b9d06 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 13:00:56 2020 From: gitlab at gitlab.haskell.org (Vladislav Zavialov) Date: Wed, 21 Oct 2020 09:00:56 -0400 Subject: [Git][ghc/ghc][wip/parsing-tests-12446-12862] 9 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f903108787b4_28003fd3ed1f4af4137141e@gitlab.haskell.org.mail> Vladislav Zavialov pushed to branch wip/parsing-tests-12446-12862 at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/linear_types.rst - docs/users_guide/using-warnings.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9dd556447c5215c0ec5ae263d30e3ac3b778bdaf...e2c4a94708e4d8789ce97bd8b034e62f0e8b81c6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9dd556447c5215c0ec5ae263d30e3ac3b778bdaf...e2c4a94708e4d8789ce97bd8b034e62f0e8b81c6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 13:38:55 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 21 Oct 2020 09:38:55 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f9039ef600d3_2800fe429d81375254@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 3818ba15 by Ryan Scott at 2020-10-21T09:25:29-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Adding a third type parameter to `HsConDeclDetails` to represent the types in an `InfixCon`, separate from the type parameters for `PrefixCon` and `RecCon`, and * Creating `HsConDeclH98Details` and `HsConDeclGADTDetails` synonyms on top of the new `HsConDeclDetails`, which instantiate the `inf` type parameter to `HsScaled pass (LBangType pass)` and `Void`, respectively. Using `Void` allows functions that consume `HsConDeclGADTDetails` to simply call `noGadtInfix` (i.e, `\x -> case x of {}`) instead of having to, say, `panic`. See also `Note [GADT syntax can't be infix]` in `GHC.Hs.Decls`. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{,H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon`. This is still possible since `RecCon`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 18 changed files: - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - utils/haddock Changes: ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -1227,7 +1227,10 @@ pprMinimalSig (L _ bf) = ppr (fmap unLoc bf) -} -- | Haskell Pattern Synonym Details -type HsPatSynDetails pass = HsConDetails (LIdP pass) [RecordPatSynField (LIdP pass)] +type HsPatSynDetails pass + = HsConDetails (LIdP pass) + [RecordPatSynField (LIdP pass)] + (LIdP pass) -- See Note [Record PatSyn Fields] -- | Record Pattern Synonym Field ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -74,8 +75,9 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclDetails, HsConDeclH98Details, HsConDeclGADTDetails, noGadtInfix, + hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -126,6 +128,7 @@ import GHC.Core.Type import GHC.Data.Bag import GHC.Data.Maybe import Data.Data hiding (TyCon,Fixity, Infix) +import Data.Void {- ************************************************************************ @@ -1473,9 +1476,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1495,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1626,94 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass - = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a data constructor declaration. The @inf@ type parameter +-- represents the representation for infix data constructors, which is +-- different depending on whether the data constructor is Haskell98-style or +-- GADT-style. +type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + +-- | The arguments in a Haskell98 data constructor, which can be infix. +type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + +-- | The arguments in a GADT constructor, which cannot be infix. +-- See @Note [GADT syntax can't be infix]@. +type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + +-- | Eliminate the payload of an 'InfixCon' of type 'HsConDeclGADTDetails'. +-- This function witnesses the fact that GADT constructors cannot be declared +-- with infix syntax (see @Note [GADT syntax can't be infix]@). This function +-- has the same implementation as 'Data.Void.absurd', but with a more specific +-- name to indicate its purpose. +noGadtInfix :: Void -> a +noGadtInfix v = case v of {} + +{- +Note [GADT syntax can't be infix] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The overall shape of Haskell98-style data constructors and GADT constructors +are very similar, which allows us to use the HsConDetails data type to +represent both forms of data constructors: + + data HsConDetails arg rec inf + = PrefixCon [arg] + | RecCon rec + | InfixCon inf inf + +But there is a key difference between the syntaxes of each form of data +constructor, however. Haskell98-style data constructors can use all three +varieties of HsConDetails above: + + data C p1 p2 + = C1 p1 p2 -- PrefixCon + | C2 { x :: p1, y :: p2 } -- InfixCon + | p1 `C2` p2 -- RecCon + +GADT constructors, on the other hand, can only use two HsConDetails varieties: + + data G p1 p2 where + G1 :: p1 -> p2 -> G p1 p2 -- PrefixCon + G2 :: { x :: p1, y :: p2 } -> G p1 p2 -- RecCon + +In other words, InfixCon is an unrepresentable state for GADT constructor +syntax (#18844). We encode this knowledge as a Haskell type by using separate +HsConDeclH98Details and HsConDeclGADTDetails type synonyms, which instantiate +the `inf` parameter of `HsConDetails pre rec inf` to different things. In +particular, HsConDeclGADTDetails instantiates `inf` to Void. This means that +when you match on an argument of type HsConDeclGADTDetails, you can "forget" +about the unrepresentable InfixCon case by using `noGadtInfix`: + + f :: HsConDeclGADTDetails pass -> blah + f (PrefixCon _) = ... + f (RecCon _) = ... + f (InfixCon v _) = noGadtInfix v + +Note that this Note only applies to the *surface syntax* of GADT constructors. +There is a notion of infix GADT constructors for the purposes of derived Show +instances (see Note [Infix GADT constructors]), but that is an orthogonal +concern. +-} getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon v _ -> noGadtInfix v hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,7 +1793,7 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, @@ -1731,7 +1801,7 @@ pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars where get_args (PrefixCon args) = map ppr args get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (InfixCon v _) = noGadtInfix v cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -316,7 +316,7 @@ type instance ConLikeP GhcTc = ConLike -- | Haskell Constructor Pattern Details -type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) +type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) (LPat p) hsConPatArgs :: HsConPatDetails p -> [LPat p] hsConPatArgs (PrefixCon ps) = ps @@ -866,7 +866,7 @@ patNeedsParens p = go -- | @'conPatNeedsParens' p cp@ returns 'True' if the constructor patterns @cp@ -- needs parentheses under precedence @p at . -conPatNeedsParens :: PprPrec -> HsConDetails a b -> Bool +conPatNeedsParens :: PprPrec -> HsConDetails a b c -> Bool conPatNeedsParens p = go where go (PrefixCon args) = p >= appPrec && not (null args) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1104,15 +1104,19 @@ instance OutputableBndrId p -- HsConDetails is used for patterns/expressions *and* for data type -- declarations --- | Haskell Constructor Details -data HsConDetails arg rec +-- | Haskell Constructor Details. +-- +-- The @arg@ and @inf@ type parameters are kept separate so that GADT +-- constructors (which cannot be declared with infix syntax) can instantiate +-- @inf@ to @Void at . See @Note [GADT syntax can't be infix]@ in "GHC.Hs.Decls". +data HsConDetails arg rec inf = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } - | InfixCon arg arg -- p1 `C` p2 + | InfixCon inf inf -- p1 `C` p2 deriving Data -instance (Outputable arg, Outputable rec) - => Outputable (HsConDetails arg rec) where +instance (Outputable arg, Outputable rec, Outputable inf) + => Outputable (HsConDetails arg rec inf) where ppr (PrefixCon args) = text "PrefixCon" <+> ppr args ppr (RecCon rec) = text "RecCon:" <+> ppr rec ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,7 +1257,7 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where (remSeen', flds) = get_flds remSeen args @@ -1269,7 +1269,7 @@ hsConDeclsBinders cons (remSeen', flds) = get_flds remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds :: Seen p -> HsConDeclDetails (GhcPass p) inf -> (Seen p, [LFieldOcc (GhcPass p)]) get_flds remSeen (RecCon flds) = (remSeen', fld_names) ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,31 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + InfixCon v _ -> noGadtInfix v + RecCon _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,52 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + InfixCon v _ -> noGadtInfix v + RecCon ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a PrefixCon. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a RecCon. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2635,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -68,6 +68,7 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Data ( Data, Typeable ) import Data.List ( foldl1' ) +import Data.Void import Control.Monad ( forM_ ) import Control.Monad.Trans.State.Strict import Control.Monad.Trans.Reader @@ -578,6 +579,9 @@ class ToHie a where class HasType a where getTypeNode :: a -> HieM [HieAST Type] +instance ToHie Void where + toHie = absurd + instance (ToHie a) => ToHie [a] where toHie = concatMapM toHie @@ -996,8 +1000,10 @@ instance HiePass p => ToHie (PScoped (Located (Pat (GhcPass p)))) where HieRn -> [] #endif where - contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) - -> HsConDetails (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a))) + contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) a + -> HsConDetails (PScoped a) + (RContext (HsRecFields (GhcPass p) (PScoped a))) + (PScoped a) contextify (PrefixCon args) = PrefixCon $ patScopes rsp scope pscope args contextify (InfixCon a b) = InfixCon a' b' where [a', b'] = patScopes rsp scope pscope [a,b] @@ -1314,7 +1320,7 @@ instance HiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p))) where , toHie $ PS Nothing sc NoScope pat ] -instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where +instance (ToHie arg, ToHie rec, ToHie inf) => ToHie (HsConDetails arg rec inf) where toHie (PrefixCon args) = toHie args toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] @@ -1530,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1545,6 +1551,12 @@ instance ToHie (Located (ConDecl GhcRn)) where tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars + + condecl_scope :: HsConDeclGADTDetails (GhcPass p) -> Scope + condecl_scope args = case args of + PrefixCon xs -> scaled_args_scope xs + InfixCon v _ -> noGadtInfix v + RecCon x -> mkLScope x ConDeclH98 { con_name = name, con_ex_tvs = qvars , con_mb_cxt = ctx, con_args = dets } -> [ toHie $ C (Decl ConDec $ getRealSpan span) name @@ -1556,12 +1568,14 @@ instance ToHie (Located (ConDecl GhcRn)) where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope + condecl_scope :: HsConDeclH98Details (GhcPass p) -> Scope condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled (GhcPass p) (LHsType (GhcPass p))] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) + instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -643,7 +643,7 @@ mkGadtDecl names ty = do , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,22 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of + con_g_args' <- + case con_g_args of PrefixCon ts -> PrefixCon <$> addHaddock ts RecCon (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + InfixCon v _ -> noGadtInfix v con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,16 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixCon args -> extract_scaled_ltys args + InfixCon v _ -> noGadtInfix v + RecCon (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1804,6 +1811,14 @@ extract_lctxt ctxt = extract_ltys (unLoc ctxt) extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_lty :: LHsType GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lty (L _ ty) acc = case ty of ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,22 +2246,36 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name + -> HsDocContext + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details = rnConDeclDetails rnScaledLHsType + +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails = rnConDeclDetails (\_ -> noGadtInfix) + +rnConDeclDetails :: + (HsDocContext -> infPs -> RnM (infRn, FreeVars)) + -> Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclDetails GhcPs infPs + -> RnM (HsConDeclDetails GhcRn infRn, FreeVars) +rnConDeclDetails _ _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } -rnConDeclDetails _ doc (InfixCon ty1 ty2) - = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 - ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 +rnConDeclDetails rnInf _ doc (InfixCon ty1 ty2) + = do { (new_ty1, fvs1) <- rnInf doc ty1 + ; (new_ty2, fvs2) <- rnInf doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclDetails _ con doc (RecCon (L l fields)) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecCon flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -81,6 +81,7 @@ import GHC.Types.Basic import qualified GHC.LanguageExtensions as LangExt import Control.Monad +import Data.Foldable import Data.Function ( on ) import Data.Functor.Identity import Data.List @@ -1563,18 +1564,33 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the type of an argument to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need --- the first two arguments. -kcConArgTys :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () -kcConArgTys new_or_data res_kind arg_tys = do - { let exp_kind = getArgExpKind new_or_data res_kind - ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind - tcMult mult) - +-- the ContextKind argument. +kcConArg :: ContextKind -> HsScaled GhcRn (LHsType GhcRn) -> TcM () +kcConArg exp_kind (HsScaled mult ty) = do + _ <- tcCheckLHsType (getBangType ty) exp_kind + _ <- tcMult mult + pure () -- See Note [Implementation of UnliftedNewtypes], STEP 2 - } + +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: ContextKind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args = kcConArgs kcConArg + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: ContextKind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs = kcConArgs (\_ -> noGadtInfix) + +-- Kind-check the types of argument to a data constructor. +kcConArgs :: (ContextKind -> infRn -> TcM ()) + -> ContextKind -> HsConDeclDetails GhcRn infRn -> TcM () +kcConArgs kc_inf exp_kind con_args = case con_args of + PrefixCon tys -> traverse_ (kcConArg exp_kind) tys + InfixCon ty1 ty2 -> traverse_ (kc_inf exp_kind) [ty1, ty2] + RecCon (L _ flds) -> traverse_ (kcConArg exp_kind) $ + map (hsLinear . cd_fld_type . unLoc) flds kcConDecls :: NewOrData -> Kind -- The result kind signature @@ -1604,14 +1620,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args (getArgExpKind new_or_data res_kind) args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1641,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs (getArgExpKind new_or_data res_kind) args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3212,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3282,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3299,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,19 +3378,20 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of InfixCon {} -> return True - _ -> return False + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True + InfixCon v _ -> noGadtInfix v RecCon {} -> return False PrefixCon arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) @@ -3383,18 +3400,31 @@ tcConIsInfixGADT con details ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args = tcConArgs tcConArg + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs = tcConArgs (\_ -> noGadtInfix) + +tcConArgs :: (ContextKind -> infRn -> TcM (Scaled TcType, HsSrcBang)) + -> ContextKind -- expected kind of arguments -- always OpenKind for datatypes, but unlifted newtypes -- might have a specific kind - -> HsConDeclDetails GhcRn + -> HsConDeclDetails GhcRn infRn -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConArgs _ exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) - = do { bty1' <- tcConArg exp_kind bty1 - ; bty2' <- tcConArg exp_kind bty2 - ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConArgs tc_inf exp_kind (InfixCon bty1 bty2) + = mapM (tc_inf exp_kind) [bty1, bty2] +tcConArgs _ exp_kind (RecCon fields) = mapM (tcConArg exp_kind) btys where -- We need a one-to-one mapping from field_names to btys @@ -3434,7 +3464,8 @@ matches what the user wrote (#18791). Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We do not currently have syntax to declare an infix constructor in GADT syntax, +We do not currently have syntax to declare an infix constructor in GADT syntax +(see Note [GADT syntax can't be infix] in GHC.Hs.Decls), but it makes a (small) difference to the Show instance. So as a slightly ad-hoc solution, we regard a GADT data constructor as infix if a) it is an operator symbol ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -631,7 +631,7 @@ cvtConstr (RecGadtC c varstrtys ty) ; rec_flds <- mapM cvt_id_arg varstrtys ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,63 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon + , ... + } + + Where: :: + + -- New type synonym introduced in GHC 9.2; equivalent to `HsConDeclDetails` + -- in previous versions of GHC + type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + + -- New type synonym introduced in GHC 9.2 + type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + + -- The `inf` type parameter is new in GHC 9.2 + type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + + -- The `inf` type parameter is new in GHC 9.2 + data HsConDetails arg rec inf + = PrefixCon [arg] -- C p1 p2 p3 + | RecCon rec -- C { x = p1, y = p2 } + | InfixCon inf inf -- p1 `C` p2 + + The use of ``Void`` in ``HsConDeclGADTDetails`` reflects the fact that GADT + constructors cannot use infix syntax like Haskell98-style constructors can. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit f1343656c11c5133ae06a5734428fe23f4d72031 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3818ba159df0856c5a43689a44513727edf47fe5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3818ba159df0856c5a43689a44513727edf47fe5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 15:36:15 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Wed, 21 Oct 2020 11:36:15 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f90556f59a9f_28003fd40085b2901387673@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: c2d41887 by David Eichmann at 2020-10-21T16:28:13+01:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -330,17 +330,75 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. - - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ - -// acquires a token which may be used to create new objects and -// evaluate them. +/* Note [Locking and Pausing the RTS] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You have to surround all access to the RtsAPI with rts_lock/rts_unlock or +with rts_pause/rts_resume. + + +# rts_lock / rts_unlock + +Use `rts_lock` to acquire a token which may be used to call other RtsAPI +functions and call `rts_unlock` to return the token. When locked, garbage +collection will not occur. As long as 1 or more capabilities are not locked, +haskell threads will continue to execute. If you want to pause execution of +all haskell threads then use rts_pause/rts_resume instead. + +The implementation of `rts_lock` acquires a capability on this thread. Hence, +at most n locks can be held simultaneously, where n is the number of +capabilities. It is an error to call `rts_lock` when the rts is already +paused by the current OS thread (see rts_pause/rts_resume below). + + +# rts_pause / rts_resume + +Use `rts_pause` to pause execution of all Haskell threads and `rts_resume` to +resume them. The implementation acquires all capabilities. `rts_resume` +must be called on the same thread as `rts_pause`. `rts_pause`, much like +rts_lock, Returns a token which may be used to call other RtsAPI functions. + +* With the RTS paused, garbage collections will not occur and haskell threads + will not execute, allocate, nor mutate their stacks. +* Non-Haskell (i.e. non-worker) threads such as those running safe FFI calls + will NOT be paused and can still mutate pinned mutable data such as pinned + `MutableByteArray#`s. +* You may call `rts_pause` from within a non-worker OS thread. +* You may call `rts_pause` from within a *safe* FFI call. In this case, make + sure to call `rts_resume` within the same FFI call or the RTS will deadlock. +* Calling `rts_pause` from an *unsafe* FFI call will cause an error. +* On return, the rts will be fully paused: all haskell threads are stopped + and all capabilities are acquired by the current OS thread. +* Calling `rts_pause` in between rts_lock/rts_unlock on the same thread will + cause an error. +* Calling `rts_pause` results in an error if the RTS is already paused by the + current OS thread. +* Only one OS thread at a time can keep the rts paused. +* `rts_pause` will block while another thread is pausing the RTS, and + continue when the current thread is given exclusive permission to pause the + RTS. + +## Note on implementation. + +Thread safety is achieved almost entirely by the mechanism of acquiring and +releasing Capabilities, resulting in a sort of mutex / critical section pattern. +This has the following consequences: + +* There are at most `n_capabilities` threads currently in a + rts_lock/rts_unlock section. +* There is at most 1 threads in a rts_pause/rts_resume section. In that case + there will be no threads in a rts_lock/rts_unlock section. +* rts_pause and rts_lock may block in order to enforce the above 2 + invariants. + +*/ + +// Acquires a token which may be used to create new objects and evaluate them. +// See Note [Locking and Pausing the RTS] for correct usage. Capability *rts_lock (void); // releases the token acquired with rts_lock(). +// See Note [Locking and Pausing the RTS] for correct usage. void rts_unlock (Capability *token); // If you are in a context where you know you have a current capability but @@ -483,6 +541,18 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads. +// See Note [Locking and Pausing the RTS] for correct usage. +Capability * rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. +// See Note [Locking and Pausing the RTS] for correct usage. +// [in] cap: the token returned by rts_pause. +void rts_resume (Capability * cap); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,14 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,16 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +// +// It's possible to remove this and instead define the pausing task as whichever +// task owns all capabilities, but using `rts_pausing_task` leads to marginally +// cleaner code/API and better error messages. +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +603,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already called rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +638,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +663,141 @@ rts_unlock (Capability *cap) } } +#if defined(THREADED_RTS) + +// See Note [Locking and Pausing the RTS] +Capability * rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (at it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + return task->cap; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See Note [Locking and Pausing the RTS]. The cap argument is here just for +// symmetry with rts_pause and to match the pattern of rts_lock/rts_unlock. +void rts_resume (Capability * cap STG_UNUSED) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +Capability * GNU_ATTRIBUTE(__noreturn__) +rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (Capability * cap STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +833,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,15 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1573,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2096,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2776,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2835,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,12 @@ +test('pause_resume_via_safe_ffi', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', [only_ways(threaded_ways), + extra_files(['pause_resume.c','pause_resume.h'])], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,242 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + Capability * cap = rts_pause(); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(cap); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + Capability * cap = rts_pause(); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(cap); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + safe_pthread_join_c :: CULong -> IO () + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,20 @@ + +test('unsafe_rts_pause', [only_ways(threaded_ways), exit_code(1)], compile_and_run, ['']) +test('rts_lock_when_paused', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ only_ways(threaded_ways), + exit_code(1), + extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,79 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + Capability * pauseCapA = rts_pause(); + printf("Paused\n"); + + printf("Pausing..."); + Capability * pauseCapB = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_unlock(pauseCapA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(pauseCapB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already called rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2d4188773de90946a01fe0db72af82623b88ba8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2d4188773de90946a01fe0db72af82623b88ba8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 15:52:49 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 11:52:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18870 Message-ID: <5f905951e153e_28003fd3ed7705781389313@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/T18870 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18870 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 15:53:38 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 11:53:38 -0400 Subject: [Git][ghc/ghc][wip/T18870] Arity: Rework `ArityType` to fix monotonicity (#18870) Message-ID: <5f905982cf374_28003fd402713cf013895c8@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18870 at Glasgow Haskell Compiler / GHC Commits: 39ec440b by Sebastian Graf at 2020-10-21T17:52:52+02:00 Arity: Rework `ArityType` to fix monotonicity (#18870) As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = ATop | ALam OneShotInfo ArityType | ABot ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/T18870.hs - testsuite/tests/arityanal/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -18,8 +18,8 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), expandableArityType, arityTypeArity - , maxWithArity, isBotArityType, idArityType + , ArityType, mkBotArityType, mkTopArityType, expandableArityType + , arityTypeArity, maxWithArity, isBotArityType, idArityType -- ** Join points , etaExpandToJoinPoint, etaExpandToJoinPointRule @@ -458,7 +458,7 @@ with function exprEtaExpandArity). Here is what the fields mean. If an arbitrary expression 'f' has ArityType 'at', then - * If at = ABot n, then (f x1..xn) definitely diverges. Partial + * If at = \o1..on.⊥, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. We allow ourselves to eta-expand bottoming functions, even @@ -466,14 +466,13 @@ ArityType 'at', then let x = in \y. error (g x y) ==> \y. let x = in error (g x y) - * If at = ATop as, and n=length as, - then expanding 'f' to (\x1..xn. f x1 .. xn) loses no sharing, - assuming the calls of f respect the one-shot-ness of - its definition. + * If at = \o1..on.T, then expanding 'f' to (\x1..xn. f x1 .. + xn) loses no sharing, assuming the calls of f respect the one-shot-ness + o1..on of its definition. NB 'f' is an arbitrary expression, eg (f = g e1 e2). This 'f' can have ArityType as ATop, with length as > 0, only if e1 e2 are - themselves. + themselves. ??? cheap? But actually the arity of g is important here. * In both cases, f, (f x1), ... (f x1 ... f(n-1)) are definitely really functions, or bottom, but *not* casts from a data type, in @@ -485,62 +484,92 @@ ArityType 'at', then Example: f = \x\y. let v = in \s(one-shot) \t(one-shot). blah - 'f' has ArityType [ManyShot,ManyShot,OneShot,OneShot] + 'f' has arity type \??11.T The one-shot-ness means we can, in effect, push that 'let' inside the \st. Suppose f = \xy. x+y -Then f :: AT [False,False] ATop - f v :: AT [False] ATop - f :: AT [] ATop - --------------------- Main arity code ---------------------------- +Then f :: \??.T + f v :: \?.T + f :: T -} data ArityType -- See Note [ArityType] - = ATop [OneShotInfo] - | ABot Arity + = ATop + | ALam !OneShotInfo !ArityType + | ABot deriving( Eq ) -- There is always an explicit lambda -- to justify the [OneShot], or the Arity +mkBotArityType :: [OneShotInfo] -> ArityType +mkBotArityType = foldr ALam ABot + +mkTopArityType :: [OneShotInfo] -> ArityType +mkTopArityType = foldr ALam ATop + +-- | Returns two components: +-- * A flag denoting whether the arity type ends in 'ABot' (and not 'ATop') +-- * A list of 'OneShotInfo's from 'ALam's we encountered along the way +splitArityType :: ArityType -> (Bool, [OneShotInfo]) +splitArityType at = go at id + where + go ABot oss = (True, oss []) + go ATop oss = (False, oss []) + go (ALam os at) oss = go at ((os:) . oss) + instance Outputable ArityType where - ppr (ATop os) = text "ATop" <> parens (ppr (length os)) - ppr (ABot n) = text "ABot" <> parens (ppr n) + ppr at + | null oss = pp_bot is_bot + | otherwise = char '\\' <> pp_oss oss <> dot <> pp_bot is_bot + where + (is_bot, oss) = splitArityType at + pp_bot True = char '⊥' + pp_bot False = char 'T' + pp_oss [] = empty + pp_oss (OneShotLam :oss) = char '1' <> pp_oss oss + pp_oss (NoOneShotInfo:oss) = char '?' <> pp_oss oss + +arityTypeOneShots :: ArityType -> [OneShotInfo] +arityTypeOneShots = snd . splitArityType +-- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity --- The number of value args for the arity type -arityTypeArity (ATop oss) = length oss -arityTypeArity (ABot ar) = ar +arityTypeArity = length . arityTypeOneShots +-- | True <=> eta-expansion will add at least one lambda expandableArityType :: ArityType -> Bool --- True <=> eta-expansion will add at least one lambda -expandableArityType (ATop oss) = not (null oss) -expandableArityType (ABot ar) = ar /= 0 +expandableArityType at = arityTypeArity at /= 0 isBotArityType :: ArityType -> Bool -isBotArityType (ABot {}) = True -isBotArityType (ATop {}) = False - -arityTypeOneShots :: ArityType -> [OneShotInfo] -arityTypeOneShots (ATop oss) = oss -arityTypeOneShots (ABot ar) = replicate ar OneShotLam - -- If we are diveging or throwing an exception anyway - -- it's fine to push redexes inside the lambdas - -botArityType :: ArityType -botArityType = ABot 0 -- Unit for andArityType +isBotArityType = fst . splitArityType +-- | Expand a non-bottoming arity type so that it has at least the given arity. maxWithArity :: ArityType -> Arity -> ArityType -maxWithArity at@(ABot {}) _ = at -maxWithArity at@(ATop oss) ar - | oss `lengthAtLeast` ar = at - | otherwise = ATop (take ar (oss ++ repeat NoOneShotInfo)) +maxWithArity at ar = go at ar + where + go (ALam os at) !ar = ALam os (go at (ar-1)) + -- The following case is the reason we go through all the trouble. + -- It expands the arity type with enough NoOneShotInfo. + go ATop ar | ar > 0 = iterate (ALam NoOneShotInfo) ATop !! ar + go _ !_ = at + +-- | Trim an arity type so that it has at most the given arity. +-- Any excess 'ALam's are truncated to 'ATop', even if they end in 'ABot'. +minWithArity :: ArityType -> Arity -> ArityType +minWithArity at ar = go at ar + where + go ABot 0 = ABot + go _ 0 = ATop + go (ALam os at) ar = ALam os (go at (ar-1)) + go at _ = at -vanillaArityType :: ArityType -vanillaArityType = ATop [] -- Totally uninformative +takeWhileOneShot :: ArityType -> ArityType +takeWhileOneShot (ALam NoOneShotInfo _) = ATop +takeWhileOneShot (ALam OneShotLam at) = ALam OneShotLam (takeWhileOneShot at) +takeWhileOneShot at = at -- | The Arity returned is the number of value args the -- expression can be applied to without doing much work @@ -551,8 +580,9 @@ exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function -getBotArity (ABot n) = Just n -getBotArity _ = Nothing +getBotArity at + | (True, oss) <- splitArityType at = Just $ length oss + | otherwise = Nothing ---------------------- findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType @@ -563,17 +593,16 @@ findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- so it is safe to expand e ==> (\x1..xn. e x1 .. xn) -- (b) if is_bot=True, then e applied to n args is guaranteed bottom findRhsArity dflags bndr rhs old_arity - = go (step botArityType) + = go (step ABot) -- We always do one step, but usually that produces a result equal to -- old_arity, and then we stop right away (since arities should not -- decrease) -- Result: the common case is that there is just one iteration where go :: ArityType -> ArityType - go cur_atype@(ATop oss) - | length oss <= old_arity = cur_atype go cur_atype - | new_atype == cur_atype = cur_atype + | not is_bot, length oss <= old_arity = cur_atype -- ... "stop right away" + | new_atype == cur_atype = cur_atype | otherwise = #if defined(DEBUG) pprTrace "Exciting arity" @@ -582,7 +611,8 @@ findRhsArity dflags bndr rhs old_arity #endif go new_atype where - new_atype = step cur_atype + (is_bot, oss) = splitArityType cur_atype + new_atype = step cur_atype step :: ArityType -> ArityType step at = -- pprTrace "step" (ppr bndr <+> ppr at <+> ppr (arityType env rhs)) $ @@ -607,7 +637,7 @@ fifteen years ago! It also shows up in the code for 'rnf' on lists in #4138. We do the neccessary, quite simple fixed-point iteration in 'findRhsArity', -which assumes for a single binding @botArityType@ on the first run and iterates +which assumes for a single binding 'ABot' on the first run and iterates until it finds a stable arity type. Two wrinkles * We often have to ask (see the Case or Let case of 'arityType') whether some @@ -651,44 +681,43 @@ dictionary-typed expression, but that's more work. -} arityLam :: Id -> ArityType -> ArityType -arityLam id (ATop as) = ATop (idStateHackOneShotInfo id : as) -arityLam _ (ABot n) = ABot (n+1) +arityLam id at = ALam (idStateHackOneShotInfo id) at floatIn :: Bool -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn _ (ABot n) = ABot n -floatIn True (ATop as) = ATop as -floatIn False (ATop as) = ATop (takeWhile isOneShotInfo as) - -- If E is not cheap, keep arity only for one-shots +floatIn cheap at + | isBotArityType at || cheap = at + -- If E is not cheap, keep arity only for one-shots + | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' -arityApp (ABot 0) _ = ABot 0 -arityApp (ABot n) _ = ABot (n-1) -arityApp (ATop []) _ = ATop [] -arityApp (ATop (_:as)) cheap = floatIn cheap (ATop as) +arityApp (ALam _ at) cheap = floatIn cheap at +arityApp at _ = at andArityType :: ArityType -> ArityType -> ArityType -- Used for branches of a 'case' -- This is least upper bound in the ArityType lattice -andArityType (ABot n1) (ABot n2) = ABot (n1 `max` n2) -- Note [ABot branches: use max] -andArityType (ATop as) (ABot _) = ATop as -andArityType (ABot _) (ATop bs) = ATop bs -andArityType (ATop as) (ATop bs) = ATop (as `combine` bs) - where -- See Note [Combining case branches] - combine (a:as) (b:bs) = (a `bestOneShot` b) : combine as bs - combine [] bs = takeWhile isOneShotInfo bs - combine as [] = takeWhile isOneShotInfo as - -{- Note [ABot branches: use max] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +andArityType ABot at2 = at2 -- Note [ABot branches: max arity wins] +andArityType at1 ABot = at1 -- Note [ABot branches: max arity wins] +andArityType (ALam os1 at1) (ALam os2 at2) = + ALam (os1 `bestOneShot` os2) (andArityType at1 at2) -- See Note [Combining case branches] +andArityType (ALam OneShotLam at) ATop = + ALam OneShotLam (andArityType at ATop) -- See Note [Combining case branches] +andArityType ATop (ALam OneShotLam at) = + ALam OneShotLam (andArityType ATop at) -- See Note [Combining case branches] +andArityType ATop _ = ATop +andArityType _ ATop = ATop + +{- Note [ABot branches: max arity wins] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider case x of True -> \x. error "urk" False -> \xy. error "urk2" -Remember: ABot n means "if you apply to n args, it'll definitely diverge". -So we need (ABot 2) for the whole thing, the /max/ of the ABot arities. +Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". +So we need \??.⊥ for the whole thing, the /max/ of both arities. Note [Combining case branches] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -698,11 +727,12 @@ Consider True -> z False -> \s(one-shot). e1 in go2 x -We *really* want to eta-expand go and go2. +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. When combining the branches of the case we have - ATop [] `andAT` ATop [OneShotLam] -and we want to get ATop [OneShotLam]. But if the inner -lambda wasn't one-shot we don't want to do this. + ATop `andAT` ALam OneShotLam ATop +and we want to get ALam [OneShotLam] ATop. +But if the inner lambda wasn't one-shot we don't want to do this. (We need a proper arity analysis to justify that.) So we combine the best of the two branches, on the (slightly dodgy) @@ -718,14 +748,15 @@ most 1, because typeArity (Int -> F a) = 1. So we have to trim the result of calling arityType on (\x y. blah). Failing to do so, and hence breaking the exprArity invariant, led to #5441. -How to trim? For ATop, it's easy. But we must take great care with ABot. -Suppose the expression was (\x y. error "urk"), we'll get (ABot 2). We -absolutely must not trim that to (ABot 1), because that claims that +How to trim? If we end in ATop, it's easy. But we must take great care with +ABot. Suppose the expression was (\x y. error "urk"), we'll get \??.⊥. +We absolutely must not trim that to \?.⊥, because that claims that ((\x y. error "urk") |> co) diverges when given one argument, which it absolutely does not. And Bad Things happen if we think something returns bottom when it doesn't (#16066). -So, do not reduce the 'n' in (ABot n); rather, switch (conservatively) to ATop. +So, if we need to trim an arity type ending in ABot, switch (conservatively) to +ATop. Historical note: long ago, we unconditionally switched to ATop when we encountered a cast, but that is far too conservative: see #5475 @@ -838,29 +869,28 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of Nothing -> isCheapApp fn n_val_args -- @Just at@ means local function with @at@ as current ArityType. -- Roughly approximate what 'isCheapApp' is doing. - Just (ABot _) -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils - Just (ATop oss) -> n_val_args < length oss -- Essentially isWorkFreeApp + Just at + | is_bot -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils + | n_val_args < length oss -> True -- Essentially isWorkFreeApp + | otherwise -> False + where + (is_bot, oss) = splitArityType at ---------------- arityType :: ArityEnv -> CoreExpr -> ArityType arityType env (Cast e co) - = case arityType env e of - ATop os -> ATop (take co_arity os) -- See Note [Arity trimming] - ABot n | co_arity < n -> ATop (replicate co_arity noOneShotInfo) - | otherwise -> ABot n + = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] where co_arity = length (typeArity (coercionRKind co)) -- See Note [exprArity invariant] (2); must be true of -- arityType too, since that is how we compute the arity -- of variables, and they in turn affect result of exprArity -- #5441 is a nice demo - -- However, do make sure that ATop -> ATop and ABot -> ABot! - -- Casts don't affect that part. Getting this wrong provoked #5475 arityType env (Var v) | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] + = ABot -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise @@ -887,18 +917,15 @@ arityType env (App fun arg ) -- arityType env (Case scrut bndr _ alts) | exprIsDeadEnd scrut || null alts - = botArityType -- Do not eta expand - -- See Note [Dealing with bottom (1)] + = ABot -- Do not eta expand. See Note [Dealing with bottom (1)] | not (pedanticBottoms env) -- See Note [Dealing with bottom (2)] , myExprIsCheap env scrut (Just (idType bndr)) = alts_type | exprOkForSpeculation scrut = alts_type - | otherwise -- In the remaining cases we may not push - = case alts_type of -- evaluation of the scrutinee in - ATop as -> ATop (takeWhile isOneShotInfo as) - ABot _ -> ATop [] + | otherwise -- In the remaining cases we may not push + = takeWhileOneShot alts_type -- evaluation of the scrutinee in where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] @@ -938,7 +965,7 @@ arityType env (Let (Rec prs) e) arityType env (Tick t e) | not (tickishIsCode t) = arityType env e -arityType _ _ = vanillaArityType +arityType _ _ = ATop {- Note [Eta-expansion and join points] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -973,12 +1000,12 @@ So we do this: body of the let. * Dually, when we come to a /call/ of a join point, just no-op - by returning botArityType, the bottom element of ArityType, + by returning ABot, the bottom element of ArityType, which so that: bot `andArityType` x = x * This works if the join point is bound in the expression we are taking the arityType of. But if it's bound further out, it makes - no sense to say that (say) the arityType of (j False) is ABot 0. + no sense to say that (say) the arityType of (j False) is ABot. Bad things happen. So we keep track of the in-scope join-point Ids in ae_join. @@ -999,10 +1026,10 @@ idArityType v , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds - = if isDeadEndDiv res then ABot arity - else ATop (take arity one_shots) + = if isDeadEndDiv res then mkBotArityType (take arity one_shots) + else mkTopArityType (take arity one_shots) | otherwise - = ATop (take (idArity v) one_shots) + = mkTopArityType (take (idArity v) one_shots) where one_shots :: [OneShotInfo] -- One-shot-ness derived from the type one_shots = typeArity (idType v) @@ -1111,13 +1138,13 @@ Consider foo = \x. case x of True -> (\s{os}. blah) |> co False -> wubble -We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]). +We'll get an ArityType for foo of \?1.T. Then we want to eta-expand to foo = \x. (\eta{os}. (case x of ...as before...) eta) |> some_co That 'eta' binder is fresh, and we really want it to have the -one-shot flag from the inner \s{osf}. By expanding with the +one-shot flag from the inner \s{os}. By expanding with the ArityType gotten from analysing the RHS, we achieve this neatly. This makes a big difference to the one-shot monad trick; ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Types.Unique ( hasKey ) import GHC.Core.Unfold import GHC.Core.Unfold.Make import GHC.Core.Utils -import GHC.Core.Opt.Arity ( ArityType(..), arityTypeArity, isBotArityType +import GHC.Core.Opt.Arity ( ArityType, arityTypeArity, isBotArityType , pushCoTyArg, pushCoValArg , idArityType, etaExpandAT ) import GHC.Core.SimpleOpt ( joinPointBinding_maybe, joinPointBindings_maybe ) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1662,8 +1662,8 @@ tryEtaExpandRhs mode bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = ABot (length oss) - | otherwise = ATop oss + arity_type | exprIsDeadEnd join_body = mkBotArityType oss + | otherwise = mkTopArityType oss ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/T18870.hs ===================================== @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +module T18870 where + +import GHC.Exts + +-- This function should not lead to an "Exciting arity" DEBUG message. +-- It should only do one round of fixed-point iteration to conclude that it has +-- arity 2. +f :: [a] -> a -> a +f [] = id +f (x:xs) = oneShot (\_ -> f xs x) ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -19,3 +19,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39ec440b47da4e8f0e2f3ef78798a3bd82a92e44 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/39ec440b47da4e8f0e2f3ef78798a3bd82a92e44 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 15:54:18 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 11:54:18 -0400 Subject: [Git][ghc/ghc][wip/T18870] Arity: Rework `ArityType` to fix monotonicity (#18870) Message-ID: <5f9059aa4e120_28003fd3ec92b32813897e1@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18870 at Glasgow Haskell Compiler / GHC Commits: 4f6b5811 by Sebastian Graf at 2020-10-21T17:54:05+02:00 Arity: Rework `ArityType` to fix monotonicity (#18870) As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = ATop | ALam OneShotInfo ArityType | ABot ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. Fixes #18870. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/T18870.hs - testsuite/tests/arityanal/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -18,8 +18,8 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), expandableArityType, arityTypeArity - , maxWithArity, isBotArityType, idArityType + , ArityType, mkBotArityType, mkTopArityType, expandableArityType + , arityTypeArity, maxWithArity, isBotArityType, idArityType -- ** Join points , etaExpandToJoinPoint, etaExpandToJoinPointRule @@ -458,7 +458,7 @@ with function exprEtaExpandArity). Here is what the fields mean. If an arbitrary expression 'f' has ArityType 'at', then - * If at = ABot n, then (f x1..xn) definitely diverges. Partial + * If at = \o1..on.⊥, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. We allow ourselves to eta-expand bottoming functions, even @@ -466,14 +466,13 @@ ArityType 'at', then let x = in \y. error (g x y) ==> \y. let x = in error (g x y) - * If at = ATop as, and n=length as, - then expanding 'f' to (\x1..xn. f x1 .. xn) loses no sharing, - assuming the calls of f respect the one-shot-ness of - its definition. + * If at = \o1..on.T, then expanding 'f' to (\x1..xn. f x1 .. + xn) loses no sharing, assuming the calls of f respect the one-shot-ness + o1..on of its definition. NB 'f' is an arbitrary expression, eg (f = g e1 e2). This 'f' can have ArityType as ATop, with length as > 0, only if e1 e2 are - themselves. + themselves. ??? cheap? But actually the arity of g is important here. * In both cases, f, (f x1), ... (f x1 ... f(n-1)) are definitely really functions, or bottom, but *not* casts from a data type, in @@ -485,62 +484,92 @@ ArityType 'at', then Example: f = \x\y. let v = in \s(one-shot) \t(one-shot). blah - 'f' has ArityType [ManyShot,ManyShot,OneShot,OneShot] + 'f' has arity type \??11.T The one-shot-ness means we can, in effect, push that 'let' inside the \st. Suppose f = \xy. x+y -Then f :: AT [False,False] ATop - f v :: AT [False] ATop - f :: AT [] ATop - --------------------- Main arity code ---------------------------- +Then f :: \??.T + f v :: \?.T + f :: T -} data ArityType -- See Note [ArityType] - = ATop [OneShotInfo] - | ABot Arity + = ATop + | ALam !OneShotInfo !ArityType + | ABot deriving( Eq ) -- There is always an explicit lambda -- to justify the [OneShot], or the Arity +mkBotArityType :: [OneShotInfo] -> ArityType +mkBotArityType = foldr ALam ABot + +mkTopArityType :: [OneShotInfo] -> ArityType +mkTopArityType = foldr ALam ATop + +-- | Returns two components: +-- * A flag denoting whether the arity type ends in 'ABot' (and not 'ATop') +-- * A list of 'OneShotInfo's from 'ALam's we encountered along the way +splitArityType :: ArityType -> (Bool, [OneShotInfo]) +splitArityType at = go at id + where + go ABot oss = (True, oss []) + go ATop oss = (False, oss []) + go (ALam os at) oss = go at ((os:) . oss) + instance Outputable ArityType where - ppr (ATop os) = text "ATop" <> parens (ppr (length os)) - ppr (ABot n) = text "ABot" <> parens (ppr n) + ppr at + | null oss = pp_bot is_bot + | otherwise = char '\\' <> pp_oss oss <> dot <> pp_bot is_bot + where + (is_bot, oss) = splitArityType at + pp_bot True = char '⊥' + pp_bot False = char 'T' + pp_oss [] = empty + pp_oss (OneShotLam :oss) = char '1' <> pp_oss oss + pp_oss (NoOneShotInfo:oss) = char '?' <> pp_oss oss + +arityTypeOneShots :: ArityType -> [OneShotInfo] +arityTypeOneShots = snd . splitArityType +-- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity --- The number of value args for the arity type -arityTypeArity (ATop oss) = length oss -arityTypeArity (ABot ar) = ar +arityTypeArity = length . arityTypeOneShots +-- | True <=> eta-expansion will add at least one lambda expandableArityType :: ArityType -> Bool --- True <=> eta-expansion will add at least one lambda -expandableArityType (ATop oss) = not (null oss) -expandableArityType (ABot ar) = ar /= 0 +expandableArityType at = arityTypeArity at /= 0 isBotArityType :: ArityType -> Bool -isBotArityType (ABot {}) = True -isBotArityType (ATop {}) = False - -arityTypeOneShots :: ArityType -> [OneShotInfo] -arityTypeOneShots (ATop oss) = oss -arityTypeOneShots (ABot ar) = replicate ar OneShotLam - -- If we are diveging or throwing an exception anyway - -- it's fine to push redexes inside the lambdas - -botArityType :: ArityType -botArityType = ABot 0 -- Unit for andArityType +isBotArityType = fst . splitArityType +-- | Expand a non-bottoming arity type so that it has at least the given arity. maxWithArity :: ArityType -> Arity -> ArityType -maxWithArity at@(ABot {}) _ = at -maxWithArity at@(ATop oss) ar - | oss `lengthAtLeast` ar = at - | otherwise = ATop (take ar (oss ++ repeat NoOneShotInfo)) +maxWithArity at ar = go at ar + where + go (ALam os at) !ar = ALam os (go at (ar-1)) + -- The following case is the reason we go through all the trouble. + -- It expands the arity type with enough NoOneShotInfo. + go ATop ar | ar > 0 = iterate (ALam NoOneShotInfo) ATop !! ar + go _ !_ = at + +-- | Trim an arity type so that it has at most the given arity. +-- Any excess 'ALam's are truncated to 'ATop', even if they end in 'ABot'. +minWithArity :: ArityType -> Arity -> ArityType +minWithArity at ar = go at ar + where + go ABot 0 = ABot + go _ 0 = ATop + go (ALam os at) ar = ALam os (go at (ar-1)) + go at _ = at -vanillaArityType :: ArityType -vanillaArityType = ATop [] -- Totally uninformative +takeWhileOneShot :: ArityType -> ArityType +takeWhileOneShot (ALam NoOneShotInfo _) = ATop +takeWhileOneShot (ALam OneShotLam at) = ALam OneShotLam (takeWhileOneShot at) +takeWhileOneShot at = at -- | The Arity returned is the number of value args the -- expression can be applied to without doing much work @@ -551,8 +580,9 @@ exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function -getBotArity (ABot n) = Just n -getBotArity _ = Nothing +getBotArity at + | (True, oss) <- splitArityType at = Just $ length oss + | otherwise = Nothing ---------------------- findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType @@ -563,17 +593,16 @@ findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- so it is safe to expand e ==> (\x1..xn. e x1 .. xn) -- (b) if is_bot=True, then e applied to n args is guaranteed bottom findRhsArity dflags bndr rhs old_arity - = go (step botArityType) + = go (step ABot) -- We always do one step, but usually that produces a result equal to -- old_arity, and then we stop right away (since arities should not -- decrease) -- Result: the common case is that there is just one iteration where go :: ArityType -> ArityType - go cur_atype@(ATop oss) - | length oss <= old_arity = cur_atype go cur_atype - | new_atype == cur_atype = cur_atype + | not is_bot, length oss <= old_arity = cur_atype -- ... "stop right away" + | new_atype == cur_atype = cur_atype | otherwise = #if defined(DEBUG) pprTrace "Exciting arity" @@ -582,7 +611,8 @@ findRhsArity dflags bndr rhs old_arity #endif go new_atype where - new_atype = step cur_atype + (is_bot, oss) = splitArityType cur_atype + new_atype = step cur_atype step :: ArityType -> ArityType step at = -- pprTrace "step" (ppr bndr <+> ppr at <+> ppr (arityType env rhs)) $ @@ -607,7 +637,7 @@ fifteen years ago! It also shows up in the code for 'rnf' on lists in #4138. We do the neccessary, quite simple fixed-point iteration in 'findRhsArity', -which assumes for a single binding @botArityType@ on the first run and iterates +which assumes for a single binding 'ABot' on the first run and iterates until it finds a stable arity type. Two wrinkles * We often have to ask (see the Case or Let case of 'arityType') whether some @@ -651,44 +681,43 @@ dictionary-typed expression, but that's more work. -} arityLam :: Id -> ArityType -> ArityType -arityLam id (ATop as) = ATop (idStateHackOneShotInfo id : as) -arityLam _ (ABot n) = ABot (n+1) +arityLam id at = ALam (idStateHackOneShotInfo id) at floatIn :: Bool -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn _ (ABot n) = ABot n -floatIn True (ATop as) = ATop as -floatIn False (ATop as) = ATop (takeWhile isOneShotInfo as) - -- If E is not cheap, keep arity only for one-shots +floatIn cheap at + | isBotArityType at || cheap = at + -- If E is not cheap, keep arity only for one-shots + | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' -arityApp (ABot 0) _ = ABot 0 -arityApp (ABot n) _ = ABot (n-1) -arityApp (ATop []) _ = ATop [] -arityApp (ATop (_:as)) cheap = floatIn cheap (ATop as) +arityApp (ALam _ at) cheap = floatIn cheap at +arityApp at _ = at andArityType :: ArityType -> ArityType -> ArityType -- Used for branches of a 'case' -- This is least upper bound in the ArityType lattice -andArityType (ABot n1) (ABot n2) = ABot (n1 `max` n2) -- Note [ABot branches: use max] -andArityType (ATop as) (ABot _) = ATop as -andArityType (ABot _) (ATop bs) = ATop bs -andArityType (ATop as) (ATop bs) = ATop (as `combine` bs) - where -- See Note [Combining case branches] - combine (a:as) (b:bs) = (a `bestOneShot` b) : combine as bs - combine [] bs = takeWhile isOneShotInfo bs - combine as [] = takeWhile isOneShotInfo as - -{- Note [ABot branches: use max] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +andArityType ABot at2 = at2 -- Note [ABot branches: max arity wins] +andArityType at1 ABot = at1 -- Note [ABot branches: max arity wins] +andArityType (ALam os1 at1) (ALam os2 at2) = + ALam (os1 `bestOneShot` os2) (andArityType at1 at2) -- See Note [Combining case branches] +andArityType (ALam OneShotLam at) ATop = + ALam OneShotLam (andArityType at ATop) -- See Note [Combining case branches] +andArityType ATop (ALam OneShotLam at) = + ALam OneShotLam (andArityType ATop at) -- See Note [Combining case branches] +andArityType ATop _ = ATop +andArityType _ ATop = ATop + +{- Note [ABot branches: max arity wins] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider case x of True -> \x. error "urk" False -> \xy. error "urk2" -Remember: ABot n means "if you apply to n args, it'll definitely diverge". -So we need (ABot 2) for the whole thing, the /max/ of the ABot arities. +Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". +So we need \??.⊥ for the whole thing, the /max/ of both arities. Note [Combining case branches] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -698,11 +727,12 @@ Consider True -> z False -> \s(one-shot). e1 in go2 x -We *really* want to eta-expand go and go2. +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. When combining the branches of the case we have - ATop [] `andAT` ATop [OneShotLam] -and we want to get ATop [OneShotLam]. But if the inner -lambda wasn't one-shot we don't want to do this. + ATop `andAT` ALam OneShotLam ATop +and we want to get ALam [OneShotLam] ATop. +But if the inner lambda wasn't one-shot we don't want to do this. (We need a proper arity analysis to justify that.) So we combine the best of the two branches, on the (slightly dodgy) @@ -718,14 +748,15 @@ most 1, because typeArity (Int -> F a) = 1. So we have to trim the result of calling arityType on (\x y. blah). Failing to do so, and hence breaking the exprArity invariant, led to #5441. -How to trim? For ATop, it's easy. But we must take great care with ABot. -Suppose the expression was (\x y. error "urk"), we'll get (ABot 2). We -absolutely must not trim that to (ABot 1), because that claims that +How to trim? If we end in ATop, it's easy. But we must take great care with +ABot. Suppose the expression was (\x y. error "urk"), we'll get \??.⊥. +We absolutely must not trim that to \?.⊥, because that claims that ((\x y. error "urk") |> co) diverges when given one argument, which it absolutely does not. And Bad Things happen if we think something returns bottom when it doesn't (#16066). -So, do not reduce the 'n' in (ABot n); rather, switch (conservatively) to ATop. +So, if we need to trim an arity type ending in ABot, switch (conservatively) to +ATop. Historical note: long ago, we unconditionally switched to ATop when we encountered a cast, but that is far too conservative: see #5475 @@ -838,29 +869,28 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of Nothing -> isCheapApp fn n_val_args -- @Just at@ means local function with @at@ as current ArityType. -- Roughly approximate what 'isCheapApp' is doing. - Just (ABot _) -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils - Just (ATop oss) -> n_val_args < length oss -- Essentially isWorkFreeApp + Just at + | is_bot -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils + | n_val_args < length oss -> True -- Essentially isWorkFreeApp + | otherwise -> False + where + (is_bot, oss) = splitArityType at ---------------- arityType :: ArityEnv -> CoreExpr -> ArityType arityType env (Cast e co) - = case arityType env e of - ATop os -> ATop (take co_arity os) -- See Note [Arity trimming] - ABot n | co_arity < n -> ATop (replicate co_arity noOneShotInfo) - | otherwise -> ABot n + = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] where co_arity = length (typeArity (coercionRKind co)) -- See Note [exprArity invariant] (2); must be true of -- arityType too, since that is how we compute the arity -- of variables, and they in turn affect result of exprArity -- #5441 is a nice demo - -- However, do make sure that ATop -> ATop and ABot -> ABot! - -- Casts don't affect that part. Getting this wrong provoked #5475 arityType env (Var v) | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] + = ABot -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise @@ -887,18 +917,15 @@ arityType env (App fun arg ) -- arityType env (Case scrut bndr _ alts) | exprIsDeadEnd scrut || null alts - = botArityType -- Do not eta expand - -- See Note [Dealing with bottom (1)] + = ABot -- Do not eta expand. See Note [Dealing with bottom (1)] | not (pedanticBottoms env) -- See Note [Dealing with bottom (2)] , myExprIsCheap env scrut (Just (idType bndr)) = alts_type | exprOkForSpeculation scrut = alts_type - | otherwise -- In the remaining cases we may not push - = case alts_type of -- evaluation of the scrutinee in - ATop as -> ATop (takeWhile isOneShotInfo as) - ABot _ -> ATop [] + | otherwise -- In the remaining cases we may not push + = takeWhileOneShot alts_type -- evaluation of the scrutinee in where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] @@ -938,7 +965,7 @@ arityType env (Let (Rec prs) e) arityType env (Tick t e) | not (tickishIsCode t) = arityType env e -arityType _ _ = vanillaArityType +arityType _ _ = ATop {- Note [Eta-expansion and join points] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -973,12 +1000,12 @@ So we do this: body of the let. * Dually, when we come to a /call/ of a join point, just no-op - by returning botArityType, the bottom element of ArityType, + by returning ABot, the bottom element of ArityType, which so that: bot `andArityType` x = x * This works if the join point is bound in the expression we are taking the arityType of. But if it's bound further out, it makes - no sense to say that (say) the arityType of (j False) is ABot 0. + no sense to say that (say) the arityType of (j False) is ABot. Bad things happen. So we keep track of the in-scope join-point Ids in ae_join. @@ -999,10 +1026,10 @@ idArityType v , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds - = if isDeadEndDiv res then ABot arity - else ATop (take arity one_shots) + = if isDeadEndDiv res then mkBotArityType (take arity one_shots) + else mkTopArityType (take arity one_shots) | otherwise - = ATop (take (idArity v) one_shots) + = mkTopArityType (take (idArity v) one_shots) where one_shots :: [OneShotInfo] -- One-shot-ness derived from the type one_shots = typeArity (idType v) @@ -1111,13 +1138,13 @@ Consider foo = \x. case x of True -> (\s{os}. blah) |> co False -> wubble -We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]). +We'll get an ArityType for foo of \?1.T. Then we want to eta-expand to foo = \x. (\eta{os}. (case x of ...as before...) eta) |> some_co That 'eta' binder is fresh, and we really want it to have the -one-shot flag from the inner \s{osf}. By expanding with the +one-shot flag from the inner \s{os}. By expanding with the ArityType gotten from analysing the RHS, we achieve this neatly. This makes a big difference to the one-shot monad trick; ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Types.Unique ( hasKey ) import GHC.Core.Unfold import GHC.Core.Unfold.Make import GHC.Core.Utils -import GHC.Core.Opt.Arity ( ArityType(..), arityTypeArity, isBotArityType +import GHC.Core.Opt.Arity ( ArityType, arityTypeArity, isBotArityType , pushCoTyArg, pushCoValArg , idArityType, etaExpandAT ) import GHC.Core.SimpleOpt ( joinPointBinding_maybe, joinPointBindings_maybe ) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1662,8 +1662,8 @@ tryEtaExpandRhs mode bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = ABot (length oss) - | otherwise = ATop oss + arity_type | exprIsDeadEnd join_body = mkBotArityType oss + | otherwise = mkTopArityType oss ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/T18870.hs ===================================== @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +module T18870 where + +import GHC.Exts + +-- This function should not lead to an "Exciting arity" DEBUG message. +-- It should only do one round of fixed-point iteration to conclude that it has +-- arity 2. +f :: [a] -> a -> a +f [] = id +f (x:xs) = oneShot (\_ -> f xs x) ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -19,3 +19,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f6b58116bd1296d9faa5e54f61762cb12d32300 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f6b58116bd1296d9faa5e54f61762cb12d32300 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 17:07:53 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Wed, 21 Oct 2020 13:07:53 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f906ae9514a7_28003fd3ed6be4681401577@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: 51fb9709 by David Eichmann at 2020-10-21T18:07:41+01:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -330,17 +330,75 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. - - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ - -// acquires a token which may be used to create new objects and -// evaluate them. +/* Note [Locking and Pausing the RTS] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You have to surround all access to the RtsAPI with rts_lock/rts_unlock or +with rts_pause/rts_resume. + + +# rts_lock / rts_unlock + +Use `rts_lock` to acquire a token which may be used to call other RtsAPI +functions and call `rts_unlock` to return the token. When locked, garbage +collection will not occur. As long as 1 or more capabilities are not locked, +haskell threads will continue to execute. If you want to pause execution of +all haskell threads then use rts_pause/rts_resume instead. + +The implementation of `rts_lock` acquires a capability on this thread. Hence, +at most n locks can be held simultaneously, where n is the number of +capabilities. It is an error to call `rts_lock` when the rts is already +paused by the current OS thread (see rts_pause/rts_resume below). + + +# rts_pause / rts_resume + +Use `rts_pause` to pause execution of all Haskell threads and `rts_resume` to +resume them. The implementation acquires all capabilities. `rts_resume` +must be called on the same thread as `rts_pause`. `rts_pause`, much like +rts_lock, Returns a token which may be used to call other RtsAPI functions. + +* With the RTS paused, garbage collections will not occur and haskell threads + will not execute, allocate, nor mutate their stacks. +* Non-Haskell (i.e. non-worker) threads such as those running safe FFI calls + will NOT be paused and can still mutate pinned mutable data such as pinned + `MutableByteArray#`s. +* You may call `rts_pause` from within a non-worker OS thread. +* You may call `rts_pause` from within a *safe* FFI call. In this case, make + sure to call `rts_resume` within the same FFI call or the RTS will deadlock. +* Calling `rts_pause` from an *unsafe* FFI call will cause an error. +* On return, the rts will be fully paused: all haskell threads are stopped + and all capabilities are acquired by the current OS thread. +* Calling `rts_pause` in between rts_lock/rts_unlock on the same thread will + cause an error. +* Calling `rts_pause` results in an error if the RTS is already paused by the + current OS thread. +* Only one OS thread at a time can keep the rts paused. +* `rts_pause` will block while another thread is pausing the RTS, and + continue when the current thread is given exclusive permission to pause the + RTS. + +## Note on implementation. + +Thread safety is achieved almost entirely by the mechanism of acquiring and +releasing Capabilities, resulting in a sort of mutex / critical section pattern. +This has the following consequences: + +* There are at most `n_capabilities` threads currently in a + rts_lock/rts_unlock section. +* There is at most 1 threads in a rts_pause/rts_resume section. In that case + there will be no threads in a rts_lock/rts_unlock section. +* rts_pause and rts_lock may block in order to enforce the above 2 + invariants. + +*/ + +// Acquires a token which may be used to create new objects and evaluate them. +// See Note [Locking and Pausing the RTS] for correct usage. Capability *rts_lock (void); // releases the token acquired with rts_lock(). +// See Note [Locking and Pausing the RTS] for correct usage. void rts_unlock (Capability *token); // If you are in a context where you know you have a current capability but @@ -483,6 +541,18 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads. +// See Note [Locking and Pausing the RTS] for correct usage. +Capability * rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. +// See Note [Locking and Pausing the RTS] for correct usage. +// [in] cap: the token returned by rts_pause. +void rts_resume (Capability * cap); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,14 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,16 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +// +// It's possible to remove this and instead define the pausing task as whichever +// task owns all capabilities, but using `rts_pausing_task` leads to marginally +// cleaner code/API and better error messages. +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +603,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already called rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +638,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +663,141 @@ rts_unlock (Capability *cap) } } +#if defined(THREADED_RTS) + +// See Note [Locking and Pausing the RTS] +Capability * rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (at it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + return task->cap; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See Note [Locking and Pausing the RTS]. The cap argument is here just for +// symmetry with rts_pause and to match the pattern of rts_lock/rts_unlock. +void rts_resume (Capability * cap STG_UNUSED) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +Capability * GNU_ATTRIBUTE(__noreturn__) +rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (Capability * cap STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +833,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,15 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1573,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2096,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2776,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2835,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,24 @@ +test('pause_resume_via_safe_ffi', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,242 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + Capability * cap = rts_pause(); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(cap); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + Capability * cap = rts_pause(); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(cap); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + safe_pthread_join_c :: CULong -> IO () + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pthread_join_c =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,27 @@ + +test('unsafe_rts_pause', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , exit_code(1) + ], compile_and_run, ['']) +test('rts_lock_when_paused', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ extra_ways(['threaded1', 'threaded2']) + , only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,79 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + Capability * pauseCap = rts_pause(); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(pauseCap); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + Capability * pauseCapA = rts_pause(); + printf("Paused\n"); + + printf("Pausing..."); + Capability * pauseCapB = rts_pause(); + printf("Paused\n"); + + printf("Resuming..."); + rts_unlock(pauseCapA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(pauseCapB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already called rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51fb970915795cf20dda97b9dd41a573b8a44bcc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/51fb970915795cf20dda97b9dd41a573b8a44bcc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 17:43:56 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 13:43:56 -0400 Subject: [Git][ghc/ghc][wip/T18870] Arity: Rework `ArityType` to fix monotonicity (#18870) Message-ID: <5f90735ccb2e7_28003fd4099731c41403854@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18870 at Glasgow Haskell Compiler / GHC Commits: 5ae31e55 by Sebastian Graf at 2020-10-21T19:43:47+02:00 Arity: Rework `ArityType` to fix monotonicity (#18870) As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = ATop | ALam OneShotInfo ArityType | ABot ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. Fixes #18870. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/T18870.hs - testsuite/tests/arityanal/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -18,8 +18,8 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), expandableArityType, arityTypeArity - , maxWithArity, isBotArityType, idArityType + , ArityType, mkBotArityType, mkTopArityType, expandableArityType + , arityTypeArity, maxWithArity, isBotArityType, idArityType -- ** Join points , etaExpandToJoinPoint, etaExpandToJoinPointRule @@ -458,7 +458,7 @@ with function exprEtaExpandArity). Here is what the fields mean. If an arbitrary expression 'f' has ArityType 'at', then - * If at = ABot n, then (f x1..xn) definitely diverges. Partial + * If at = \o1..on.⊥, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. We allow ourselves to eta-expand bottoming functions, even @@ -466,14 +466,13 @@ ArityType 'at', then let x = in \y. error (g x y) ==> \y. let x = in error (g x y) - * If at = ATop as, and n=length as, - then expanding 'f' to (\x1..xn. f x1 .. xn) loses no sharing, - assuming the calls of f respect the one-shot-ness of - its definition. + * If at = \o1..on.T, then expanding 'f' to (\x1..xn. f x1 .. + xn) loses no sharing, assuming the calls of f respect the one-shot-ness + o1..on of its definition. NB 'f' is an arbitrary expression, eg (f = g e1 e2). This 'f' can have ArityType as ATop, with length as > 0, only if e1 e2 are - themselves. + themselves. ??? cheap? But actually the arity of g is important here. * In both cases, f, (f x1), ... (f x1 ... f(n-1)) are definitely really functions, or bottom, but *not* casts from a data type, in @@ -485,62 +484,90 @@ ArityType 'at', then Example: f = \x\y. let v = in \s(one-shot) \t(one-shot). blah - 'f' has ArityType [ManyShot,ManyShot,OneShot,OneShot] + 'f' has arity type \??11.T The one-shot-ness means we can, in effect, push that 'let' inside the \st. Suppose f = \xy. x+y -Then f :: AT [False,False] ATop - f v :: AT [False] ATop - f :: AT [] ATop - --------------------- Main arity code ---------------------------- +Then f :: \??.T + f v :: \?.T + f :: T -} data ArityType -- See Note [ArityType] - = ATop [OneShotInfo] - | ABot Arity + = ATop + | ALam !OneShotInfo !ArityType + | ABot deriving( Eq ) -- There is always an explicit lambda -- to justify the [OneShot], or the Arity +mkBotArityType :: [OneShotInfo] -> ArityType +mkBotArityType = foldr ALam ABot + +mkTopArityType :: [OneShotInfo] -> ArityType +mkTopArityType = foldr ALam ATop + +-- | Returns two components: +-- * A flag denoting whether the arity type ends in 'ABot' (and not 'ATop') +-- * A list of 'OneShotInfo's from 'ALam's we encountered along the way +splitArityType :: ArityType -> (Bool, [OneShotInfo]) +splitArityType at = go at id + where + go ABot oss = (True, oss []) + go ATop oss = (False, oss []) + go (ALam os at) oss = go at ((os:) . oss) + instance Outputable ArityType where - ppr (ATop os) = text "ATop" <> parens (ppr (length os)) - ppr (ABot n) = text "ABot" <> parens (ppr n) + ppr at + | null oss = pp_bot is_bot + | otherwise = char '\\' <> pp_oss oss <> dot <> pp_bot is_bot + where + (is_bot, oss) = splitArityType at + pp_bot True = char '⊥' + pp_bot False = char 'T' + pp_oss [] = empty + pp_oss (OneShotLam :oss) = char '1' <> pp_oss oss + pp_oss (NoOneShotInfo:oss) = char '?' <> pp_oss oss + +arityTypeOneShots :: ArityType -> [OneShotInfo] +arityTypeOneShots = snd . splitArityType +-- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity --- The number of value args for the arity type -arityTypeArity (ATop oss) = length oss -arityTypeArity (ABot ar) = ar +arityTypeArity = length . arityTypeOneShots +-- | True <=> eta-expansion will add at least one lambda expandableArityType :: ArityType -> Bool --- True <=> eta-expansion will add at least one lambda -expandableArityType (ATop oss) = not (null oss) -expandableArityType (ABot ar) = ar /= 0 +expandableArityType at = arityTypeArity at /= 0 isBotArityType :: ArityType -> Bool -isBotArityType (ABot {}) = True -isBotArityType (ATop {}) = False - -arityTypeOneShots :: ArityType -> [OneShotInfo] -arityTypeOneShots (ATop oss) = oss -arityTypeOneShots (ABot ar) = replicate ar OneShotLam - -- If we are diveging or throwing an exception anyway - -- it's fine to push redexes inside the lambdas - -botArityType :: ArityType -botArityType = ABot 0 -- Unit for andArityType +isBotArityType = fst . splitArityType +-- | Expand a non-bottoming arity type so that it has at least the given arity. maxWithArity :: ArityType -> Arity -> ArityType -maxWithArity at@(ABot {}) _ = at -maxWithArity at@(ATop oss) ar - | oss `lengthAtLeast` ar = at - | otherwise = ATop (take ar (oss ++ repeat NoOneShotInfo)) +maxWithArity (ALam os at) !ar = ALam os (maxWithArity at (ar-1)) +-- The following case is the reason we maxWithArity through all the trouble. +-- It expands the arity type with enough NoOneShotInfo. +maxWithArity ATop ar | ar > 0 = iterate (ALam NoOneShotInfo) ATop !! ar +maxWithArity at !_ = at + +-- | Trim an arity type so that it has at most the given arity. +-- Any excess 'ALam's are truncated to 'ATop', even if they end in 'ABot'. +minWithArity :: ArityType -> Arity -> ArityType +minWithArity at ar = go at ar + where + go ABot 0 = ABot + go _ 0 = ATop + go (ALam os at) ar = ALam os (go at (ar-1)) + go at _ = at -vanillaArityType :: ArityType -vanillaArityType = ATop [] -- Totally uninformative +takeWhileOneShot :: ArityType -> ArityType +takeWhileOneShot (ALam NoOneShotInfo _) = ATop +takeWhileOneShot (ALam OneShotLam at) = ALam OneShotLam (takeWhileOneShot at) +takeWhileOneShot at = at -- | The Arity returned is the number of value args the -- expression can be applied to without doing much work @@ -551,8 +578,9 @@ exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function -getBotArity (ABot n) = Just n -getBotArity _ = Nothing +getBotArity at + | (True, oss) <- splitArityType at = Just $ length oss + | otherwise = Nothing ---------------------- findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType @@ -563,17 +591,16 @@ findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- so it is safe to expand e ==> (\x1..xn. e x1 .. xn) -- (b) if is_bot=True, then e applied to n args is guaranteed bottom findRhsArity dflags bndr rhs old_arity - = go (step botArityType) + = go (step ABot) -- We always do one step, but usually that produces a result equal to -- old_arity, and then we stop right away (since arities should not -- decrease) -- Result: the common case is that there is just one iteration where go :: ArityType -> ArityType - go cur_atype@(ATop oss) - | length oss <= old_arity = cur_atype go cur_atype - | new_atype == cur_atype = cur_atype + | not is_bot, length oss <= old_arity = cur_atype -- ... "stop right away" + | new_atype == cur_atype = cur_atype | otherwise = #if defined(DEBUG) pprTrace "Exciting arity" @@ -582,7 +609,8 @@ findRhsArity dflags bndr rhs old_arity #endif go new_atype where - new_atype = step cur_atype + (is_bot, oss) = splitArityType cur_atype + new_atype = step cur_atype step :: ArityType -> ArityType step at = -- pprTrace "step" (ppr bndr <+> ppr at <+> ppr (arityType env rhs)) $ @@ -607,7 +635,7 @@ fifteen years ago! It also shows up in the code for 'rnf' on lists in #4138. We do the neccessary, quite simple fixed-point iteration in 'findRhsArity', -which assumes for a single binding @botArityType@ on the first run and iterates +which assumes for a single binding 'ABot' on the first run and iterates until it finds a stable arity type. Two wrinkles * We often have to ask (see the Case or Let case of 'arityType') whether some @@ -651,44 +679,43 @@ dictionary-typed expression, but that's more work. -} arityLam :: Id -> ArityType -> ArityType -arityLam id (ATop as) = ATop (idStateHackOneShotInfo id : as) -arityLam _ (ABot n) = ABot (n+1) +arityLam id at = ALam (idStateHackOneShotInfo id) at floatIn :: Bool -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn _ (ABot n) = ABot n -floatIn True (ATop as) = ATop as -floatIn False (ATop as) = ATop (takeWhile isOneShotInfo as) - -- If E is not cheap, keep arity only for one-shots +floatIn cheap at + | isBotArityType at || cheap = at + -- If E is not cheap, keep arity only for one-shots + | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' -arityApp (ABot 0) _ = ABot 0 -arityApp (ABot n) _ = ABot (n-1) -arityApp (ATop []) _ = ATop [] -arityApp (ATop (_:as)) cheap = floatIn cheap (ATop as) +arityApp (ALam _ at) cheap = floatIn cheap at +arityApp at _ = at andArityType :: ArityType -> ArityType -> ArityType -- Used for branches of a 'case' -- This is least upper bound in the ArityType lattice -andArityType (ABot n1) (ABot n2) = ABot (n1 `max` n2) -- Note [ABot branches: use max] -andArityType (ATop as) (ABot _) = ATop as -andArityType (ABot _) (ATop bs) = ATop bs -andArityType (ATop as) (ATop bs) = ATop (as `combine` bs) - where -- See Note [Combining case branches] - combine (a:as) (b:bs) = (a `bestOneShot` b) : combine as bs - combine [] bs = takeWhile isOneShotInfo bs - combine as [] = takeWhile isOneShotInfo as - -{- Note [ABot branches: use max] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +andArityType ABot at2 = at2 -- Note [ABot branches: max arity wins] +andArityType at1 ABot = at1 -- Note [ABot branches: max arity wins] +andArityType (ALam os1 at1) (ALam os2 at2) = + ALam (os1 `bestOneShot` os2) (andArityType at1 at2) -- See Note [Combining case branches] +andArityType (ALam OneShotLam at) ATop = + ALam OneShotLam (andArityType at ATop) -- See Note [Combining case branches] +andArityType ATop (ALam OneShotLam at) = + ALam OneShotLam (andArityType ATop at) -- See Note [Combining case branches] +andArityType ATop _ = ATop +andArityType _ ATop = ATop + +{- Note [ABot branches: max arity wins] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider case x of True -> \x. error "urk" False -> \xy. error "urk2" -Remember: ABot n means "if you apply to n args, it'll definitely diverge". -So we need (ABot 2) for the whole thing, the /max/ of the ABot arities. +Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". +So we need \??.⊥ for the whole thing, the /max/ of both arities. Note [Combining case branches] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -698,11 +725,12 @@ Consider True -> z False -> \s(one-shot). e1 in go2 x -We *really* want to eta-expand go and go2. +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. When combining the branches of the case we have - ATop [] `andAT` ATop [OneShotLam] -and we want to get ATop [OneShotLam]. But if the inner -lambda wasn't one-shot we don't want to do this. + ATop `andAT` ALam OneShotLam ATop +and we want to get ALam [OneShotLam] ATop. +But if the inner lambda wasn't one-shot we don't want to do this. (We need a proper arity analysis to justify that.) So we combine the best of the two branches, on the (slightly dodgy) @@ -718,14 +746,15 @@ most 1, because typeArity (Int -> F a) = 1. So we have to trim the result of calling arityType on (\x y. blah). Failing to do so, and hence breaking the exprArity invariant, led to #5441. -How to trim? For ATop, it's easy. But we must take great care with ABot. -Suppose the expression was (\x y. error "urk"), we'll get (ABot 2). We -absolutely must not trim that to (ABot 1), because that claims that +How to trim? If we end in ATop, it's easy. But we must take great care with +ABot. Suppose the expression was (\x y. error "urk"), we'll get \??.⊥. +We absolutely must not trim that to \?.⊥, because that claims that ((\x y. error "urk") |> co) diverges when given one argument, which it absolutely does not. And Bad Things happen if we think something returns bottom when it doesn't (#16066). -So, do not reduce the 'n' in (ABot n); rather, switch (conservatively) to ATop. +So, if we need to trim an arity type ending in ABot, switch (conservatively) to +ATop. Historical note: long ago, we unconditionally switched to ATop when we encountered a cast, but that is far too conservative: see #5475 @@ -838,29 +867,28 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of Nothing -> isCheapApp fn n_val_args -- @Just at@ means local function with @at@ as current ArityType. -- Roughly approximate what 'isCheapApp' is doing. - Just (ABot _) -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils - Just (ATop oss) -> n_val_args < length oss -- Essentially isWorkFreeApp + Just at + | is_bot -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils + | n_val_args < length oss -> True -- Essentially isWorkFreeApp + | otherwise -> False + where + (is_bot, oss) = splitArityType at ---------------- arityType :: ArityEnv -> CoreExpr -> ArityType arityType env (Cast e co) - = case arityType env e of - ATop os -> ATop (take co_arity os) -- See Note [Arity trimming] - ABot n | co_arity < n -> ATop (replicate co_arity noOneShotInfo) - | otherwise -> ABot n + = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] where co_arity = length (typeArity (coercionRKind co)) -- See Note [exprArity invariant] (2); must be true of -- arityType too, since that is how we compute the arity -- of variables, and they in turn affect result of exprArity -- #5441 is a nice demo - -- However, do make sure that ATop -> ATop and ABot -> ABot! - -- Casts don't affect that part. Getting this wrong provoked #5475 arityType env (Var v) | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] + = ABot -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise @@ -887,18 +915,15 @@ arityType env (App fun arg ) -- arityType env (Case scrut bndr _ alts) | exprIsDeadEnd scrut || null alts - = botArityType -- Do not eta expand - -- See Note [Dealing with bottom (1)] + = ABot -- Do not eta expand. See Note [Dealing with bottom (1)] | not (pedanticBottoms env) -- See Note [Dealing with bottom (2)] , myExprIsCheap env scrut (Just (idType bndr)) = alts_type | exprOkForSpeculation scrut = alts_type - | otherwise -- In the remaining cases we may not push - = case alts_type of -- evaluation of the scrutinee in - ATop as -> ATop (takeWhile isOneShotInfo as) - ABot _ -> ATop [] + | otherwise -- In the remaining cases we may not push + = takeWhileOneShot alts_type -- evaluation of the scrutinee in where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] @@ -938,7 +963,7 @@ arityType env (Let (Rec prs) e) arityType env (Tick t e) | not (tickishIsCode t) = arityType env e -arityType _ _ = vanillaArityType +arityType _ _ = ATop {- Note [Eta-expansion and join points] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -973,12 +998,12 @@ So we do this: body of the let. * Dually, when we come to a /call/ of a join point, just no-op - by returning botArityType, the bottom element of ArityType, + by returning ABot, the bottom element of ArityType, which so that: bot `andArityType` x = x * This works if the join point is bound in the expression we are taking the arityType of. But if it's bound further out, it makes - no sense to say that (say) the arityType of (j False) is ABot 0. + no sense to say that (say) the arityType of (j False) is ABot. Bad things happen. So we keep track of the in-scope join-point Ids in ae_join. @@ -999,10 +1024,10 @@ idArityType v , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds - = if isDeadEndDiv res then ABot arity - else ATop (take arity one_shots) + = if isDeadEndDiv res then mkBotArityType (take arity one_shots) + else mkTopArityType (take arity one_shots) | otherwise - = ATop (take (idArity v) one_shots) + = mkTopArityType (take (idArity v) one_shots) where one_shots :: [OneShotInfo] -- One-shot-ness derived from the type one_shots = typeArity (idType v) @@ -1111,13 +1136,13 @@ Consider foo = \x. case x of True -> (\s{os}. blah) |> co False -> wubble -We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]). +We'll get an ArityType for foo of \?1.T. Then we want to eta-expand to foo = \x. (\eta{os}. (case x of ...as before...) eta) |> some_co That 'eta' binder is fresh, and we really want it to have the -one-shot flag from the inner \s{osf}. By expanding with the +one-shot flag from the inner \s{os}. By expanding with the ArityType gotten from analysing the RHS, we achieve this neatly. This makes a big difference to the one-shot monad trick; ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Types.Unique ( hasKey ) import GHC.Core.Unfold import GHC.Core.Unfold.Make import GHC.Core.Utils -import GHC.Core.Opt.Arity ( ArityType(..), arityTypeArity, isBotArityType +import GHC.Core.Opt.Arity ( ArityType, arityTypeArity, isBotArityType , pushCoTyArg, pushCoValArg , idArityType, etaExpandAT ) import GHC.Core.SimpleOpt ( joinPointBinding_maybe, joinPointBindings_maybe ) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1662,8 +1662,8 @@ tryEtaExpandRhs mode bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = ABot (length oss) - | otherwise = ATop oss + arity_type | exprIsDeadEnd join_body = mkBotArityType oss + | otherwise = mkTopArityType oss ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/T18870.hs ===================================== @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +module T18870 where + +import GHC.Exts + +-- This function should not lead to an "Exciting arity" DEBUG message. +-- It should only do one round of fixed-point iteration to conclude that it has +-- arity 2. +f :: [a] -> a -> a +f [] = id +f (x:xs) = oneShot (\_ -> f xs x) ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -19,3 +19,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ae31e550a16ff9e8612a786ab06d0b56183dfe0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ae31e550a16ff9e8612a786ab06d0b56183dfe0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 17:46:39 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 21 Oct 2020 13:46:39 -0400 Subject: [Git][ghc/ghc][wip/T18870] Arity: Rework `ArityType` to fix monotonicity (#18870) Message-ID: <5f9073ff767f_28003fd4093ddef8140572a@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/T18870 at Glasgow Haskell Compiler / GHC Commits: c9bae924 by Sebastian Graf at 2020-10-21T19:46:29+02:00 Arity: Rework `ArityType` to fix monotonicity (#18870) As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = ATop | ALam OneShotInfo ArityType | ABot ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. Fixes #18870. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/T18870.hs - testsuite/tests/arityanal/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -18,8 +18,8 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), expandableArityType, arityTypeArity - , maxWithArity, isBotArityType, idArityType + , ArityType, mkBotArityType, mkTopArityType, expandableArityType + , arityTypeArity, maxWithArity, isBotArityType, idArityType -- ** Join points , etaExpandToJoinPoint, etaExpandToJoinPointRule @@ -458,7 +458,7 @@ with function exprEtaExpandArity). Here is what the fields mean. If an arbitrary expression 'f' has ArityType 'at', then - * If at = ABot n, then (f x1..xn) definitely diverges. Partial + * If at = \o1..on.⊥, then (f x1..xn) definitely diverges. Partial applications to fewer than n args may *or may not* diverge. We allow ourselves to eta-expand bottoming functions, even @@ -466,14 +466,13 @@ ArityType 'at', then let x = in \y. error (g x y) ==> \y. let x = in error (g x y) - * If at = ATop as, and n=length as, - then expanding 'f' to (\x1..xn. f x1 .. xn) loses no sharing, - assuming the calls of f respect the one-shot-ness of - its definition. + * If at = \o1..on.T, then expanding 'f' to (\x1..xn. f x1 .. + xn) loses no sharing, assuming the calls of f respect the one-shot-ness + o1..on of its definition. NB 'f' is an arbitrary expression, eg (f = g e1 e2). This 'f' can have ArityType as ATop, with length as > 0, only if e1 e2 are - themselves. + themselves. ??? cheap? But actually the arity of g is important here. * In both cases, f, (f x1), ... (f x1 ... f(n-1)) are definitely really functions, or bottom, but *not* casts from a data type, in @@ -485,62 +484,90 @@ ArityType 'at', then Example: f = \x\y. let v = in \s(one-shot) \t(one-shot). blah - 'f' has ArityType [ManyShot,ManyShot,OneShot,OneShot] + 'f' has arity type \??11.T The one-shot-ness means we can, in effect, push that 'let' inside the \st. Suppose f = \xy. x+y -Then f :: AT [False,False] ATop - f v :: AT [False] ATop - f :: AT [] ATop - --------------------- Main arity code ---------------------------- +Then f :: \??.T + f v :: \?.T + f :: T -} data ArityType -- See Note [ArityType] - = ATop [OneShotInfo] - | ABot Arity + = ATop + | ALam !OneShotInfo !ArityType + | ABot deriving( Eq ) -- There is always an explicit lambda -- to justify the [OneShot], or the Arity +mkBotArityType :: [OneShotInfo] -> ArityType +mkBotArityType = foldr ALam ABot + +mkTopArityType :: [OneShotInfo] -> ArityType +mkTopArityType = foldr ALam ATop + +-- | Returns two components: +-- * A flag denoting whether the arity type ends in 'ABot' (and not 'ATop') +-- * A list of 'OneShotInfo's from 'ALam's we encountered along the way +splitArityType :: ArityType -> (Bool, [OneShotInfo]) +splitArityType at = go at id + where + go ABot oss = (True, oss []) + go ATop oss = (False, oss []) + go (ALam os at) oss = go at ((os:) . oss) + instance Outputable ArityType where - ppr (ATop os) = text "ATop" <> parens (ppr (length os)) - ppr (ABot n) = text "ABot" <> parens (ppr n) + ppr at + | null oss = pp_bot is_bot + | otherwise = char '\\' <> pp_oss oss <> dot <> pp_bot is_bot + where + (is_bot, oss) = splitArityType at + pp_bot True = char '⊥' + pp_bot False = char 'T' + pp_oss [] = empty + pp_oss (OneShotLam :oss) = char '1' <> pp_oss oss + pp_oss (NoOneShotInfo:oss) = char '?' <> pp_oss oss + +arityTypeOneShots :: ArityType -> [OneShotInfo] +arityTypeOneShots = snd . splitArityType +-- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity --- The number of value args for the arity type -arityTypeArity (ATop oss) = length oss -arityTypeArity (ABot ar) = ar +arityTypeArity = length . arityTypeOneShots +-- | True <=> eta-expansion will add at least one lambda expandableArityType :: ArityType -> Bool --- True <=> eta-expansion will add at least one lambda -expandableArityType (ATop oss) = not (null oss) -expandableArityType (ABot ar) = ar /= 0 +expandableArityType at = arityTypeArity at /= 0 isBotArityType :: ArityType -> Bool -isBotArityType (ABot {}) = True -isBotArityType (ATop {}) = False - -arityTypeOneShots :: ArityType -> [OneShotInfo] -arityTypeOneShots (ATop oss) = oss -arityTypeOneShots (ABot ar) = replicate ar OneShotLam - -- If we are diveging or throwing an exception anyway - -- it's fine to push redexes inside the lambdas - -botArityType :: ArityType -botArityType = ABot 0 -- Unit for andArityType +isBotArityType = fst . splitArityType +-- | Expand a non-bottoming arity type so that it has at least the given arity. maxWithArity :: ArityType -> Arity -> ArityType -maxWithArity at@(ABot {}) _ = at -maxWithArity at@(ATop oss) ar - | oss `lengthAtLeast` ar = at - | otherwise = ATop (take ar (oss ++ repeat NoOneShotInfo)) +maxWithArity (ALam os at) !ar = ALam os (maxWithArity at (ar-1)) +-- The following case is the reason we go through all the trouble. +-- It expands the arity type with enough NoOneShotInfo. +maxWithArity ATop ar | ar > 0 = iterate (ALam NoOneShotInfo) ATop !! ar +maxWithArity at !_ = at + +-- | Trim an arity type so that it has at most the given arity. +-- Any excess 'ALam's are truncated to 'ATop', even if they end in 'ABot'. +minWithArity :: ArityType -> Arity -> ArityType +minWithArity at ar = go at ar + where + go ABot 0 = ABot + go _ 0 = ATop + go (ALam os at) ar = ALam os (go at (ar-1)) + go at _ = at -vanillaArityType :: ArityType -vanillaArityType = ATop [] -- Totally uninformative +takeWhileOneShot :: ArityType -> ArityType +takeWhileOneShot (ALam NoOneShotInfo _) = ATop +takeWhileOneShot (ALam OneShotLam at) = ALam OneShotLam (takeWhileOneShot at) +takeWhileOneShot at = at -- | The Arity returned is the number of value args the -- expression can be applied to without doing much work @@ -551,8 +578,9 @@ exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function -getBotArity (ABot n) = Just n -getBotArity _ = Nothing +getBotArity at + | (True, oss) <- splitArityType at = Just $ length oss + | otherwise = Nothing ---------------------- findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType @@ -563,17 +591,16 @@ findRhsArity :: DynFlags -> Id -> CoreExpr -> Arity -> ArityType -- so it is safe to expand e ==> (\x1..xn. e x1 .. xn) -- (b) if is_bot=True, then e applied to n args is guaranteed bottom findRhsArity dflags bndr rhs old_arity - = go (step botArityType) + = go (step ABot) -- We always do one step, but usually that produces a result equal to -- old_arity, and then we stop right away (since arities should not -- decrease) -- Result: the common case is that there is just one iteration where go :: ArityType -> ArityType - go cur_atype@(ATop oss) - | length oss <= old_arity = cur_atype go cur_atype - | new_atype == cur_atype = cur_atype + | not is_bot, length oss <= old_arity = cur_atype -- ... "stop right away" + | new_atype == cur_atype = cur_atype | otherwise = #if defined(DEBUG) pprTrace "Exciting arity" @@ -582,7 +609,8 @@ findRhsArity dflags bndr rhs old_arity #endif go new_atype where - new_atype = step cur_atype + (is_bot, oss) = splitArityType cur_atype + new_atype = step cur_atype step :: ArityType -> ArityType step at = -- pprTrace "step" (ppr bndr <+> ppr at <+> ppr (arityType env rhs)) $ @@ -607,7 +635,7 @@ fifteen years ago! It also shows up in the code for 'rnf' on lists in #4138. We do the neccessary, quite simple fixed-point iteration in 'findRhsArity', -which assumes for a single binding @botArityType@ on the first run and iterates +which assumes for a single binding 'ABot' on the first run and iterates until it finds a stable arity type. Two wrinkles * We often have to ask (see the Case or Let case of 'arityType') whether some @@ -651,44 +679,43 @@ dictionary-typed expression, but that's more work. -} arityLam :: Id -> ArityType -> ArityType -arityLam id (ATop as) = ATop (idStateHackOneShotInfo id : as) -arityLam _ (ABot n) = ABot (n+1) +arityLam id at = ALam (idStateHackOneShotInfo id) at floatIn :: Bool -> ArityType -> ArityType -- We have something like (let x = E in b), -- where b has the given arity type. -floatIn _ (ABot n) = ABot n -floatIn True (ATop as) = ATop as -floatIn False (ATop as) = ATop (takeWhile isOneShotInfo as) - -- If E is not cheap, keep arity only for one-shots +floatIn cheap at + | isBotArityType at || cheap = at + -- If E is not cheap, keep arity only for one-shots + | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' -arityApp (ABot 0) _ = ABot 0 -arityApp (ABot n) _ = ABot (n-1) -arityApp (ATop []) _ = ATop [] -arityApp (ATop (_:as)) cheap = floatIn cheap (ATop as) +arityApp (ALam _ at) cheap = floatIn cheap at +arityApp at _ = at andArityType :: ArityType -> ArityType -> ArityType -- Used for branches of a 'case' -- This is least upper bound in the ArityType lattice -andArityType (ABot n1) (ABot n2) = ABot (n1 `max` n2) -- Note [ABot branches: use max] -andArityType (ATop as) (ABot _) = ATop as -andArityType (ABot _) (ATop bs) = ATop bs -andArityType (ATop as) (ATop bs) = ATop (as `combine` bs) - where -- See Note [Combining case branches] - combine (a:as) (b:bs) = (a `bestOneShot` b) : combine as bs - combine [] bs = takeWhile isOneShotInfo bs - combine as [] = takeWhile isOneShotInfo as - -{- Note [ABot branches: use max] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +andArityType ABot at2 = at2 -- Note [ABot branches: max arity wins] +andArityType at1 ABot = at1 -- Note [ABot branches: max arity wins] +andArityType (ALam os1 at1) (ALam os2 at2) = + ALam (os1 `bestOneShot` os2) (andArityType at1 at2) -- See Note [Combining case branches] +andArityType (ALam OneShotLam at) ATop = + ALam OneShotLam (andArityType at ATop) -- See Note [Combining case branches] +andArityType ATop (ALam OneShotLam at) = + ALam OneShotLam (andArityType ATop at) -- See Note [Combining case branches] +andArityType ATop _ = ATop +andArityType _ ATop = ATop + +{- Note [ABot branches: max arity wins] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider case x of True -> \x. error "urk" False -> \xy. error "urk2" -Remember: ABot n means "if you apply to n args, it'll definitely diverge". -So we need (ABot 2) for the whole thing, the /max/ of the ABot arities. +Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". +So we need \??.⊥ for the whole thing, the /max/ of both arities. Note [Combining case branches] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -698,11 +725,12 @@ Consider True -> z False -> \s(one-shot). e1 in go2 x -We *really* want to eta-expand go and go2. +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. When combining the branches of the case we have - ATop [] `andAT` ATop [OneShotLam] -and we want to get ATop [OneShotLam]. But if the inner -lambda wasn't one-shot we don't want to do this. + ATop `andAT` ALam OneShotLam ATop +and we want to get ALam [OneShotLam] ATop. +But if the inner lambda wasn't one-shot we don't want to do this. (We need a proper arity analysis to justify that.) So we combine the best of the two branches, on the (slightly dodgy) @@ -718,14 +746,15 @@ most 1, because typeArity (Int -> F a) = 1. So we have to trim the result of calling arityType on (\x y. blah). Failing to do so, and hence breaking the exprArity invariant, led to #5441. -How to trim? For ATop, it's easy. But we must take great care with ABot. -Suppose the expression was (\x y. error "urk"), we'll get (ABot 2). We -absolutely must not trim that to (ABot 1), because that claims that +How to trim? If we end in ATop, it's easy. But we must take great care with +ABot. Suppose the expression was (\x y. error "urk"), we'll get \??.⊥. +We absolutely must not trim that to \?.⊥, because that claims that ((\x y. error "urk") |> co) diverges when given one argument, which it absolutely does not. And Bad Things happen if we think something returns bottom when it doesn't (#16066). -So, do not reduce the 'n' in (ABot n); rather, switch (conservatively) to ATop. +So, if we need to trim an arity type ending in ABot, switch (conservatively) to +ATop. Historical note: long ago, we unconditionally switched to ATop when we encountered a cast, but that is far too conservative: see #5475 @@ -838,29 +867,28 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of Nothing -> isCheapApp fn n_val_args -- @Just at@ means local function with @at@ as current ArityType. -- Roughly approximate what 'isCheapApp' is doing. - Just (ABot _) -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils - Just (ATop oss) -> n_val_args < length oss -- Essentially isWorkFreeApp + Just at + | is_bot -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils + | n_val_args < length oss -> True -- Essentially isWorkFreeApp + | otherwise -> False + where + (is_bot, oss) = splitArityType at ---------------- arityType :: ArityEnv -> CoreExpr -> ArityType arityType env (Cast e co) - = case arityType env e of - ATop os -> ATop (take co_arity os) -- See Note [Arity trimming] - ABot n | co_arity < n -> ATop (replicate co_arity noOneShotInfo) - | otherwise -> ABot n + = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] where co_arity = length (typeArity (coercionRKind co)) -- See Note [exprArity invariant] (2); must be true of -- arityType too, since that is how we compute the arity -- of variables, and they in turn affect result of exprArity -- #5441 is a nice demo - -- However, do make sure that ATop -> ATop and ABot -> ABot! - -- Casts don't affect that part. Getting this wrong provoked #5475 arityType env (Var v) | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] + = ABot -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise @@ -887,18 +915,15 @@ arityType env (App fun arg ) -- arityType env (Case scrut bndr _ alts) | exprIsDeadEnd scrut || null alts - = botArityType -- Do not eta expand - -- See Note [Dealing with bottom (1)] + = ABot -- Do not eta expand. See Note [Dealing with bottom (1)] | not (pedanticBottoms env) -- See Note [Dealing with bottom (2)] , myExprIsCheap env scrut (Just (idType bndr)) = alts_type | exprOkForSpeculation scrut = alts_type - | otherwise -- In the remaining cases we may not push - = case alts_type of -- evaluation of the scrutinee in - ATop as -> ATop (takeWhile isOneShotInfo as) - ABot _ -> ATop [] + | otherwise -- In the remaining cases we may not push + = takeWhileOneShot alts_type -- evaluation of the scrutinee in where alts_type = foldr1 andArityType [arityType env rhs | (_,_,rhs) <- alts] @@ -938,7 +963,7 @@ arityType env (Let (Rec prs) e) arityType env (Tick t e) | not (tickishIsCode t) = arityType env e -arityType _ _ = vanillaArityType +arityType _ _ = ATop {- Note [Eta-expansion and join points] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -973,12 +998,12 @@ So we do this: body of the let. * Dually, when we come to a /call/ of a join point, just no-op - by returning botArityType, the bottom element of ArityType, + by returning ABot, the bottom element of ArityType, which so that: bot `andArityType` x = x * This works if the join point is bound in the expression we are taking the arityType of. But if it's bound further out, it makes - no sense to say that (say) the arityType of (j False) is ABot 0. + no sense to say that (say) the arityType of (j False) is ABot. Bad things happen. So we keep track of the in-scope join-point Ids in ae_join. @@ -999,10 +1024,10 @@ idArityType v , not $ isTopSig strict_sig , (ds, res) <- splitStrictSig strict_sig , let arity = length ds - = if isDeadEndDiv res then ABot arity - else ATop (take arity one_shots) + = if isDeadEndDiv res then mkBotArityType (take arity one_shots) + else mkTopArityType (take arity one_shots) | otherwise - = ATop (take (idArity v) one_shots) + = mkTopArityType (take (idArity v) one_shots) where one_shots :: [OneShotInfo] -- One-shot-ness derived from the type one_shots = typeArity (idType v) @@ -1111,13 +1136,13 @@ Consider foo = \x. case x of True -> (\s{os}. blah) |> co False -> wubble -We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]). +We'll get an ArityType for foo of \?1.T. Then we want to eta-expand to foo = \x. (\eta{os}. (case x of ...as before...) eta) |> some_co That 'eta' binder is fresh, and we really want it to have the -one-shot flag from the inner \s{osf}. By expanding with the +one-shot flag from the inner \s{os}. By expanding with the ArityType gotten from analysing the RHS, we achieve this neatly. This makes a big difference to the one-shot monad trick; ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -50,7 +50,7 @@ import GHC.Types.Unique ( hasKey ) import GHC.Core.Unfold import GHC.Core.Unfold.Make import GHC.Core.Utils -import GHC.Core.Opt.Arity ( ArityType(..), arityTypeArity, isBotArityType +import GHC.Core.Opt.Arity ( ArityType, arityTypeArity, isBotArityType , pushCoTyArg, pushCoValArg , idArityType, etaExpandAT ) import GHC.Core.SimpleOpt ( joinPointBinding_maybe, joinPointBindings_maybe ) ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1662,8 +1662,8 @@ tryEtaExpandRhs mode bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = ABot (length oss) - | otherwise = ATop oss + arity_type | exprIsDeadEnd join_body = mkBotArityType oss + | otherwise = mkTopArityType oss ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/T18870.hs ===================================== @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +module T18870 where + +import GHC.Exts + +-- This function should not lead to an "Exciting arity" DEBUG message. +-- It should only do one round of fixed-point iteration to conclude that it has +-- arity 2. +f :: [a] -> a -> a +f [] = id +f (x:xs) = oneShot (\_ -> f xs x) ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -19,3 +19,4 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9bae9247e6a455d7f4ee4d8dc5f60fc0924acf8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9bae9247e6a455d7f4ee4d8dc5f60fc0924acf8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 18:49:02 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 21 Oct 2020 14:49:02 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports Message-ID: <5f90829e15960_28003fd40908bdf41410653@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 19:41:26 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 21 Oct 2020 15:41:26 -0400 Subject: [Git][ghc/ghc][wip/backports] API Annotations: Keep track of unicode for linear arrow notation Message-ID: <5f908ee686076_28003fd385be9d1014152d1@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC Commits: 3549d084 by Alan Zimmerman at 2020-10-21T15:41:12-04:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule (cherry picked from commit ea736839d85594c95490dcf02d3325c2bbc68f33) - - - - - 20 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - ghc/GHCi/UI.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/KindSigs.stderr - testsuite/tests/parser/should_compile/T14189.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -935,22 +935,23 @@ isUnrestricted _ = False -- | Denotes the type of arrows in the surface language data HsArrow pass - = HsUnrestrictedArrow - -- ^ a -> b - | HsLinearArrow - -- ^ a %1 -> b - | HsExplicitMult (LHsType pass) - -- ^ a %m -> b (very much including `a %Many -> b`! This is how the - -- programmer wrote it). It is stored as an `HsType` so as to preserve the - -- syntax as written in the program. + = HsUnrestrictedArrow IsUnicodeSyntax + -- ^ a -> b or a → b + | HsLinearArrow IsUnicodeSyntax + -- ^ a %1 -> b or a %1 → b, or a ⊸ b + | HsExplicitMult IsUnicodeSyntax (LHsType pass) + -- ^ a %m -> b or a %m → b (very much including `a %Many -> b`! + -- This is how the programmer wrote it). It is stored as an + -- `HsType` so as to preserve the syntax as written in the + -- program. -- | Convert an arrow into its corresponding multiplicity. In essence this -- erases the information of whether the programmer wrote an explicit -- multiplicity or a shorthand. arrowToHsType :: HsArrow GhcRn -> LHsType GhcRn -arrowToHsType HsUnrestrictedArrow = noLoc manyDataConHsTy -arrowToHsType HsLinearArrow = noLoc oneDataConHsTy -arrowToHsType (HsExplicitMult p) = p +arrowToHsType (HsUnrestrictedArrow _) = noLoc manyDataConHsTy +arrowToHsType (HsLinearArrow _) = noLoc oneDataConHsTy +arrowToHsType (HsExplicitMult _ p) = p -- | This is used in the syntax. In constructor declaration. It must keep the -- arrow representation. @@ -965,20 +966,23 @@ hsScaledThing (HsScaled _ t) = t -- | When creating syntax we use the shorthands. It's better for printing, also, -- the shorthands work trivially at each pass. hsUnrestricted, hsLinear :: a -> HsScaled pass a -hsUnrestricted = HsScaled HsUnrestrictedArrow -hsLinear = HsScaled HsLinearArrow +hsUnrestricted = HsScaled (HsUnrestrictedArrow NormalSyntax) +hsLinear = HsScaled (HsLinearArrow NormalSyntax) instance Outputable a => Outputable (HsScaled pass a) where ppr (HsScaled _cnt t) = -- ppr cnt <> ppr t - ppr t + ppr t instance (OutputableBndrId pass) => Outputable (HsArrow (GhcPass pass)) where - ppr HsUnrestrictedArrow = parens arrow - ppr HsLinearArrow = parens lollipop - ppr (HsExplicitMult p) = parens (mulArrow (ppr p)) + ppr arr = parens (pprHsArrow arr) +-- See #18846 +pprHsArrow :: (OutputableBndrId pass) => HsArrow (GhcPass pass) -> SDoc +pprHsArrow (HsUnrestrictedArrow _) = arrow +pprHsArrow (HsLinearArrow _) = lollipop +pprHsArrow (HsExplicitMult _ p) = (mulArrow (ppr p)) {- Note [Unit tuples] @@ -1968,10 +1972,7 @@ ppr_fun_ty :: (OutputableBndrId p) ppr_fun_ty mult ty1 ty2 = let p1 = ppr_mono_lty ty1 p2 = ppr_mono_lty ty2 - arr = case mult of - HsLinearArrow -> lollipop - HsUnrestrictedArrow -> arrow - HsExplicitMult p -> mulArrow (ppr p) + arr = pprHsArrow mult in sep [p1, arr <+> p2] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -135,6 +135,7 @@ import GHC.Utils.Misc import GHC.Data.Bag import GHC.Utils.Outputable import GHC.Settings.Constants +import GHC.Parser.Annotation import Data.Either import Data.Function @@ -535,12 +536,12 @@ nlList exprs = noLoc (ExplicitList noExtField Nothing exprs) nlHsAppTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsTyVar :: IdP (GhcPass p) -> LHsType (GhcPass p) -nlHsFunTy :: HsArrow (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) +nlHsFunTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsParTy :: LHsType (GhcPass p) -> LHsType (GhcPass p) nlHsAppTy f t = noLoc (HsAppTy noExtField f (parenthesizeHsType appPrec t)) nlHsTyVar x = noLoc (HsTyVar noExtField NotPromoted (noLoc x)) -nlHsFunTy mult a b = noLoc (HsFunTy noExtField mult (parenthesizeHsType funPrec a) b) +nlHsFunTy a b = noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) (parenthesizeHsType funPrec a) b) nlHsParTy t = noLoc (HsParTy noExtField t) nlHsTyConApp :: LexicalFixity -> IdP (GhcPass p) ===================================== compiler/GHC/Parser.y ===================================== @@ -1956,23 +1956,22 @@ is connected to the first type too. type :: { LHsType GhcPs } : btype { $1 } - | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsUnrestrictedArrow $1 $3) + | btype '->' ctype {% ams $1 [mu AnnRarrow $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsUnrestrictedArrow (toUnicode $2)) $1 $3) [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField (unLoc $2) $1 $4) - [mu AnnRarrow $3] } + >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) + [mj AnnMult $2,mu AnnRarrow $3] } | btype '->.' ctype {% hintLinear (getLoc $2) - >> ams $1 [mu AnnLollyU $2] -- See note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField HsLinearArrow $1 $3) + >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (mkMultTy $2) } - +mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } btype :: { LHsType GhcPs } : tyapps {% mergeOps (unLoc $1) } @@ -3911,6 +3910,9 @@ mu a lt@(L l t) = AddAnn (toUnicodeAnn a lt) l toUnicodeAnn :: AnnKeywordId -> Located Token -> AnnKeywordId toUnicodeAnn a t = if isUnicode t then unicodeAnn a else a +toUnicode :: Located Token -> IsUnicodeSyntax +toUnicode t = if isUnicode t then UnicodeSyntax else NormalSyntax + gl :: Located a -> SrcSpan gl = getLoc ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -302,6 +302,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule + | AnnMult -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -3069,9 +3069,9 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: LHsType GhcPs -> HsArrow GhcPs -mkMultTy (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow -mkMultTy t = HsExplicitMult t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u +mkMultTy u t = HsExplicitMult u t ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -962,10 +962,10 @@ instance HasHaddock (LHsType GhcPs) where pure $ L l (HsQualTy noExtField lhs rhs') -- arg -> res - HsFunTy _ mult lhs rhs -> do + HsFunTy u mult lhs rhs -> do lhs' <- addHaddock lhs rhs' <- addHaddock rhs - pure $ L l (HsFunTy noExtField mult lhs' rhs') + pure $ L l (HsFunTy u mult lhs' rhs') -- other types _ -> liftHdkA $ do ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -599,7 +599,7 @@ rnHsTyKi env ty@(HsRecTy _ flds) 2 (ppr ty)) ; return [] } -rnHsTyKi env (HsFunTy _ mult ty1 ty2) +rnHsTyKi env (HsFunTy u mult ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 -- Might find a for-all as the arg of a function type ; (ty2', fvs2) <- rnLHsTyKi env ty2 @@ -611,7 +611,7 @@ rnHsTyKi env (HsFunTy _ mult ty1 ty2) ; res_ty <- mkHsOpTyRn (hs_fun_ty mult') funTyConName funTyFixity ty1' ty2' ; return (res_ty, fvs1 `plusFV` fvs2 `plusFV` w_fvs) } where - hs_fun_ty w a b = HsFunTy noExtField w a b + hs_fun_ty w a b = HsFunTy u w a b rnHsTyKi env listTy@(HsListTy _ ty) = do { data_kinds <- xoptM LangExt.DataKinds @@ -708,10 +708,10 @@ rnHsTyKi env (HsWildCardTy _) ; return (HsWildCardTy noExtField, emptyFVs) } rnHsArrow :: RnTyKiEnv -> HsArrow GhcPs -> RnM (HsArrow GhcRn, FreeVars) -rnHsArrow _env HsUnrestrictedArrow = return (HsUnrestrictedArrow, emptyFVs) -rnHsArrow _env HsLinearArrow = return (HsLinearArrow, emptyFVs) -rnHsArrow env (HsExplicitMult p) - = (\(mult, fvs) -> (HsExplicitMult mult, fvs)) <$> rnLHsTyKi env p +rnHsArrow _env (HsUnrestrictedArrow u) = return (HsUnrestrictedArrow u, emptyFVs) +rnHsArrow _env (HsLinearArrow u) = return (HsLinearArrow u, emptyFVs) +rnHsArrow env (HsExplicitMult u p) + = (\(mult, fvs) -> (HsExplicitMult u mult, fvs)) <$> rnLHsTyKi env p -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name @@ -1840,7 +1840,7 @@ extract_lty (L _ ty) acc extract_hs_arrow :: HsArrow GhcPs -> FreeKiTyVars -> FreeKiTyVars -extract_hs_arrow (HsExplicitMult p) acc = extract_lty p acc +extract_hs_arrow (HsExplicitMult _ p) acc = extract_lty p acc extract_hs_arrow _ acc = acc extract_hs_for_all_telescope :: HsForAllTelescope GhcPs ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -118,6 +118,7 @@ import GHC.Data.FastString import GHC.Builtin.Names hiding ( wildCardName ) import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt +import GHC.Parser.Annotation import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -979,7 +980,7 @@ tc_hs_type mode ty@(HsFunTy _ mult ty1 ty2) exp_kind tc_hs_type mode (HsOpTy _ ty1 (L _ op) ty2) exp_kind | op `hasKey` funTyConKey - = tc_fun_type mode HsUnrestrictedArrow ty1 ty2 exp_kind + = tc_fun_type mode (HsUnrestrictedArrow NormalSyntax) ty1 ty2 exp_kind --------- Foralls tc_hs_type mode forall@(HsForAllTy { hst_tele = tele, hst_body = ty }) exp_kind ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2453,7 +2453,7 @@ getGhciStepIO = do { hst_tele = mkHsForAllInvisTele [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)] , hst_xforall = noExtField - , hst_body = nlHsFunTy HsUnrestrictedArrow ghciM ioM } + , hst_body = nlHsFunTy ghciM ioM } stepTy :: LHsSigWcType GhcRn stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty) ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3410,7 +3410,7 @@ tcConArg exp_kind (HsScaled w bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } tcDataConMult :: HsArrow GhcRn -> TcM Mult -tcDataConMult arr at HsUnrestrictedArrow = do +tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] linearEnabled <- xoptM LangExt.LinearTypes if linearEnabled then tcMult arr else return oneDataConTy ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -50,6 +50,7 @@ import GHC.Utils.Lexeme import GHC.Utils.Misc import GHC.Data.FastString import GHC.Utils.Outputable as Outputable +import GHC.Parser.Annotation (IsUnicodeSyntax(..)) import qualified Data.ByteString as BS import Control.Monad( unless, ap ) @@ -1457,7 +1458,7 @@ cvtTypeKind ty_str ty _ -> return $ parenthesizeHsType sigPrec x' let y'' = parenthesizeHsType sigPrec y' - returnL (HsFunTy noExtField HsUnrestrictedArrow x'' y'') + returnL (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) x'' y'') | otherwise -> mk_apps (HsTyVar noExtField NotPromoted (noLoc (getRdrName unrestrictedFunTyCon))) @@ -1609,9 +1610,9 @@ cvtTypeKind ty_str ty hsTypeToArrow :: LHsType GhcPs -> HsArrow GhcPs hsTypeToArrow w = case unLoc w of HsTyVar _ _ (L _ (isExact_maybe -> Just n)) - | n == oneDataConName -> HsLinearArrow - | n == manyDataConName -> HsUnrestrictedArrow - _ -> HsExplicitMult w + | n == oneDataConName -> HsLinearArrow NormalSyntax + | n == manyDataConName -> HsUnrestrictedArrow NormalSyntax + _ -> HsExplicitMult NormalSyntax w -- ConT/InfixT can contain both data constructor (i.e., promoted) names and -- other (i.e, unpromoted) names, as opposed to PromotedT, which can only ===================================== ghc/GHCi/UI.hs ===================================== @@ -1676,7 +1676,7 @@ defineMacro overwrite s = do ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar compose_RDR `mkHsApp` (nlHsPar step) `mkHsApp` (nlHsPar expr) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow stringTy ioM) + tySig = mkLHsSigWcType (nlHsFunTy stringTy ioM) new_expr = L (getLoc expr) $ ExprWithTySig noExtField body tySig hv <- GHC.compileParsedExprRemote new_expr @@ -1744,7 +1744,7 @@ getGhciStepIO = do ghciM = nlHsTyVar (getRdrName ghciTyConName) `nlHsAppTy` stringTy ioM = nlHsTyVar (getRdrName ioTyConName) `nlHsAppTy` stringTy body = nlHsVar (getRdrName ghciStepIoMName) - tySig = mkLHsSigWcType (nlHsFunTy HsUnrestrictedArrow ghciM ioM) + tySig = mkLHsSigWcType (nlHsFunTy ghciM ioM) return $ noLoc $ ExprWithTySig noExtField body tySig ----------------------------------------------------------------------------- ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -44,7 +44,8 @@ ({ T17544.hs:6:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:6:9 } (HsTyVar (NoExtField) @@ -104,7 +105,8 @@ ({ T17544.hs:10:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:10:9 } (HsTyVar (NoExtField) @@ -161,7 +163,8 @@ ({ T17544.hs:14:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:14:9 } (HsTyVar (NoExtField) @@ -221,7 +224,8 @@ ({ T17544.hs:18:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:18:9 } (HsTyVar (NoExtField) @@ -248,7 +252,8 @@ ({ T17544.hs:20:9-16 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544.hs:20:9 } (HsTyVar (NoExtField) ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -85,7 +85,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T17544_kw.hs:19:18-19 } (HsTupleTy (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpParsedAst.stderr ===================================== @@ -66,7 +66,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:7:26-30 } (HsTyVar (NoExtField) @@ -258,7 +259,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpParsedAst.hs:14:25-29 } (HsParTy (NoExtField) @@ -392,7 +394,8 @@ ({ DumpParsedAst.hs:16:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpParsedAst.hs:16:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -100,7 +100,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:9:26-30 } (HsTyVar (NoExtField) @@ -254,7 +255,8 @@ ({ DumpRenamedAst.hs:15:20-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:20 } (HsTyVar (NoExtField) @@ -264,7 +266,8 @@ ({ DumpRenamedAst.hs:15:25-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:15:25 } (HsTyVar (NoExtField) @@ -308,7 +311,8 @@ ({ DumpRenamedAst.hs:18:28-36 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:28 } (HsTyVar (NoExtField) @@ -332,14 +336,16 @@ ({ DumpRenamedAst.hs:18:42-60 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:42-52 } (HsParTy (NoExtField) ({ DumpRenamedAst.hs:18:43-51 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:18:43 } (HsTyVar (NoExtField) @@ -370,7 +376,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:10-34 } (HsParTy (NoExtField) @@ -388,7 +395,8 @@ ({ DumpRenamedAst.hs:19:22-33 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:19:22-25 } (HsAppTy (NoExtField) @@ -496,7 +504,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:21:25-29 } (HsParTy (NoExtField) @@ -620,7 +629,8 @@ ({ DumpRenamedAst.hs:23:31-39 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ DumpRenamedAst.hs:23:31 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/KindSigs.stderr ===================================== @@ -276,7 +276,8 @@ ({ KindSigs.hs:22:8-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:8-20 } (HsParTy (NoExtField) @@ -300,7 +301,8 @@ ({ KindSigs.hs:22:25-44 } (HsFunTy (NoExtField) - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ KindSigs.hs:22:25-28 } (HsTyVar (NoExtField) ===================================== testsuite/tests/parser/should_compile/T14189.stderr ===================================== @@ -42,7 +42,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsLinearArrow) + (HsLinearArrow + (NormalSyntax)) ({ T14189.hs:6:18-20 } (HsTyVar (NoExtField) ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -41,7 +41,8 @@ (Nothing) (PrefixCon [(HsScaled - (HsUnrestrictedArrow) + (HsUnrestrictedArrow + (NormalSyntax)) ({ T18791.hs:5:10-12 } (HsTyVar (NoExtField) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 20098c8951743244bb71b41f470a7546ec31d0f2 +Subproject commit 3e29ec51498dfe092b228889343dc8370ec0e64b View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3549d084834146573be5dff1270e03fb9cec5f0b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3549d084834146573be5dff1270e03fb9cec5f0b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 20:15:17 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 21 Oct 2020 16:15:17 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/foreignhint-note Message-ID: <5f9096d5905f5_28003fd3844ee4581417960@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/foreignhint-note at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/foreignhint-note You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 21 21:18:21 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Wed, 21 Oct 2020 17:18:21 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/apiann-annpercent Message-ID: <5f90a59dee248_28003fd3dd15844814197e7@gitlab.haskell.org.mail> Alan Zimmerman pushed new branch wip/az/apiann-annpercent at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/apiann-annpercent You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 14:06:56 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 23 Oct 2020 10:06:56 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 4 commits: [CmmSized Int] unpacked ints, part 2 Message-ID: <5f92e3802720a_8973fa3dc1939fc90332@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 872b3b35 by Moritz Angermann at 2020-10-23T10:44:32+08:00 [CmmSized Int] unpacked ints, part 2 - - - - - 39b8861c by Moritz Angermann at 2020-10-23T21:58:18+08:00 [CmmSized Int] unpacked ints, part 3 - - - - - a6e59c84 by Moritz Angermann at 2020-10-23T21:58:51+08:00 [CmmSized Int] T8832 fix test stdout. - - - - - 657c5e6a by Moritz Angermann at 2020-10-23T21:59:07+08:00 [Debug] Fix CmmFloat warnings. - - - - - 14 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/HsToCore/Foreign/Call.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Utils.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/parser/should_run/BinaryLiterals2.hs - testsuite/tests/simplCore/should_compile/T8832.stdout Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -291,8 +291,8 @@ section "Int8#" primtype Int8# -primop Int8Extend "extendInt8#" GenPrimOp Int8# -> Int# -primop Int8Narrow "narrowInt8#" GenPrimOp Int# -> Int8# +primop Int8ExtendOp "extendInt8#" GenPrimOp Int8# -> Int# +primop Int8NarrowOp "narrowInt8#" GenPrimOp Int# -> Int8# primop Int8NegOp "negateInt8#" GenPrimOp Int8# -> Int8# @@ -373,8 +373,8 @@ section "Int16#" primtype Int16# -primop Int16Extend "extendInt16#" GenPrimOp Int16# -> Int# -primop Int16Narrow "narrowInt16#" GenPrimOp Int# -> Int16# +primop Int16ExtendOp "extendInt16#" GenPrimOp Int16# -> Int# +primop Int16NarrowOp "narrowInt16#" GenPrimOp Int# -> Int16# primop Int16NegOp "negateInt16#" GenPrimOp Int16# -> Int16# @@ -412,8 +412,8 @@ section "Int32#" {Operations on 32-bit integers.} ------------------------------------------------------------------------ -primop Int32Extend "extendInt32#" GenPrimOp Int32# -> Int# -primop Int32Narrow "narrowInt32#" GenPrimOp Int# -> Int32# +primop Int32ExtendOp "extendInt32#" GenPrimOp Int32# -> Int# +primop Int32NarrowOp "narrowInt32#" GenPrimOp Int# -> Int32# ------------------------------------------------------------------------ section "Word16#" ===================================== compiler/GHC/ByteCode/Asm.hs ===================================== @@ -457,6 +457,12 @@ assembleI platform i = case i of literal (LitNumber nt i) = case nt of LitNumInt -> int (fromIntegral i) LitNumWord -> int (fromIntegral i) + LitNumInt8 -> int8 (fromIntegral i) + LitNumWord8 -> int8 (fromIntegral i) + LitNumInt16 -> int16 (fromIntegral i) + LitNumWord16 -> int16 (fromIntegral i) + LitNumInt32 -> int32 (fromIntegral i) + LitNumWord32 -> int32 (fromIntegral i) LitNumInt64 -> int64 (fromIntegral i) LitNumWord64 -> int64 (fromIntegral i) LitNumInteger -> panic "GHC.ByteCode.Asm.literal: LitNumInteger" @@ -471,6 +477,9 @@ assembleI platform i = case i of float = words . mkLitF double = words . mkLitD platform int = words . mkLitI + int8 = words . mkLitI64 platform + int16 = words . mkLitI64 platform + int32 = words . mkLitI64 platform int64 = words . mkLitI64 platform words ws = lit (map BCONPtrWord ws) word w = words [w] ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -193,6 +193,32 @@ primOpRules nm = \case SrlOp -> mkPrimOpRule nm 2 [ shiftRule LitNumWord shiftRightLogical ] -- coercions + + Int8ExtendOp -> mkPrimOpRule nm 1 [ do [Var primop_id `App` e] <- getArgs + matchPrimOpId Int8NarrowOp primop_id + return (Var (mkPrimOpId Narrow8IntOp) `App` e) ] + Int16ExtendOp -> mkPrimOpRule nm 1 [ do [Var primop_id `App` e] <- getArgs + matchPrimOpId Int16NarrowOp primop_id + return (Var (mkPrimOpId Narrow16IntOp) `App` e) ] + Int32ExtendOp -> mkPrimOpRule nm 1 [ do [Var primop_id `App` e] <- getArgs + matchPrimOpId Int32NarrowOp primop_id + return (Var (mkPrimOpId Narrow32IntOp) `App` e) ] + Int8NarrowOp -> mkPrimOpRule nm 1 [ subsumedByPrimOp Int8NarrowOp + , narrowSubsumesAnd AndIOp Int8NarrowOp 8 ] + Int16NarrowOp -> mkPrimOpRule nm 1 [ subsumedByPrimOp Int8NarrowOp + , subsumedByPrimOp Int16NarrowOp + , narrowSubsumesAnd AndIOp Int16NarrowOp 16 ] + Int32NarrowOp -> mkPrimOpRule nm 1 [ subsumedByPrimOp Int8NarrowOp + , subsumedByPrimOp Int16NarrowOp + , subsumedByPrimOp Int32NarrowOp + , narrowSubsumesAnd AndIOp Int32NarrowOp 32 ] + -- Int64NarrowOp -> mkPrimOpRule nm 1 [ narrowSubsumesAnd AndIOp Int64NarrowOp 64 ] + + -- Word8Narrow -> mkPrimOpRule nm 1 [ narrowSubsumesAnd AndOp Word8Narrow 8 ] + -- Word16Narrow -> mkPrimOpRule nm 1 [ narrowSubsumesAnd AndOp Word16Narrow 16 ] + -- Word32Narrow -> mkPrimOpRule nm 1 [ narrowSubsumesAnd AndOp Word32Narrow 32 ] + -- Word64Narrow -> mkPrimOpRule nm 1 [ narrowSubsumesAnd AndOp Word64Narrow 64 ] + WordToIntOp -> mkPrimOpRule nm 1 [ liftLitPlatform wordToIntLit , inversePrimOp IntToWordOp ] IntToWordOp -> mkPrimOpRule nm 1 [ liftLitPlatform intToWordLit @@ -593,8 +619,14 @@ isMinBound :: Platform -> Literal -> Bool isMinBound _ (LitChar c) = c == minBound isMinBound platform (LitNumber nt i) = case nt of LitNumInt -> i == platformMinInt platform + LitNumInt8 -> i == toInteger (minBound :: Int8) + LitNumInt16 -> i == toInteger (minBound :: Int16) + LitNumInt32 -> i == toInteger (minBound :: Int32) LitNumInt64 -> i == toInteger (minBound :: Int64) LitNumWord -> i == 0 + LitNumWord8 -> i == 0 + LitNumWord16 -> i == 0 + LitNumWord32 -> i == 0 LitNumWord64 -> i == 0 LitNumNatural -> i == 0 LitNumInteger -> False @@ -604,8 +636,14 @@ isMaxBound :: Platform -> Literal -> Bool isMaxBound _ (LitChar c) = c == maxBound isMaxBound platform (LitNumber nt i) = case nt of LitNumInt -> i == platformMaxInt platform + LitNumInt8 -> i == toInteger (maxBound :: Int8) + LitNumInt16 -> i == toInteger (maxBound :: Int16) + LitNumInt32 -> i == toInteger (maxBound :: Int32) LitNumInt64 -> i == toInteger (maxBound :: Int64) LitNumWord -> i == platformMaxWord platform + LitNumWord8 -> i == toInteger (maxBound :: Word8) + LitNumWord16 -> i == toInteger (maxBound :: Word16) + LitNumWord32 -> i == toInteger (maxBound :: Word32) LitNumWord64 -> i == toInteger (maxBound :: Word64) LitNumNatural -> False LitNumInteger -> False ===================================== compiler/GHC/CoreToByteCode.hs ===================================== @@ -1383,6 +1383,12 @@ primRepToFFIType platform r VoidRep -> FFIVoid IntRep -> signed_word WordRep -> unsigned_word + Int8Rep -> FFISInt8 + Word8Rep -> FFIUInt8 + Int16Rep -> FFISInt16 + Word16Rep -> FFIUInt16 + Int32Rep -> FFISInt32 + Word32Rep -> FFIUInt32 Int64Rep -> FFISInt64 Word64Rep -> FFIUInt64 AddrRep -> FFIPointer @@ -1401,6 +1407,12 @@ mkDummyLiteral platform pr = case pr of IntRep -> mkLitInt platform 0 WordRep -> mkLitWord platform 0 + Int8Rep -> mkLitInt8 0 + Word8Rep -> mkLitWord8 0 + Int16Rep -> mkLitInt16 0 + Word16Rep -> mkLitWord16 0 + Int32Rep -> mkLitInt32 0 + Word32Rep -> mkLitWord32 0 Int64Rep -> mkLitInt64 0 Word64Rep -> mkLitWord64 0 AddrRep -> LitNullAddr @@ -1633,6 +1645,12 @@ pushAtom _ _ (AnnLit lit) = do LitNumber nt _ -> case nt of LitNumInt -> code N LitNumWord -> code N + LitNumInt8 -> code (toArgRep Int8Rep) + LitNumWord8 -> code (toArgRep Word8Rep) + LitNumInt16 -> code (toArgRep Int16Rep) + LitNumWord16 -> code (toArgRep Word16Rep) + LitNumInt32 -> code (toArgRep Int32Rep) + LitNumWord32 -> code (toArgRep Word32Rep) LitNumInt64 -> code L LitNumWord64 -> code L -- No LitInteger's or LitNatural's should be left by the time this is ===================================== compiler/GHC/HsToCore/Foreign/Call.hs ===================================== @@ -21,9 +21,7 @@ where #include "HsVersions.h" - import GHC.Prelude -import GHC.Platform import GHC.Core @@ -40,7 +38,6 @@ import GHC.Core.Type import GHC.Core.Multiplicity import GHC.Types.Id ( Id ) import GHC.Core.Coercion -import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim import GHC.Core.TyCon import GHC.Builtin.Types @@ -354,36 +351,13 @@ resultWrapper result_ty | Just (tycon, tycon_arg_tys) <- maybe_tc_app , Just data_con <- isDataProductTyCon_maybe tycon -- One constructor, no existentials , [Scaled _ unwrapped_res_ty] <- dataConInstOrigArgTys data_con tycon_arg_tys -- One argument - = do { dflags <- getDynFlags - ; let platform = targetPlatform dflags - ; (maybe_ty, wrapper) <- resultWrapper unwrapped_res_ty - ; let narrow_wrapper = maybeNarrow platform tycon - marshal_con e = Var (dataConWrapId data_con) + = do { (maybe_ty, wrapper) <- resultWrapper unwrapped_res_ty + ; let marshal_con e = Var (dataConWrapId data_con) `mkTyApps` tycon_arg_tys - `App` wrapper (narrow_wrapper e) + `App` wrapper e ; return (maybe_ty, marshal_con) } | otherwise = pprPanic "resultWrapper" (ppr result_ty) where maybe_tc_app = splitTyConApp_maybe result_ty - --- When the result of a foreign call is smaller than the word size, we --- need to sign- or zero-extend the result up to the word size. The C --- standard appears to say that this is the responsibility of the --- caller, not the callee. - -maybeNarrow :: Platform -> TyCon -> (CoreExpr -> CoreExpr) -maybeNarrow platform tycon - | tycon `hasKey` int8TyConKey = \e -> App (Var (mkPrimOpId Narrow8IntOp)) e - | tycon `hasKey` int16TyConKey = \e -> App (Var (mkPrimOpId Narrow16IntOp)) e - | tycon `hasKey` int32TyConKey - , platformWordSizeInBytes platform > 4 - = \e -> App (Var (mkPrimOpId Narrow32IntOp)) e - - | tycon `hasKey` word8TyConKey = \e -> App (Var (mkPrimOpId Narrow8WordOp)) e - | tycon `hasKey` word16TyConKey = \e -> App (Var (mkPrimOpId Narrow16WordOp)) e - | tycon `hasKey` word32TyConKey - , platformWordSizeInBytes platform > 4 - = \e -> App (Var (mkPrimOpId Narrow32WordOp)) e - | otherwise = id ===================================== compiler/GHC/HsToCore/Foreign/Decl.hs ===================================== @@ -838,6 +838,10 @@ primTyDescChar platform ty = case typePrimRep1 (getPrimTyOf ty) of IntRep -> signed_word WordRep -> unsigned_word + Int8Rep -> 'B' + Word8Rep -> 'b' + Int16Rep -> 'S' + Word16Rep -> 's' Int32Rep -> 'W' Word32Rep -> 'w' Int64Rep -> 'L' ===================================== compiler/GHC/Runtime/Heap/Inspect.hs ===================================== @@ -467,6 +467,10 @@ repPrim t = rep where | t == wordPrimTyCon = text $ show (build x :: Word) | t == floatPrimTyCon = text $ show (build x :: Float) | t == doublePrimTyCon = text $ show (build x :: Double) + | t == int8PrimTyCon = text $ show (build x :: Int8) + | t == word8PrimTyCon = text $ show (build x :: Word8) + | t == int16PrimTyCon = text $ show (build x :: Int16) + | t == word16PrimTyCon = text $ show (build x :: Word16) | t == int32PrimTyCon = text $ show (build x :: Int32) | t == word32PrimTyCon = text $ show (build x :: Word32) | t == int64PrimTyCon = text $ show (build x :: Int64) ===================================== compiler/GHC/StgToCmm/Foreign.hs ===================================== @@ -112,6 +112,8 @@ cgForeignCall (CCall (CCallSpec target cconv safety)) typ stg_args res_ty (CmmLit _, AddrHint) -> pure () (CmmReg _, AddrHint) -> pure () (CmmRegOff _ _, AddrHint) -> pure () + (CmmLit (CmmFloat _ w), SignedHint w') | w == w' -> pure () + (CmmLit (CmmFloat _ w), NoHint w') | w == w' -> pure () (CmmLit (CmmInt _ w), SignedHint w') | w == w' -> pure () (CmmLit (CmmInt _ w), NoHint w') | w == w' -> pure () (CmmReg (CmmLocal (LocalReg _ ty)), _) | isFloatType ty -> pure () ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1172,8 +1172,8 @@ emitPrimOp dflags primop = case primop of -- Int8# signed ops - Int8Extend -> \args -> opTranslate args (MO_SS_Conv W8 (wordWidth platform)) - Int8Narrow -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W8) + Int8ExtendOp -> \args -> opTranslate args (MO_SS_Conv W8 (wordWidth platform)) + Int8NarrowOp -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W8) Int8NegOp -> \args -> opTranslate args (MO_S_Neg W8) Int8AddOp -> \args -> opTranslate args (MO_Add W8) Int8SubOp -> \args -> opTranslate args (MO_Sub W8) @@ -1208,8 +1208,8 @@ emitPrimOp dflags primop = case primop of -- Int16# signed ops - Int16Extend -> \args -> opTranslate args (MO_SS_Conv W16 (wordWidth platform)) - Int16Narrow -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W16) + Int16ExtendOp -> \args -> opTranslate args (MO_SS_Conv W16 (wordWidth platform)) + Int16NarrowOp -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W16) Int16NegOp -> \args -> opTranslate args (MO_S_Neg W16) Int16AddOp -> \args -> opTranslate args (MO_Add W16) Int16SubOp -> \args -> opTranslate args (MO_Sub W16) @@ -1226,8 +1226,8 @@ emitPrimOp dflags primop = case primop of -- Int32# signed ops - Int32Extend -> \args -> opTranslate args (MO_SS_Conv W32 (wordWidth platform)) - Int32Narrow -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W32) + Int32ExtendOp -> \args -> opTranslate args (MO_SS_Conv W32 (wordWidth platform)) + Int32NarrowOp -> \args -> opTranslate args (MO_SS_Conv (wordWidth platform) W32) -- Word16# unsigned ops ===================================== compiler/GHC/StgToCmm/Utils.hs ===================================== @@ -106,8 +106,14 @@ mkSimpleLit platform = \case (wordWidth platform) LitNullAddr -> zeroCLit platform (LitNumber LitNumInt i) -> CmmInt i (wordWidth platform) + (LitNumber LitNumInt8 i) -> CmmInt i W8 + (LitNumber LitNumInt16 i) -> CmmInt i W16 + (LitNumber LitNumInt32 i) -> CmmInt i W32 (LitNumber LitNumInt64 i) -> CmmInt i W64 (LitNumber LitNumWord i) -> CmmInt i (wordWidth platform) + (LitNumber LitNumWord8 i) -> CmmInt i W8 + (LitNumber LitNumWord16 i) -> CmmInt i W16 + (LitNumber LitNumWord32 i) -> CmmInt i W32 (LitNumber LitNumWord64 i) -> CmmInt i W64 (LitFloat r) -> CmmFloat r W32 (LitDouble r) -> CmmFloat r W64 ===================================== compiler/GHC/Types/Literal.hs ===================================== @@ -17,6 +17,12 @@ module GHC.Types.Literal -- ** Creating Literals , mkLitInt, mkLitIntWrap, mkLitIntWrapC, mkLitIntUnchecked , mkLitWord, mkLitWordWrap, mkLitWordWrapC + , mkLitInt8, mkLitInt8Wrap + , mkLitWord8, mkLitWord8Wrap + , mkLitInt16, mkLitInt16Wrap + , mkLitWord16, mkLitWord16Wrap + , mkLitInt32, mkLitInt32Wrap + , mkLitWord32, mkLitWord32Wrap , mkLitInt64, mkLitInt64Wrap , mkLitWord64, mkLitWord64Wrap , mkLitFloat, mkLitDouble @@ -43,6 +49,8 @@ module GHC.Types.Literal , narrowLit , narrow8IntLit, narrow16IntLit, narrow32IntLit , narrow8WordLit, narrow16WordLit, narrow32WordLit + , int8Lit, int16Lit, int32Lit + , word8Lit, word16Lit, word32Lit , charToIntLit, intToCharLit , floatToIntLit, intToFloatLit, doubleToIntLit, intToDoubleLit , nullAddrLit, rubbishLit, floatToDoubleLit, doubleToFloatLit @@ -153,8 +161,14 @@ data LitNumType = LitNumInteger -- ^ @Integer@ (see Note [BigNum literals]) | LitNumNatural -- ^ @Natural@ (see Note [BigNum literals]) | LitNumInt -- ^ @Int#@ - according to target machine + | LitNumInt8 -- ^ @Int8#@ - exactly 8 bits + | LitNumInt16 -- ^ @Int16#@ - exactly 16 bits + | LitNumInt32 -- ^ @Int32#@ - exactly 32 bits | LitNumInt64 -- ^ @Int64#@ - exactly 64 bits | LitNumWord -- ^ @Word#@ - according to target machine + | LitNumWord8 -- ^ @Word8#@ - exactly 8 bits + | LitNumWord16 -- ^ @Word16#@ - exactly 16 bits + | LitNumWord32 -- ^ @Word32#@ - exactly 32 bits | LitNumWord64 -- ^ @Word64#@ - exactly 64 bits deriving (Data,Enum,Eq,Ord) @@ -164,8 +178,14 @@ litNumIsSigned nt = case nt of LitNumInteger -> True LitNumNatural -> False LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> False + LitNumWord8 -> False + LitNumWord16 -> False + LitNumWord32 -> False LitNumWord64 -> False {- @@ -293,6 +313,12 @@ wrapLitNumber platform v@(LitNumber nt i) = case nt of LitNumWord -> case platformWordSize platform of PW4 -> LitNumber nt (toInteger (fromIntegral i :: Word32)) PW8 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) + LitNumInt8 -> LitNumber nt (toInteger (fromIntegral i :: Int8)) + LitNumWord8 -> LitNumber nt (toInteger (fromIntegral i :: Word8)) + LitNumInt16 -> LitNumber nt (toInteger (fromIntegral i :: Int16)) + LitNumWord16 -> LitNumber nt (toInteger (fromIntegral i :: Word16)) + LitNumInt32 -> LitNumber nt (toInteger (fromIntegral i :: Int32)) + LitNumWord32 -> LitNumber nt (toInteger (fromIntegral i :: Word32)) LitNumInt64 -> LitNumber nt (toInteger (fromIntegral i :: Int64)) LitNumWord64 -> LitNumber nt (toInteger (fromIntegral i :: Word64)) LitNumInteger -> v @@ -308,7 +334,13 @@ litNumCheckRange :: Platform -> LitNumType -> Integer -> Bool litNumCheckRange platform nt i = case nt of LitNumInt -> platformInIntRange platform i LitNumWord -> platformInWordRange platform i + LitNumInt8 -> inInt8Range i + LitNumInt16 -> inInt16Range i + LitNumInt32 -> inInt32Range i LitNumInt64 -> inInt64Range i + LitNumWord8 -> inWord8Range i + LitNumWord16 -> inWord16Range i + LitNumWord32 -> inWord32Range i LitNumWord64 -> inWord64Range i LitNumNatural -> i >= 0 LitNumInteger -> True @@ -367,6 +399,84 @@ mkLitWordWrapC platform i = (n, i /= i') where n@(LitNumber _ i') = mkLitWordWrap platform i +-- | Creates a 'Literal' of type @Int8#@ +mkLitInt8 :: Integer -> Literal +mkLitInt8 x = ASSERT2( inInt8Range x, integer x ) (mkLitInt8Unchecked x) + +-- | Creates a 'Literal' of type @Int8#@. +-- If the argument is out of the range, it is wrapped. +mkLitInt8Wrap :: Platform -> Integer -> Literal +mkLitInt8Wrap platform i = wrapLitNumber platform $ mkLitInt8Unchecked i + +-- | Creates a 'Literal' of type @Int8#@ without checking its range. +mkLitInt8Unchecked :: Integer -> Literal +mkLitInt8Unchecked i = LitNumber LitNumInt8 i + +-- | Creates a 'Literal' of type @Word8#@ +mkLitWord8 :: Integer -> Literal +mkLitWord8 x = ASSERT2( inWord8Range x, integer x ) (mkLitWord8Unchecked x) + +-- | Creates a 'Literal' of type @Word8#@. +-- If the argument is out of the range, it is wrapped. +mkLitWord8Wrap :: Platform -> Integer -> Literal +mkLitWord8Wrap platform i = wrapLitNumber platform $ mkLitWord8Unchecked i + +-- | Creates a 'Literal' of type @Word8#@ without checking its range. +mkLitWord8Unchecked :: Integer -> Literal +mkLitWord8Unchecked i = LitNumber LitNumWord8 i + +-- | Creates a 'Literal' of type @Int16#@ +mkLitInt16 :: Integer -> Literal +mkLitInt16 x = ASSERT2( inInt16Range x, integer x ) (mkLitInt16Unchecked x) + +-- | Creates a 'Literal' of type @Int16#@. +-- If the argument is out of the range, it is wrapped. +mkLitInt16Wrap :: Platform -> Integer -> Literal +mkLitInt16Wrap platform i = wrapLitNumber platform $ mkLitInt16Unchecked i + +-- | Creates a 'Literal' of type @Int16#@ without checking its range. +mkLitInt16Unchecked :: Integer -> Literal +mkLitInt16Unchecked i = LitNumber LitNumInt16 i + +-- | Creates a 'Literal' of type @Word16#@ +mkLitWord16 :: Integer -> Literal +mkLitWord16 x = ASSERT2( inWord16Range x, integer x ) (mkLitWord16Unchecked x) + +-- | Creates a 'Literal' of type @Word16#@. +-- If the argument is out of the range, it is wrapped. +mkLitWord16Wrap :: Platform -> Integer -> Literal +mkLitWord16Wrap platform i = wrapLitNumber platform $ mkLitWord16Unchecked i + +-- | Creates a 'Literal' of type @Word16#@ without checking its range. +mkLitWord16Unchecked :: Integer -> Literal +mkLitWord16Unchecked i = LitNumber LitNumWord16 i + +-- | Creates a 'Literal' of type @Int32#@ +mkLitInt32 :: Integer -> Literal +mkLitInt32 x = ASSERT2( inInt32Range x, integer x ) (mkLitInt32Unchecked x) + +-- | Creates a 'Literal' of type @Int32#@. +-- If the argument is out of the range, it is wrapped. +mkLitInt32Wrap :: Platform -> Integer -> Literal +mkLitInt32Wrap platform i = wrapLitNumber platform $ mkLitInt32Unchecked i + +-- | Creates a 'Literal' of type @Int32#@ without checking its range. +mkLitInt32Unchecked :: Integer -> Literal +mkLitInt32Unchecked i = LitNumber LitNumInt32 i + +-- | Creates a 'Literal' of type @Word32#@ +mkLitWord32 :: Integer -> Literal +mkLitWord32 x = ASSERT2( inWord32Range x, integer x ) (mkLitWord32Unchecked x) + +-- | Creates a 'Literal' of type @Word32#@. +-- If the argument is out of the range, it is wrapped. +mkLitWord32Wrap :: Platform -> Integer -> Literal +mkLitWord32Wrap platform i = wrapLitNumber platform $ mkLitWord32Unchecked i + +-- | Creates a 'Literal' of type @Word32#@ without checking its range. +mkLitWord32Unchecked :: Integer -> Literal +mkLitWord32Unchecked i = LitNumber LitNumWord32 i + -- | Creates a 'Literal' of type @Int64#@ mkLitInt64 :: Integer -> Literal mkLitInt64 x = ASSERT2( inInt64Range x, integer x ) (mkLitInt64Unchecked x) @@ -421,7 +531,20 @@ mkLitNatural x = ASSERT2( inNaturalRange x, integer x ) inNaturalRange :: Integer -> Bool inNaturalRange x = x >= 0 -inInt64Range, inWord64Range :: Integer -> Bool +inInt8Range, inWord8Range, inInt16Range, inWord16Range :: Integer -> Bool +inInt32Range, inWord32Range, inInt64Range, inWord64Range :: Integer -> Bool +inInt8Range x = x >= toInteger (minBound :: Int8) && + x <= toInteger (maxBound :: Int8) +inWord8Range x = x >= toInteger (minBound :: Word8) && + x <= toInteger (maxBound :: Word8) +inInt16Range x = x >= toInteger (minBound :: Int16) && + x <= toInteger (maxBound :: Int16) +inWord16Range x = x >= toInteger (minBound :: Word16) && + x <= toInteger (maxBound :: Word16) +inInt32Range x = x >= toInteger (minBound :: Int32) && + x <= toInteger (maxBound :: Int32) +inWord32Range x = x >= toInteger (minBound :: Word32) && + x <= toInteger (maxBound :: Word32) inInt64Range x = x >= toInteger (minBound :: Int64) && x <= toInteger (maxBound :: Int64) inWord64Range x = x >= toInteger (minBound :: Word64) && @@ -474,6 +597,8 @@ isLitValue = isJust . isLitValue_maybe narrow8IntLit, narrow16IntLit, narrow32IntLit, narrow8WordLit, narrow16WordLit, narrow32WordLit, + int8Lit, int16Lit, int32Lit, + word8Lit, word16Lit, word32Lit, charToIntLit, intToCharLit, floatToIntLit, intToFloatLit, doubleToIntLit, intToDoubleLit, floatToDoubleLit, doubleToFloatLit @@ -508,6 +633,19 @@ narrow8WordLit = narrowLit (Proxy :: Proxy Word8) narrow16WordLit = narrowLit (Proxy :: Proxy Word16) narrow32WordLit = narrowLit (Proxy :: Proxy Word32) +int8Lit (LitNumber _ i) = mkLitInt8 i +int8Lit l = pprPanic "int8Lit" (ppr l) +int16Lit (LitNumber _ i) = mkLitInt16 i +int16Lit l = pprPanic "int16Lit" (ppr l) +int32Lit (LitNumber _ i) = mkLitInt32 i +int32Lit l = pprPanic "int32Lit" (ppr l) +word8Lit (LitNumber _ i) = mkLitWord8 i +word8Lit l = pprPanic "word8Lit" (ppr l) +word16Lit (LitNumber _ i) = mkLitWord16 i +word16Lit l = pprPanic "word16Lit" (ppr l) +word32Lit (LitNumber _ i) = mkLitWord32 i +word32Lit l = pprPanic "word32Lit" (ppr l) + charToIntLit (LitChar c) = mkLitIntUnchecked (toInteger (ord c)) charToIntLit l = pprPanic "charToIntLit" (ppr l) intToCharLit (LitNumber _ i) = LitChar (chr (fromInteger i)) @@ -580,8 +718,14 @@ litIsTrivial (LitNumber nt _) = case nt of LitNumInteger -> False LitNumNatural -> False LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> True + LitNumWord8 -> True + LitNumWord16 -> True + LitNumWord32 -> True LitNumWord64 -> True litIsTrivial _ = True @@ -593,8 +737,14 @@ litIsDupable platform x = case x of LitNumInteger -> platformInIntRange platform i LitNumNatural -> platformInWordRange platform i LitNumInt -> True + LitNumInt8 -> True + LitNumInt16 -> True + LitNumInt32 -> True LitNumInt64 -> True LitNumWord -> True + LitNumWord8 -> True + LitNumWord16 -> True + LitNumWord32 -> True LitNumWord64 -> True (LitString _) -> False _ -> True @@ -609,8 +759,14 @@ litIsLifted (LitNumber nt _) = case nt of LitNumInteger -> True LitNumNatural -> True LitNumInt -> False + LitNumInt8 -> False + LitNumInt16 -> False + LitNumInt32 -> False LitNumInt64 -> False LitNumWord -> False + LitNumWord8 -> False + LitNumWord16 -> False + LitNumWord32 -> False LitNumWord64 -> False litIsLifted _ = False @@ -631,8 +787,14 @@ literalType (LitNumber lt _) = case lt of LitNumInteger -> integerTy LitNumNatural -> naturalTy LitNumInt -> intPrimTy + LitNumInt8 -> int8PrimTy + LitNumInt16 -> int16PrimTy + LitNumInt32 -> int32PrimTy LitNumInt64 -> int64PrimTy LitNumWord -> wordPrimTy + LitNumWord8 -> word8PrimTy + LitNumWord16 -> word16PrimTy + LitNumWord32 -> word32PrimTy LitNumWord64 -> word64PrimTy literalType (LitRubbish) = mkForAllTy a Inferred (mkTyVarTy a) where @@ -707,8 +869,14 @@ pprLiteral add_par (LitNumber nt i) LitNumInteger -> pprIntegerVal add_par i LitNumNatural -> pprIntegerVal add_par i LitNumInt -> pprPrimInt i + LitNumInt8 -> pprPrimInt8 i + LitNumInt16 -> pprPrimInt16 i + LitNumInt32 -> pprPrimInt32 i LitNumInt64 -> pprPrimInt64 i LitNumWord -> pprPrimWord i + LitNumWord8 -> pprPrimWord8 i + LitNumWord16 -> pprPrimWord16 i + LitNumWord32 -> pprPrimWord32 i LitNumWord64 -> pprPrimWord64 i pprLiteral add_par (LitLabel l mb fod) = add_par (text "__label" <+> b <+> ppr fod) ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -59,7 +59,9 @@ module GHC.Utils.Outputable ( primFloatSuffix, primCharSuffix, primWordSuffix, primDoubleSuffix, primInt64Suffix, primWord64Suffix, primIntSuffix, - pprPrimChar, pprPrimInt, pprPrimWord, pprPrimInt64, pprPrimWord64, + pprPrimChar, pprPrimInt, pprPrimWord, + pprPrimInt8, pprPrimInt16, pprPrimInt32, pprPrimInt64, + pprPrimWord8, pprPrimWord16, pprPrimWord32, pprPrimWord64, pprFastFilePath, pprFilePathString, @@ -1018,22 +1020,40 @@ pprHsBytes bs = let escaped = concatMap escape $ BS.unpack bs -- Postfix modifiers for unboxed literals. -- See Note [Printing of literals in Core] in "GHC.Types.Literal". primCharSuffix, primFloatSuffix, primIntSuffix :: SDoc -primDoubleSuffix, primWordSuffix, primInt64Suffix, primWord64Suffix :: SDoc +primDoubleSuffix, primWordSuffix :: SDoc +primInt8Suffix, primWord8Suffix :: SDoc +primInt16Suffix, primWord16Suffix :: SDoc +primInt32Suffix, primWord32Suffix :: SDoc +primInt64Suffix, primWord64Suffix :: SDoc primCharSuffix = char '#' primFloatSuffix = char '#' primIntSuffix = char '#' primDoubleSuffix = text "##" primWordSuffix = text "##" -primInt64Suffix = text "L#" -primWord64Suffix = text "L##" +primInt8Suffix = text "#8" +primWord8Suffix = text "##8" +primInt16Suffix = text "#16" +primWord16Suffix = text "##16" +primInt32Suffix = text "#32" +primWord32Suffix = text "##32" +primInt64Suffix = text "#64" +primWord64Suffix = text "##64" -- | Special combinator for showing unboxed literals. pprPrimChar :: Char -> SDoc -pprPrimInt, pprPrimWord, pprPrimInt64, pprPrimWord64 :: Integer -> SDoc +pprPrimInt, pprPrimWord :: Integer -> SDoc +pprPrimInt8, pprPrimInt16, pprPrimInt32, pprPrimInt64 :: Integer -> SDoc +pprPrimWord8, pprPrimWord16, pprPrimWord32, pprPrimWord64 :: Integer -> SDoc pprPrimChar c = pprHsChar c <> primCharSuffix pprPrimInt i = integer i <> primIntSuffix pprPrimWord w = word w <> primWordSuffix +pprPrimInt8 i = integer i <> primInt8Suffix +pprPrimInt16 i = integer i <> primInt16Suffix +pprPrimInt32 i = integer i <> primInt32Suffix pprPrimInt64 i = integer i <> primInt64Suffix +pprPrimWord8 w = word w <> primWord8Suffix +pprPrimWord16 w = word w <> primWord16Suffix +pprPrimWord32 w = word w <> primWord32Suffix pprPrimWord64 w = word w <> primWord64Suffix --------------------- ===================================== testsuite/tests/parser/should_run/BinaryLiterals2.hs ===================================== @@ -6,6 +6,7 @@ module Main where +import GHC.Base import GHC.Types import GHC.Int @@ -26,4 +27,4 @@ main = do , -0B11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 ] - print [ I8# -0B10000000#, I8# 0B1111111# ] + print [ I8# (narrowInt8# -0B10000000#), I8# (narrowInt8# 0B1111111#) ] ===================================== testsuite/tests/simplCore/should_compile/T8832.stdout ===================================== @@ -1,7 +1,7 @@ i = GHC.Types.I# 0# -i8 = GHC.Int.I8# 0# -i16 = GHC.Int.I16# 0# -i32 = GHC.Int.I32# 0# +i8 = GHC.Int.I8# (GHC.Prim.narrowInt8# 0#) +i16 = GHC.Int.I16# (GHC.Prim.narrowInt16# 0#) +i32 = GHC.Int.I32# (GHC.Prim.narrowInt32# 0#) i64 = GHC.Int.I64# 0# w = GHC.Types.W# 0## w8 = GHC.Word.W8# 0## View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0506dc0ffd0b70af352b76625d7b4be5d7505992...657c5e6a78d0068d62e702edc02c2eec03528d71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0506dc0ffd0b70af352b76625d7b4be5d7505992...657c5e6a78d0068d62e702edc02c2eec03528d71 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 14:09:37 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 23 Oct 2020 10:09:37 -0400 Subject: [Git][ghc/ghc][wip/T16762] Minor changes (dare I call them "wibbles"?) Message-ID: <5f92e421d0d09_8973fa3bac998a0920d@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: af060b33 by Ryan Scott at 2020-10-23T09:14:44-04:00 Minor changes (dare I call them "wibbles"?) - - - - - 8 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/polykinds/T16762c.hs Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -457,7 +457,7 @@ data HsOuterTyVarBndrs flag pass -- | Used for signatures, e.g., -- -- @ --- f :: forall a {b}. blahg +-- f :: forall a {b}. blah -- @ -- -- We use 'Specificity' for the 'HsOuterTyVarBndrs' @flag@ to allow @@ -1664,8 +1664,8 @@ splitLHsSigmaTyInvis ty -- | Decompose a GADT type into its constituent parts. -- Returns @(outer_bndrs, mb_ctxt, body)@, where: -- --- * @outer_bndrs@ are 'OuterExplicit' if the type has explicit, outermost --- type variable binders. Otherwise, they are 'OuterImplicit'. +-- * @outer_bndrs@ are 'HsOuterExplicit' if the type has explicit, outermost +-- type variable binders. Otherwise, they are 'HsOuterImplicit'. -- -- * @mb_ctxt@ is @Just@ the context, if it is provided. -- Otherwise, it is @Nothing at . @@ -1684,7 +1684,7 @@ splitLHsGadtTy (L _ sig_ty) = (outer_bndrs, mb_ctxt, tau_ty) where split_bndrs :: HsSigType GhcPs -> (HsOuterSigTyVarBndrs GhcPs, LHsType GhcPs) - split_bndrs (HsSig { sig_bndrs = outer_bndrs, sig_body = body_ty}) = + split_bndrs (HsSig{sig_bndrs = outer_bndrs, sig_body = body_ty}) = (outer_bndrs, body_ty) -- | Decompose a type of the form @forall . body@ into its constituent ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -933,8 +933,6 @@ instance HasHaddock a => HasHaddock (HsWildCardBndrs GhcPs a) where instance HasHaddock (Located (HsSigType GhcPs)) where addHaddock (L l (HsSig{sig_bndrs = outer_bndrs, sig_body = body})) = - -- TODO RGS: I cargo-culted this code from the HsForAllTy case of the - -- HasHaddock instance for HsType. Is this right? Need Vlad to check. extendHdkA l $ do case outer_bndrs of HsOuterImplicit{} -> pure () ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -12,7 +12,7 @@ module GHC.Rename.HsType ( rnHsType, rnLHsType, rnLHsTypes, rnContext, rnHsKind, rnLHsKind, rnLHsTypeArgs, rnHsSigType, rnHsWcType, - HsSigWcTypeScoping(..), rnHsSigWcType, rnHsPatSigType, + HsPatSigTypeScoping(..), rnHsSigWcType, rnHsPatSigType, newTyVarNameRn, rnConDeclFields, rnLTyVar, @@ -81,7 +81,7 @@ to break several loops. ********************************************************* -} -data HsSigWcTypeScoping +data HsPatSigTypeScoping = AlwaysBind -- ^ Always bind any free tyvars of the given type, regardless of whether we -- have a forall at the top. @@ -131,7 +131,7 @@ rnHsSigWcType doc (HsWC { hswc_body = , sig_bndrs = outer_bndrs', sig_body = body_ty' }} , fvs) } } -rnHsPatSigType :: HsSigWcTypeScoping +rnHsPatSigType :: HsPatSigTypeScoping -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) @@ -146,32 +146,20 @@ rnHsPatSigType :: HsSigWcTypeScoping rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ - \nwcs imp_tvs body -> - do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } - sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } - ; thing_inside sig_ty' - } } - --- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext - -> LHsType GhcPs - -> ([Name] -- Wildcard names - -> [Name] -- Implicitly bound type variable names - -> LHsType GhcRn - -> RnM (a, FreeVars)) - -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside - = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) + ; free_vars <- filterInScopeM (extractHsTyRdrTyVars pat_sig_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' - ; implicit_bndrs <- case scoping of - AlwaysBind -> pure tv_rdrs - NeverBind -> pure [] - ; rnImplicitBndrs Nothing implicit_bndrs $ \ vars -> - do { (wcs, hs_ty', fvs1) <- rnWcBody ctxt nwc_rdrs hs_ty - ; (res, fvs2) <- thing_inside wcs vars hs_ty' + implicit_bndrs = case scoping of + AlwaysBind -> tv_rdrs + NeverBind -> [] + ; rnImplicitBndrs Nothing implicit_bndrs $ \ imp_tvs -> + do { (nwcs, pat_sig_ty', fvs1) <- rnWcBody ctx nwc_rdrs pat_sig_ty + ; let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } + sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = pat_sig_ty' } + ; (res, fvs2) <- thing_inside sig_ty' ; return (res, fvs1 `plusFV` fvs2) } } + where + pat_sig_ty = hsPatSigType sig_ty rnHsWcType :: HsDocContext -> LHsWcType GhcPs -> RnM (LHsWcType GhcRn, FreeVars) rnHsWcType ctxt (HsWC { hswc_body = hs_ty }) ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -1658,7 +1658,6 @@ decideGeneralisationPlan dflags lbinds closed sig_fn = [ null theta | TcIdSig (PartialSig { psig_hs_ty = hs_ty }) <- mapMaybe sig_fn (collectHsBindListBinders lbinds) - -- TODO RGS: What about outer parentheses here? , let (L _ theta, _) = splitLHsQualTy (hsSigWcType hs_ty) ] has_partial_sigs = not (null partial_sig_mrs) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3289,7 +3289,7 @@ When we /must not/ clone There is no need, I think. The payoff here is that avoidng gratuitious cloning means that we can - lmost always take the fast path in swizzleTcTyConBndrs. "Almost + almost always take the fast path in swizzleTcTyConBndrs. "Almost always" means not the case of mutual recursion with polymorphic kinds. When we /must/ clone. @@ -4118,8 +4118,11 @@ promotionErr name err NoDataKindsTC -> text "perhaps you intended to use DataKinds" NoDataKindsDC -> text "perhaps you intended to use DataKinds" PatSynPE -> text "pattern synonyms cannot be promoted" - _ -> text "it is defined and used in the same recursive group" - -- RecDataConPE, ClassPE, TyConPE + RecDataConPE -> same_rec_group_msg + ClassPE -> same_rec_group_msg + TyConPE -> same_rec_group_msg + + same_rec_group_msg = text "it is defined and used in the same recursive group" {- ************************************************************************ ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -338,7 +338,7 @@ So here's the plan (see tcHsSigType): * buildTvImplication: build an implication for the residual, unsolved constraint -* simplifyAndEmitFlatConstraints: try to float out every unsolved equalities +* simplifyAndEmitFlatConstraints: try to float out every unsolved equality inside that implication, in the hope that it constrains only global type variables, not the locally-quantified ones. ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2934,7 +2934,7 @@ without treating the explicitly-quanfitifed ones specially. Wrinkles: variables, so that we get an error from Validity.checkFamPatBinders if a forall'd variable is not bound on the LHS - - We still want to complain about an bad telescope among the user-specified + - We still want to complain about a bad telescope among the user-specified variables. So in checkFamTelescope we emit an implication constraint quantifying only over them, purely so that we get a good telescope error. @@ -3300,7 +3300,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) } - ; (outer_tv_bndrs :: [TcInvisTVBinder]) <- scopedSortOuter outer_bndrs + ; outer_tv_bndrs <- scopedSortOuter outer_bndrs ; tkvs <- kindGeneralizeAll (mkInvisForAllTys outer_tv_bndrs $ mkPhiTy ctxt $ ===================================== testsuite/tests/polykinds/T16762c.hs ===================================== @@ -8,4 +8,3 @@ data SameKind :: k -> k -> Type -- Bad telescope data T = forall a k (b::k). MkT (SameKind a b) - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af060b335c35f796ae9d6cea3604123d44f4e0e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af060b335c35f796ae9d6cea3604123d44f4e0e4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 14:54:24 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 23 Oct 2020 10:54:24 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-11342-char-kind Message-ID: <5f92eea01d9b2_8973fa3d9a2092498034@gitlab.haskell.org.mail> Danya Rogozin pushed new branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-11342-char-kind You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 15:24:22 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 23 Oct 2020 11:24:22 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f92f5a6c0cd3_8973fa3d99872b01149dd@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 80a72ca5 by Daniel Rogozin at 2020-10-23T18:23:55+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitmodules - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/ghc-prim/GHC/Types.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80a72ca5a79212798c5725afc6a68e6b6d355fe9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/80a72ca5a79212798c5725afc6a68e6b6d355fe9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 15:27:37 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 23 Oct 2020 11:27:37 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] [aarch64/elf] fixup elf symbols Message-ID: <5f92f6697d9a8_897a14ec40115135@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 0ed74a26 by Moritz Angermann at 2020-10-23T23:27:17+08:00 [aarch64/elf] fixup elf symbols - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -546,21 +546,21 @@ pprInstr platform instr = case instr of text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. LDR _f o1 (OpImm (ImmIndex lbl off)) -> - text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl <> text "@page" $$ - text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> ppr lbl <> text "@pageoff" $$ + text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ + text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> test ":lo12:" <> ppr lbl $$ text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> ppr lbl <> text "@gotpageoff" <> text "]" + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" ppr lbl $$ + text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text ":got_lo12:" <> ppr lbl <> text "]" LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl <> text "@gotpage" $$ - text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> ppr lbl <> text "@gotpageoff" <> text "]" + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" ppr lbl $$ + text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text ":got_lo12:" <> ppr lbl <> text "]" LDR _f o1 (OpImm (ImmCLbl lbl)) -> - text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl <> text "@page" $$ - text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> ppr lbl <> text "@pageoff" + text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ + text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl #endif LDR _f o1@(OpReg W8 (RegReal (RealRegSingle i))) o2 | i < 32 -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ed74a2621004cd54473b4737de4c6c51037a11f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0ed74a2621004cd54473b4737de4c6c51037a11f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 15:29:54 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 23 Oct 2020 11:29:54 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] :facepalm: Message-ID: <5f92f6f23a8d3_8973fa3d9e6bd941166a7@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 217633b4 by Moritz Angermann at 2020-10-23T23:29:29+08:00 :facepalm: - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -547,7 +547,7 @@ pprInstr platform instr = case instr of LDR _f o1 (OpImm (ImmIndex lbl off)) -> text "\tadrp" <+> pprOp o1 <> comma <+> ppr lbl $$ - text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> test ":lo12:" <> ppr lbl $$ + text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> text ":lo12:" <> ppr lbl $$ text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/217633b4926b024bae3c67104fd76f185480194e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/217633b4926b024bae3c67104fd76f185480194e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 15:32:21 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Fri, 23 Oct 2020 11:32:21 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] :facepalm: Message-ID: <5f92f7852f0ec_8973fa3d8ca23381207c2@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 0f47da63 by Moritz Angermann at 2020-10-23T23:32:00+08:00 :facepalm: - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/Ppr.hs ===================================== @@ -551,11 +551,11 @@ pprInstr platform instr = case instr of text "\tadd" <+> pprOp o1 <> comma <+> pprOp o1 <> comma <+> char '#' <> int off -- XXX: check that off is in 12bits. LDR _f o1 (OpImm (ImmCLbl lbl')) | Just (_info, lbl) <- dynamicLinkerLabelInfo lbl' -> - text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" ppr lbl $$ + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" <> ppr lbl $$ text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text ":got_lo12:" <> ppr lbl <> text "]" LDR _f o1 (OpImm (ImmCLbl lbl)) | isForeignLabel lbl -> - text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" ppr lbl $$ + text "\tadrp" <+> pprOp o1 <> comma <+> text ":got:" <> ppr lbl $$ text "\tldr" <+> pprOp o1 <> comma <+> text "[" <> pprOp o1 <> comma <+> text ":got_lo12:" <> ppr lbl <> text "]" LDR _f o1 (OpImm (ImmCLbl lbl)) -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f47da637496321c0d0bdf34a34d22093d6c0236 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f47da637496321c0d0bdf34a34d22093d6c0236 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 15:36:48 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Fri, 23 Oct 2020 11:36:48 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f92f8903cb35_8973fa3ba888ef01237b4@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 9f7d0a80 by Daniel Rogozin at 2020-10-23T18:36:22+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitmodules - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f7d0a8028e51a0ce36700ab405780716f7e611f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f7d0a8028e51a0ce36700ab405780716f7e611f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 20:56:44 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Fri, 23 Oct 2020 16:56:44 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] 2 commits: A few error message wibbles Message-ID: <5f93438c6ddce_8973fa3a64c9fa81654e3@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 3b096c57 by Richard Eisenberg at 2020-10-23T16:55:19-04:00 A few error message wibbles - - - - - cdc73a4c by Richard Eisenberg at 2020-10-23T16:56:32-04:00 Fix trailing whitespace to appease linter - - - - - 5 changed files: - testsuite/tests/indexed-types/should_fail/Simple13.hs - testsuite/tests/indexed-types/should_fail/T13784.stderr - testsuite/tests/partial-sigs/should_compile/T14715.stderr - testsuite/tests/typecheck/should_compile/PolytypeDecomp.stderr - testsuite/tests/typecheck/should_compile/T5490.hs Changes: ===================================== testsuite/tests/indexed-types/should_fail/Simple13.hs ===================================== @@ -21,7 +21,7 @@ foo p = same p (mkf p) [G] g : a ~ [F a] [W] w : a ~ [F a] ----> +---> g' = g;[x] g'=aq4 [G] g' : a ~ [fsk] g=aqW [W] x : F a ~ fsk x=aq3 @@ -36,7 +36,7 @@ foo p = same p (mkf p) w = g' ; w2 [W] w2 : [fsk] ~ [F a] - --> decompose + --> decompose w2 = [w3] [W] w3 : fsk ~ F a @@ -44,5 +44,5 @@ foo p = same p (mkf p) cycle is aq3 = Sym (F aq4) ; aq5 x = Sym (F g') ; x2 - aq4 = apw ; aq3 g' = + aq4 = apw ; aq3 g' = -} ===================================== testsuite/tests/indexed-types/should_fail/T13784.stderr ===================================== @@ -15,7 +15,7 @@ T13784.hs:29:28: error: T13784.hs:33:24: error: • Couldn't match type: Product (a : as0) - with: (b, Product (Divide b (a : as))) + with: (b, Product (a : Divide b as)) Expected: (b, Product (Divide b (a : as))) Actual: Product (a1 : as0) • In the expression: a :* divide as ===================================== testsuite/tests/partial-sigs/should_compile/T14715.stderr ===================================== @@ -1,11 +1,11 @@ T14715.hs:13:53: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Reduce (LiftOf zq) zq’ - Where: ‘zq’ is a rigid type variable bound by + • Found type wildcard ‘_’ standing for ‘Reduce z zq’ + Where: ‘z’, ‘zq’ are rigid type variables bound by the inferred type of bench_mulPublic :: (z ~ LiftOf zq, Reduce (LiftOf zq) zq) => Cyc zp -> Cyc z -> IO (zp, zq) - at T14715.hs:13:32-33 + at T14715.hs:13:27-33 • In the type signature: bench_mulPublic :: forall z zp zq. (z ~ LiftOf zq, _) => Cyc zp -> Cyc z -> IO (zp, zq) ===================================== testsuite/tests/typecheck/should_compile/PolytypeDecomp.stderr ===================================== @@ -8,13 +8,3 @@ PolytypeDecomp.hs:30:17: error: • In the expression: x In the first argument of ‘myLength’, namely ‘[x, f]’ In the expression: myLength [x, f] - -PolytypeDecomp.hs:30:19: error: - • Couldn't match type ‘a0’ with ‘[forall a. F [a]]’ - Expected: Id a0 - Actual: [forall a. F [a]] - Cannot instantiate unification variable ‘a0’ - with a type involving polytypes: [forall a. F [a]] - • In the expression: f - In the first argument of ‘myLength’, namely ‘[x, f]’ - In the expression: myLength [x, f] ===================================== testsuite/tests/typecheck/should_compile/T5490.hs ===================================== @@ -16,7 +16,7 @@ import Data.Functor import Control.Exception data Attempt α = Success α - | ∀ e . Exception e ⇒ Failure e + | ∀ e . Exception e ⇒ Failure e fromAttempt ∷ Attempt α → IO α fromAttempt (Success a) = return a @@ -136,7 +136,7 @@ instance IsPeano PZero where peano = PZero instance IsPeano p ⇒ IsPeano (PSucc p) where - peano = PSucc peano + peano = PSucc peano class (n ~ PSucc (PPred n)) ⇒ PHasPred n where type PPred n @@ -297,4 +297,3 @@ hGetIfNth _ _ = Nothing elem0 ∷ HNonEmpty l ⇒ HElemOf l → Maybe (HHead l) elem0 = hGetIfNth PZero - View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd69f2b1ddb2330a25847312964d7f7a939602dd...cdc73a4c3e789c7725e594b7582896301d77f8c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fd69f2b1ddb2330a25847312964d7f7a939602dd...cdc73a4c3e789c7725e594b7582896301d77f8c7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 23:18:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 23 Oct 2020 19:18:57 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/keepAlive-the-return-of-the-primop Message-ID: <5f9364e1b87c4_8973fa3a61440181687b5@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/keepAlive-the-return-of-the-primop at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/keepAlive-the-return-of-the-primop You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 23 23:44:56 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 23 Oct 2020 19:44:56 -0400 Subject: [Git][ghc/ghc][wip/T17917] 715 commits: Enable large address space optimization on windows. Message-ID: <5f936af8cf4bf_8973fa3658e3be817189b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17917 at Glasgow Haskell Compiler / GHC Commits: 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - 7a420271 by Simon Peyton Jones at 2020-10-23T19:44:29-04:00 Avoid useless w/w split This patch is just a tidy-up for the post-strictness-analysis worker wrapper split. Consider f x = x Strictnesss analysis does not lead to a w/w split, so the obvious thing is to leave it 100% alone. But actually, because the RHS is small, we ended up adding a StableUnfolding for it. There is some reason to do this if we choose /not/ do to w/w on the grounds that the function is small. See Note [Don't w/w inline small non-loop-breaker things] But there is no reason if we would not have done w/w anyway. This patch just moves the conditional to later. Easy. This does move soem -ddump-simpl printouts around a bit. I also discovered that the previous code was overwritten an InlineCompulsory with InlineStable, which is utterly wrong. That in turn meant that some default methods (marked InlineCompulsory) were getting their InlineCompulsory squashed. This patch fixes that bug --- but of course that does mean a bit more inlining! Metric Decrease: T9233 T9675 Metric Increase: T12707 T3064 T4029 T9872b T9872d haddock.Cabal - - - - - 23 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/test-metrics.sh - CODEOWNERS - Makefile - README.md - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Uniques.hs-boot - compiler/GHC/Builtin/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e94eaf5afcb6a6ecd77d3f39cae87f85d7d9f1ae...7a420271dc750a4546f80d9ae7acc8716d0a7cbd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e94eaf5afcb6a6ecd77d3f39cae87f85d7d9f1ae...7a420271dc750a4546f80d9ae7acc8716d0a7cbd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 01:02:54 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 23 Oct 2020 21:02:54 -0400 Subject: [Git][ghc/ghc][wip/T17917] Avoid useless w/w split Message-ID: <5f937d3e91d43_8973fa3a77c536417473e@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17917 at Glasgow Haskell Compiler / GHC Commits: 1d32f1f2 by Simon Peyton Jones at 2020-10-24T01:02:03+00:00 Avoid useless w/w split This patch is just a tidy-up for the post-strictness-analysis worker wrapper split. Consider f x = x Strictnesss analysis does not lead to a w/w split, so the obvious thing is to leave it 100% alone. But actually, because the RHS is small, we ended up adding a StableUnfolding for it. There is some reason to do this if we choose /not/ do to w/w on the grounds that the function is small. See Note [Don't w/w inline small non-loop-breaker things] But there is no reason if we would not have done w/w anyway. This patch just moves the conditional to later. Easy. This does move soem -ddump-simpl printouts around a bit. I also discovered that the previous code was overwritten an InlineCompulsory with InlineStable, which is utterly wrong. That in turn meant that some default methods (marked InlineCompulsory) were getting their InlineCompulsory squashed. This patch fixes that bug --- but of course that does mean a bit more inlining! Metric Decrease: T9233 T9675 Metric Increase: T12707 T3064 T4029 T9872b T9872d haddock.Cabal - - - - - 3 changed files: - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Unfold.hs - testsuite/tests/dependent/should_compile/dynamic-paper.stderr Changes: ===================================== compiler/GHC/Core/Opt/WorkWrap.hs ===================================== @@ -29,6 +29,7 @@ import GHC.Types.Cpr import GHC.Core.Opt.WorkWrap.Utils import GHC.Utils.Misc import GHC.Utils.Outputable +import GHC.Types.Unique import GHC.Utils.Panic import GHC.Core.FamInstEnv import GHC.Utils.Monad @@ -207,6 +208,23 @@ unfolding to the *worker*. So we will get something like this: How do we "transfer the unfolding"? Easy: by using the old one, wrapped in work_fn! See GHC.Core.Unfold.mkWorkerUnfolding. +Note [No worker-wrapper for record selectors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We sometimes generate a lot of record selectors, and generally the +don't benefit from worker/wrapper. Yes, mkWwBodies would find a w/w split, +but it is then suppressed by the certainlyWillInline test in splitFun. + +The wasted effort in mkWwBodies makes a measurable difference in +compile time (see MR !2873), so although it's a terribly ad-hoc test, +we just check here for record selectors, and do a no-op in that case. + +I did look for a generalisation, so that it's not just record +selectors that benefit. But you'd need a cheap test for "this +function will definitely get a w/w split" and that's hard to predict +in advance...the logic in mkWwBodies is complex. So I've left the +super-simple test, with this Note to explain. + + Note [Worker-wrapper for NOINLINE functions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We used to disable worker/wrapper for NOINLINE things, but it turns out @@ -320,8 +338,8 @@ Note [Don't w/w inline small non-loop-breaker things] In general, we refrain from w/w-ing *small* functions, which are not loop breakers, because they'll inline anyway. But we must take care: it may look small now, but get to be big later after other inlining -has happened. So we take the precaution of adding an INLINE pragma to -any such functions. +has happened. So we take the precaution of adding a StableUnfolding +for any such functions. I made this change when I observed a big function at the end of compilation with a useful strictness signature but no w-w. (It was @@ -586,93 +604,114 @@ See https://gitlab.haskell.org/ghc/ghc/merge_requests/312#note_192064. splitFun :: DynFlags -> FamInstEnvs -> Id -> IdInfo -> [Demand] -> Divergence -> CprResult -> CoreExpr -> UniqSM [(Id, CoreExpr)] splitFun dflags fam_envs fn_id fn_info wrap_dmds div cpr rhs - = WARN( not (wrap_dmds `lengthIs` arity), ppr fn_id <+> (ppr arity $$ ppr wrap_dmds $$ ppr cpr) ) do - -- The arity should match the signature - stuff <- mkWwBodies dflags fam_envs rhs_fvs fn_id wrap_dmds use_cpr_info - case stuff of - Just (work_demands, join_arity, wrap_fn, work_fn) -> do - work_uniq <- getUniqueM - let work_rhs = work_fn rhs - work_act = case fn_inline_spec of -- See Note [Worker activation] - NoInline -> inl_act fn_inl_prag - _ -> inl_act wrap_prag - - work_prag = InlinePragma { inl_src = SourceText "{-# INLINE" - , inl_inline = fn_inline_spec - , inl_sat = Nothing - , inl_act = work_act - , inl_rule = FunLike } - -- inl_inline: copy from fn_id; see Note [Worker-wrapper for INLINABLE functions] - -- inl_act: see Note [Worker activation] - -- inl_rule: it does not make sense for workers to be constructorlike. - - work_join_arity | isJoinId fn_id = Just join_arity - | otherwise = Nothing - -- worker is join point iff wrapper is join point - -- (see Note [Don't w/w join points for CPR]) - - simpl_opts = initSimpleOpts dflags - - work_id = mkWorkerId work_uniq fn_id (exprType work_rhs) - `setIdOccInfo` occInfo fn_info - -- Copy over occurrence info from parent - -- Notably whether it's a loop breaker - -- Doesn't matter much, since we will simplify next, but - -- seems right-er to do so - - `setInlinePragma` work_prag - - `setIdUnfolding` mkWorkerUnfolding simpl_opts work_fn fn_unfolding - -- See Note [Worker-wrapper for INLINABLE functions] - - `setIdStrictness` mkClosedStrictSig work_demands div - -- Even though we may not be at top level, - -- it's ok to give it an empty DmdEnv - - `setIdCprInfo` mkCprSig work_arity work_cpr_info - - `setIdDemandInfo` worker_demand - - `setIdArity` work_arity - -- Set the arity so that the Core Lint check that the - -- arity is consistent with the demand type goes - -- through - `asJoinId_maybe` work_join_arity - - work_arity = length work_demands - - -- See Note [Demand on the Worker] - single_call = saturatedByOneShots arity (demandInfo fn_info) - worker_demand | single_call = mkWorkerDemand work_arity - | otherwise = topDmd - - wrap_rhs = wrap_fn work_id - wrap_prag = mkStrWrapperInlinePrag fn_inl_prag - wrap_id = fn_id `setIdUnfolding` mkWwInlineRule simpl_opts wrap_rhs arity - `setInlinePragma` wrap_prag - `setIdOccInfo` noOccInfo - -- Zap any loop-breaker-ness, to avoid bleating from Lint - -- about a loop breaker with an INLINE rule - - - - return $ [(work_id, work_rhs), (wrap_id, wrap_rhs)] - -- Worker first, because wrapper mentions it - - Nothing -> return [(fn_id, rhs)] + | isRecordSelector fn_id -- See Note [No worker/wrapper for record selectors] + = return [ (fn_id, rhs ) ] + + | otherwise + = WARN( not (wrap_dmds `lengthIs` arity), ppr fn_id <+> (ppr arity $$ ppr wrap_dmds $$ ppr cpr) ) + -- The arity should match the signature + do { mb_stuff <- mkWwBodies dflags fam_envs rhs_fvs fn_id wrap_dmds use_cpr_info + ; case mb_stuff of + Nothing -> return [(fn_id, rhs)] + + Just stuff + | Just stable_unf <- certainlyWillInline (unfoldingOpts dflags) fn_info + -> return [ (fn_id `setIdUnfolding` stable_unf, rhs) ] + -- See Note [Don't w/w INLINE things] + -- See Note [Don't w/w inline small non-loop-breaker things] + + | otherwise + -> do { work_uniq <- getUniqueM + ; return (mkWWBindPair dflags fn_id fn_info arity rhs + work_uniq div cpr stuff) } } where - rhs_fvs = exprFreeVars rhs - fn_inl_prag = inlinePragInfo fn_info - fn_inline_spec = inl_inline fn_inl_prag - fn_unfolding = unfoldingInfo fn_info - arity = arityInfo fn_info - -- The arity is set by the simplifier using exprEtaExpandArity - -- So it may be more than the number of top-level-visible lambdas + rhs_fvs = exprFreeVars rhs + arity = arityInfo fn_info + -- The arity is set by the simplifier using exprEtaExpandArity + -- So it may be more than the number of top-level-visible lambdas -- use_cpr_info is the CPR we w/w for. Note that we kill it for join points, -- see Note [Don't w/w join points for CPR]. use_cpr_info | isJoinId fn_id = topCpr | otherwise = cpr + + +mkWWBindPair :: DynFlags -> Id -> IdInfo -> Arity + -> CoreExpr -> Unique -> Divergence -> CprResult + -> ([Demand], JoinArity, Id -> CoreExpr, Expr CoreBndr -> CoreExpr) + -> [(Id, CoreExpr)] +mkWWBindPair dflags fn_id fn_info arity rhs work_uniq div cpr + (work_demands, join_arity, wrap_fn, work_fn) + = [(work_id, work_rhs), (wrap_id, wrap_rhs)] + -- Worker first, because wrapper mentions it + where + simpl_opts = initSimpleOpts dflags + + work_rhs = work_fn rhs + work_act = case fn_inline_spec of -- See Note [Worker activation] + NoInline -> inl_act fn_inl_prag + _ -> inl_act wrap_prag + + work_prag = InlinePragma { inl_src = SourceText "{-# INLINE" + , inl_inline = fn_inline_spec + , inl_sat = Nothing + , inl_act = work_act + , inl_rule = FunLike } + -- inl_inline: copy from fn_id; see Note [Worker-wrapper for INLINABLE functions] + -- inl_act: see Note [Worker activation] + -- inl_rule: it does not make sense for workers to be constructorlike. + + work_join_arity | isJoinId fn_id = Just join_arity + | otherwise = Nothing + -- worker is join point iff wrapper is join point + -- (see Note [Don't w/w join points for CPR]) + + work_id = mkWorkerId work_uniq fn_id (exprType work_rhs) + `setIdOccInfo` occInfo fn_info + -- Copy over occurrence info from parent + -- Notably whether it's a loop breaker + -- Doesn't matter much, since we will simplify next, but + -- seems right-er to do so + + `setInlinePragma` work_prag + + `setIdUnfolding` mkWorkerUnfolding simpl_opts work_fn fn_unfolding + -- See Note [Worker-wrapper for INLINABLE functions] + + `setIdStrictness` mkClosedStrictSig work_demands div + -- Even though we may not be at top level, + -- it's ok to give it an empty DmdEnv + + `setIdCprInfo` mkCprSig work_arity work_cpr_info + + `setIdDemandInfo` worker_demand + + `setIdArity` work_arity + -- Set the arity so that the Core Lint check that the + -- arity is consistent with the demand type goes + -- through + `asJoinId_maybe` work_join_arity + + work_arity = length work_demands + + -- See Note [Demand on the Worker] + single_call = saturatedByOneShots arity (demandInfo fn_info) + worker_demand | single_call = mkWorkerDemand work_arity + | otherwise = topDmd + + wrap_rhs = wrap_fn work_id + wrap_prag = mkStrWrapperInlinePrag fn_inl_prag + + wrap_id = fn_id `setIdUnfolding` mkWwInlineRule simpl_opts wrap_rhs arity + `setInlinePragma` wrap_prag + `setIdOccInfo` noOccInfo + -- Zap any loop-breaker-ness, to avoid bleating from Lint + -- about a loop breaker with an INLINE rule + + fn_inl_prag = inlinePragInfo fn_info + fn_inline_spec = inl_inline fn_inl_prag + fn_unfolding = unfoldingInfo fn_info + -- Even if we don't w/w join points for CPR, we might still do so for -- strictness. In which case a join point worker keeps its original CPR -- property; see Note [Don't w/w join points for CPR]. Otherwise, the worker @@ -680,7 +719,6 @@ splitFun dflags fam_envs fn_id fn_info wrap_dmds div cpr rhs work_cpr_info | isJoinId fn_id = cpr | otherwise = topCpr - mkStrWrapperInlinePrag :: InlinePragma -> InlinePragma mkStrWrapperInlinePrag (InlinePragma { inl_act = act, inl_rule = rule_info }) = InlinePragma { inl_src = SourceText "{-# INLINE" ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -936,11 +936,21 @@ certainlyWillInline :: UnfoldingOpts -> IdInfo -> Maybe Unfolding -- ^ Sees if the unfolding is pretty certain to inline. -- If so, return a *stable* unfolding for it, that will always inline. certainlyWillInline opts fn_info - = case unfoldingInfo fn_info of - CoreUnfolding { uf_tmpl = e, uf_guidance = g } - | loop_breaker -> Nothing -- Won't inline, so try w/w - | noinline -> Nothing -- See Note [Worker-wrapper for NOINLINE functions] - | otherwise -> do_cunf e g -- Depends on size, so look at that + = case fn_unf of + CoreUnfolding { uf_tmpl = expr, uf_guidance = guidance, uf_src = src } + | loop_breaker -> Nothing -- Won't inline, so try w/w + | noinline -> Nothing -- See Note [Worker-wrapper for NOINLINE functions] + | otherwise + -> case guidance of + UnfNever -> Nothing + UnfWhen {} -> Just (fn_unf { uf_src = src' }) + -- INLINE functions have UnfWhen + UnfIfGoodArgs { ug_size = size, ug_args = args } + -> do_cunf expr size args src' + where + src' = case src of + InlineRhs -> InlineStable + _ -> src -- Do not change InlineCompulsory! DFunUnfolding {} -> Just fn_unf -- Don't w/w DFuns; it never makes sense -- to do so, and even if it is currently a @@ -953,17 +963,12 @@ certainlyWillInline opts fn_info noinline = inlinePragmaSpec (inlinePragInfo fn_info) == NoInline fn_unf = unfoldingInfo fn_info - do_cunf :: CoreExpr -> UnfoldingGuidance -> Maybe Unfolding - do_cunf _ UnfNever = Nothing - do_cunf _ (UnfWhen {}) = Just (fn_unf { uf_src = InlineStable }) - -- INLINE functions have UnfWhen - -- The UnfIfGoodArgs case seems important. If we w/w small functions -- binary sizes go up by 10%! (This is with SplitObjs.) -- I'm not totally sure why. -- INLINABLE functions come via this path -- See Note [certainlyWillInline: INLINABLE] - do_cunf expr (UnfIfGoodArgs { ug_size = size, ug_args = args }) + do_cunf expr size args src' | arityInfo fn_info > 0 -- See Note [certainlyWillInline: be careful of thunks] , not (isDeadEndSig (strictnessInfo fn_info)) -- Do not unconditionally inline a bottoming functions even if @@ -971,7 +976,7 @@ certainlyWillInline opts fn_info -- so we don't want to re-inline it. , let unf_arity = length args , size - (10 * (unf_arity + 1)) <= unfoldingUseThreshold opts - = Just (fn_unf { uf_src = InlineStable + = Just (fn_unf { uf_src = src' , uf_guidance = UnfWhen { ug_arity = unf_arity , ug_unsat_ok = unSaturatedOk , ug_boring_ok = inlineBoringOk expr } }) ===================================== testsuite/tests/dependent/should_compile/dynamic-paper.stderr ===================================== @@ -12,4 +12,4 @@ Simplifier ticks exhausted simplifier non-termination has been judged acceptable. To see detailed counts use -ddump-simpl-stats - Total ticks: 136961 + Total ticks: 157325 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d32f1f2903ac81202919addd2023814b4de5f44 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1d32f1f2903ac81202919addd2023814b4de5f44 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 01:28:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 23 Oct 2020 21:28:49 -0400 Subject: [Git][ghc/ghc][wip/tsan/ci] gitlab-ci: Disable documentation in TSAN build Message-ID: <5f938351e95b2_8973fa3b812974c17702b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/ci at Glasgow Haskell Compiler / GHC Commits: ea1f9ea2 by Ben Gamari at 2020-10-23T21:28:06-04:00 gitlab-ci: Disable documentation in TSAN build Haddock chews through enough memory to cause the CI builders to OOM and there's frankly no reason to build documentation in this job anyways. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -642,6 +642,9 @@ nightly-x86_64-linux-deb9-integer-simple: TEST_ENV: "x86_64-linux-deb9-tsan" BUILD_FLAVOUR: "thread-sanitizer" TSAN_OPTIONS: "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + # Haddock is large enough to make TSAN choke without massive quantities of + # memory. + HADRIAN_ARGS: "--docs=none" nightly-x86_64-linux-deb9-tsan: <<: *nightly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea1f9ea25937639d642d40975ae2371cd6d012b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ea1f9ea25937639d642d40975ae2371cd6d012b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 01:29:06 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 23 Oct 2020 21:29:06 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 2 commits: gitlab-ci: Disable documentation in TSAN build Message-ID: <5f938362861c9_897a48592c17764@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: ea1f9ea2 by Ben Gamari at 2020-10-23T21:28:06-04:00 gitlab-ci: Disable documentation in TSAN build Haddock chews through enough memory to cause the CI builders to OOM and there's frankly no reason to build documentation in this job anyways. - - - - - 47c904e9 by Ben Gamari at 2020-10-23T21:29:00-04:00 Merge branch 'wip/tsan/ci' into wip/tsan/all - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -642,6 +642,9 @@ nightly-x86_64-linux-deb9-integer-simple: TEST_ENV: "x86_64-linux-deb9-tsan" BUILD_FLAVOUR: "thread-sanitizer" TSAN_OPTIONS: "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions" + # Haddock is large enough to make TSAN choke without massive quantities of + # memory. + HADRIAN_ARGS: "--docs=none" nightly-x86_64-linux-deb9-tsan: <<: *nightly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/51a5d3ae25416dec609743ff491514ba2d7753cb...47c904e9946951d43f9950acef35c1f16d890bf5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/51a5d3ae25416dec609743ff491514ba2d7753cb...47c904e9946951d43f9950acef35c1f16d890bf5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 12:00:12 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sat, 24 Oct 2020 08:00:12 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] More stuff Message-ID: <5f94174ca90cb_8971007096c1863a0@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: ff1d9fba by Sebastian Graf at 2020-10-24T14:00:02+02:00 More stuff - - - - - 1 changed file: - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -21,7 +21,7 @@ module GHC.Types.Demand ( lubDmd, bothDmd, lazyApply1Dmd, lazyApply2Dmd, strictApply1Dmd, isTopDmd, isAbsDmd, isSeqDmd, - peelUseCall, cleanUseDmd_maybe, strictenDmd, bothCleanDmd, + peelUseCall, strictenDmd, bothCleanDmd, addCaseBndrDmd, DmdType(..), dmdTypeDepth, lubDmdType, bothDmdType, @@ -46,12 +46,12 @@ module GHC.Types.Demand ( splitDmdTy, splitFVs, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, - splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, + peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, mkWorkerDemand, dmdTransformSig, dmdTransformDataConSig, dmdTransformDictSelSig, argOneShots, argsOneShots, saturatedByOneShots, TypeShape(..), trimToType, - useCount, isUsedOnce, reuseEnv, + isUsedOnce, reuseEnv, zapUsageDemand, zapUsageEnvSig, zapUsedOnceDemand, zapUsedOnceSig, strictifyDictDmd, strictifyDmd @@ -234,14 +234,10 @@ mkSCall s = SCall s mkSProd :: [ArgStr] -> StrDmd mkSProd sx - | any isHyperStr sx = HyperStr + | any isHyperStr sx = HyperStr -- ??? Why any? | all isLazy sx = HeadStr | otherwise = SProd sx -isLazy :: ArgStr -> Bool -isLazy Lazy = True -isLazy (Str {}) = False - isHyperStr :: ArgStr -> Bool isHyperStr (Str HyperStr) = True isHyperStr _ = False @@ -478,15 +474,11 @@ addCaseBndrDmd :: Demand -- On the case binder -> [Demand] -- On the components of the constructor -> [Demand] -- Final demands for the components of the constructor -- See Note [Demand on case-alternative binders] -addCaseBndrDmd (JD { sd = ms, ud = mu }) alt_dmds - = case mu of - Abs -> alt_dmds - Use _ u -> zipWith bothDmd alt_dmds (mkJointDmds ss us) - where - Just ss = splitArgStrProdDmd arity ms -- Guaranteed not to be a call - Just us = splitUseProdDmd arity u -- Ditto +addCaseBndrDmd dmd@(_ :* cd) alt_dmds + | isAbsDmd dmd = alt_dmds + | otherwise = zipWith bothDmd alt_dmds ds where - arity = length alt_dmds + Just ds = viewProd (length alt_dmds) cd -- Guaranteed not to be a call {- Note [Demand on case-alternative binders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -565,45 +557,6 @@ Compare with: (C) making Used win for both, but UProd win for lub Geometric Mean +0.0% +0.0% -0.0% -0.1% -0.1% -} --- If a demand is used multiple times (i.e. reused), than any use-once --- mentioned there, that is not protected by a UCall, can happen many times. -markReusedDmd :: ArgUse -> ArgUse -markReusedDmd Abs = Abs -markReusedDmd (Use _ a) = Use Many (markReused a) - -markReused :: UseDmd -> UseDmd -markReused (UCall _ u) = UCall Many u -- No need to recurse here -markReused (UProd ux) = UProd (map markReusedDmd ux) -markReused u = u - -isUsedMU :: ArgUse -> Bool --- True <=> markReusedDmd d = d -isUsedMU Abs = True -isUsedMU (Use One _) = False -isUsedMU (Use Many u) = isUsedU u - -isUsedU :: UseDmd -> Bool --- True <=> markReused d = d -isUsedU Used = True -isUsedU UHead = True -isUsedU (UProd us) = all isUsedMU us -isUsedU (UCall One _) = False -isUsedU (UCall Many _) = True -- No need to recurse - --- Squashing usage demand demands -seqUseDmd :: UseDmd -> () -seqUseDmd (UProd ds) = seqArgUseList ds -seqUseDmd (UCall c d) = c `seq` seqUseDmd d -seqUseDmd _ = () - -seqArgUseList :: [ArgUse] -> () -seqArgUseList [] = () -seqArgUseList (d:ds) = seqArgUse d `seq` seqArgUseList ds - -seqArgUse :: ArgUse -> () -seqArgUse (Use c u) = c `seq` seqUseDmd u -seqArgUse _ = () - -- Splitting polymorphic Maybe-Used demands splitUseProdDmd :: Int -> UseDmd -> Maybe [ArgUse] splitUseProdDmd n Used = Just (replicate n useTop) @@ -616,12 +569,6 @@ splitUseProdDmd _ (UCall _ _) = Nothing -- This can happen when the programmer uses unsafeCoerce, -- and we don't then want to crash the compiler (#9208) -useCount :: Use u -> Count -useCount Abs = One -useCount (Use One _) = One -useCount _ = Many - - {- ************************************************************************ * * @@ -663,30 +610,17 @@ f g = (snd (g 3), True) should be: m -} -bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand -bothCleanDmd (JD { sd = s1, ud = a1}) (JD { sd = s2, ud = a2}) - = JD { sd = s1 `bothStr` s2, ud = a1 `bothUse` a2 } - -mkHeadStrict :: CleanDemand -> CleanDemand -mkHeadStrict cd = cd { sd = HeadStr } - mkOnceUsedDmd, mkManyUsedDmd :: CleanDemand -> Demand -mkOnceUsedDmd (JD {sd = s,ud = a}) = JD { sd = Str s, ud = Use One a } -mkManyUsedDmd (JD {sd = s,ud = a}) = JD { sd = Str s, ud = Use Many a } +mkOnceUsedDmd cd = C_11 :* cd +mkManyUsedDmd cd = C_1N :* cd evalDmd :: Demand -- Evaluated strictly, and used arbitrarily deeply -evalDmd = JD { sd = Str HeadStr, ud = useTop } - -mkProdDmd :: [Demand] -> CleanDemand -mkProdDmd dx - = JD { sd = mkSProd $ map getStrDmd dx - , ud = mkUProd $ map getUseDmd dx } +evalDmd = C_1N :* topCleanDmd -- | Wraps the 'CleanDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCallDmd :: CleanDemand -> CleanDemand -mkCallDmd (JD {sd = d, ud = u}) - = JD { sd = mkSCall d, ud = mkUCall One u } +mkCallDmd cd = Call C_11 cd -- | @mkCallDmds n d@ returns @C1(C1...(C1 d))@ where there are @n@ @C1@'s. mkCallDmds :: Arity -> CleanDemand -> CleanDemand @@ -694,16 +628,15 @@ mkCallDmds arity cd = iterate mkCallDmd cd !! arity -- See Note [Demand on the worker] in GHC.Core.Opt.WorkWrap mkWorkerDemand :: Int -> Demand -mkWorkerDemand n = JD { sd = Lazy, ud = Use One (go n) } - where go 0 = Used - go n = mkUCall One $ go (n-1) +mkWorkerDemand n = C_01 :* go n + where go 0 = topCleanDmd + go n = Call C_01 $ go (n-1) cleanEvalDmd :: CleanDemand -cleanEvalDmd = JD { sd = HeadStr, ud = Used } +cleanEvalDmd = topCleanDmd cleanEvalProdDmd :: Arity -> CleanDemand -cleanEvalProdDmd n = JD { sd = HeadStr, ud = UProd (replicate n useTop) } - +cleanEvalProdDmd n = Prod (replicate n topDmd) {- ************************************************************************ @@ -756,6 +689,25 @@ lubCard _ C_01 = C_01 -- {0} ∪ {0,1} = {0,1} -- Handle C_00 lubCard C_00 C_00 = C_00 -- reflexivity +-- | Denotes '+' on 'Card'. +bothCard :: Card -> Card -> Card +-- Handle C_00 +bothCard C_00 n = n -- {0}+n = n +bothCard n C_00 = n -- {0}+n = n +-- Handle C_10 +bothCard C_10 C_01 = C_11 -- These follow by applying + to lower and upper +bothCard C_10 C_0N = C_1N -- bounds individually +bothCard C_10 n = n +bothCard C_01 C_10 = C_11 +bothCard C_0N C_10 = C_1N +bothCard n C_10 = n +-- Handle the rest (C_01, C_0N, C_11, C_1N) +bothCard C_01 C_01 = C_0N -- The upper bound is at least 1, so upper bound of +bothCard C_01 C_0N = C_0N -- the result must be 1+1 ~= N. +bothCard C_0N C_01 = C_0N -- But for the lower bound we have 4 cases where +bothCard C_0N C_0N = C_0N -- 0+0 ~= 0 (as opposed to 1), so we match on these. +bothCard _ _ = C_1N -- Otherwise we return topCard + -- It's similar to @'Scaled' 'CleanDemand'@, but it's scaled by 'Card', which -- is an interval on 'Multiplicity'. data Demand = !Card :* !CleanDemand @@ -775,7 +727,8 @@ data CleanDemand deriving ( Eq, Show ) -poly00, poly01, poly0N, poly11, poly1N, poly10, topCleanDmd, botCleanDmd :: CleanDemand +poly00, poly01, poly0N, poly11, poly1N, poly10 :: CleanDemand +topCleanDmd, botCleanDmd, seqCleanDmd :: CleanDemand poly00 = Poly C_00 poly01 = Poly C_01 poly0N = Poly C_0N @@ -784,6 +737,7 @@ poly1N = Poly C_1N poly10 = Poly C_10 topCleanDmd = poly0N botCleanDmd = poly10 +seqCleanDmd = poly00 polyDmd :: Card -> Demand polyDmd C_00 = C_00 :* poly00 @@ -801,11 +755,18 @@ polyCleanDmd C_11 = poly11 polyCleanDmd C_1N = poly1N polyCleanDmd C_10 = poly10 - -topDmd, absDmd, botDmd :: Demand +topDmd, absDmd, botDmd, seqDmd :: Demand +strictApply1Dmd, lazyApply1Dmd, lazyApply2Dmd :: Demand topDmd = polyDmd C_0N -absDmd = polyDmd C_00 +absDmd = polyDmd C_01 botDmd = polyDmd C_10 +seqDmd = C_11 :* seqCleanDmd +strictApply1Dmd = C_1N :* Call C_1N topCleanDmd +lazyApply1Dmd = C_01 :* Call C_01 topCleanDmd +-- | Second argument of catch#: +-- uses its arg at most once, applies it once +-- but is lazy (might not be called at all) +lazyApply2Dmd = C_01 :* Call C_01 (Call C_01 topCleanDmd) viewProd :: Arity -> CleanDemand -> Maybe [Demand] viewProd n (Prod ds) | ds `lengthIs` n = Just ds @@ -820,7 +781,7 @@ viewCall _ = Nothing lubCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand -- Handle Prod lubCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = - Prod $ zipWith lubDmd ds1 ds2 + Prod $ zipWith lubDmd ds1 ds2 -- TODO: What about Note [Used should win]? -- Handle Call lubCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = Call (lubCard n1 n2) (lubCleanDmd d1 d2) @@ -834,119 +795,162 @@ lubCleanDmd _ _ = topCleanDmd lubDmd :: Demand -> Demand -> Demand lubDmd (n1 :* cd1) (n2 :* cd2) = lubCard n1 n2 :* lubCleanDmd cd1 cd2 --- | Denotes '+' on 'Card'. -bothCard :: Card -> Card -> Card --- Handle C_00 -bothCard C_00 n = n -- {0}+n = n -bothCard n C_00 = n -- {0}+n = n --- Handle C_10 -bothCard C_10 C_01 = C_11 -- These follow by applying + to lower and upper bounds individually -bothCard C_10 C_0N = C_1N -bothCard C_10 n = n -bothCard C_01 C_10 = C_11 -bothCard C_0N C_10 = C_1N -bothCard n C_10 = n --- Handle the rest (C_01, C_0N, C_11, C_1N) -bothCard C_01 C_01 = C_0N -- The upper bound is at least 1, so upper bound of -bothCard C_01 C_0N = C_0N -- the result must be 1+1 ~= N. -bothCard C_0N C_01 = C_0N -- But for the lower bound we have 4 cases where -bothCard C_0N C_0N = C_0N -- 0+0 ~= 0 (as opposed to 1), so we match on these. -bothCard _ _ = C_1N -- Otherwise we return topCard - bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand --- Handle HeadDmd -bothCleanDmd HeadDmd cd = cd -bothCleanDmd cd HeadDmd = cd -- Handle Prod bothCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = Prod $ zipWith bothDmd ds1 ds2 -- Handle Call +-- TODO: Exciting special treatment of inner demand for call demands: +-- use `lubUse` instead of `bothUse`! bothCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = - Call (bothCard n1 n2) (bothCleanDmd d1 d2) --- Handle TopDmd. Do not move before Prod, because we want to handle TopDmd through viewProd. -bothCleanDmd BotDmd BotDmd = BotDmd -bothCleanDmd TopDmd BotDmd = BotDmd -bothCleanDmd TopDmd _ = TopDmd -bothCleanDmd _ TopDmd = TopDmd --- A dead catch-all -bothCleanDmd cd1 cd2 = pprPanic "bothCleanDmd: impossible" (ppr cd1 <+> ppr cd2) - -bothDmd :: Demand -> Demand -> Demand -bothDmd Absent dmd = dmd -bothDmd dmd Absent = dmd -bothDmd (n1 :* cd1) (n2 :* cd2) = bothCard n1 n2 :* bothCleanDmd cd1 cd2 - -lazyApply1Dmd, lazyApply2Dmd, strictApply1Dmd :: Demand - -strictApply1Dmd = JD { sd = Str (SCall HeadStr) - , ud = Use Many (UCall One Used) } - -lazyApply1Dmd = JD { sd = Lazy - , ud = Use One (UCall One Used) } - --- Second argument of catch#: --- uses its arg at most once, applies it once --- but is lazy (might not be called at all) -lazyApply2Dmd = JD { sd = Lazy - , ud = Use One (UCall One (UCall One Used)) } - -absDmd :: Demand -absDmd = JD { sd = Lazy, ud = Abs } - -topDmd :: Demand -topDmd = JD { sd = Lazy, ud = useTop } - -botDmd :: Demand -botDmd = JD { sd = strBot, ud = useBot } + Call (bothCard n1 n2) (lubCleanDmd d1 d2) +-- Handle Poly +bothCleanDmd (Poly n1) (Poly n2) = Poly (bothCard n1 n2) +-- Make use of reflexivity (so we'll match the Prod or Call cases again). +bothCleanDmd cd1 at Poly{} cd2 = bothCleanDmd cd2 cd1 +-- Otherwise (Call `lub` Prod) return Top +bothCleanDmd _ _ = topCleanDmd -seqDmd :: Demand -seqDmd = JD { sd = Str HeadStr, ud = Use One UHead } +bothDmd :: Demand -> Demand +bothDmd (n1 :* cd1) (n2 :* cd2) = bothCard n1 n2 :* bothCleanDmd cd1 cd2 -oneifyDmd :: JointDmd s (Use u) -> JointDmd s (Use u) -oneifyDmd (JD { sd = s, ud = Use _ a }) = JD { sd = s, ud = Use One a } -oneifyDmd jd = jd +oneifyDmd :: Demand -> Demand +oneifyDmd (C_0N :* cd) = C_01 :* cd +oneifyDmd (C_1N :* cd) = C_11 :* cd +oneifyDmd dmd = dmd isTopDmd :: Demand -> Bool --- Used to suppress pretty-printing of an uninformative demand -isTopDmd (JD {sd = Lazy, ud = Use Many Used}) = True -isTopDmd _ = False +-- ^ Used to suppress pretty-printing of an uninformative demand +isTopDmd dmd = dmd == topDmd -isAbsDmd :: JointDmd (Str s) (Use u) -> Bool -isAbsDmd (JD {ud = Abs}) = True -- The strictness part can be HyperStr -isAbsDmd _ = False -- for a bottom demand +isAbsDmd :: Demand -> Bool +isAbsDmd (C_00 :* _) = True +isAbsDmd (C_10 :* _) = True -- Bottom demand is also absent +isAbsDmd _ = False isSeqDmd :: Demand -> Bool -isSeqDmd (JD {sd = Str HeadStr, ud = Use _ UHead}) = True -isSeqDmd _ = False +isSeqDmd (C_11 :* cd) = cd == seqCleanDmd +isSeqDmd (C_1N :* cd) = cd == seqCleanDmd -- I wonder if we need this case. +isSeqDmd _ = False -isUsedOnce :: JointDmd (Str s) (Use u) -> Bool -isUsedOnce (JD { ud = a }) = case useCount a of - One -> True - Many -> False +-- | Is the value used at most once? +isUsedOnce :: Demand -> Bool +isUsedOnce (C_0N :* _) = False +isUsedOnce (C_1N :* _) = False +isUsedOnce _ = True -- More utility functions for strictness seqDemand :: Demand -> () -seqDemand (JD {sd = s, ud = u}) = seqArgStr s `seq` seqArgUse u +seqDemand (_ :* Prod ds) = seqDemandList ds +seqDemand _ = () seqDemandList :: [Demand] -> () -seqDemandList [] = () -seqDemandList (d:ds) = seqDemand d `seq` seqDemandList ds +seqDemandList = foldr (seq . seqDemand) () -isStrictDmd :: JointDmd (Str s) (Use u) -> Bool +isStrictDmd :: Demand -> Bool -- See Note [Strict demands] -isStrictDmd (JD {ud = Abs}) = False -isStrictDmd (JD {sd = Lazy}) = False -isStrictDmd _ = True +isStrictDmd (C_10 :* _) = True +isStrictDmd (C_11 :* _) = True +isStrictDmd (C_1N :* _) = True +isStrictDmd _ = False + +isLazy :: Card -> Bool +isLazy C_01 = False +isLazy C_0N = False +isLazy _ = True + +{- Note [Scaling demands] +~~~~~~~~~~~~~~~~~~~~~~~~~ +If a demand is used multiple times (/reused/), for example the argument in an +unsaturated function call, then any upper bound of 1 mentioned that is not +protected by a Call (See Note [Scaling Call demands]), has to be relaxed to an +upper bound of n. +Essentially, the cardinality in all demands are /scaled/ by a factor >1. + +Since + * 'both*' roughly amounts to + on the involved cardinalities + * scaling by n is the same as performing + n times, meaning we can scale by + doing n 'both*'s + * 'both*' is idempotent, e.g. @a `both` a `both` a == a `both` a@ +A simple specification for scaling @a@ is by doing @a `both` a at . +In practice, we implement this operation by the 'scale*' family of +functions, which is a bit more optimised. + +Additionally, we provide predicates 'isScaleInvariant*' that are satisfied +exactly iff they are invariant under 'scale*'. + +Note [Scaling Call demands] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Scaling a 'Call' only concerns the outer call information, because the nested +'CleanDemand' is implicitly scaled by the outer cardinality. E.g., reusing + C1(C1(U)) ("Called once with at least two arguments") +yields C(C1(U)) ("Called multiple times, but each time with at least two + arguments"), +*not* C(C(U)) ("Called multiple times with one argument, and the resulting + PAP is also called multiple times with one argument"). + +This also follows from the specification + scaleCleanDmd cd = bothCleanDmd cd cd, +which dictates that + scaleCleanDmd (Call n cd) = Call (scaleCard n) (lubCleanDmd cd cd) +and 'lubCleanDmd' is reflexive, hence + scaleCleanDmd (Call n cd) = Call (scaleCard n) cd. +-} +-- | Scale the given 'Card' with a factor >1, as if it was used multiple +-- times. Invariant on 0 and n bounds, but turns 1 bounds into n bounds. +-- Example: @scaleCard C_01 == C_0N@, but @scaleCard C_1N == C_1N at . +-- NB: There is no lower bound (strictness) n, hence no change there. +-- +-- See Note [Scaling demands]. +scaleCard :: Card -> Card +-- scaling by 2 is sufficient, because bothCard is idempotent +-- I double-checked that this will generate optimal code +scaleCard c = bothCard c c + +-- | Whether the given 'Card' is invariant to scaling, such as with +-- 'scaleDmd' (which scales by n). +-- See Note [Scaling demands]. +isScaleInvariantCard :: Card -> Bool +-- I double-checked that this will generate optimal code +isScaleInvariantCard c = scaleCard c == c + +-- | See Note [Scaling demands]. +scaleDmd :: Demand -> Demand +-- scaleDmd dmd = bothDmd dmd dmd +scaleDmd (n :* cd) = scaleCard n :* scaleCleanDmd cd + +-- | See Note [Scaling demands]. +isScaleInvariantDmd :: Demand -> Bool +-- isScaleInvariantDmd dmd = scaleDmd dmd == dmd +isScaleInvariantDmd (n :* cd) = isScaleInvariantCard n && isScaleInvariantCleanDmd cd + +-- | See Note [Scaling demands]. +scaleCleanDmd :: CleanDemand -> CleanDemand +-- scaleCleanDmd cd = bothCleanDmd cd cd +scaleCleanDmd (Poly n) = Poly $ scaleCard n +scaleCleanDmd (Prod ds) = Prod $ map scaleDmd ds +scaleCleanDmd (Call n cd) = Call (scaleCard n) cd -- See Note [Scaling Call demands] + +-- | See Note [Scaling demands]. +isScaleInvariantCleanDmd :: CleanDemand -> Bool +-- isScaleInvariantCleanDmd cd = scaleCleanDmd cd == cd +isScaleInvariantCleanDmd (Poly n) = isScaleInvariantCard n +isScaleInvariantCleanDmd (Prod ds) = all isScaleInvariantDmd ds +isScaleInvariantCleanDmd (Call n _) = isScaleInvariantCard n -- See Note [Scaling Call demands] + +-- | We try to avoid tracking weak free variable demands in strictness +-- signatures for analysis performance reasons. FVs with weak demands +-- provide next to no information when unleashed, so they are unleashed +-- once, upon leaving the scope of the binding whose strictness signature +-- was incomplete. +-- See Note [Lazy and unleashable free variables] in "GHC.Core.Opt.DmdAnal". isWeakDmd :: Demand -> Bool -isWeakDmd (JD {sd = s, ud = a}) = isLazy s && isUsedMU a - -cleanUseDmd_maybe :: Demand -> Maybe UseDmd -cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u -cleanUseDmd_maybe _ = Nothing +isWeakDmd (n :* cd) = isLazy n && isScaleInvariantCleanDmd cd splitFVs :: Bool -- Thunk -> DmdEnv -> (DmdEnv, DmdEnv) +-- See Note [Lazy and unleashable free variables] in "GHC.Core.Opt.DmdAnal". splitFVs is_thunk rhs_fvs | is_thunk = strictPairToTuple $ nonDetStrictFoC_dFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs @@ -961,6 +965,11 @@ splitFVs is_thunk rhs_fvs :*: addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) +data StrictPair a b = !a :*: !b + +strictPairToTuple :: StrictPair a b -> (a, b) +strictPairToTuple (x :*: y) = (x, y) + keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -978,24 +987,6 @@ keepAliveDmdEnv env vs add_dmd dmd _ | isAbsDmd dmd = topDmd | otherwise = dmd -splitProdDmd_maybe :: Demand -> Maybe [Demand] --- Split a product into its components, iff there is any --- useful information to be extracted thereby --- The demand is not necessarily strict! -splitProdDmd_maybe (JD { sd = s, ud = u }) - = case (s,u) of - (Str (SProd sx), Use _ u) | Just ux <- splitUseProdDmd (length sx) u - -> Just (mkJointDmds sx ux) - (Str s, Use _ (UProd ux)) | Just sx <- splitStrProdDmd (length ux) s - -> Just (mkJointDmds sx ux) - (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) - _ -> Nothing - -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming @@ -1534,7 +1525,7 @@ postProcessDmd (JD { sd = ss, ud = us }) (JD { sd = s, ud = a}) Str _ -> s a' = case us of Abs -> Abs - Use Many _ -> markReusedDmd a + Use Many _ -> scaleDmd a Use One _ -> a -- Peels one call level from the demand, and also returns @@ -1908,9 +1899,8 @@ dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType -- for dictionary selectors. If the selector is saturated (ie has one -- argument: the dictionary), we feed the demand on the result into -- the indicated dictionary component. -dmdTransformDictSelSig (StrictSig (DmdType _ [dict_dmd] _)) cd +dmdTransformDictSelSig (StrictSig (DmdType _ [Prod jds] _)) cd | (cd',defer_use) <- peelCallDmd cd - , Just jds <- splitProdDmd_maybe dict_dmd = postProcessUnsat defer_use $ DmdType emptyDmdEnv [mkOnceUsedDmd $ mkProdDmd $ map (enhance cd') jds] topDiv | otherwise @@ -1930,7 +1920,7 @@ We just look at the strictness signature of the class op, which will be something like: U(AAASAAAAA). Then replace the 'S' by the demand 'd'. For single-method classes, which are represented by newtypes the signature -of 'op' won't look like U(...), so the splitProdDmd_maybe will fail. +of 'op' won't look like U(...), so matching on Prod will fail. That's fine: if we are doing strictness analysis we are also doing inlining, so we'll have inlined 'op' into a cast. So we can bale out in a conservative way, returning nopDmdType. @@ -2064,43 +2054,42 @@ zap_usg kfs (UCall c u) zap_usg kfs (UProd us) = UProd (map (zap_musg kfs) us) zap_usg _ u = u --- If the argument is a used non-newtype dictionary, give it strict --- demand. Also split the product type & demand and recur in order to --- similarly strictify the argument's contained used non-newtype --- superclass dictionaries. We use the demand as our recursive measure --- to guarantee termination. +-- | If the argument is a used non-newtype dictionary, give it strict demand. +-- Also split the product type & demand and recur in order to similarly +-- strictify the argument's contained used non-newtype superclass dictionaries. +-- We use the demand as our recursive measure to guarantee termination. strictifyDictDmd :: Type -> Demand -> Demand -strictifyDictDmd ty dmd = case getUseDmd dmd of - Use n _ | - Just (tycon, _arg_tys, _data_con, inst_con_arg_tys) - <- splitDataProductType_maybe ty, - not (isNewTyCon tycon), isClassTyCon tycon -- is a non-newtype dictionary - -> seqDmd `bothDmd` -- main idea: ensure it's strict - case splitProdDmd_maybe dmd of - -- superclass cycles should not be a problem, since the demand we are - -- consuming would also have to be infinite in order for us to diverge - Nothing -> dmd -- no components have interesting demand, so stop - -- looking for superclass dicts - Just dmds - | all (not . isAbsDmd) dmds -> evalDmd - -- abstract to strict w/ arbitrary component use, since this - -- smells like reboxing; results in CBV boxed - -- - -- TODO revisit this if we ever do boxity analysis - | otherwise -> case mkProdDmd $ zipWith strictifyDictDmd (map scaledThing inst_con_arg_tys) dmds of - JD {sd = s,ud = a} -> JD (Str s) (Use n a) - -- TODO could optimize with an aborting variant of zipWith since - -- the superclass dicts are always a prefix - _ -> dmd -- unused or not a dictionary +strictifyDictDmd ty dmd@(n :* Prod ds) + | not (isAbsDmd dmd) + , Just (tycon, field_tys) <- as_non_newtype_dict ty + = C_1N :* -- main idea: ensure it's strict + if all (not . isAbsDmd) ds + then topCleanDmd -- abstract to strict w/ arbitrary component use, + -- since this smells like reboxing; results in CBV + -- boxed + -- + -- TODO revisit this if we ever do boxity analysis + else Prod (zipWith strictifyDictDmd field_tys ds) + where + -- | Return a TyCon and a list of field types if the given + -- type is a non-newtype dictionary type + as_non_newtype_dict ty + | Just (tycon, _arg_tys, _data_con, scaledThing -> inst_con_arg_tys) + <- splitDataProductType_maybe ty + , not (isNewTyCon tycon) + , isClassTyCon tycon + = Just (tycon, inst_con_arg_tys) + | otherwise + = Nothing +strictifyDictDmd _ dmd = dmd strictifyDmd :: Demand -> Demand -strictifyDmd dmd@(JD { sd = str }) - = dmd { sd = str `bothArgStr` Str HeadStr } +strictifyDmd (n :* cd) = bothCard n C_10 :* cd {- Note [HyperStr and Use demands] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - +TODO: Irrelevant?! The information "HyperStr" needs to be in the strictness signature, and not in the demand signature, because we still want to know about the demand on things. Consider View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff1d9fba26e6de0b28fccc273729d32bc7890c87 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff1d9fba26e6de0b28fccc273729d32bc7890c87 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 12:13:10 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sat, 24 Oct 2020 08:13:10 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/dmdanal-split-fvs Message-ID: <5f941a56262b8_8973fa3d9b364a81867b5@gitlab.haskell.org.mail> Sebastian Graf pushed new branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/dmdanal-split-fvs You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 12:19:32 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 24 Oct 2020 08:19:32 -0400 Subject: [Git][ghc/ghc][wip/T18389] Accept even more stderr changes, improve UnliftedNewtypes-related suggestion Message-ID: <5f941bd4cab80_8973fa3a64e809818839f@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC Commits: 44939c67 by Ryan Scott at 2020-10-24T08:18:29-04:00 Accept even more stderr changes, improve UnliftedNewtypes-related suggestion - - - - - 6 changed files: - compiler/GHC/Tc/TyCl.hs - testsuite/tests/typecheck/should_fail/T12729.stderr - testsuite/tests/typecheck/should_fail/T15807.stderr - testsuite/tests/typecheck/should_fail/T15883.stderr - testsuite/tests/typecheck/should_fail/UnliftedNewtypesNotEnabled.stderr - testsuite/tests/typecheck/should_fail/tcfail079.stderr Changes: ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4180,7 +4180,7 @@ checkNewDataCon con ; let allowedArgType = unlifted_newtypes || isLiftedType_maybe (scaledThing arg_ty1) == Just True ; checkTc allowedArgType $ vcat - [ text "A newtype cannot have an unlifted argument type" + [ text "A newtype must have an argument of kind" <+> ppr liftedTypeKind , text "Perhaps you intended to use UnliftedNewtypes" ] ; show_linear_types <- xopt LangExt.LinearTypes <$> getDynFlags ===================================== testsuite/tests/typecheck/should_fail/T12729.stderr ===================================== @@ -1,12 +1,12 @@ T12729.hs:8:4: error: - • A newtype cannot have an unlifted argument type + • A newtype must have an argument of kind * Perhaps you intended to use UnliftedNewtypes • In the definition of data constructor ‘MkA’ In the newtype declaration for ‘A’ T12729.hs:10:13: error: - • A newtype cannot have an unlifted argument type + • A newtype must have an argument of kind * Perhaps you intended to use UnliftedNewtypes • In the definition of data constructor ‘MkB’ In the newtype declaration for ‘B’ ===================================== testsuite/tests/typecheck/should_fail/T15807.stderr ===================================== @@ -1,8 +1,10 @@ T15807.hs:12:3: error: - • Cannot generalise type; skolem ‘f’ would escape its scope + • Cannot generalise type; skolem + ‘(f :: k0 -> *)’ + would escape its scope if I tried to quantify (f0 :: f -> *) in this type: - forall f (a :: f). f a %1 -> App @f @f0 a + forall (f :: k0 -> *) (a :: k0). f a %1 -> App @f @f0 a (Indeed, I sometimes struggle even printing this correctly, due to its ill-scoped nature.) • In the definition of data constructor ‘MkApp’ ===================================== testsuite/tests/typecheck/should_fail/T15883.stderr ===================================== @@ -1,5 +1,6 @@ -T15883.hs:9:1: error: - • Newtype has non-* return kind ‘TYPE rep’ +T15883.hs:9:19: error: + • A newtype must have an argument of kind * Perhaps you intended to use UnliftedNewtypes - • In the newtype declaration for ‘Foo’ + • In the definition of data constructor ‘MkFoo’ + In the newtype declaration for ‘Foo’ ===================================== testsuite/tests/typecheck/should_fail/UnliftedNewtypesNotEnabled.stderr ===================================== @@ -1,6 +1,6 @@ UnliftedNewtypesNotEnabled.hs:9:15: error: - • A newtype cannot have an unlifted argument type + • A newtype must have an argument of kind * Perhaps you intended to use UnliftedNewtypes • In the definition of data constructor ‘Baz’ In the newtype declaration for ‘Baz’ ===================================== testsuite/tests/typecheck/should_fail/tcfail079.stderr ===================================== @@ -1,5 +1,6 @@ -tcfail079.hs:9:1: error: - • Newtype has non-* return kind ‘TYPE 'GHC.Types.IntRep’ +tcfail079.hs:9:19: error: + • A newtype must have an argument of kind * Perhaps you intended to use UnliftedNewtypes - • In the newtype declaration for ‘Unboxed’ + • In the definition of data constructor ‘Unboxed’ + In the newtype declaration for ‘Unboxed’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44939c67cb93b75296ffe4c788239d07589b5a29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/44939c67cb93b75296ffe4c788239d07589b5a29 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 12:35:48 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sat, 24 Oct 2020 08:35:48 -0400 Subject: [Git][ghc/ghc][wip/dmdanal-split-fvs] DmdAnal: Don't `splitFV` strict demands Message-ID: <5f941fa4577c7_8973fa3bb493128189026@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC Commits: c4176ed4 by Sebastian Graf at 2020-10-24T14:34:14+02:00 DmdAnal: Don't `splitFV` strict demands The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. But in case of a strict FV demand, we still add the FV to the demand signature *and* the lazy_fv DmdEnv. It would be far simpler (and more precise) not having to split the demand over both places, if analysis performance doesn't degrade too much. - - - - - 1 changed file: - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -806,11 +806,9 @@ splitFVs is_thunk rhs_fvs -- in the envs again | otherwise = partitionVarEnv isWeakDmd rhs_fvs where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) + add uniq dmd@(JD { sd = s }) (lazy_fv :*: sig_fv) | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) + | otherwise = lazy_fv :*: addToUFM_Directly sig_fv uniq dmd keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4176ed45aa296058417ac946ce785193be24b3a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c4176ed45aa296058417ac946ce785193be24b3a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 14:12:46 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sat, 24 Oct 2020 10:12:46 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] RTS symbol weirness Message-ID: <5f94365e97bce_8973fa3bb06dfbc19302@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 1b4a4ba9 by Sven Tennie at 2020-10-24T16:12:35+02:00 RTS symbol weirness - - - - - 1 changed file: - rts/RtsSymbols.c Changes: ===================================== rts/RtsSymbols.c ===================================== @@ -12,6 +12,8 @@ #include "Rts.h" #include "TopHandler.h" #include "HsFFI.h" +#include "CloneStack.h" +#include "rts/PrinterAPI.h" #include "sm/Storage.h" #include "sm/NonMovingMark.h" @@ -999,6 +1001,8 @@ SymI_HasProto(cas) \ SymI_HasProto(_assertFail) \ SymI_HasProto(keepCAFs) \ + SymI_HasProto(sendCloneStackMessage) \ + SymI_HasProto(printStack) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b4a4ba9a7ba95acc2beb8d9c6ce7554eba3416f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b4a4ba9a7ba95acc2beb8d9c6ce7554eba3416f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 14:51:46 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 24 Oct 2020 10:51:46 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18844-alternate Message-ID: <5f943f826d072_897a66cd441941a8@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18844-alternate at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18844-alternate You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 15:19:26 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sat, 24 Oct 2020 11:19:26 -0400 Subject: [Git][ghc/ghc][wip/dmdanal-split-fvs] DmdAnal: Kill `is_thunk` case in `splitFV` Message-ID: <5f9445fe7d39_8973fa3d8c53db41994c8@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC Commits: 01cf781b by Sebastian Graf at 2020-10-24T17:18:17+02:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. TODO: Update commit message But in case of a strict FV demand, we still add the FV to the demand signature *and* the lazy_fv DmdEnv. It would be far simpler (and more precise) not having to split the demand over both places, if analysis performance doesn't degrade too much. - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,7 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 is_thunk = not (exprIsHNF rhs) && not (isJoinId id) -- Find the RHS free vars of the unfoldings and RULES ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -796,22 +796,6 @@ cleanUseDmd_maybe :: Demand -> Maybe UseDmd cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u cleanUseDmd_maybe _ = Nothing -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoldUFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -842,11 +826,6 @@ splitProdDmd_maybe (JD { sd = s, ud = u }) (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) _ -> Nothing -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01cf781b4ef8210f4270a31dffd66558a05268a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01cf781b4ef8210f4270a31dffd66558a05268a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 24 21:59:41 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sat, 24 Oct 2020 17:59:41 -0400 Subject: [Git][ghc/ghc][wip/dmdanal-split-fvs] DmdAnal: Kill `is_thunk` case in `splitFV` Message-ID: <5f94a3cd143a4_8973fa3bb08467c2054ce@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC Commits: fc6d33ca by Sebastian Graf at 2020-10-24T23:57:42+02:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. TODO: Update commit message But in case of a strict FV demand, we still add the FV to the demand signature *and* the lazy_fv DmdEnv. It would be far simpler (and more precise) not having to split the demand over both places, if analysis performance doesn't degrade too much. - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,8 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 - is_thunk = not (exprIsHNF rhs) && not (isJoinId id) + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 -- Find the RHS free vars of the unfoldings and RULES -- See Note [Absence analysis for stable unfoldings and RULES] ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -796,22 +796,6 @@ cleanUseDmd_maybe :: Demand -> Maybe UseDmd cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u cleanUseDmd_maybe _ = Nothing -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoldUFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -842,11 +826,6 @@ splitProdDmd_maybe (JD { sd = s, ud = u }) (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) _ -> Nothing -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc6d33ca3f9e2acea3ac452491d409a4ba3ee77a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc6d33ca3f9e2acea3ac452491d409a4ba3ee77a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 00:05:16 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 24 Oct 2020 20:05:16 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 5 commits: Fix ordering of SET_HDR and add SET_HDR_RELEASE Message-ID: <5f94c13c52714_8977d1cc3c206110@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 7d1fa38e by Ben Gamari at 2020-10-24T11:02:46-04:00 Fix ordering of SET_HDR and add SET_HDR_RELEASE - - - - - 088e8cb5 by Ben Gamari at 2020-10-24T11:03:00-04:00 lockCAF - - - - - 9a810bab by Ben Gamari at 2020-10-24T11:12:11-04:00 TSANUtils: Ensure that C11 atomics are supported - - - - - aa15b37e by Ben Gamari at 2020-10-24T19:51:15-04:00 rts: Move stat_exit until after exitHeapProfiling Since the latter wants to call getRTSStats. - - - - - eb195518 by Ben Gamari at 2020-10-24T19:56:01-04:00 WSDeque tweak - - - - - 5 changed files: - includes/rts/TSANUtils.h - includes/rts/storage/ClosureMacros.h - rts/RtsStartup.c - rts/WSDeque.c - rts/sm/Storage.c Changes: ===================================== includes/rts/TSANUtils.h ===================================== @@ -40,6 +40,10 @@ #endif #if defined(TSAN_ENABLED) +#if !defined(HAVE_C11_ATOMICS) +#error TSAN cannot be enabled without C11 atomics suppoort. +#endif + #define TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \ AnnotateHappensBefore(__FILE__, __LINE__, (void*)(addr)) #define TSAN_ANNOTATE_HAPPENS_AFTER(addr) \ ===================================== includes/rts/storage/ClosureMacros.h ===================================== @@ -140,13 +140,19 @@ INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) #define SET_HDR(c,_info,ccs) \ { \ + SET_PROF_HDR((StgClosure *)(c),ccs); \ RELAXED_STORE(&(c)->header.info, _info); \ + } + +#define SET_HDR_RELEASE(c,_info,ccs) \ + { \ SET_PROF_HDR((StgClosure *)(c),ccs); \ + RELEASE_STORE(&(c)->header.info, _info); \ } #define SET_ARR_HDR(c,info,costCentreStack,n_bytes) \ - SET_HDR(c,info,costCentreStack); \ - (c)->bytes = n_bytes; + (c)->bytes = n_bytes; \ + SET_HDR(c,info,costCentreStack); // Use when changing a closure from one kind to another #define OVERWRITE_INFO(c, new_info) \ ===================================== rts/RtsStartup.c ===================================== @@ -574,6 +574,10 @@ hs_exit_(bool wait_foreign) if (is_io_mng_native_p()) hs_restoreConsoleCP(); #endif + + /* Print the final runtime stats */ + stat_exit(); + /* free hash table storage */ exitHashTable(); ===================================== rts/WSDeque.c ===================================== @@ -52,6 +52,7 @@ #include "RtsUtils.h" #include "WSDeque.h" +// Returns true on success. static inline bool cas_top(WSDeque *q, StgInt old, StgInt new) { @@ -211,13 +212,13 @@ pushWSDeque (WSDeque* q, void * elem) } RELAXED_STORE(&q->elements[b & q->moduloSize], elem); - RELEASE_FENCE(); #if defined(TSAN_ENABLED) // ThreadSanizer doesn't know about release fences, so we need to // strengthen this to a release store lest we get spurious data race // reports. RELEASE_STORE(&q->bottom, b+1); #else + RELEASE_FENCE(); RELAXED_STORE(&q->bottom, b+1); #endif return true; ===================================== rts/sm/Storage.c ===================================== @@ -302,7 +302,6 @@ exitStorage (void) { nonmovingExit(); updateNurseriesStats(); - stat_exit(); } void @@ -500,11 +499,11 @@ lockCAF (StgRegTable *reg, StgIndStatic *caf) bh = (StgInd *)allocate(cap, sizeofW(*bh)); } bh->indirectee = (StgClosure *)cap->r.rCurrentTSO; - SET_HDR(bh, &stg_CAF_BLACKHOLE_info, caf->header.prof.ccs); + SET_HDR_RELEASE(bh, &stg_CAF_BLACKHOLE_info, caf->header.prof.ccs); // RELEASE ordering to ensure that above writes are visible before we // introduce reference as CAF indirectee. - RELEASE_STORE(&caf->indirectee, (StgClosure *) bh); + RELAXED_STORE(&caf->indirectee, (StgClosure *) bh); SET_INFO_RELEASE((StgClosure*)caf, &stg_IND_STATIC_info); return bh; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c904e9946951d43f9950acef35c1f16d890bf5...eb195518f11b9cc28c051388484d867124f390dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47c904e9946951d43f9950acef35c1f16d890bf5...eb195518f11b9cc28c051388484d867124f390dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 00:18:47 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 24 Oct 2020 20:18:47 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 2 commits: Stats: squash Message-ID: <5f94c4675eb8c_8973fa37a2a744020672a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 76600026 by Ben Gamari at 2020-10-24T20:18:22-04:00 Stats: squash - - - - - 52901280 by Ben Gamari at 2020-10-24T20:18:37-04:00 hadrian flavour - - - - - 5 changed files: - hadrian/src/Flavour.hs - rts/RtsStartup.c - rts/Stats.c - rts/Stats.h - rts/sm/Storage.c Changes: ===================================== hadrian/src/Flavour.hs ===================================== @@ -120,9 +120,9 @@ splitSections = splitSectionsIf (/=ghc) enableThreadSanitizer :: Flavour -> Flavour enableThreadSanitizer = addArgs $ mconcat [ builder (Ghc CompileHs) ? arg "-optc-fsanitize=thread" - , builder (Ghc CompileCWithGhc) ? arg "-optc-fsanitize=thread" + , builder (Ghc CompileCWithGhc) ? (arg "-optc-fsanitize=thread" <> arg "-DTSAN_ENABLED") , builder (Ghc LinkHs) ? arg "-optl-fsanitize=thread" - , builder (Cc CompileC) ? arg "-fsanitize=thread" + , builder (Cc CompileC) ? (arg "-fsanitize=thread" <> arg "-DTSAN_ENABLED") , builder (Cabal Flags) ? arg "thread-sanitizer" , builder RunTest ? arg "--config=have_thread_sanitizer=True" ] ===================================== rts/RtsStartup.c ===================================== @@ -575,7 +575,7 @@ hs_exit_(bool wait_foreign) hs_restoreConsoleCP(); #endif - /* Print the final runtime stats */ + /* tear down statistics subsystem */ stat_exit(); /* free hash table storage */ ===================================== rts/Stats.c ===================================== @@ -1245,7 +1245,7 @@ static void report_one_line(const RTSSummaryStats * sum) } void -stat_exit (void) +stat_exitReport (void) { RTSSummaryStats sum; init_RTSSummaryStats(&sum); @@ -1450,9 +1450,6 @@ stat_exit (void) } } RELEASE_LOCK(&stats_mutex); -#if defined(THREADED_RTS) - closeMutex(&stats_mutex); -#endif statsFlush(); statsClose(); @@ -1476,6 +1473,13 @@ stat_exit (void) RELEASE_LOCK(&all_tasks_mutex); } +void stat_exit() +{ +#if defined(THREADED_RTS) + closeMutex(&stats_mutex); +#endif +} + /* Note [Work Balance] ---------------------- Work balance is a measure of how evenly the work done during parallel garbage ===================================== rts/Stats.h ===================================== @@ -58,6 +58,7 @@ void stat_endHeapCensus(void); void stat_startExit(void); void stat_endExit(void); +void stat_exitReport(void); void stat_exit(void); void stat_workerStop(void); ===================================== rts/sm/Storage.c ===================================== @@ -302,6 +302,7 @@ exitStorage (void) { nonmovingExit(); updateNurseriesStats(); + stat_exitReport(); } void View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb195518f11b9cc28c051388484d867124f390dd...52901280e40cb05c3566c857e92caf1296d8d3ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb195518f11b9cc28c051388484d867124f390dd...52901280e40cb05c3566c857e92caf1296d8d3ee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 01:11:23 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 24 Oct 2020 21:11:23 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 277 commits: Introduce OutputableP Message-ID: <5f94d0bbd639a_8973fa3bb65ebc4210388@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - b9d4dd9c by Ben Gamari at 2020-10-24T20:44:17-04:00 SMP.h: Add C11-style atomic operations - - - - - ccf2d4b0 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Infrastructure for testing with ThreadSanitizer - - - - - a61f66d6 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/CNF: Initialize all bdescrs in group It seems wise and cheap to ensure that the whole bdescr of all blocks of a compact group is valid, even if most cases only look at the flags field. - - - - - 65136c13 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Capability: Intialize interrupt field Previously this was left uninitialized. Also clarify some comments. - - - - - b3ce6aca by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Task: Make comments proper Notes - - - - - d3890ac7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/SpinLock: Move to proper atomics This is fairly straightforward; we just needed to use relaxed operations for the PROF_SPIN counters and a release store instead of a write barrier. - - - - - ef88712f by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/OSThreads: Fix data race Previously we would race on the cached processor count. Avoiding this is straightforward; just use relaxed operations. - - - - - 33a719c3 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/ClosureMaros: Use relaxed atomics - - - - - f08951fd by Ben Gamari at 2020-10-24T20:59:39-04:00 configure: Bump minimum-supported gcc version to 4.7 Since the __atomic_* builtins are not supported until gcc 4.7. Given that this version was released in 2012 I think this is acceptable. - - - - - d584923a by Ben Gamari at 2020-10-24T20:59:39-04:00 testsuite: Fix thread leak in hs_try_putmvar00[13] - - - - - bf1b0bc7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Introduce SET_HDR_RELEASE Also ensure that we also store the info table pointer last to ensure that the synchronization covers all stores. - - - - - 1a2e9f5e by Ben Gamari at 2020-10-24T21:00:19-04:00 gitlab-ci: Add nightly-x86_64-linux-deb9-tsan job - - - - - 58a5b0e5 by GHC GitLab CI at 2020-10-24T21:00:19-04:00 testsuite: Mark setnumcapabilities001 as broken with TSAN Due to #18808. - - - - - d9bc7dea by GHC GitLab CI at 2020-10-24T21:00:19-04:00 testsuite: Skip divbyzero and derefnull under TSAN ThreadSanitizer changes the output of these tests. - - - - - fcc42a10 by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Skip high memory usage tests with TSAN ThreadSanitizer significantly increases the memory footprint of tests, so much so that it can send machines into OOM. - - - - - cae4bb3e by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark hie002 as high_memory_usage This test has a peak residency of 1GByte; this is large enough to classify as "high" in my book. - - - - - dae1b86a by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T9872[abc] as high_memory_usage These all have a maximum residency of over 2 GB. - - - - - c5a0bb22 by Ben Gamari at 2020-10-24T21:00:19-04:00 gitlab-ci: Disable documentation in TSAN build Haddock chews through enough memory to cause the CI builders to OOM and there's frankly no reason to build documentation in this job anyways. - - - - - 4cb1232e by Ben Gamari at 2020-10-24T21:00:19-04:00 TSANUtils: Ensure that C11 atomics are supported - - - - - 7ed15f7f by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T3807 as broken with TSAN Due to #18883. - - - - - f7e6f012 by Ben Gamari at 2020-10-24T21:00:19-04:00 testsuite: Mark T13702 as broken with TSAN due to #18884 - - - - - 16b136b0 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Factor out logic to identify a good capability for running a task Not only does this make the control flow a bit clearer but it also allows us to add a TSAN suppression on this logic, which requires (harmless) data races. - - - - - 2781d68c by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Annotate benign race in waitForCapability - - - - - f6b4b492 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Clarify locking behavior of releaseCapability_ - - - - - 65219810 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Add assertions for task ownership of capabilities - - - - - 31fa87ec by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Use relaxed atomics on n_returning_tasks This mitigates the warning of a benign race on n_returning_tasks in shouldYieldCapability. See #17261. - - - - - 6517a2ea by Ben Gamari at 2020-10-24T21:00:36-04:00 rts: Mitigate races in capability interruption logic - - - - - 2e9ba3f2 by Ben Gamari at 2020-10-24T21:00:36-04:00 rts/Capability: Use relaxed operations for last_free_capability - - - - - e10dde37 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Use relaxed operations for cap->running_task (TODO) This shouldn't be necessary since only the owning thread of the capability should be touching this. - - - - - 855325cd by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Schedule: Use relaxed operations for sched_state - - - - - 811f915d by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Accept data race in work-stealing implementation This race is okay since the task is owned by the capability pushing it. By Note [Ownership of Task] this means that the capability is free to write to `task->cap` without taking `task->lock`. Fixes #17276. - - - - - 8d2b3c3d by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Eliminate data races on pending_sync - - - - - f8871018 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Schedule: Eliminate data races on recent_activity We cannot safely use relaxed atomics here. - - - - - d079b943 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts: Avoid data races in message handling - - - - - 06f80497 by Ben Gamari at 2020-10-24T21:00:37-04:00 rts/Messages: Drop incredibly fishy write barrier executeMessage previously had a write barrier at the beginning of its loop apparently in an attempt to synchronize with another thread's writes to the Message. I would guess that the author had intended to use a load barrier here given that there are no globally-visible writes done in executeMessage. I've removed the redundant barrier since the necessary load barrier is now provided by the ACQUIRE_LOAD. - - - - - d4a87779 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/ThreadPaused: Avoid data races - - - - - 56778ab3 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/Schedule: Eliminate data races in run queue management - - - - - 086521f7 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts: Eliminate shutdown data race on task counters - - - - - abad9778 by Ben Gamari at 2020-10-24T21:00:38-04:00 rts/Threads: Avoid data races (TODO) Replace barriers with appropriate ordering. Drop redundant barrier in tryWakeupThread (the RELEASE barrier will be provided by sendMessage's mutex release). We use relaxed operations on why_blocked and the stack although it's not clear to me why this is necessary. - - - - - 2f56be8a by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/Messages: Annotate benign race - - - - - 7c0cdab1 by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/RaiseAsync: Synchronize what_next read - - - - - 6cc2a8a5 by Ben Gamari at 2020-10-24T21:00:39-04:00 rts/Task: Move debugTrace to avoid data race Specifically, we need to hold all_tasks_mutex to read taskCount. - - - - - bbaec97d by Ben Gamari at 2020-10-24T21:00:39-04:00 Disable flawed assertion - - - - - dd175a92 by Ben Gamari at 2020-10-24T21:00:39-04:00 Document schedulePushWork race - - - - - 3416244b by Ben Gamari at 2020-10-24T21:00:40-04:00 Capabiliity: Properly fix data race on n_returning_tasks There is a real data race but can be made safe by using proper atomic (but relaxed) accesses. - - - - - dffd9432 by Ben Gamari at 2020-10-24T21:00:40-04:00 rts: Make write of to_cap->inbox atomic This is necessary since emptyInbox may read from to_cap->inbox without taking cap->lock. - - - - - 1f4cbc29 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/BlockAlloc: Use relaxed operations - - - - - d0d07cff by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Rework handling of mutlist scavenging statistics - - - - - 9e5c7f6d by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Avoid data races in StablePtr implementation This fixes two potentially problematic data races in the StablePtr implementation: * We would fail to RELEASE the stable pointer table when enlarging it, causing other cores to potentially see uninitialized memory. * We would fail to ACQUIRE when dereferencing a stable pointer. - - - - - 316add67 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/Storage: Use atomics - - - - - 5c23bc4c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Updates: Use proper atomic operations - - - - - 3d0f033c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Weak: Eliminate data races By taking all_tasks_mutex in stat_exit. Also better-document the fact that the task statistics are protected by all_tasks_mutex. - - - - - ce2ee5cb by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/GC: Use atomics - - - - - e2901e49 by Ben Gamari at 2020-10-24T21:00:58-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - 463d71d0 by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Storage: Accept races on heap size counters - - - - - ab1c0702 by Ben Gamari at 2020-10-24T21:00:58-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - 98237242 by GHC GitLab CI at 2020-10-24T21:00:58-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - edb4b92b by Ben Gamari at 2020-10-24T21:01:18-04:00 rts/WSDeque: Rewrite with proper atomics After a few attempts at shoring up the previous implementation, I ended up turning to the literature and now use the proven implementation, > N.M. Lê, A. Pop, A.Cohen, and F.Z. Nardelli. "Correct and Efficient > Work-Stealing for Weak Memory Models". PPoPP'13, February 2013, > ACM 978-1-4503-1922/13/02. Note only is this approach formally proven correct under C11 semantics but it is also proved to be a bit faster in practice. - - - - - d39bbd3d by Ben Gamari at 2020-10-24T21:01:33-04:00 rts: Use relaxed atomics for whitehole spin stats - - - - - 8f802f38 by Ben Gamari at 2020-10-24T21:01:33-04:00 rts: Avoid lock order inversion during fork Fixes #17275. - - - - - cef667b0 by GHC GitLab CI at 2020-10-24T21:01:34-04:00 rts: Use proper relaxe operations in getCurrentThreadCPUTime Here we are doing lazy initialization; it's okay if we do the check more than once, hence relaxed operation is fine. - - - - - 8cf50eb1 by Ben Gamari at 2020-10-24T21:01:54-04:00 rts/STM: Use atomics This fixes a potentially harmful race where we failed to synchronize before looking at a TVar's current_value. Also did a bit of refactoring to avoid abstract over management of max_commits. - - - - - 88a7ce38 by Ben Gamari at 2020-10-24T21:01:54-04:00 rts/stm: Strengthen orderings to SEQ_CST instead of volatile Previously the `current_value`, `first_watch_queue_entry`, and `num_updates` fields of `StgTVar` were marked as `volatile` in an attempt to provide strong ordering. Of course, this isn't sufficient. We now use proper atomic operations. In most of these cases I strengthen the ordering all the way to SEQ_CST although it's possible that some could be weakened with some thought. - - - - - f97c59ce by Ben Gamari at 2020-10-24T21:02:11-04:00 Mitigate data races in event manager startup/shutdown - - - - - c7c3f8aa by Ben Gamari at 2020-10-24T21:02:22-04:00 rts: Accept benign races in Proftimer - - - - - 5a98dfca by Ben Gamari at 2020-10-24T21:02:22-04:00 rts: Pause timer while changing capability count This avoids #17289. - - - - - 01d95525 by Ben Gamari at 2020-10-24T21:02:22-04:00 Fix #17289 - - - - - 9a528985 by Ben Gamari at 2020-10-24T21:02:23-04:00 suppress #17289 (ticker) race - - - - - 1726ec41 by Ben Gamari at 2020-10-24T21:02:23-04:00 rts: Fix timer initialization Previously `initScheduler` would attempt to pause the ticker and in so doing acquire the ticker mutex. However, initTicker, which is responsible for initializing said mutex, hadn't been called yet. - - - - - bfbe4366 by Ben Gamari at 2020-10-24T21:02:23-04:00 rts: Fix races in Pthread timer backend shudown We can generally be pretty relaxed in the barriers here since the timer thread is a loop. - - - - - 297acc71 by Ben Gamari at 2020-10-24T21:02:44-04:00 rts/Stats: Hide a few unused unnecessarily global functions - - - - - 0cdb34a0 by Ben Gamari at 2020-10-24T21:02:44-04:00 rts/Stats: Protect with mutex While on face value this seems a bit heavy, I think it's far better than enforcing ordering on every access. - - - - - bacdbe51 by Ben Gamari at 2020-10-24T21:04:43-04:00 rts: Tear down stats_mutex after exitHeapProfiling Since the latter wants to call getRTSStats. - - - - - 2b49fcb3 by Ben Gamari at 2020-10-24T21:10:30-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr', 'wip/tsan/timer' and 'wip/tsan/stats' into wip/tsan/all - - - - - 642f2ed0 by Ben Gamari at 2020-10-24T21:11:14-04:00 testing - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lexer.x The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52901280e40cb05c3566c857e92caf1296d8d3ee...642f2ed0a68dc40abb9379e5c561c8c37d8ddfc4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52901280e40cb05c3566c857e92caf1296d8d3ee...642f2ed0a68dc40abb9379e5c561c8c37d8ddfc4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 07:51:41 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sun, 25 Oct 2020 03:51:41 -0400 Subject: [Git][ghc/ghc][wip/dmdanal-split-fvs] DmdAnal: Kill `is_thunk` case in `splitFV` Message-ID: <5f952e8d6e2dc_8973fa3a769ac002115da@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC Commits: 2ce74f9b by Sebastian Graf at 2020-10-25T08:51:25+01:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,8 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 - is_thunk = not (exprIsHNF rhs) && not (isJoinId id) + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 -- Find the RHS free vars of the unfoldings and RULES -- See Note [Absence analysis for stable unfoldings and RULES] @@ -595,8 +594,9 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs mkRhsDmd :: AnalEnv -> Arity -> CoreExpr -> CleanDemand mkRhsDmd _env rhs_arity _rhs = mkCallDmds rhs_arity cleanEvalDmd --- | If given the let-bound 'Id', 'useLetUp' determines whether we should --- process the binding up (body before rhs) or down (rhs before body). +-- | If given the (local, non-recursive) let-bound 'Id', 'useLetUp' determines +-- whether we should process the binding up (body before rhs) or down (rhs +-- before body). -- -- We use LetDown if there is a chance to get a useful strictness signature to -- unleash at call sites. LetDown is generally more precise than LetUp if we can ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -796,22 +796,6 @@ cleanUseDmd_maybe :: Demand -> Maybe UseDmd cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u cleanUseDmd_maybe _ = Nothing -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoldUFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -842,11 +826,6 @@ splitProdDmd_maybe (JD { sd = s, ud = u }) (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) _ -> Nothing -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ce74f9bfb05d1aeaa97d06c262a78ff0e653544 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ce74f9bfb05d1aeaa97d06c262a78ff0e653544 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 09:43:26 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Sun, 25 Oct 2020 05:43:26 -0400 Subject: [Git][ghc/ghc][wip/dmdanal-split-fvs] DmdAnal: Kill `is_thunk` case in `splitFV` Message-ID: <5f9548bed3c3f_8977e88f58212331@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/dmdanal-split-fvs at Glasgow Haskell Compiler / GHC Commits: f1d5ea5a by Sebastian Graf at 2020-10-25T10:42:34+01:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,8 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 - is_thunk = not (exprIsHNF rhs) && not (isJoinId id) + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 -- Find the RHS free vars of the unfoldings and RULES -- See Note [Absence analysis for stable unfoldings and RULES] @@ -595,8 +594,9 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs mkRhsDmd :: AnalEnv -> Arity -> CoreExpr -> CleanDemand mkRhsDmd _env rhs_arity _rhs = mkCallDmds rhs_arity cleanEvalDmd --- | If given the let-bound 'Id', 'useLetUp' determines whether we should --- process the binding up (body before rhs) or down (rhs before body). +-- | If given the (local, non-recursive) let-bound 'Id', 'useLetUp' determines +-- whether we should process the binding up (body before rhs) or down (rhs +-- before body). -- -- We use LetDown if there is a chance to get a useful strictness signature to -- unleash at call sites. LetDown is generally more precise than LetUp if we can ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -796,22 +796,6 @@ cleanUseDmd_maybe :: Demand -> Maybe UseDmd cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u cleanUseDmd_maybe _ = Nothing -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoldUFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -842,11 +826,6 @@ splitProdDmd_maybe (JD { sd = s, ud = u }) (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) _ -> Nothing -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1d5ea5a389f07ac37f65c6c12378f234944f28c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f1d5ea5a389f07ac37f65c6c12378f234944f28c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 11:28:52 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 25 Oct 2020 07:28:52 -0400 Subject: [Git][ghc/ghc][wip/T18389] Restore Note that I accidentally deleted Message-ID: <5f95617485d23_897fe1a604214382@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC Commits: 1bc50b8c by Ryan Scott at 2020-10-25T07:25:16-04:00 Restore Note that I accidentally deleted - - - - - 1 changed file: - compiler/GHC/Tc/TyCl.hs Changes: ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3310,6 +3310,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data do { ctxt <- tcHsMbContext cxt ; btys <- tcConArgs hs_args ; (res_ty, res_kind) <- tcInferLHsTypeKind hs_res_ty + -- See Note [GADT return kinds] ; let (arg_tys, stricts) = unzip btys ; dflags <- getDynFlags ; final_arg_tys <- unifyNewtypeKind dflags new_or_data @@ -3368,6 +3369,20 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data where skol_info = DataConSkol (unLoc (head names)) +{- Note [GADT return kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + type family Star where Star = Type + data T :: Type where + MkT :: Int -> T + +If, for some stupid reason, tcInferLHsTypeKind on the return type of +MkT returned (T |> ax, Star), then the return-type check in +checkValidDataCon would reject the decl (although of course there is +nothing wrong with it). We are implicitly requiring tha +tcInferLHsTypeKind doesn't any gratuitous top-level casts. +-} + tcConIsInfixH98 :: Name -> HsConDetails a b -> TcM Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bc50b8c6b188870734ec49ab2edd51f734986a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1bc50b8c6b188870734ec49ab2edd51f734986a6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 11:30:25 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 25 Oct 2020 07:30:25 -0400 Subject: [Git][ghc/ghc][wip/T18844-alternate] Split HsConDecl{H98, GADT}Details Message-ID: <5f9561d13edcd_897fe1a6042148c@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844-alternate at Glasgow Haskell Compiler / GHC Commits: 3f19bcef by Ryan Scott at 2020-10-25T07:29:24-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 21 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1473,9 +1473,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1492,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1623,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,15 +1731,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,29 +1257,41 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) + = get_flds remSeen flds + get_flds_h98 remSeen _ + = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) + = get_flds remSeen flds + get_flds_gadt remSeen _ + = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a PrefixCon. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a RecCon. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2634,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1319,6 +1319,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1530,7 +1534,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1541,7 +1545,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1555,13 +1561,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -633,17 +633,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,27 +2246,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1563,12 +1563,12 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. -kcConArgTys :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () -kcConArgTys new_or_data res_kind arg_tys = do +kcConArgs :: NewOrData -> Kind -> [HsScaled GhcRn (LHsType GhcRn)] -> TcM () +kcConArgs new_or_data res_kind arg_tys = do { let exp_kind = getArgExpKind new_or_data res_kind ; forM_ arg_tys (\(HsScaled mult ty) -> do _ <- tcCheckLHsType (getBangType ty) exp_kind tcMult mult) @@ -1576,6 +1576,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgs new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgs new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgs new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgs new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgs new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1604,14 +1619,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1640,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3211,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3281,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3298,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,48 +3377,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3415,6 +3432,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -620,7 +620,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -629,9 +629,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit c62bc3137ccc2c07bf7f52d6fef1ba89c489f7e0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f19bcef8092b9ae21b76155c75830c7a5c1f77b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3f19bcef8092b9ae21b76155c75830c7a5c1f77b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 11:51:42 2020 From: gitlab at gitlab.haskell.org (Sven Tennie) Date: Sun, 25 Oct 2020 07:51:42 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 4 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f9566cec0b34_8973fa3b8d660c821808a@gitlab.haskell.org.mail> Sven Tennie pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - d1da7d7d by Sven Tennie at 2020-10-25T12:48:17+01:00 Add cloneThreadStack, cloneMyStack and printStack (#18741) These functions clone the stack of either another thread (cloneThreadStack) or the currently active one (cloneMyStack). printStack prints a cloned stack. A cloned stack is offline/cold, i.e. it isn't evaluated any further. The stack is represented by a new primtype (StackSnapshot#) in Haskell. For technical details, please see note [Stack Cloning]. - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm/Type.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - + includes/rts/PrinterAPI.h - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - libraries/base/GHC/Conc/Sync.hs - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Disassembler.c - rts/Disassembler.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/package.conf.in - rts/rts.cabal.in - + testsuite/tests/parser/should_compile/T12862.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_fail/T12446.hs - + testsuite/tests/parser/should_fail/T12446.stderr - testsuite/tests/parser/should_fail/all.T - testsuite/tests/patsyn/should_fail/T11010.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b4a4ba9a7ba95acc2beb8d9c6ce7554eba3416f...d1da7d7da23b62719346cf79695664de694cb8b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1b4a4ba9a7ba95acc2beb8d9c6ce7554eba3416f...d1da7d7da23b62719346cf79695664de694cb8b3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 12:13:18 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 25 Oct 2020 08:13:18 -0400 Subject: [Git][ghc/ghc][wip/T18844] 4 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f956bde3fdbd_897fb79a0822135b@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 04b85ddc by Ryan Scott at 2020-10-25T08:12:41-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Adding a third type parameter to `HsConDeclDetails` to represent the types in an `InfixCon`, separate from the type parameters for `PrefixCon` and `RecCon`, and * Creating `HsConDeclH98Details` and `HsConDeclGADTDetails` synonyms on top of the new `HsConDeclDetails`, which instantiate the `inf` type parameter to `HsScaled pass (LBangType pass)` and `Void`, respectively. Using `Void` allows functions that consume `HsConDeclGADTDetails` to simply call `noGadtInfix` (i.e, `\x -> case x of {}`) instead of having to, say, `panic`. See also `Note [GADT syntax can't be infix]` in `GHC.Hs.Decls`. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{,H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon`. This is still possible since `RecCon`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 29 changed files: - compiler/GHC/Cmm/Type.hs - compiler/GHC/Hs/Binds.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Pat.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - + testsuite/tests/parser/should_compile/T12862.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_fail/T12446.hs - + testsuite/tests/parser/should_fail/T12446.stderr - testsuite/tests/parser/should_fail/all.T - testsuite/tests/patsyn/should_fail/T11010.stderr - + testsuite/tests/patsyn/should_fail/T18856.hs - + testsuite/tests/patsyn/should_fail/T18856.stderr - testsuite/tests/patsyn/should_fail/all.T - utils/haddock Changes: ===================================== compiler/GHC/Cmm/Type.hs ===================================== @@ -311,6 +311,8 @@ isVecType _ = False -- Hints are extra type information we attach to the arguments and -- results of a foreign call, where more type information is sometimes -- needed by the ABI to make the correct kind of call. +-- +-- See Note [Signed vs unsigned] for one case where this is used. data ForeignHint = NoHint | AddrHint | SignedHint ===================================== compiler/GHC/Hs/Binds.hs ===================================== @@ -1227,7 +1227,10 @@ pprMinimalSig (L _ bf) = ppr (fmap unLoc bf) -} -- | Haskell Pattern Synonym Details -type HsPatSynDetails pass = HsConDetails (LIdP pass) [RecordPatSynField (LIdP pass)] +type HsPatSynDetails pass + = HsConDetails (LIdP pass) + [RecordPatSynField (LIdP pass)] + (LIdP pass) -- See Note [Record PatSyn Fields] -- | Record Pattern Synonym Field ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -2,6 +2,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE EmptyCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -74,8 +75,9 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclDetails, HsConDeclH98Details, HsConDeclGADTDetails, noGadtInfix, + hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -126,6 +128,7 @@ import GHC.Core.Type import GHC.Data.Bag import GHC.Data.Maybe import Data.Data hiding (TyCon,Fixity, Infix) +import Data.Void {- ************************************************************************ @@ -1473,9 +1476,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1495,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1626,94 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass - = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a data constructor declaration. The @inf@ type parameter +-- represents the representation for infix data constructors, which is +-- different depending on whether the data constructor is Haskell98-style or +-- GADT-style. +type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + +-- | The arguments in a Haskell98-style data constructor, which can be infix. +type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + +-- | The arguments in a GADT constructor, which cannot be infix. +-- See @Note [GADT syntax can't be infix]@. +type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + +-- | Eliminate the payload of an 'InfixCon' of type 'HsConDeclGADTDetails'. +-- This function witnesses the fact that GADT constructors cannot be declared +-- with infix syntax (see @Note [GADT syntax can't be infix]@). This function +-- has the same implementation as 'Data.Void.absurd', but with a more specific +-- name to indicate its purpose. +noGadtInfix :: Void -> a +noGadtInfix v = case v of {} + +{- +Note [GADT syntax can't be infix] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The overall shape of Haskell98-style data constructors and GADT constructors +are very similar, which allows us to use the HsConDetails data type to +represent both forms of data constructors: + + data HsConDetails arg rec inf + = PrefixCon [arg] + | RecCon rec + | InfixCon inf inf + +But there is a key difference between the syntaxes of each form of data +constructor, however. Haskell98-style data constructors can use all three +varieties of HsConDetails above: + + data C p1 p2 + = C1 p1 p2 -- PrefixCon + | C2 { x :: p1, y :: p2 } -- InfixCon + | p1 `C2` p2 -- RecCon + +GADT constructors, on the other hand, can only use two HsConDetails varieties: + + data G p1 p2 where + G1 :: p1 -> p2 -> G p1 p2 -- PrefixCon + G2 :: { x :: p1, y :: p2 } -> G p1 p2 -- RecCon + +In other words, InfixCon is an unrepresentable state for GADT constructor +syntax (#18844). We encode this knowledge as a Haskell type by using separate +HsConDeclH98Details and HsConDeclGADTDetails type synonyms, which instantiate +the `inf` parameter of `HsConDetails pre rec inf` to different things. In +particular, HsConDeclGADTDetails instantiates `inf` to Void. This means that +when you match on an argument of type HsConDeclGADTDetails, you can "forget" +about the unrepresentable InfixCon case by using `noGadtInfix`: + + f :: HsConDeclGADTDetails pass -> blah + f (PrefixCon _) = ... + f (RecCon _) = ... + f (InfixCon v _) = noGadtInfix v + +Note that this Note only applies to the *surface syntax* of GADT constructors. +There is a notion of infix GADT constructors for the purposes of derived Show +instances (see Note [Infix GADT constructors] in GHC.Tc.TyCl), but that is an +orthogonal concern. +-} getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon v _ -> noGadtInfix v hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,7 +1793,7 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, @@ -1731,7 +1801,7 @@ pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars where get_args (PrefixCon args) = map ppr args get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (InfixCon v _) = noGadtInfix v cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Pat.hs ===================================== @@ -316,7 +316,7 @@ type instance ConLikeP GhcTc = ConLike -- | Haskell Constructor Pattern Details -type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) +type HsConPatDetails p = HsConDetails (LPat p) (HsRecFields p (LPat p)) (LPat p) hsConPatArgs :: HsConPatDetails p -> [LPat p] hsConPatArgs (PrefixCon ps) = ps @@ -866,7 +866,7 @@ patNeedsParens p = go -- | @'conPatNeedsParens' p cp@ returns 'True' if the constructor patterns @cp@ -- needs parentheses under precedence @p at . -conPatNeedsParens :: PprPrec -> HsConDetails a b -> Bool +conPatNeedsParens :: PprPrec -> HsConDetails a b c -> Bool conPatNeedsParens p = go where go (PrefixCon args) = p >= appPrec && not (null args) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1104,15 +1104,19 @@ instance OutputableBndrId p -- HsConDetails is used for patterns/expressions *and* for data type -- declarations --- | Haskell Constructor Details -data HsConDetails arg rec +-- | Haskell Constructor Details. +-- +-- The @arg@ and @inf@ type parameters are kept separate so that GADT +-- constructors (which cannot be declared with infix syntax) can instantiate +-- @inf@ to @Void at . See @Note [GADT syntax can't be infix]@ in "GHC.Hs.Decls". +data HsConDetails arg rec inf = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } - | InfixCon arg arg -- p1 `C` p2 + | InfixCon inf inf -- p1 `C` p2 deriving Data -instance (Outputable arg, Outputable rec) - => Outputable (HsConDetails arg rec) where +instance (Outputable arg, Outputable rec, Outputable inf) + => Outputable (HsConDetails arg rec inf) where ppr (PrefixCon args) = text "PrefixCon" <+> ppr args ppr (RecCon rec) = text "RecCon:" <+> ppr rec ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r] ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,7 +1257,7 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where (remSeen', flds) = get_flds remSeen args @@ -1269,7 +1269,7 @@ hsConDeclsBinders cons (remSeen', flds) = get_flds remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds :: Seen p -> HsConDeclDetails (GhcPass p) inf -> (Seen p, [LFieldOcc (GhcPass p)]) get_flds remSeen (RecCon flds) = (remSeen', fld_names) ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,31 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + InfixCon v _ -> noGadtInfix v + RecCon _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,52 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + InfixCon v _ -> noGadtInfix v + RecCon ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a PrefixCon. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a RecCon. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2635,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -68,6 +68,7 @@ import qualified Data.Map as M import qualified Data.Set as S import Data.Data ( Data, Typeable ) import Data.List ( foldl1' ) +import Data.Void import Control.Monad ( forM_ ) import Control.Monad.Trans.State.Strict import Control.Monad.Trans.Reader @@ -578,6 +579,9 @@ class ToHie a where class HasType a where getTypeNode :: a -> HieM [HieAST Type] +instance ToHie Void where + toHie = absurd + instance (ToHie a) => ToHie [a] where toHie = concatMapM toHie @@ -996,8 +1000,10 @@ instance HiePass p => ToHie (PScoped (Located (Pat (GhcPass p)))) where HieRn -> [] #endif where - contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) - -> HsConDetails (PScoped a) (RContext (HsRecFields (GhcPass p) (PScoped a))) + contextify :: a ~ LPat (GhcPass p) => HsConDetails a (HsRecFields (GhcPass p) a) a + -> HsConDetails (PScoped a) + (RContext (HsRecFields (GhcPass p) (PScoped a))) + (PScoped a) contextify (PrefixCon args) = PrefixCon $ patScopes rsp scope pscope args contextify (InfixCon a b) = InfixCon a' b' where [a', b'] = patScopes rsp scope pscope [a,b] @@ -1314,7 +1320,7 @@ instance HiePass p => ToHie (RScoped (ApplicativeArg (GhcPass p))) where , toHie $ PS Nothing sc NoScope pat ] -instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where +instance (ToHie arg, ToHie rec, ToHie inf) => ToHie (HsConDetails arg rec inf) where toHie (PrefixCon args) = toHie args toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] @@ -1530,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1541,7 +1547,10 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixCon xs -> scaled_args_scope xs + InfixCon v _ -> noGadtInfix v + RecCon x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1555,13 +1564,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -643,7 +643,7 @@ mkGadtDecl names ty = do , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,22 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of + con_g_args' <- + case con_g_args of PrefixCon ts -> PrefixCon <$> addHaddock ts RecCon (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + InfixCon v _ -> noGadtInfix v con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,16 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixCon args -> extract_scaled_ltys args + InfixCon v _ -> noGadtInfix v + RecCon (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1808,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,22 +2246,36 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name + -> HsDocContext + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details = rnConDeclDetails rnScaledLHsType + +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails = rnConDeclDetails (\_ -> noGadtInfix) + +rnConDeclDetails :: + (HsDocContext -> infPs -> RnM (infRn, FreeVars)) + -> Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclDetails GhcPs infPs + -> RnM (HsConDeclDetails GhcRn infRn, FreeVars) +rnConDeclDetails _ _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } -rnConDeclDetails _ doc (InfixCon ty1 ty2) - = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 - ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 +rnConDeclDetails rn_inf _ doc (InfixCon ty1 ty2) + = do { (new_ty1, fvs1) <- rn_inf doc ty1 + ; (new_ty2, fvs2) <- rn_inf doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclDetails _ con doc (RecCon (L l fields)) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecCon flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1563,7 +1563,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the type of an argument to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1576,6 +1576,23 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args = kcConArgs kcConArgTys + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs = kcConArgs (\_ _ -> mapM_ noGadtInfix) + +-- Kind-check the types of argument to a data constructor. +kcConArgs :: (NewOrData -> Kind -> [infRn] -> TcM ()) + -> NewOrData -> Kind -> HsConDeclDetails GhcRn infRn -> TcM () +kcConArgs kc_inf new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kc_inf new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1604,14 +1621,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1642,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3213,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3283,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3300,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,19 +3379,20 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of InfixCon {} -> return True - _ -> return False + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True + InfixCon v _ -> noGadtInfix v RecCon {} -> return False PrefixCon arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) @@ -3383,18 +3401,31 @@ tcConIsInfixGADT con details ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args = tcConArgs tcConArg + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs = tcConArgs (\_ -> noGadtInfix) + +tcConArgs :: (ContextKind -> infRn -> TcM (Scaled TcType, HsSrcBang)) + -> ContextKind -- expected kind of arguments -- always OpenKind for datatypes, but unlifted newtypes -- might have a specific kind - -> HsConDeclDetails GhcRn + -> HsConDeclDetails GhcRn infRn -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConArgs _ exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) - = do { bty1' <- tcConArg exp_kind bty1 - ; bty2' <- tcConArg exp_kind bty2 - ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConArgs tc_inf exp_kind (InfixCon bty1 bty2) + = mapM (tc_inf exp_kind) [bty1, bty2] +tcConArgs _ exp_kind (RecCon fields) = mapM (tcConArg exp_kind) btys where -- We need a one-to-one mapping from field_names to btys @@ -3434,7 +3465,8 @@ matches what the user wrote (#18791). Note [Infix GADT constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We do not currently have syntax to declare an infix constructor in GADT syntax, +We do not currently have syntax to declare an infix constructor in GADT syntax +(see Note [GADT syntax can't be infix] in GHC.Hs.Decls), but it makes a (small) difference to the Show instance. So as a slightly ad-hoc solution, we regard a GADT data constructor as infix if a) it is an operator symbol ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -31,9 +31,9 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Builtin.Types.Prim import GHC.Types.Name +import GHC.Types.Name.Set import GHC.Types.SrcLoc import GHC.Core.PatSyn -import GHC.Types.Name.Set import GHC.Utils.Panic import GHC.Utils.Outputable import GHC.Data.FastString @@ -422,14 +422,22 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details ; tc_patsyn_finish lname dir is_infix lpat' (univ_bndrs, req_theta, ev_binds, req_dicts) (ex_bndrs, mkTyVarTys ex_tvs', prov_theta, prov_dicts) - (args', (map scaledThing arg_tys)) + (args', map scaledThing arg_tys) pat_ty rec_fields } where tc_arg :: TCvSubst -> Name -> Type -> TcM (LHsExpr GhcTc) + -- Look up the variable actually bound by lpat + -- and check that it has the expected type tc_arg subst arg_name arg_ty - = do { -- Look up the variable actually bound by lpat - -- and check that it has the expected type - arg_id <- tcLookupId arg_name + = setSrcSpan (nameSrcSpan arg_name) $ + -- Set the SrcSpan to be the binding site of the Id (#18856) + -- e.g. pattern P :: Int -> Maybe (Int,Bool) + -- pattern P x = Just (x,True) + -- Before unifying x's actual type with its expected type, in tc_arg, set + -- location to x's binding site in lpat, namely the 'x' in Just (x,True). + -- Else the error message location is wherever tcCheckPat finished, + -- namely the right-hand corner of the pattern + do { arg_id <- tcLookupId arg_name ; wrap <- tcSubTypeSigma GenSigCtxt (idType arg_id) (substTyUnchecked subst arg_ty) ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -631,7 +631,7 @@ cvtConstr (RecGadtC c varstrtys ty) ; rec_flds <- mapM cvt_id_arg varstrtys ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,63 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never InfixCon + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be InfixCon + , ... + } + + Where: :: + + -- New type synonym introduced in GHC 9.2; equivalent to `HsConDeclDetails` + -- in previous versions of GHC + type HsConDeclH98Details pass + = HsConDeclDetails pass (HsScaled pass (LBangType pass)) + + -- New type synonym introduced in GHC 9.2 + type HsConDeclGADTDetails pass + = HsConDeclDetails pass Void + + -- The `inf` type parameter is new in GHC 9.2 + type HsConDeclDetails pass inf + = HsConDetails (HsScaled pass (LBangType pass)) + (XRec pass [LConDeclField pass]) + inf + + -- The `inf` type parameter is new in GHC 9.2 + data HsConDetails arg rec inf + = PrefixCon [arg] -- C p1 p2 p3 + | RecCon rec -- C { x = p1, y = p2 } + | InfixCon inf inf -- p1 `C` p2 + + The use of ``Void`` in ``HsConDeclGADTDetails`` reflects the fact that GADT + constructors cannot use infix syntax like Haskell98-style constructors can. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/parser/should_compile/T12862.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TypeFamilies, InstanceSigs #-} +{-# LANGUAGE BangPatterns #-} -- should parse even with BangPatterns enabled + +module T12862 where + +import Data.Kind (Type) + +class Key key where + data TotalMap key :: Type -> Type + (!) :: TotalMap key val -> (key -> val) + +instance Key Bool where + data TotalMap Bool val = BoolMap val val + (!) :: TotalMap Bool val -> (Bool -> val) + (BoolMap f _) ! False = f -- with parentheses + BoolMap f _ ! True = f -- without parentheses ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -172,3 +172,4 @@ test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) test('T18834a', normal, compile, ['']) test('T18834b', normal, compile, ['']) +test('T12862', normal, compile, ['']) ===================================== testsuite/tests/parser/should_fail/T12446.hs ===================================== @@ -0,0 +1,3 @@ +module T12446 where + +x = undefined @(_ ~ _) ===================================== testsuite/tests/parser/should_fail/T12446.stderr ===================================== @@ -0,0 +1,4 @@ + +T12446.hs:3:5: error: + Illegal visible type application ‘@(_ ~ _)’ + Perhaps you intended to use TypeApplications ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -173,3 +173,4 @@ test('T18251c', normal, compile_fail, ['']) test('T18251d', normal, compile_fail, ['']) test('T18251e', normal, compile_fail, ['']) test('T18251f', normal, compile_fail, ['']) +test('T12446', normal, compile_fail, ['']) ===================================== testsuite/tests/patsyn/should_fail/T11010.stderr ===================================== @@ -1,5 +1,5 @@ -T11010.hs:9:36: error: +T11010.hs:9:34: error: • Couldn't match type ‘a1’ with ‘Int’ Expected: a -> b Actual: a1 -> b @@ -12,3 +12,6 @@ T11010.hs:9:36: error: • Relevant bindings include x :: Expr a1 (bound at T11010.hs:9:36) f :: a1 -> b (bound at T11010.hs:9:34) + | +9 | pattern IntFun str f x = Fun str f x + | ^ ===================================== testsuite/tests/patsyn/should_fail/T18856.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE PatternSynonyms, ViewPatterns #-} + +module T18856 where + +pattern P :: Int -> Bool -> (Int, Bool, [(Bool,Bool)]) +pattern P p q <- (q, p, [(True,False)]) + ===================================== testsuite/tests/patsyn/should_fail/T18856.stderr ===================================== @@ -0,0 +1,14 @@ + +T18856.hs:6:19: error: + • Couldn't match expected type ‘Bool’ with actual type ‘Int’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ + +T18856.hs:6:22: error: + • Couldn't match expected type ‘Int’ with actual type ‘Bool’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ ===================================== testsuite/tests/patsyn/should_fail/all.T ===================================== @@ -9,7 +9,7 @@ test('T9705-2', normal, compile_fail, ['']) test('unboxed-bind', normal, compile_fail, ['']) test('unboxed-wrapper-naked', normal, compile_fail, ['']) test('T10873', normal, compile_fail, ['']) -test('T11010', normal, compile_fail, ['']) +test('T11010', normal, compile_fail, ['-fdiagnostics-show-caret']) test('records-check-sels', normal, compile_fail, ['']) test('records-no-uni-update', normal, compile_fail, ['']) test('records-no-uni-update2', normal, compile_fail, ['']) @@ -47,3 +47,4 @@ test('T15692', normal, compile, ['']) # It has -fdefer-type-errors inside test('T15694', normal, compile_fail, ['']) test('T16900', normal, compile_fail, ['-fdiagnostics-show-caret']) test('T14552', normal, compile_fail, ['']) +test('T18856', normal, compile_fail, ['-fdiagnostics-show-caret']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 27a4229b2082bc4f55a0e11f2f39f3076b9ea0d8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3818ba159df0856c5a43689a44513727edf47fe5...04b85ddce6dfe17a319716308b7e5d858477b852 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3818ba159df0856c5a43689a44513727edf47fe5...04b85ddce6dfe17a319716308b7e5d858477b852 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 12:28:05 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 25 Oct 2020 08:28:05 -0400 Subject: [Git][ghc/ghc][wip/T18844-alternate] Split HsConDecl{H98, GADT}Details Message-ID: <5f956f55186ce_89710b2d9182219c9@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844-alternate at Glasgow Haskell Compiler / GHC Commits: 265f0811 by Ryan Scott at 2020-10-25T08:27:47-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 21 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1473,9 +1473,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1492,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1623,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,15 +1731,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,29 +1257,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2634,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1319,6 +1319,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1530,7 +1534,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1541,7 +1545,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1555,13 +1561,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -633,17 +633,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,27 +2246,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1563,7 +1563,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1576,6 +1576,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1604,14 +1619,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1640,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3211,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3281,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3298,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,48 +3377,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3415,6 +3432,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -620,7 +620,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -629,9 +629,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 74ca5b1c6a11998747b3219a4e002cff17810533 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265f0811d568ea8f32daf78def96b1d4e1bd2d90 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265f0811d568ea8f32daf78def96b1d4e1bd2d90 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 12:29:37 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sun, 25 Oct 2020 08:29:37 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f956fb1c95e0_89710b2d918222141@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 265f0811 by Ryan Scott at 2020-10-25T08:27:47-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 21 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1473,9 +1473,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1492,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1623,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,15 +1731,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,29 +1257,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2634,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1319,6 +1319,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1530,7 +1534,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1541,7 +1545,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1555,13 +1561,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -633,17 +633,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,27 +2246,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1563,7 +1563,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1576,6 +1576,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1604,14 +1619,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1640,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3211,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3281,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3298,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,48 +3377,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3415,6 +3432,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -620,7 +620,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -629,9 +629,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 74ca5b1c6a11998747b3219a4e002cff17810533 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265f0811d568ea8f32daf78def96b1d4e1bd2d90 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/265f0811d568ea8f32daf78def96b1d4e1bd2d90 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 15:09:49 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 25 Oct 2020 11:09:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/gc-gen-no Message-ID: <5f95953db7857_8973fa3810ed10c2288d1@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/gc-gen-no at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/gc-gen-no You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 15:10:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 25 Oct 2020 11:10:03 -0400 Subject: [Git][ghc/ghc][wip/gc-gen-no] Scav: Use bd->gen_no instead of bd->gen->no Message-ID: <5f95954b7a4f_8973fa3b878425422907a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/gc-gen-no at Glasgow Haskell Compiler / GHC Commits: c54d7e90 by Ben Gamari at 2020-10-25T11:09:56-04:00 Scav: Use bd->gen_no instead of bd->gen->no This potentially saves a cache miss per scavenge. - - - - - 1 changed file: - rts/sm/Scav.c Changes: ===================================== rts/sm/Scav.c ===================================== @@ -435,7 +435,7 @@ scavenge_block (bdescr *bd) saved_eager_promotion = gct->eager_promotion; gct->failed_to_evac = false; - ws = &gct->gens[bd->gen->no]; + ws = &gct->gens[bd->gen_no]; p = bd->u.scan; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c54d7e903540dd86fa64a9e235f4161f91e490af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c54d7e903540dd86fa64a9e235f4161f91e490af You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 15:11:15 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sun, 25 Oct 2020 11:11:15 -0400 Subject: [Git][ghc/ghc][ghc-9.0] Naming, value types and tests for Addr# atomics Message-ID: <5f959593d264e_8973fa3810ed10c23225b@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: 5a2400c6 by Viktor Dukhovni at 2020-10-23T20:51:00-04:00 Naming, value types and tests for Addr# atomics The atomic Exchange and CAS operations on integral types are updated to take and return more natural `Word#` rather than `Int#` values. These are bit-block not arithmetic operations, and the sign bit plays no special role. Standardises the names to `atomic<OpType><ValType>Addr#`, where `OpType` is one of `Cas` or `Exchange` and `ValType` is presently either `Word` or `Addr`. Eventually, variants for `Word32` and `Word64` can and should be added, once #11953 and related issues (e.g. #13825) are resolved. Adds tests for `Addr#` CAS that mirror existing tests for `MutableByteArray#`. - - - - - 8 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - libraries/base/GHC/Ptr.hs - libraries/ghc-prim/changelog.md - testsuite/tests/codeGen/should_compile/cg011.hs - testsuite/tests/codeGen/should_run/cgrun080.hs - testsuite/tests/concurrent/should_run/AtomicPrimops.hs - testsuite/tests/concurrent/should_run/AtomicPrimops.stdout Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -2471,17 +2471,47 @@ primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp with has_side_effects = True can_fail = True -primop InterlockedExchange_Addr "interlockedExchangeAddr#" GenPrimOp +primop InterlockedExchange_Addr "atomicExchangeAddrAddr#" GenPrimOp Addr# -> Addr# -> State# s -> (# State# s, Addr# #) {The atomic exchange operation. Atomically exchanges the value at the first address with the Addr# given as second argument. Implies a read barrier.} with has_side_effects = True + can_fail = True -primop InterlockedExchange_Int "interlockedExchangeInt#" GenPrimOp - Addr# -> Int# -> State# s -> (# State# s, Int# #) +primop InterlockedExchange_Word "atomicExchangeWordAddr#" GenPrimOp + Addr# -> Word# -> State# s -> (# State# s, Word# #) {The atomic exchange operation. Atomically exchanges the value at the address with the given value. Returns the old value. Implies a read barrier.} with has_side_effects = True + can_fail = True + +primop CasAddrOp_Addr "atomicCasAddrAddr#" GenPrimOp + Addr# -> Addr# -> Addr# -> State# s -> (# State# s, Addr# #) + { Compare and swap on a word-sized memory location. + + Use as: \s -> atomicCasAddrAddr# location expected desired s + + This version always returns the old value read. This follows the normal + protocol for CAS operations (and matches the underlying instruction on + most architectures). + + Implies a full memory barrier.} + with has_side_effects = True + can_fail = True + +primop CasAddrOp_Word "atomicCasWordAddr#" GenPrimOp + Addr# -> Word# -> Word# -> State# s -> (# State# s, Word# #) + { Compare and swap on a word-sized and aligned memory location. + + Use as: \s -> atomicCasWordAddr# location expected desired s + + This version always returns the old value read. This follows the normal + protocol for CAS operations (and matches the underlying instruction on + most architectures). + + Implies a full memory barrier.} + with has_side_effects = True + can_fail = True ------------------------------------------------------------------------ section "Mutable variables" ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -846,9 +846,14 @@ emitPrimOp dflags primop = case primop of -- Atomic operations InterlockedExchange_Addr -> \[src, value] -> opIntoRegs $ \[res] -> emitPrimCall [res] (MO_Xchg (wordWidth platform)) [src, value] - InterlockedExchange_Int -> \[src, value] -> opIntoRegs $ \[res] -> + InterlockedExchange_Word -> \[src, value] -> opIntoRegs $ \[res] -> emitPrimCall [res] (MO_Xchg (wordWidth platform)) [src, value] + CasAddrOp_Addr -> \[dst, expected, new] -> opIntoRegs $ \[res] -> + emitPrimCall [res] (MO_Cmpxchg (wordWidth platform)) [dst, expected, new] + CasAddrOp_Word -> \[dst, expected, new] -> opIntoRegs $ \[res] -> + emitPrimCall [res] (MO_Cmpxchg (wordWidth platform)) [dst, expected, new] + -- SIMD primops (VecBroadcastOp vcat n w) -> \[e] -> opIntoRegs $ \[res] -> do checkVecCompatibility dflags vcat n w ===================================== libraries/base/GHC/Ptr.hs ===================================== @@ -171,7 +171,7 @@ castPtrToFunPtr (Ptr addr) = FunPtr addr exchangePtr :: Ptr (Ptr a) -> Ptr b -> IO (Ptr c) exchangePtr (Ptr dst) (Ptr val) = IO $ \s -> - case (interlockedExchangeAddr# dst val s) of + case (atomicExchangeAddrAddr# dst val s) of (# s2, old_val #) -> (# s2, Ptr old_val #) ------------------------------------------------------------------------ ===================================== libraries/ghc-prim/changelog.md ===================================== @@ -21,8 +21,13 @@ - Add primops for atomic exchange: - interlockedExchangeAddr# :: Addr# -> Addr# -> State# s -> (# State# s, Addr# #) - interlockedExchangeInt# :: Addr# -> Int# -> State# s -> (# State# s, Int# #) + atomicExchangeAddrAddr# :: Addr# -> Addr# -> State# s -> (# State# s, Addr# #) + atomicExchangeWordAddr# :: Addr# -> Word# -> State# s -> (# State# s, Word# #) + +- Add primops for atomic compare and swap at a given Addr#: + + atomicCasAddrAddr# :: Addr# -> Addr# -> Addr# -> State# s -> (# State# s, Addr# #) + atomicCasWordAddr# :: Addr# -> Word# -> Word# -> State# s -> (# State# s, Word# #) - Add an explicit fixity for `(~)` and `(~~)`: ===================================== testsuite/tests/codeGen/should_compile/cg011.hs ===================================== @@ -1,11 +1,11 @@ {-# LANGUAGE CPP, MagicHash, BlockArguments, UnboxedTuples #-} --- Tests compilation for interlockedExchange primop. +-- Tests compilation for atomicExchangeWordAddr# primop. module M where -import GHC.Exts (interlockedExchangeInt#, Int#, Addr#, State# ) +import GHC.Exts (atomicExchangeWordAddr#, Word#, Addr#, State# ) -swap :: Addr# -> Int# -> State# s -> (# #) -swap ptr val s = case (interlockedExchangeInt# ptr val s) of +swap :: Addr# -> Word# -> State# s -> (# #) +swap ptr val s = case (atomicExchangeWordAddr# ptr val s) of (# s2, old_val #) -> (# #) ===================================== testsuite/tests/codeGen/should_run/cgrun080.hs ===================================== @@ -25,8 +25,8 @@ import GHC.Types main = do alloca $ \ptr_i -> do - poke ptr_i (1 :: Int) - w1 <- newEmptyMVar :: IO (MVar Int) + poke ptr_i (1 :: Word) + w1 <- newEmptyMVar :: IO (MVar Word) forkIO $ do v <- swapN 50000 2 ptr_i putMVar w1 v @@ -37,15 +37,14 @@ main = do -- Should be [1,2,3] print $ sort [v0,v1,v2] -swapN :: Int -> Int -> Ptr Int -> IO Int +swapN :: Word -> Word -> Ptr Word -> IO Word swapN 0 val ptr = return val swapN n val ptr = do val' <- swap ptr val swapN (n-1) val' ptr -swap :: Ptr Int -> Int -> IO Int -swap (Ptr ptr) (I# val) = do - IO $ \s -> case (interlockedExchangeInt# ptr val s) of - (# s2, old_val #) -> (# s2, I# old_val #) - +swap :: Ptr Word -> Word -> IO Word +swap (Ptr ptr) (W# val) = do + IO $ \s -> case (atomicExchangeWordAddr# ptr val s) of + (# s2, old_val #) -> (# s2, W# old_val #) ===================================== testsuite/tests/concurrent/should_run/AtomicPrimops.hs ===================================== @@ -6,6 +6,8 @@ module Main ( main ) where import Control.Concurrent import Control.Concurrent.MVar import Control.Monad (when) +import Foreign.Marshal.Alloc +import Foreign.Ptr import Foreign.Storable import GHC.Exts import GHC.IO @@ -22,6 +24,7 @@ main = do fetchOrTest fetchXorTest casTest + casTestAddr readWriteTest -- | Test fetchAddIntArray# by having two threads concurrenctly @@ -54,12 +57,14 @@ fetchXorTest = do work mba 0 val = return () work mba n val = fetchXorIntArray mba 0 val >> work mba (n-1) val - -- Initial value is a large prime and the two patterns are 1010... - -- and 0101... + -- The two patterns are 1010... and 0101... The second pattern is larger + -- than maxBound, avoid warnings by initialising as a Word. (n0, t1pat, t2pat) | sizeOf (undefined :: Int) == 8 = - (0x00000000ffffffff, 0x5555555555555555, 0x9999999999999999) - | otherwise = (0x0000ffff, 0x55555555, 0x99999999) + ( 0x00000000ffffffff, 0x5555555555555555 + , fromIntegral (0x9999999999999999 :: Word)) + | otherwise = ( 0x0000ffff, 0x55555555 + , fromIntegral (0x99999999 :: Word)) expected | sizeOf (undefined :: Int) == 8 = 4294967295 | otherwise = 65535 @@ -90,13 +95,15 @@ fetchOpTest op expected name = do -- | Initial value and operation arguments for race test. -- --- Initial value is a large prime and the two patterns are 1010... --- and 0101... +-- The two patterns are 1010... and 0101... The second pattern is larger than +-- maxBound, avoid warnings by initialising as a Word. n0, t1pat, t2pat :: Int (n0, t1pat, t2pat) | sizeOf (undefined :: Int) == 8 = - (0x00000000ffffffff, 0x5555555555555555, 0x9999999999999999) - | otherwise = (0x0000ffff, 0x55555555, 0x99999999) + ( 0x00000000ffffffff, 0x5555555555555555 + , fromIntegral (0x9999999999999999 :: Word)) + | otherwise = ( 0x0000ffff, 0x55555555 + , fromIntegral (0x99999999 :: Word)) fetchAndTest :: IO () fetchAndTest = fetchOpTest fetchAndIntArray expected "fetchAndTest" @@ -120,8 +127,10 @@ fetchNandTest = do fetchOrTest :: IO () fetchOrTest = fetchOpTest fetchOrIntArray expected "fetchOrTest" where expected - | sizeOf (undefined :: Int) == 8 = 15987178197787607039 - | otherwise = 3722313727 + | sizeOf (undefined :: Int) == 8 + = fromIntegral (15987178197787607039 :: Word) + | otherwise + = fromIntegral (3722313727 :: Word) -- | Test casIntArray# by using it to emulate fetchAddIntArray# and -- then having two threads concurrenctly increment a counter, @@ -131,7 +140,7 @@ casTest = do tot <- race 0 (\ mba -> work mba iters 1) (\ mba -> work mba iters 2) - assertEq 3000000 tot "casTest" + assertEq (3 * iters) tot "casTest" where work :: MByteArray -> Int -> Int -> IO () work mba 0 val = return () @@ -179,6 +188,45 @@ race n0 thread1 thread2 = do mapM_ takeMVar [done1, done2] readIntArray mba 0 +-- | Test atomicCasWordAddr# by having two threads concurrenctly increment a +-- counter, checking the sum at the end. +casTestAddr :: IO () +casTestAddr = do + tot <- raceAddr 0 + (\ addr -> work addr (fromIntegral iters) 1) + (\ addr -> work addr (fromIntegral iters) 2) + assertEq (3 * fromIntegral iters) tot "casTestAddr" + where + work :: Ptr Word -> Word -> Word -> IO () + work ptr 0 val = return () + work ptr n val = add ptr val >> work ptr (n-1) val + + -- Fetch-and-add implemented using CAS. + add :: Ptr Word -> Word -> IO () + add ptr n = peek ptr >>= go + where + go old = do + old' <- atomicCasWordPtr ptr old (old + n) + when (old /= old') $ go old' + + -- | Create two threads that mutate the byte array passed to them + -- concurrently. The array is one word large. + raceAddr :: Word -- ^ Initial value of array element + -> (Ptr Word -> IO ()) -- ^ Thread 1 action + -> (Ptr Word -> IO ()) -- ^ Thread 2 action + -> IO Word -- ^ Final value of array element + raceAddr n0 thread1 thread2 = do + done1 <- newEmptyMVar + done2 <- newEmptyMVar + ptr <- asWordPtr <$> callocBytes (sizeOf (undefined :: Word)) + forkIO $ thread1 ptr >> putMVar done1 () + forkIO $ thread2 ptr >> putMVar done2 () + mapM_ takeMVar [done1, done2] + peek ptr + where + asWordPtr :: Ptr a -> Ptr Word + asWordPtr = castPtr + ------------------------------------------------------------------------ -- Test helper @@ -254,3 +302,13 @@ casIntArray :: MByteArray -> Int -> Int -> Int -> IO Int casIntArray (MBA mba#) (I# ix#) (I# old#) (I# new#) = IO $ \ s# -> case casIntArray# mba# ix# old# new# s# of (# s2#, old2# #) -> (# s2#, I# old2# #) + +------------------------------------------------------------------------ +-- Wrappers around Addr# + +-- Should this be added to Foreign.Storable? Similar to poke, but does the +-- update atomically. +atomicCasWordPtr :: Ptr Word -> Word -> Word -> IO Word +atomicCasWordPtr (Ptr addr#) (W# old#) (W# new#) = IO $ \ s# -> + case atomicCasWordAddr# addr# old# new# s# of + (# s2#, old2# #) -> (# s2#, W# old2# #) ===================================== testsuite/tests/concurrent/should_run/AtomicPrimops.stdout ===================================== @@ -4,4 +4,5 @@ fetchNandTest: OK fetchOrTest: OK fetchXorTest: OK casTest: OK +casTestAddr: OK readWriteTest: OK View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a2400c6570e4069b04f8d727c9058620bb99f3c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a2400c6570e4069b04f8d727c9058620bb99f3c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 19:59:19 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 25 Oct 2020 15:59:19 -0400 Subject: [Git][ghc/ghc][wip/T18599] Add Projection syntax Message-ID: <5f95d9179748a_8973fa3d98774d82449fe@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: d27f241b by Shayne Fletcher at 2020-10-25T15:57:56-04:00 Add Projection syntax Add case `Projection` to `HsExpr` for record selectors. - - - - - 10 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Types/Origin.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -457,9 +457,10 @@ data HsExpr p -- For a type family, the arg types are of the *instance* tycon, -- not the family tycon - -- | Record projections + -- | Record field selection. + -- Expressions of these cases arise only when the RecordDotSyntax + -- langauge extensions is enabled. - -- A get_field @fIELD arg expression. -- e.g. z.x = GetField { -- gf_ext=noExtField, gf_expr=z, gf_fIELD=x, gf_getField = getField @"x" z -- }. @@ -469,9 +470,24 @@ data HsExpr p , gf_fIELD :: Located FastString , gf_getField :: LHsExpr p -- Equivalent 'getField' term. } - -- Expressions of this case only arise when the RecordDotSyntax + + -- | Record field selector. + -- Expressions of these cases arise only when the RecordDotSyntax -- langauge extensions is enabled. + -- e.g. .x = Projection { + -- proj_ext=noExtField, proj_rhs=Nothing, proj_fIELD=x, proj_projection = \z -> z.x + -- }, + -- .x.y = Projection { + -- proj_ext=noExtField, proj_rhs=Just .x, proj_fIELD=y, proj_projection = (\z -> z.y) . (\z -> z.x) + -- } + | Projection + { proj_ext :: XProjection p + , proj_rhs :: Maybe (LHsExpr p) + , proj_fIELD :: Located FastString + , proj_projection :: LHsExpr p -- Equivalent 'getField' term. + } + -- | Expression with an explicit type signature. @e :: type@ -- -- - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnDcolon' @@ -595,8 +611,8 @@ data RecordUpdTc = RecordUpdTc , rupd_wrap :: HsWrapper -- See note [Record Update HsWrapper] } --- | Extra data fields for a 'GetField', added by the type checker data GetFieldTc = GetFieldTc +data ProjectionTc = ProjectionTc -- | HsWrap appears only in typechecker output -- Invariant: The contained Expr is *NOT* itself an HsWrap. @@ -670,6 +686,10 @@ type instance XGetField GhcPs = NoExtField type instance XGetField GhcRn = NoExtField type instance XGetField GhcTc = NoExtField +type instance XProjection GhcPs = NoExtField +type instance XProjection GhcRn = NoExtField +type instance XProjection GhcTc = NoExtField + type instance XExprWithTySig (GhcPass _) = NoExtField type instance XArithSeq GhcPs = NoExtField @@ -1218,6 +1238,11 @@ ppr_expr (RecordUpd { rupd_expr = L _ aexp, rupd_flds = rbinds }) ppr_expr (GetField { gf_expr = L _ fexp, gf_fIELD = field, gf_getField = _}) = ppr fexp <> dot <> ppr field +ppr_expr (Projection { proj_rhs = maybeRhs, proj_fIELD = field, proj_projection = _}) + = case maybeRhs of + Nothing -> dot <> ppr field + Just e -> ppr e <> dot <> ppr field + ppr_expr (ExprWithTySig _ expr sig) = hang (nest 2 (ppr_lexpr expr) <+> dcolon) 4 (ppr sig) @@ -1346,6 +1371,7 @@ hsExprNeedsParens p = go go (NegApp{}) = p > topPrec go (SectionL{}) = True go (SectionR{}) = True + go (Projection{}) = True go (ExplicitTuple{}) = False go (ExplicitSum{}) = False go (HsLam{}) = p > topPrec ===================================== compiler/GHC/Hs/Extension.hs ===================================== @@ -556,6 +556,7 @@ type family XExplicitList x type family XRecordCon x type family XRecordUpd x type family XGetField x +type family XProjection x type family XExprWithTySig x type family XArithSeq x type family XBracket x ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -346,6 +346,7 @@ deriving instance Data (ArithSeqInfo GhcTc) deriving instance Data RecordConTc deriving instance Data RecordUpdTc deriving instance Data GetFieldTc +deriving instance Data ProjectionTc deriving instance Data CmdTopTc deriving instance Data PendingRnSplice deriving instance Data PendingTcSplice ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -272,6 +272,7 @@ dsExpr (HsOverLabel{}) = panic "dsExpr: HsOverLabel" -- I feel these should have been eliminated by their equivalent -- getField expressions by now. dsExpr (GetField{}) = panic "dsExpr: GetField" +dsExpr (Projection{}) = panic "dsExpr: Projection" dsExpr (HsLit _ lit) = do { warnAboutOverflowedLit lit ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1165,6 +1165,9 @@ instance HiePass p => ToHie (Located (HsExpr (GhcPass p))) where GetField _ expr _ _ -> [ toHie expr ] + Projection _ maybeExpr _ _ -> + [ toHie maybeExpr + ] XExpr x | GhcTc <- ghcPass @p , WrapExpr (HsWrap w a) <- x ===================================== compiler/GHC/Parser.y ===================================== @@ -2807,8 +2807,10 @@ aexp2 :: { ECP } projection :: { LHsExpr GhcPs } projection -- See Note [Whitespace-sensitive operator parsing] in GHC.Parsing.Lexer - : projection TIGHT_INFIX_PROJ field { mkProj (Just $1) $3 } - | PREFIX_PROJ field { mkProj Nothing $2 } + : projection TIGHT_INFIX_PROJ field + {% ams (mkProjection (comb3 $1 $2 $3) (Just $1) $3) [mj AnnDot $2] } + | PREFIX_PROJ field + {% ams (mkProjection (comb2 $1 $2) Nothing $2) [mj AnnDot $1] } splice_exp :: { LHsExpr GhcPs } : splice_untyped { mapLoc (HsSpliceE noExtField) $1 } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -19,7 +19,7 @@ {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Parser.PostProcess ( - mkGetField, mkFieldUpdater, mkProj, isGetField, Fbind(..), -- RecordDot + mkGetField, mkProjection, mkFieldUpdater, mkProj, isGetField, Fbind(..), -- RecordDot mkHsOpApp, mkHsIntegral, mkHsFractional, mkHsIsString, mkHsDo, mkSpliceDecl, @@ -3006,6 +3006,15 @@ mkGetField loc arg fIELD = , gf_getField = mkGet arg fIELD } +mkProjection :: SrcSpan -> Maybe (LHsExpr GhcPs) -> Located FastString -> LHsExpr GhcPs +mkProjection loc maybeRhs fIELD = + L loc Projection { + proj_ext = noExtField + , proj_rhs = maybeRhs + , proj_fIELD = fIELD + , proj_projection = mkProj maybeRhs fIELD + } + -- mkSet a fIELD b calculates a set_field @fIELD expression. -- e.g mkSet a fIELD b = set_field @"fIELD" a b (read as "set field 'fIELD' on a to b"). mkSet :: LHsExpr GhcPs -> Located FastString -> LHsExpr GhcPs -> LHsExpr GhcPs ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -218,6 +218,16 @@ rnExpr (GetField x e f g) ; return (GetField x e' f g', fv) } +rnExpr (Projection x e f p) + = do { e' <- case e of + Nothing -> pure Nothing + Just expr -> do + (e', _) <- rnLExpr expr + pure (Just e') + ; (p', fv) <- rnLExpr p + ; return (Projection x e' f p', fv) + } + ------------------------------------------ -- Template Haskell extensions rnExpr e@(HsBracket _ br_body) = rnBracket e br_body ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -1037,6 +1037,7 @@ tcExpr (ArithSeq _ witness seq) res_ty ************************************************************************ -} tcExpr (GetField _ _ _ (L _ g)) res_ty = tcExpr g res_ty +tcExpr (Projection _ _ _ (L _ p)) res_ty = tcExpr p res_ty {- ************************************************************************ ===================================== compiler/GHC/Tc/Types/Origin.hs ===================================== @@ -500,6 +500,7 @@ exprCtOrigin (OpApp _ _ op _) = lexprCtOrigin op exprCtOrigin (NegApp _ e _) = lexprCtOrigin e exprCtOrigin (HsPar _ e) = lexprCtOrigin e exprCtOrigin (GetField _ e _ _) = lexprCtOrigin e +exprCtOrigin (Projection _ _ _ _) = SectionOrigin exprCtOrigin (SectionL _ _ _) = SectionOrigin exprCtOrigin (SectionR _ _ _) = SectionOrigin exprCtOrigin (ExplicitTuple {}) = Shouldn'tHappenOrigin "explicit tuple" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d27f241b3ae8df2ccc5238768be5caa3608d8496 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d27f241b3ae8df2ccc5238768be5caa3608d8496 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 20:35:38 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 25 Oct 2020 16:35:38 -0400 Subject: [Git][ghc/ghc][wip/T18599] freshen up the test script Message-ID: <5f95e19a86705_8973fa3bbed3c5024689a@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 58b13043 by Shayne Fletcher at 2020-10-25T16:35:19-04:00 freshen up the test script - - - - - 1 changed file: - record-dot-syntax-test.sh Changes: ===================================== record-dot-syntax-test.sh ===================================== @@ -1,9 +1,24 @@ #!/usr/bin/env bash +set -euo pipefail + PATH=`pwd`/_build/stage1/bin:$PATH; export PATH -make test TEST=RecordDotSyntax -make test TEST=RecordDotSyntaxFail0 -make test TEST=RecordDotSyntaxFail1 -make test TEST=RecordDotSyntaxFail2 -make test TEST=RecordDotSyntaxFail3 -make test TEST=RecordDotSyntaxFail4 + +tests=( \ + RecordDotSyntax \ + RecordDotSyntaxFail0 \ + RecordDotSyntaxFail1 \ + RecordDotSyntaxFail2 \ + RecordDotSyntaxFail3 \ + RecordDotSyntaxFail4 \ + ) + +test () { + printf "make test TEST=$%s\n" $1 + make test TEST=$1 +} + +for t in "${tests[@]}" +do + test $t +done View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58b130435474aca0e0c40036819da031816838b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58b130435474aca0e0c40036819da031816838b5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 21:25:02 2020 From: gitlab at gitlab.haskell.org (Shayne Fletcher) Date: Sun, 25 Oct 2020 17:25:02 -0400 Subject: [Git][ghc/ghc][wip/T18599] reconsider hsExprNeedsParens impl Message-ID: <5f95ed2ea1967_8973fa3baf0f15c2480e0@gitlab.haskell.org.mail> Shayne Fletcher pushed to branch wip/T18599 at Glasgow Haskell Compiler / GHC Commits: 5e29a359 by Shayne Fletcher at 2020-10-25T17:24:07-04:00 reconsider hsExprNeedsParens impl - - - - - 2 changed files: - compiler/GHC/Hs/Expr.hs - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Hs/Expr.hs ===================================== @@ -1371,7 +1371,6 @@ hsExprNeedsParens p = go go (NegApp{}) = p > topPrec go (SectionL{}) = True go (SectionR{}) = True - go (Projection{}) = True go (ExplicitTuple{}) = False go (ExplicitSum{}) = False go (HsLam{}) = p > topPrec @@ -1398,10 +1397,11 @@ hsExprNeedsParens p = go go (HsBinTick _ _ _ (L _ e)) = go e go (RecordCon{}) = False go (HsRecFld{}) = False - -- To be honest I'm not sure right now but we know that projection - -- has higher precedence than application since f r.a.b parses as - -- f (r.a.b) so I'm going to with False for the moment. + + -- Not entirely clear about these. go (GetField{}) = False + go (Projection{}) = False + go (XExpr x) | GhcTc <- ghcPass @p = case x of ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -19,7 +19,7 @@ {-# OPTIONS_GHC -Wno-incomplete-record-updates #-} module GHC.Parser.PostProcess ( - mkGetField, mkProjection, mkFieldUpdater, mkProj, isGetField, Fbind(..), -- RecordDot + mkGetField, mkProjection, mkFieldUpdater, isGetField, Fbind(..), -- RecordDot mkHsOpApp, mkHsIntegral, mkHsFractional, mkHsIsString, mkHsDo, mkSpliceDecl, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e29a35991a311951978b06ab03b0e04452b10b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e29a35991a311951978b06ab03b0e04452b10b5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sun Oct 25 22:42:48 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Sun, 25 Oct 2020 18:42:48 -0400 Subject: [Git][ghc/ghc][wip/az/apiann-annpercent] 5 commits: testsuite: Mark T12971 as fragile on Windows Message-ID: <5f95ff68e879d_8973fa3bba598a0256125@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/apiann-annpercent at Glasgow Haskell Compiler / GHC Commits: cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 60f7085a by Alan Zimmerman at 2020-10-25T22:37:56+00:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - 15 changed files: - compiler/GHC/Cmm/Type.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - testsuite/tests/driver/all.T - + testsuite/tests/parser/should_compile/T12862.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_fail/T12446.hs - + testsuite/tests/parser/should_fail/T12446.stderr - testsuite/tests/parser/should_fail/all.T - testsuite/tests/patsyn/should_fail/T11010.stderr - + testsuite/tests/patsyn/should_fail/T18856.hs - + testsuite/tests/patsyn/should_fail/T18856.stderr - testsuite/tests/patsyn/should_fail/all.T Changes: ===================================== compiler/GHC/Cmm/Type.hs ===================================== @@ -311,6 +311,8 @@ isVecType _ = False -- Hints are extra type information we attach to the arguments and -- results of a foreign call, where more type information is sometimes -- needed by the ABI to make the correct kind of call. +-- +-- See Note [Signed vs unsigned] for one case where this is used. data ForeignHint = NoHint | AddrHint | SignedHint ===================================== compiler/GHC/Parser.y ===================================== @@ -2056,17 +2056,19 @@ type :: { LHsType GhcPs } [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) - [mj AnnMult $2,mu AnnRarrow $3] } + >> let (arr, anns) = (unLoc $2) (toUnicode $3) + in (ams $1 (mu AnnRarrow $3:anns) -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField arr $1 $4) + (mu AnnRarrow $3:anns)) } | btype '->.' ctype {% hintLinear (getLoc $2) >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } +mult :: { Located (IsUnicodeSyntax -> (HsArrow GhcPs, [AddAnn])) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2 + (AddAnn AnnPercentOne (comb2 $1 $2), mj AnnPercent $1)) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,7 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule - | AnnMult -- ^ '%1' + | AnnPercentOne -- ^ '%1' | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf @@ -318,6 +318,7 @@ data AnnKeywordId | AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell | AnnPackageName | AnnPattern + | AnnPercent -- ^ '%' -- for HsExplicitMult | AnnProc | AnnQualified | AnnRarrow -- ^ '->' ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,10 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs -mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u -mkMultTy u t = HsExplicitMult u t +mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> (AddAnn, AddAnn) -> (HsArrow GhcPs, [AddAnn]) +mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) (ann,_) + = (HsLinearArrow u, [ann]) +mkMultTy u t (_, ann) = (HsExplicitMult u t, [ann]) ----------------------------------------------------------------------------- -- Token symbols ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -31,9 +31,9 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Builtin.Types.Prim import GHC.Types.Name +import GHC.Types.Name.Set import GHC.Types.SrcLoc import GHC.Core.PatSyn -import GHC.Types.Name.Set import GHC.Utils.Panic import GHC.Utils.Outputable import GHC.Data.FastString @@ -422,14 +422,22 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details ; tc_patsyn_finish lname dir is_infix lpat' (univ_bndrs, req_theta, ev_binds, req_dicts) (ex_bndrs, mkTyVarTys ex_tvs', prov_theta, prov_dicts) - (args', (map scaledThing arg_tys)) + (args', map scaledThing arg_tys) pat_ty rec_fields } where tc_arg :: TCvSubst -> Name -> Type -> TcM (LHsExpr GhcTc) + -- Look up the variable actually bound by lpat + -- and check that it has the expected type tc_arg subst arg_name arg_ty - = do { -- Look up the variable actually bound by lpat - -- and check that it has the expected type - arg_id <- tcLookupId arg_name + = setSrcSpan (nameSrcSpan arg_name) $ + -- Set the SrcSpan to be the binding site of the Id (#18856) + -- e.g. pattern P :: Int -> Maybe (Int,Bool) + -- pattern P x = Just (x,True) + -- Before unifying x's actual type with its expected type, in tc_arg, set + -- location to x's binding site in lpat, namely the 'x' in Just (x,True). + -- Else the error message location is wherever tcCheckPat finished, + -- namely the right-hand corner of the pattern + do { arg_id <- tcLookupId arg_name ; wrap <- tcSubTypeSigma GenSigCtxt (idType arg_id) (substTyUnchecked subst arg_ty) ===================================== testsuite/tests/driver/all.T ===================================== @@ -258,7 +258,7 @@ test('T12752pass', normal, compile, ['-DSHOULD_PASS=1 -Wcpp-undef']) test('T12955', normal, makefile_test, []) -test('T12971', [when(opsys('mingw32'), expect_broken(17945)), ignore_stdout], makefile_test, []) +test('T12971', [when(opsys('mingw32'), fragile(17945)), ignore_stdout], makefile_test, []) test('json', normal, compile_fail, ['-ddump-json']) test('json2', normalise_version('base','ghc-prim'), compile, ['-ddump-types -ddump-json']) test('T16167', exit_code(1), run_command, ===================================== testsuite/tests/parser/should_compile/T12862.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TypeFamilies, InstanceSigs #-} +{-# LANGUAGE BangPatterns #-} -- should parse even with BangPatterns enabled + +module T12862 where + +import Data.Kind (Type) + +class Key key where + data TotalMap key :: Type -> Type + (!) :: TotalMap key val -> (key -> val) + +instance Key Bool where + data TotalMap Bool val = BoolMap val val + (!) :: TotalMap Bool val -> (Bool -> val) + (BoolMap f _) ! False = f -- with parentheses + BoolMap f _ ! True = f -- without parentheses ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -172,3 +172,4 @@ test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) test('T18834a', normal, compile, ['']) test('T18834b', normal, compile, ['']) +test('T12862', normal, compile, ['']) ===================================== testsuite/tests/parser/should_fail/T12446.hs ===================================== @@ -0,0 +1,3 @@ +module T12446 where + +x = undefined @(_ ~ _) ===================================== testsuite/tests/parser/should_fail/T12446.stderr ===================================== @@ -0,0 +1,4 @@ + +T12446.hs:3:5: error: + Illegal visible type application ‘@(_ ~ _)’ + Perhaps you intended to use TypeApplications ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -173,3 +173,4 @@ test('T18251c', normal, compile_fail, ['']) test('T18251d', normal, compile_fail, ['']) test('T18251e', normal, compile_fail, ['']) test('T18251f', normal, compile_fail, ['']) +test('T12446', normal, compile_fail, ['']) ===================================== testsuite/tests/patsyn/should_fail/T11010.stderr ===================================== @@ -1,5 +1,5 @@ -T11010.hs:9:36: error: +T11010.hs:9:34: error: • Couldn't match type ‘a1’ with ‘Int’ Expected: a -> b Actual: a1 -> b @@ -12,3 +12,6 @@ T11010.hs:9:36: error: • Relevant bindings include x :: Expr a1 (bound at T11010.hs:9:36) f :: a1 -> b (bound at T11010.hs:9:34) + | +9 | pattern IntFun str f x = Fun str f x + | ^ ===================================== testsuite/tests/patsyn/should_fail/T18856.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE PatternSynonyms, ViewPatterns #-} + +module T18856 where + +pattern P :: Int -> Bool -> (Int, Bool, [(Bool,Bool)]) +pattern P p q <- (q, p, [(True,False)]) + ===================================== testsuite/tests/patsyn/should_fail/T18856.stderr ===================================== @@ -0,0 +1,14 @@ + +T18856.hs:6:19: error: + • Couldn't match expected type ‘Bool’ with actual type ‘Int’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ + +T18856.hs:6:22: error: + • Couldn't match expected type ‘Int’ with actual type ‘Bool’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ ===================================== testsuite/tests/patsyn/should_fail/all.T ===================================== @@ -9,7 +9,7 @@ test('T9705-2', normal, compile_fail, ['']) test('unboxed-bind', normal, compile_fail, ['']) test('unboxed-wrapper-naked', normal, compile_fail, ['']) test('T10873', normal, compile_fail, ['']) -test('T11010', normal, compile_fail, ['']) +test('T11010', normal, compile_fail, ['-fdiagnostics-show-caret']) test('records-check-sels', normal, compile_fail, ['']) test('records-no-uni-update', normal, compile_fail, ['']) test('records-no-uni-update2', normal, compile_fail, ['']) @@ -47,3 +47,4 @@ test('T15692', normal, compile, ['']) # It has -fdefer-type-errors inside test('T15694', normal, compile_fail, ['']) test('T16900', normal, compile_fail, ['-fdiagnostics-show-caret']) test('T14552', normal, compile_fail, ['']) +test('T18856', normal, compile_fail, ['-fdiagnostics-show-caret']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc4976be22fbe3eba1fe5e6828e66c304f61a869...60f7085a068b0152ae720215c55a2b04e2b6bcb0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc4976be22fbe3eba1fe5e6828e66c304f61a869...60f7085a068b0152ae720215c55a2b04e2b6bcb0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 05:15:12 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 26 Oct 2020 01:15:12 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 3 commits: [AArch64] Aarch64 Always PIC Message-ID: <5f965b608f74a_8973fa3ba78537826414e@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 92127659 by Moritz Angermann at 2020-10-26T10:46:14+08:00 [AArch64] Aarch64 Always PIC - - - - - 42f4c7de by Moritz Angermann at 2020-10-26T10:46:52+08:00 [Adjustors] Proper allocator handling. - - - - - 5764bca3 by Moritz Angermann at 2020-10-26T13:11:48+08:00 [CmmSized Int] fix haddock - - - - - 4 changed files: - compiler/GHC/Builtin/primops.txt.pp - includes/rts/Flags.h - rts/RtsSymbols.c - rts/sm/Storage.c Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -412,6 +412,8 @@ section "Int32#" {Operations on 32-bit integers.} ------------------------------------------------------------------------ +primtype Int32# + primop Int32ExtendOp "extendInt32#" GenPrimOp Int32# -> Int# primop Int32NarrowOp "narrowInt32#" GenPrimOp Int# -> Int32# ===================================== includes/rts/Flags.h ===================================== @@ -202,7 +202,7 @@ typedef struct _CONCURRENT_FLAGS { * Note that there is no 32bit darwin system we can realistically expect to * run on or compile for. */ -#if defined(darwin_HOST_OS) +#if defined(darwin_HOST_OS) || defined(aarch64_HOST_ARCH) #define DEFAULT_LINKER_ALWAYS_PIC true #else #define DEFAULT_LINKER_ALWAYS_PIC false ===================================== rts/RtsSymbols.c ===================================== @@ -958,6 +958,9 @@ SymI_HasProto(allocateExec) \ SymI_HasProto(flushExec) \ SymI_HasProto(freeExec) \ + SymI_HasProto(allocateWrite) \ + SymI_HasProto(markExec) \ + SymI_HasProto(freeWrite) \ SymI_HasProto(getAllocations) \ SymI_HasProto(revertCAFs) \ SymI_HasProto(RtsFlags) \ ===================================== rts/sm/Storage.c ===================================== @@ -1700,6 +1700,20 @@ void flushExec (W_ len, AdjustorExecutable exec_addr) #endif } +#if RTS_LINKER_USE_MMAP +AdjustorWritable allocateWrite(W_ bytes) { + return mmapForLinker(bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); +} + +void markExec(W_ bytes, AdjustorWritable writ) { + mmapForLinkerMarkExecutable(writ, bytes); +} + +void freeWrite(W_ bytes, AdjustorWritable writ) { + munmap(writ, bytes); +} +#endif + #if defined(linux_HOST_OS) || defined(netbsd_HOST_OS) // On Linux we need to use libffi for allocating executable memory, @@ -1749,20 +1763,6 @@ AdjustorWritable allocateExec(W_ bytes, AdjustorExecutable *exec_ret) return writ; } -#if RTS_LINKER_USE_MMAP -AdjustorWritable allocateWrite(W_ bytes) { - return mmapForLinker(bytes, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0); -} - -void markExec(W_ bytes, AdjustorWritable writ) { - mmapForLinkerMarkExecutable(writ, bytes); -} - -void freeWrite(W_ bytes, AdjustorWritable writ) { - munmap(writ, bytes); -} -#endif - AdjustorWritable execToWritable(AdjustorExecutable exec) { AdjustorWritable writ; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f47da637496321c0d0bdf34a34d22093d6c0236...5764bca329c18619598fbe99433f581a119a5898 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f47da637496321c0d0bdf34a34d22093d6c0236...5764bca329c18619598fbe99433f581a119a5898 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 08:34:06 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Mon, 26 Oct 2020 04:34:06 -0400 Subject: [Git][ghc/ghc][wip/az/apiann-annpercent] Api Annotations: Introduce AnnPercent for HsExplicitMult Message-ID: <5f9689fe45bc3_8973fa3ba7328302835f1@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/apiann-annpercent at Glasgow Haskell Compiler / GHC Commits: c15b5f25 by Alan Zimmerman at 2020-10-26T08:31:31+00:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - 3 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2056,17 +2056,18 @@ type :: { LHsType GhcPs } [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) - [mj AnnMult $2,mu AnnRarrow $3] } + >> let (arr, ann) = (unLoc $2) (toUnicode $3) + in (ams $1 [ann,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField arr $1 $4) + [ann,mu AnnRarrow $3]) } | btype '->.' ctype {% hintLinear (getLoc $2) >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } +mult :: { Located (IsUnicodeSyntax -> (HsArrow GhcPs, AddAnn)) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $1 $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,7 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule - | AnnMult -- ^ '%1' + | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf @@ -318,6 +318,7 @@ data AnnKeywordId | AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell | AnnPackageName | AnnPattern + | AnnPercent -- ^ '%' -- for HsExplicitMult | AnnProc | AnnQualified | AnnRarrow -- ^ '->' ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,10 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs -mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u -mkMultTy u t = HsExplicitMult u t +mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> (HsArrow GhcPs, AddAnn) +mkMultTy u tok t@(L _ (HsTyLit _ (HsNumTy _ 1))) + = (HsLinearArrow u, AddAnn AnnPercentOne (combineLocs tok t)) +mkMultTy u tok t = (HsExplicitMult u t, AddAnn AnnPercent (getLoc tok)) ----------------------------------------------------------------------------- -- Token symbols View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c15b5f25ad54164c951e797ecbd10d0df1cf4ba6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c15b5f25ad54164c951e797ecbd10d0df1cf4ba6 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 09:29:21 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Mon, 26 Oct 2020 05:29:21 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] tmp Message-ID: <5f9696f15d3a3_8973fa3bb4e9a28287911@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: 014516dd by Sebastian Graf at 2020-10-25T18:52:01+01:00 tmp - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,8 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 - is_thunk = not (exprIsHNF rhs) && not (isJoinId id) + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 -- Find the RHS free vars of the unfoldings and RULES -- See Note [Absence analysis for stable unfoldings and RULES] ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -43,7 +43,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -228,70 +228,6 @@ strBot, strTop :: ArgStr strBot = Str HyperStr strTop = Lazy -mkSCall :: StrDmd -> StrDmd -mkSCall HyperStr = HyperStr -mkSCall s = SCall s - -mkSProd :: [ArgStr] -> StrDmd -mkSProd sx - | any isHyperStr sx = HyperStr -- ??? Why any? - | all isLazy sx = HeadStr - | otherwise = SProd sx - -isHyperStr :: ArgStr -> Bool -isHyperStr (Str HyperStr) = True -isHyperStr _ = False - --- Pretty-printing -instance Outputable StrDmd where - ppr HyperStr = char 'B' - ppr (SCall s) = char 'C' <> parens (ppr s) - ppr HeadStr = char 'S' - ppr (SProd sx) = char 'S' <> parens (hcat (map ppr sx)) - -instance Outputable ArgStr where - ppr (Str s) = ppr s - ppr Lazy = char 'L' - -lubArgStr :: ArgStr -> ArgStr -> ArgStr -lubArgStr Lazy _ = Lazy -lubArgStr _ Lazy = Lazy -lubArgStr (Str s1) (Str s2) = Str (s1 `lubStr` s2) - -lubStr :: StrDmd -> StrDmd -> StrDmd -lubStr HyperStr s = s -lubStr (SCall s1) HyperStr = SCall s1 -lubStr (SCall _) HeadStr = HeadStr -lubStr (SCall s1) (SCall s2) = SCall (s1 `lubStr` s2) -lubStr (SCall _) (SProd _) = HeadStr -lubStr (SProd sx) HyperStr = SProd sx -lubStr (SProd _) HeadStr = HeadStr -lubStr (SProd s1) (SProd s2) - | s1 `equalLength` s2 = mkSProd (zipWith lubArgStr s1 s2) - | otherwise = HeadStr -lubStr (SProd _) (SCall _) = HeadStr -lubStr HeadStr _ = HeadStr - -bothArgStr :: ArgStr -> ArgStr -> ArgStr -bothArgStr Lazy s = s -bothArgStr s Lazy = s -bothArgStr (Str s1) (Str s2) = Str (s1 `bothStr` s2) - -bothStr :: StrDmd -> StrDmd -> StrDmd -bothStr HyperStr _ = HyperStr -bothStr HeadStr s = s -bothStr (SCall _) HyperStr = HyperStr -bothStr (SCall s1) HeadStr = SCall s1 -bothStr (SCall s1) (SCall s2) = SCall (s1 `bothStr` s2) -bothStr (SCall _) (SProd _) = HyperStr -- Weird - -bothStr (SProd _) HyperStr = HyperStr -bothStr (SProd s1) HeadStr = SProd s1 -bothStr (SProd s1) (SProd s2) - | s1 `equalLength` s2 = mkSProd (zipWith bothArgStr s1 s2) - | otherwise = HyperStr -- Weird -bothStr (SProd _) (SCall _) = HyperStr - -- utility functions to deal with memory leaks seqStrDmd :: StrDmd -> () seqStrDmd (SProd ds) = seqStrDmdList ds @@ -474,9 +410,9 @@ addCaseBndrDmd :: Demand -- On the case binder -> [Demand] -- On the components of the constructor -> [Demand] -- Final demands for the components of the constructor -- See Note [Demand on case-alternative binders] -addCaseBndrDmd dmd@(_ :* cd) alt_dmds - | isAbsDmd dmd = alt_dmds - | otherwise = zipWith bothDmd alt_dmds ds +addCaseBndrDmd (n :* cd) alt_dmds + | isAbs n = alt_dmds + | otherwise = zipWith bothDmd alt_dmds ds where Just ds = viewProd (length alt_dmds) cd -- Guaranteed not to be a call @@ -811,7 +747,7 @@ bothCleanDmd cd1 at Poly{} cd2 = bothCleanDmd cd2 cd1 -- Otherwise (Call `lub` Prod) return Top bothCleanDmd _ _ = topCleanDmd -bothDmd :: Demand -> Demand +bothDmd :: Demand -> Demand -> Demand bothDmd (n1 :* cd1) (n2 :* cd2) = bothCard n1 n2 :* bothCleanDmd cd1 cd2 oneifyDmd :: Demand -> Demand @@ -824,9 +760,7 @@ isTopDmd :: Demand -> Bool isTopDmd dmd = dmd == topDmd isAbsDmd :: Demand -> Bool -isAbsDmd (C_00 :* _) = True -isAbsDmd (C_10 :* _) = True -- Bottom demand is also absent -isAbsDmd _ = False +isAbsDmd (n :* _) = isAbs n isSeqDmd :: Demand -> Bool isSeqDmd (C_11 :* cd) = cd == seqCleanDmd @@ -854,11 +788,18 @@ isStrictDmd (C_11 :* _) = True isStrictDmd (C_1N :* _) = True isStrictDmd _ = False +-- | True <=> lower bound is 0. isLazy :: Card -> Bool isLazy C_01 = False isLazy C_0N = False isLazy _ = True +-- | True <=> upper bound is 0. +isAbs :: Card -> Bool +isAbs C_00 = True +isAbs C_10 = True -- Bottom cardinality is also absent +isAbs _ = False + {- Note [Scaling demands] ~~~~~~~~~~~~~~~~~~~~~~~~~ If a demand is used multiple times (/reused/), for example the argument in an @@ -948,28 +889,6 @@ isScaleInvariantCleanDmd (Call n _) = isScaleInvariantCard n -- See Note [Scalin isWeakDmd :: Demand -> Bool isWeakDmd (n :* cd) = isLazy n && isScaleInvariantCleanDmd cd -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) --- See Note [Lazy and unleashable free variables] in "GHC.Core.Opt.DmdAnal". -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoC_dFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -1002,38 +921,20 @@ data TypeShape -- See Note [Trimming a demand to a type] trimToType :: Demand -> TypeShape -> Demand -- See Note [Trimming a demand to a type] in GHC.Core.Opt.DmdAnal -trimToType (JD { sd = ms, ud = mu }) ts - = JD (go_ms ms ts) (go_mu mu ts) +trimToType (n :* cd) ts + = n :* go cd ts where - go_ms :: ArgStr -> TypeShape -> ArgStr - go_ms Lazy _ = Lazy - go_ms (Str s) ts = Str (go_s s ts) - - go_s :: StrDmd -> TypeShape -> StrDmd - go_s HyperStr _ = HyperStr - go_s (SCall s) (TsFun ts) = SCall (go_s s ts) - go_s (SProd mss) (TsProd tss) - | equalLength mss tss = SProd (zipWith go_ms mss tss) - go_s _ _ = HeadStr - - go_mu :: ArgUse -> TypeShape -> ArgUse - go_mu Abs _ = Abs - go_mu (Use c u) ts = Use c (go_u u ts) - - go_u :: UseDmd -> TypeShape -> UseDmd - go_u UHead _ = UHead - go_u (UCall c u) (TsFun ts) = UCall c (go_u u ts) - go_u (UProd mus) (TsProd tss) - | equalLength mus tss = UProd (zipWith go_mu mus tss) - go_u _ _ = Used + go (Prod ds) (TsProd tss) + | equalLength ds tss = Prod (zipWith trimToType ds tss) + go (Call n cd) (TsFun ts) = Call n (go cd ts) + go cd at Poly{} _ = cd + go _ _ = topCleanDmd instance Outputable TypeShape where ppr TsUnk = text "TsUnk" ppr (TsFun ts) = text "TsFun" <> parens (ppr ts) ppr (TsProd tss) = parens (hsep $ punctuate comma $ map ppr tss) - - {- ********************************************************************* * * Termination @@ -1450,74 +1351,63 @@ deferAfterPreciseException :: DmdType -> DmdType deferAfterPreciseException = lubDmdType exnDmdType strictenDmd :: Demand -> Demand -strictenDmd (JD { sd = s, ud = u}) - = JD { sd = poke_s s, ud = poke_u u } - where - poke_s Lazy = Str HeadStr - poke_s s = s - poke_u Abs = useTop - poke_u u = u +strictenDmd (n :* cd) = bothCard C_10 n :* cd -- Deferring and peeling type DmdShell -- Describes the "outer shell" -- of a Demand - = JointDmd (Str ()) (Use ()) + = Card toCleanDmd :: Demand -> (DmdShell, CleanDemand) -- Splits a Demand into its "shell" and the inner "clean demand" -toCleanDmd (JD { sd = s, ud = u }) - = (JD { sd = ss, ud = us }, JD { sd = s', ud = u' }) +toCleanDmd (n :* cd) = (n, cd) -- See Note [Analyzing with lazy demand and lambdas] -- See Note [Analysing with absent demand] - where - (ss, s') = case s of - Str s' -> (Str (), s') - Lazy -> (Lazy, HeadStr) - - (us, u') = case u of - Use c u' -> (Use c (), u') - Abs -> (Abs, Used) -- This is used in dmdAnalStar when post-processing -- a function's argument demand. So we only care about what -- does to free variables, and whether it terminates. -- see Note [Asymmetry of 'both*'] postProcessDmdType :: DmdShell -> DmdType -> BothDmdArg -postProcessDmdType du@(JD { sd = ss }) (DmdType fv _ res_ty) - = (postProcessDmdEnv du fv, postProcessDivergence ss res_ty) +postProcessDmdType n (DmdType fv _ res_ty) + = (postProcessDmdEnv n fv, postProcessDivergence n res_ty) -postProcessDivergence :: Str () -> Divergence -> Divergence +postProcessDivergence :: DmdShell -> Divergence -> Divergence -- In a Lazy scenario, we might not force the Divergence, in which case we -- converge, hence Dunno. -postProcessDivergence Lazy _ = Dunno -postProcessDivergence _ d = d +postProcessDivergence n _ | isLazy n = Dunno +postProcessDivergence _ d = d postProcessDmdEnv :: DmdShell -> DmdEnv -> DmdEnv -postProcessDmdEnv ds@(JD { sd = ss, ud = us }) env - | Abs <- us = emptyDmdEnv +postProcessDmdEnv n env + | isAbs n = emptyDmdEnv -- In this case (postProcessDmd ds) == id; avoid a redundant rebuild -- of the environment. Be careful, bad things will happen if this doesn't -- match postProcessDmd (see #13977). - | Str _ <- ss - , Use One _ <- us = env - | otherwise = mapVarEnv (postProcessDmd ds) env + | n == C_11 = env + | otherwise = mapVarEnv (postProcessDmd n) env -- For the Absent case just discard alC_ sage information -- We only processed the thing at all to analyse the body -- See Note [Always analyse in virgin pass] +-- | See Note [Scaling demands] reuseEnv :: DmdEnv -> DmdEnv -reuseEnv = mapVarEnv (postProcessDmd - (JD { sd = Str (), ud = Use Many () })) +reuseEnv = mapVarEnv (postProcessDmd C_1N) postProcessUnsat :: DmdShell -> DmdType -> DmdType -postProcessUnsat ds@(JD { sd = ss }) (DmdType fv args res_ty) - = DmdType (postProcessDmdEnv ds fv) - (map (postProcessDmd ds) args) - (postProcessDivergence ss res_ty) +postProcessUnsat n (DmdType fv args res_ty) + = DmdType (postProcessDmdEnv n fv) + (map (postProcessDmd n) args) + (postProcessDivergence n res_ty) postProcessDmd :: DmdShell -> Demand -> Demand -postProcessDmd (JD { sd = ss, ud = us }) (JD { sd = s, ud = a}) +postProcessDmd C_11 dmd = dmd +postProcessDmd n _ + | isAbs n = absDmd +postProcessDmd C_01 (n :* dmd) = lubCard C_01 n :* dmd +postProcessDmd C_10 _ = Dmd +postProcessDmd n (JD { sd = s, ud = a}) = JD { sd = s', ud = a' } where s' = case ss of @@ -1899,10 +1789,10 @@ dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType -- for dictionary selectors. If the selector is saturated (ie has one -- argument: the dictionary), we feed the demand on the result into -- the indicated dictionary component. -dmdTransformDictSelSig (StrictSig (DmdType _ [Prod jds] _)) cd +dmdTransformDictSelSig (StrictSig (DmdType _ [Prod ds] _)) cd | (cd',defer_use) <- peelCallDmd cd = postProcessUnsat defer_use $ - DmdType emptyDmdEnv [mkOnceUsedDmd $ mkProdDmd $ map (enhance cd') jds] topDiv + DmdType emptyDmdEnv [mkOnceUsedDmd $ Prod $ map (enhance cd') ds] topDiv | otherwise = nopDmdType -- See Note [Demand transformer for a dictionary selector] where @@ -2059,8 +1949,8 @@ zap_usg _ u = u -- strictify the argument's contained used non-newtype superclass dictionaries. -- We use the demand as our recursive measure to guarantee termination. strictifyDictDmd :: Type -> Demand -> Demand -strictifyDictDmd ty dmd@(n :* Prod ds) - | not (isAbsDmd dmd) +strictifyDictDmd ty (n :* Prod ds) + | not (isAbs n) , Just (tycon, field_tys) <- as_non_newtype_dict ty = C_1N :* -- main idea: ensure it's strict if all (not . isAbsDmd) ds View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/014516dd465dea1f669d08e736d2ab4dea337b3a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/014516dd465dea1f669d08e736d2ab4dea337b3a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 10:04:49 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 26 Oct 2020 06:04:49 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f969f4122679_8973fa3a6afa0a829623@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 77bb2604 by Ryan Scott at 2020-10-26T06:03:35-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 22 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1473,9 +1473,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1492,7 +1492,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1623,27 +1623,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1723,15 +1731,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1102,9 +1102,22 @@ instance OutputableBndrId p => Outputable (ConDeclField (GhcPass p)) where ppr (ConDeclField _ fld_n fld_ty _) = ppr fld_n <+> dcolon <+> ppr fld_ty --- HsConDetails is used for patterns/expressions *and* for data type --- declarations --- | Haskell Constructor Details +-- | Describes the arguments to a data constructor. This is a common +-- representation for several constructor-related concepts, including: +-- +-- * The arguments in a Haskell98-style constructor declaration +-- (see 'HsConDeclH98Details' in "GHC.Hs.Decls"). +-- +-- * The arguments in constructor patterns in @case@/function definitions +-- (see 'HsConPatDetails' in "GHC.Hs.Pat"). +-- +-- * The left-hand side arguments in a pattern synonym binding +-- (see 'HsPatSynDetails' in "GHC.Hs.Binds"). +-- +-- One notable exception is the arguments in a GADT constructor, which uses +-- a separate data type entirely (see 'HsConDeclGADTDetails' in +-- "GHC.Hs.Decls"). This is because GADT constructors cannot be declared with +-- infix syntax, unlike the concepts above (#18844). data HsConDetails arg rec = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1257,29 +1257,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -869,7 +869,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -889,7 +889,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2581,49 +2581,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2632,16 +2634,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1319,6 +1319,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1530,7 +1534,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1541,7 +1545,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1555,13 +1561,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2332,7 +2332,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -608,7 +608,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -633,17 +633,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1615,7 +1615,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2180,7 +2180,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2197,15 +2197,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2213,9 +2210,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2223,7 +2220,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2238,7 +2235,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2249,27 +2246,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -759,7 +759,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1563,7 +1563,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1576,6 +1576,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1604,14 +1619,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1625,7 +1640,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3196,7 +3211,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3266,7 +3281,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3283,7 +3298,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3362,48 +3377,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3415,6 +3432,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -620,7 +620,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -629,9 +629,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -639,7 +639,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 74ca5b1c6a11998747b3219a4e002cff17810533 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77bb260484de84fca54dbc9ddb95eb74a28511f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77bb260484de84fca54dbc9ddb95eb74a28511f5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 10:26:00 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 26 Oct 2020 06:26:00 -0400 Subject: [Git][ghc/ghc][wip/T18389] Refactor RecCon case of tcConArgs Message-ID: <5f96a4382e156_8973fa3b88dfa68302983@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC Commits: d54ad263 by Ryan Scott at 2020-10-26T06:25:42-04:00 Refactor RecCon case of tcConArgs - - - - - 1 changed file: - compiler/GHC/Tc/TyCl.hs Changes: ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3416,13 +3416,15 @@ tcConArgs (InfixCon bty1 bty2) tcConArgs (RecCon fields) = mapM tcConArg btys where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - + -- We need to ensure that each distinct field name gets its own type. + -- For example, if we have: + -- + -- data T = MkT { a,b,c :: Int } + -- + -- Then we should return /three/ Int types, not just one! + btys = [ hsLinear (cd_fld_type f) + | L _ f <- unLoc fields + , _fld_name <- cd_fld_names f ] tcConArg :: HsScaled GhcRn (LHsType GhcRn) -> TcM (Scaled TcType, HsSrcBang) tcConArg (HsScaled w bty) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d54ad2638c07c65f013fa02be8eaf4083ce06f1e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d54ad2638c07c65f013fa02be8eaf4083ce06f1e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 11:18:24 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Mon, 26 Oct 2020 07:18:24 -0400 Subject: [Git][ghc/ghc][wip/T18389] tcConArgs: Only typecheck each record type once Message-ID: <5f96b0806f95d_897106d463c316784@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC Commits: b55cf285 by Ryan Scott at 2020-10-26T07:18:00-04:00 tcConArgs: Only typecheck each record type once - - - - - 1 changed file: - compiler/GHC/Tc/TyCl.hs Changes: ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -3413,18 +3413,22 @@ tcConArgs (InfixCon bty1 bty2) = do { bty1' <- tcConArg bty1 ; bty2' <- tcConArg bty2 ; return [bty1', bty2'] } -tcConArgs (RecCon fields) - = mapM tcConArg btys +tcConArgs (RecCon (L _ fields)) + = concatMapM tc_field fields where -- We need to ensure that each distinct field name gets its own type. -- For example, if we have: -- -- data T = MkT { a,b,c :: Int } -- - -- Then we should return /three/ Int types, not just one! - btys = [ hsLinear (cd_fld_type f) - | L _ f <- unLoc fields - , _fld_name <- cd_fld_names f ] + -- Then we should return /three/ Int types, not just one! At the same + -- time, we don't want to kind-check Int three separate times, as that + -- would be redundant. Therefore, we kind-check Int once and 'replicate' + -- it so that we return three occurrences of it. + tc_field :: LConDeclField GhcRn -> TcM [(Scaled TcType, HsSrcBang)] + tc_field (L _ f) = do + bty' <- tcConArg $ hsLinear $ cd_fld_type f + pure $ replicate (length (cd_fld_names f)) bty' tcConArg :: HsScaled GhcRn (LHsType GhcRn) -> TcM (Scaled TcType, HsSrcBang) tcConArg (HsScaled w bty) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b55cf28534eaef254c16da050f5e63dc3ff6d7af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b55cf28534eaef254c16da050f5e63dc3ff6d7af You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 12:29:00 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 26 Oct 2020 08:29:00 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f96c10c55c60_897cce5dcc32284d@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 8d634c88 by Daniel Rogozin at 2020-10-26T15:28:25+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitmodules - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d634c881317c9205209a13aef9c447513786d5a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8d634c881317c9205209a13aef9c447513786d5a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 12:53:57 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 26 Oct 2020 08:53:57 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f96c6e560252_8973fa3da033b903283af@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: af98d24e by Daniel Rogozin at 2020-10-26T15:53:27+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitmodules - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af98d24e979d6349cd2e24d3850d685df06d215c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/af98d24e979d6349cd2e24d3850d685df06d215c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 13:26:45 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 26 Oct 2020 09:26:45 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] fix haddock Message-ID: <5f96ce959925_8973fa3a743f3e8334265@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: ef9013ce by Daniel Rogozin at 2020-10-26T16:26:22+03:00 fix haddock - - - - - 1 changed file: - utils/haddock Changes: ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit a7d1d8e034d25612d5d08ed8fdbf6f472aded4a1 +Subproject commit 9da49ee8e4b37ee03d7c6535b485b7e251185296 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef9013ce203ba4f8de34afc7d50ba0a8a0c8f99c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ef9013ce203ba4f8de34afc7d50ba0a8a0c8f99c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 13:27:47 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 26 Oct 2020 09:27:47 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f96ced3a2163_8973fa3bbd0645433475d@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 4a2e3d36 by Daniel Rogozin at 2020-10-26T16:27:22+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitmodules - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a2e3d3639e7922aa60da04e110cb62fd325d3ee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a2e3d3639e7922aa60da04e110cb62fd325d3ee You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 13:46:56 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Mon, 26 Oct 2020 09:46:56 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f96d3503f0c5_8973fa3eb7ea1983352aa@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 58cf6a5c by Daniel Rogozin at 2020-10-26T16:46:03+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/binary - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58cf6a5c3536c658d2fa2cf4302b4f6a7a792da2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/58cf6a5c3536c658d2fa2cf4302b4f6a7a792da2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:05:07 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:05:07 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/uf-conf-codegen Message-ID: <5f96d79379fc0_8974fa51143357fd@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/uf-conf-codegen You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:06:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:06:21 -0400 Subject: [Git][ghc/ghc][wip/bump-ci-images] 12 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f96d7dde3978_8973fa3bb4143dc3373ac@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-ci-images at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 6435d418 by Ben Gamari at 2020-10-26T10:06:15-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Outputable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b1abd4e53179f2fd518ce76243ce2b524e769cfd...6435d4189bae640ff24f87705b9296500fe61b76 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b1abd4e53179f2fd518ce76243ce2b524e769cfd...6435d4189bae640ff24f87705b9296500fe61b76 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:15:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:15:29 -0400 Subject: [Git][ghc/ghc][wip/T18835] 4 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f96da0112dbd_8973fa3bbe0123c3405e3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18835 at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - d963882e by Ben Gamari at 2020-10-26T10:15:22-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 13 changed files: - compiler/GHC/Cmm/Type.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - hadrian/hadrian.cabal - hadrian/src/Builder.hs - + testsuite/tests/parser/should_compile/T12862.hs - testsuite/tests/parser/should_compile/all.T - + testsuite/tests/parser/should_fail/T12446.hs - + testsuite/tests/parser/should_fail/T12446.stderr - testsuite/tests/parser/should_fail/all.T - testsuite/tests/patsyn/should_fail/T11010.stderr - + testsuite/tests/patsyn/should_fail/T18856.hs - + testsuite/tests/patsyn/should_fail/T18856.stderr - testsuite/tests/patsyn/should_fail/all.T Changes: ===================================== compiler/GHC/Cmm/Type.hs ===================================== @@ -311,6 +311,8 @@ isVecType _ = False -- Hints are extra type information we attach to the arguments and -- results of a foreign call, where more type information is sometimes -- needed by the ABI to make the correct kind of call. +-- +-- See Note [Signed vs unsigned] for one case where this is used. data ForeignHint = NoHint | AddrHint | SignedHint ===================================== compiler/GHC/Tc/TyCl/PatSyn.hs ===================================== @@ -31,9 +31,9 @@ import GHC.Tc.Utils.TcMType import GHC.Tc.Utils.Zonk import GHC.Builtin.Types.Prim import GHC.Types.Name +import GHC.Types.Name.Set import GHC.Types.SrcLoc import GHC.Core.PatSyn -import GHC.Types.Name.Set import GHC.Utils.Panic import GHC.Utils.Outputable import GHC.Data.FastString @@ -422,14 +422,22 @@ tcCheckPatSynDecl psb at PSB{ psb_id = lname@(L _ name), psb_args = details ; tc_patsyn_finish lname dir is_infix lpat' (univ_bndrs, req_theta, ev_binds, req_dicts) (ex_bndrs, mkTyVarTys ex_tvs', prov_theta, prov_dicts) - (args', (map scaledThing arg_tys)) + (args', map scaledThing arg_tys) pat_ty rec_fields } where tc_arg :: TCvSubst -> Name -> Type -> TcM (LHsExpr GhcTc) + -- Look up the variable actually bound by lpat + -- and check that it has the expected type tc_arg subst arg_name arg_ty - = do { -- Look up the variable actually bound by lpat - -- and check that it has the expected type - arg_id <- tcLookupId arg_name + = setSrcSpan (nameSrcSpan arg_name) $ + -- Set the SrcSpan to be the binding site of the Id (#18856) + -- e.g. pattern P :: Int -> Maybe (Int,Bool) + -- pattern P x = Just (x,True) + -- Before unifying x's actual type with its expected type, in tc_arg, set + -- location to x's binding site in lpat, namely the 'x' in Just (x,True). + -- Else the error message location is wherever tcCheckPat finished, + -- namely the right-hand corner of the pattern + do { arg_id <- tcLookupId arg_name ; wrap <- tcSubTypeSigma GenSigCtxt (idType arg_id) (substTyUnchecked subst arg_ty) ===================================== hadrian/hadrian.cabal ===================================== @@ -138,6 +138,7 @@ executable hadrian build-depends: Cabal >= 3.0 && < 3.3 , QuickCheck >= 2.6 && < 2.14 , base >= 4.8 && < 5 + , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== hadrian/src/Builder.hs ===================================== @@ -15,6 +15,7 @@ module Builder ( ) where import Control.Exception.Extra (Partial) +import qualified Data.ByteString.Lazy.Char8 as BSL import Development.Shake.Classes import Development.Shake.Command import GHC.Generics @@ -26,6 +27,8 @@ import Hadrian.Builder.Tar import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities +import System.Exit +import System.IO (stderr) import Base import Context @@ -286,7 +289,18 @@ instance H.Builder Builder where Makeinfo -> do cmd' echo [path] "--no-split" [ "-o", output] [input] - Xelatex -> unit $ cmd' [Cwd output] [path] buildArgs + Xelatex -> + -- xelatex produces an incredible amount of output, almost + -- all of which is useless. Suppress it unless user + -- requests a loud build. + if verbosity >= Loud + then cmd' [Cwd output] [path] buildArgs + else do (Stdouterr out, Exit code) <- cmd' [Cwd output] [path] buildArgs + when (code /= ExitSuccess) $ do + liftIO $ BSL.hPutStrLn stderr out + putFailure "xelatex failed!" + fail "xelatex failed" + Makeindex -> unit $ cmd' [Cwd output] [path] (buildArgs ++ [input]) Tar _ -> cmd' buildOptions echo [path] buildArgs ===================================== testsuite/tests/parser/should_compile/T12862.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TypeFamilies, InstanceSigs #-} +{-# LANGUAGE BangPatterns #-} -- should parse even with BangPatterns enabled + +module T12862 where + +import Data.Kind (Type) + +class Key key where + data TotalMap key :: Type -> Type + (!) :: TotalMap key val -> (key -> val) + +instance Key Bool where + data TotalMap Bool val = BoolMap val val + (!) :: TotalMap Bool val -> (Bool -> val) + (BoolMap f _) ! False = f -- with parentheses + BoolMap f _ ! True = f -- without parentheses ===================================== testsuite/tests/parser/should_compile/all.T ===================================== @@ -172,3 +172,4 @@ test('T15730a', normal, compile_and_run, ['']) test('T18130', normal, compile, ['']) test('T18834a', normal, compile, ['']) test('T18834b', normal, compile, ['']) +test('T12862', normal, compile, ['']) ===================================== testsuite/tests/parser/should_fail/T12446.hs ===================================== @@ -0,0 +1,3 @@ +module T12446 where + +x = undefined @(_ ~ _) ===================================== testsuite/tests/parser/should_fail/T12446.stderr ===================================== @@ -0,0 +1,4 @@ + +T12446.hs:3:5: error: + Illegal visible type application ‘@(_ ~ _)’ + Perhaps you intended to use TypeApplications ===================================== testsuite/tests/parser/should_fail/all.T ===================================== @@ -173,3 +173,4 @@ test('T18251c', normal, compile_fail, ['']) test('T18251d', normal, compile_fail, ['']) test('T18251e', normal, compile_fail, ['']) test('T18251f', normal, compile_fail, ['']) +test('T12446', normal, compile_fail, ['']) ===================================== testsuite/tests/patsyn/should_fail/T11010.stderr ===================================== @@ -1,5 +1,5 @@ -T11010.hs:9:36: error: +T11010.hs:9:34: error: • Couldn't match type ‘a1’ with ‘Int’ Expected: a -> b Actual: a1 -> b @@ -12,3 +12,6 @@ T11010.hs:9:36: error: • Relevant bindings include x :: Expr a1 (bound at T11010.hs:9:36) f :: a1 -> b (bound at T11010.hs:9:34) + | +9 | pattern IntFun str f x = Fun str f x + | ^ ===================================== testsuite/tests/patsyn/should_fail/T18856.hs ===================================== @@ -0,0 +1,7 @@ +{-# LANGUAGE PatternSynonyms, ViewPatterns #-} + +module T18856 where + +pattern P :: Int -> Bool -> (Int, Bool, [(Bool,Bool)]) +pattern P p q <- (q, p, [(True,False)]) + ===================================== testsuite/tests/patsyn/should_fail/T18856.stderr ===================================== @@ -0,0 +1,14 @@ + +T18856.hs:6:19: error: + • Couldn't match expected type ‘Bool’ with actual type ‘Int’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ + +T18856.hs:6:22: error: + • Couldn't match expected type ‘Int’ with actual type ‘Bool’ + • In the declaration for pattern synonym ‘P’ + | +6 | pattern P p q <- (q, p, [(True,False)]) + | ^ ===================================== testsuite/tests/patsyn/should_fail/all.T ===================================== @@ -9,7 +9,7 @@ test('T9705-2', normal, compile_fail, ['']) test('unboxed-bind', normal, compile_fail, ['']) test('unboxed-wrapper-naked', normal, compile_fail, ['']) test('T10873', normal, compile_fail, ['']) -test('T11010', normal, compile_fail, ['']) +test('T11010', normal, compile_fail, ['-fdiagnostics-show-caret']) test('records-check-sels', normal, compile_fail, ['']) test('records-no-uni-update', normal, compile_fail, ['']) test('records-no-uni-update2', normal, compile_fail, ['']) @@ -47,3 +47,4 @@ test('T15692', normal, compile, ['']) # It has -fdefer-type-errors inside test('T15694', normal, compile_fail, ['']) test('T16900', normal, compile_fail, ['-fdiagnostics-show-caret']) test('T14552', normal, compile_fail, ['']) +test('T18856', normal, compile_fail, ['-fdiagnostics-show-caret']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ed84df27aa043c016c69b3e225931cf5710491d...d963882ed1c55f262bbc93f30fbc7a636d1d908b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6ed84df27aa043c016c69b3e225931cf5710491d...d963882ed1c55f262bbc93f30fbc7a636d1d908b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:20:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:20:59 -0400 Subject: [Git][ghc/ghc][wip/T18854] 12 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f96db4ba2cb8_8973fa3b815dd3034559@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - ae63b16a by Ben Gamari at 2020-10-26T10:20:53-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Driver/Types.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Lexer.x - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Outputable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86380ed17f0d5b2bc0b9d40a9edd03c1c7bbde39...ae63b16a7fa87f58ad0644be4a98266fe9bbbeae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86380ed17f0d5b2bc0b9d40a9edd03c1c7bbde39...ae63b16a7fa87f58ad0644be4a98266fe9bbbeae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:22:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:22:35 -0400 Subject: [Git][ghc/ghc][wip/T18698] 206 commits: Introduce OutputableP Message-ID: <5f96dbab4e2c6_8973fa3b8314638346311@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18698 at Glasgow Haskell Compiler / GHC Commits: ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 242f2874 by Ben Gamari at 2020-10-26T10:22:24-04:00 testsuite: Add performance test for #18698 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lexer.x The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6c7d709fa1dc701dee66ebfab8b8e7e1fe1c700b...242f28746b31f8ab73cc9ce77407c7c48936ec92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6c7d709fa1dc701dee66ebfab8b8e7e1fe1c700b...242f28746b31f8ab73cc9ce77407c7c48936ec92 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 14:45:39 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 10:45:39 -0400 Subject: [Git][ghc/ghc][wip/T17605] 1563 commits: Fix +RTS -Z flag documentation Message-ID: <5f96e113afeea_897dd495243506b3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17605 at Glasgow Haskell Compiler / GHC Commits: 0499e3bc by Ömer Sinan Ağacan at 2020-01-20T15:31:33-05:00 Fix +RTS -Z flag documentation Stack squeezing is done on context switch, not on GC or stack overflow. Fix the documentation. Fixes #17685 [ci skip] - - - - - a661df91 by Ömer Sinan Ağacan at 2020-01-20T15:32:13-05:00 Document Stg.FVs module Fixes #17662 [ci skip] - - - - - db24e480 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Don't trash STG registers Fixes #13904. - - - - - f3d7fdb3 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix typo in readnone attribute - - - - - 442751c6 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Add lower-expect to the -O0 optimisation set @kavon says that this will improve block layout for stack checks. - - - - - e90ecc93 by Ben Gamari at 2020-01-20T15:32:52-05:00 llvmGen: Fix #14251 Fixes the calling convention for functions passing raw SSE-register values by adding padding as needed to get the values in the right registers. This problem cropped up when some args were unused an dropped from the live list. This folds together 2e23e1c7de01c92b038e55ce53d11bf9db993dd4 and 73273be476a8cc6c13368660b042b3b0614fd928 previously from @kavon. Metric Increase: T12707 ManyConstructors - - - - - 66e511a4 by Ben Gamari at 2020-01-20T15:33:28-05:00 testsuite: Preserve more information in framework failures Namely print the entire exception in hopes that this will help track down #17649. - - - - - b62b8cea by Ömer Sinan Ağacan at 2020-01-20T15:34:06-05:00 Remove deprecated -smp flag It was deprecated in 2012 with 46258b40 - - - - - 0c04a86a by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Reenable submodule linter - - - - - 2bfabd22 by Ben Gamari at 2020-01-20T15:34:43-05:00 gitlab-ci: Allow submodule cleaning to fail on Windows Currently CI is inexplicably failing with ``` $ git submodule foreach git clean -xdf fatal: not a git repository: libffi-tarballs/../.git/modules/libffi-tarballs ``` I have no idea how this working tree got into such a state but we do need to fail more gracefully when it happens. Consequently, we allow the cleaning step to fail. - - - - - 14bced99 by Xavier Denis at 2020-01-20T15:35:21-05:00 Put the docs for :instances in alphabetical position - - - - - 7e0bb82b by Ben Gamari at 2020-01-20T15:35:57-05:00 Add missing Note [Improvement from Ground Wanteds] Closes #17659. - - - - - 17e43a7c by Ben Gamari at 2020-01-20T15:36:32-05:00 unregisterised: Fix declaration for stg_NO_FINALIZER Previously it had a redundant _entry suffix. We never noticed this previously presumably because we never generated references to it (however hard to believe this may be). However, it did start failing in !1304. - - - - - 3dae006f by PHO at 2020-01-20T15:37:08-05:00 Avoid ./configure failure on NetBSD - - - - - 738e2912 by Ben Gamari at 2020-01-24T13:42:56-05:00 testsuite: Widen acceptance window of T1969 I have seen >20% fluctuations in this number, leading to spurious failures. - - - - - ad4eb7a7 by Gabor Greif at 2020-01-25T05:19:07-05:00 Document the fact, that openFileBlocking can consume an OS thread indefinitely. Also state that a deadlock can happen with the non-threaded runtime. [ci skip] - - - - - be910728 by Sebastian Graf at 2020-01-25T05:19:46-05:00 `-ddump-str-signatures` dumps Text, not STG [skip ci] - - - - - 0e57d8a1 by Ömer Sinan Ağacan at 2020-01-25T05:20:27-05:00 Fix chaining tagged and untagged ptrs in compacting GC Currently compacting GC has the invariant that in a chain all fields are tagged the same. However this does not really hold: root pointers are not tagged, so when we thread a root we initialize a chain without a tag. When the pointed objects is evaluated and we have more pointers to it from the heap, we then add *tagged* fields to the chain (because pointers to it from the heap are tagged), ending up chaining fields with different tags (pointers from roots are NOT tagged, pointers from heap are). This breaks the invariant and as a result compacting GC turns tagged pointers into non-tagged. This later causes problem in the generated code where we do reads assuming that the pointer is aligned, e.g. 0x7(%rax) -- assumes that pointer is tagged 1 which causes misaligned reads. This caused #17088. We fix this using the "pointer tagging for large families" patch (#14373, !1742): - With the pointer tagging patch the GC can know what the tagged pointer to a CONSTR should be (previously we'd need to know the family size -- large families are always tagged 1, small families are tagged depending on the constructor). - Since we now know what the tags should be we no longer need to store the pointer tag in the info table pointers when forming chains in the compacting GC. As a result we no longer need to tag pointers in chains with 1/2 depending on whether the field points to an info table pointer, or to another field: an info table pointer is always tagged 0, everything else in the chain is tagged 1. The lost tags in pointers can be retrieved by looking at the info table. Finally, instead of using tag 1 for fields and tag 0 for info table pointers, we use two different tags for fields: - 1 for fields that have untagged pointers - 2 for fields that have tagged pointers When unchaining we then look at the pointer to a field, and depending on its tag we either leave a tagged pointer or an untagged pointer in the field. This allows chaining untagged and tagged fields together in compacting GC. Fixes #17088 Nofib results ------------- Binaries are smaller because of smaller `Compact.c` code. make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" EXTRA_HC_OPTS="-with-rtsopts=-c" NoFibRuns=1 -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.3% 0.0% +0.0% +0.0% +0.0% CSD -0.3% 0.0% +0.0% +0.0% +0.0% FS -0.3% 0.0% +0.0% -0.0% -0.0% S -0.3% 0.0% +5.4% +0.8% +3.9% VS -0.3% 0.0% +0.0% -0.0% -0.0% VSD -0.3% 0.0% -0.0% -0.0% -0.2% VSM -0.3% 0.0% +0.0% +0.0% +0.0% anna -0.1% 0.0% +0.0% +0.0% +0.0% ansi -0.3% 0.0% +0.1% +0.0% +0.0% atom -0.2% 0.0% +0.0% +0.0% +0.0% awards -0.2% 0.0% +0.0% 0.0% -0.0% banner -0.3% 0.0% +0.0% +0.0% +0.0% bernouilli -0.3% 0.0% +0.1% +0.0% +0.0% binary-trees -0.2% 0.0% +0.0% 0.0% +0.0% boyer -0.3% 0.0% +0.2% +0.0% +0.0% boyer2 -0.2% 0.0% +0.2% +0.1% +0.0% bspt -0.2% 0.0% +0.0% +0.0% +0.0% cacheprof -0.2% 0.0% +0.0% +0.0% +0.0% calendar -0.3% 0.0% +0.0% +0.0% +0.0% cichelli -0.3% 0.0% +1.1% +0.2% +0.5% circsim -0.2% 0.0% +0.0% -0.0% -0.0% clausify -0.3% 0.0% +0.0% -0.0% -0.0% comp_lab_zift -0.2% 0.0% +0.0% +0.0% +0.0% compress -0.3% 0.0% +0.0% +0.0% +0.0% compress2 -0.3% 0.0% +0.0% -0.0% -0.0% constraints -0.3% 0.0% +0.2% +0.1% +0.1% cryptarithm1 -0.3% 0.0% +0.0% -0.0% 0.0% cryptarithm2 -0.3% 0.0% +0.0% +0.0% +0.0% cse -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e1 -0.3% 0.0% +0.0% +0.0% +0.0% digits-of-e2 -0.3% 0.0% +0.0% +0.0% -0.0% dom-lt -0.2% 0.0% +0.0% +0.0% +0.0% eliza -0.2% 0.0% +0.0% +0.0% +0.0% event -0.3% 0.0% +0.1% +0.0% -0.0% exact-reals -0.2% 0.0% +0.0% +0.0% +0.0% exp3_8 -0.3% 0.0% +0.0% +0.0% +0.0% expert -0.2% 0.0% +0.0% +0.0% +0.0% fannkuch-redux -0.3% 0.0% -0.0% -0.0% -0.0% fasta -0.3% 0.0% +0.0% +0.0% +0.0% fem -0.2% 0.0% +0.1% +0.0% +0.0% fft -0.2% 0.0% +0.0% -0.0% -0.0% fft2 -0.2% 0.0% +0.0% -0.0% +0.0% fibheaps -0.3% 0.0% +0.0% -0.0% -0.0% fish -0.3% 0.0% +0.0% +0.0% +0.0% fluid -0.2% 0.0% +0.4% +0.1% +0.1% fulsom -0.2% 0.0% +0.0% +0.0% +0.0% gamteb -0.2% 0.0% +0.1% +0.0% +0.0% gcd -0.3% 0.0% +0.0% +0.0% +0.0% gen_regexps -0.3% 0.0% +0.0% -0.0% -0.0% genfft -0.3% 0.0% +0.0% +0.0% +0.0% gg -0.2% 0.0% +0.7% +0.3% +0.2% grep -0.2% 0.0% +0.0% +0.0% +0.0% hidden -0.2% 0.0% +0.0% +0.0% +0.0% hpg -0.2% 0.0% +0.1% +0.0% +0.0% ida -0.3% 0.0% +0.0% +0.0% +0.0% infer -0.2% 0.0% +0.0% -0.0% -0.0% integer -0.3% 0.0% +0.0% +0.0% +0.0% integrate -0.2% 0.0% +0.0% +0.0% +0.0% k-nucleotide -0.2% 0.0% +0.0% +0.0% -0.0% kahan -0.3% 0.0% -0.0% -0.0% -0.0% knights -0.3% 0.0% +0.0% -0.0% -0.0% lambda -0.3% 0.0% +0.0% -0.0% -0.0% last-piece -0.3% 0.0% +0.0% +0.0% +0.0% lcss -0.3% 0.0% +0.0% +0.0% 0.0% life -0.3% 0.0% +0.0% -0.0% -0.0% lift -0.2% 0.0% +0.0% +0.0% +0.0% linear -0.2% 0.0% +0.0% +0.0% +0.0% listcompr -0.3% 0.0% +0.0% +0.0% +0.0% listcopy -0.3% 0.0% +0.0% +0.0% +0.0% maillist -0.3% 0.0% +0.0% -0.0% -0.0% mandel -0.2% 0.0% +0.0% +0.0% +0.0% mandel2 -0.3% 0.0% +0.0% +0.0% +0.0% mate -0.2% 0.0% +0.0% +0.0% +0.0% minimax -0.3% 0.0% +0.0% +0.0% +0.0% mkhprog -0.2% 0.0% +0.0% +0.0% +0.0% multiplier -0.3% 0.0% +0.0% -0.0% -0.0% n-body -0.2% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.2% 0.0% +0.0% +0.0% +0.0% para -0.2% 0.0% +0.0% -0.0% -0.0% paraffins -0.3% 0.0% +0.0% -0.0% -0.0% parser -0.2% 0.0% +0.0% +0.0% +0.0% parstof -0.2% 0.0% +0.8% +0.2% +0.2% pic -0.2% 0.0% +0.1% -0.1% -0.1% pidigits -0.3% 0.0% +0.0% +0.0% +0.0% power -0.2% 0.0% +0.0% -0.0% -0.0% pretty -0.3% 0.0% -0.0% -0.0% -0.1% primes -0.3% 0.0% +0.0% +0.0% -0.0% primetest -0.2% 0.0% +0.0% -0.0% -0.0% prolog -0.3% 0.0% +0.0% -0.0% -0.0% puzzle -0.3% 0.0% +0.0% +0.0% +0.0% queens -0.3% 0.0% +0.0% +0.0% +0.0% reptile -0.2% 0.0% +0.2% +0.1% +0.0% reverse-complem -0.3% 0.0% +0.0% +0.0% +0.0% rewrite -0.3% 0.0% +0.0% -0.0% -0.0% rfib -0.2% 0.0% +0.0% +0.0% -0.0% rsa -0.2% 0.0% +0.0% +0.0% +0.0% scc -0.3% 0.0% -0.0% -0.0% -0.1% sched -0.3% 0.0% +0.0% +0.0% +0.0% scs -0.2% 0.0% +0.1% +0.0% +0.0% simple -0.2% 0.0% +3.4% +1.0% +1.8% solid -0.2% 0.0% +0.0% +0.0% +0.0% sorting -0.3% 0.0% +0.0% +0.0% +0.0% spectral-norm -0.2% 0.0% -0.0% -0.0% -0.0% sphere -0.2% 0.0% +0.0% +0.0% +0.0% symalg -0.2% 0.0% +0.0% +0.0% +0.0% tak -0.3% 0.0% +0.0% +0.0% -0.0% transform -0.2% 0.0% +0.2% +0.1% +0.1% treejoin -0.3% 0.0% +0.2% -0.0% -0.1% typecheck -0.3% 0.0% +0.0% +0.0% +0.0% veritas -0.1% 0.0% +0.0% +0.0% +0.0% wang -0.2% 0.0% +0.0% -0.0% -0.0% wave4main -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve1 -0.3% 0.0% +0.0% -0.0% -0.0% wheel-sieve2 -0.3% 0.0% +0.0% -0.0% -0.0% x2n1 -0.3% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min -0.3% 0.0% -0.0% -0.1% -0.2% Max -0.1% 0.0% +5.4% +1.0% +3.9% Geometric Mean -0.3% -0.0% +0.1% +0.0% +0.1% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.2% 0.0% +1.6% +0.4% +0.7% constraints -0.3% 0.0% +4.3% +1.5% +2.3% fibheaps -0.3% 0.0% +3.5% +1.2% +1.3% fulsom -0.2% 0.0% +3.6% +1.2% +1.8% gc_bench -0.3% 0.0% +4.1% +1.3% +2.3% hash -0.3% 0.0% +6.6% +2.2% +3.6% lcss -0.3% 0.0% +0.7% +0.2% +0.7% mutstore1 -0.3% 0.0% +4.8% +1.4% +2.8% mutstore2 -0.3% 0.0% +3.4% +1.0% +1.7% power -0.2% 0.0% +2.7% +0.6% +1.9% spellcheck -0.3% 0.0% +1.1% +0.4% +0.4% -------------------------------------------------------------------------------- Min -0.3% 0.0% +0.7% +0.2% +0.4% Max -0.2% 0.0% +6.6% +2.2% +3.6% Geometric Mean -0.3% +0.0% +3.3% +1.0% +1.8% Metric changes -------------- While it sounds ridiculous, this change causes increased allocations in the following tests. We concluded that this change can't cause a difference in allocations and decided to land this patch. Fluctuations in "bytes allocated" metric is tracked in #17686. Metric Increase: Naperian T10547 T12150 T12234 T12425 T13035 T5837 T6048 - - - - - 8038cbd9 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Formulate as translation between Clause Trees We used to check `GrdVec`s arising from multiple clauses and guards in isolation. That resulted in a split between `pmCheck` and `pmCheckGuards`, the implementations of which were similar, but subtly different in detail. Also the throttling mechanism described in `Note [Countering exponential blowup]` ultimately got quite complicated because it had to cater for both checking functions. This patch realises that pattern match checking doesn't just consider single guarded RHSs, but that it's always a whole set of clauses, each of which can have multiple guarded RHSs in turn. We do so by translating a list of `Match`es to a `GrdTree`: ```haskell data GrdTree = Rhs !RhsInfo | Guard !PmGrd !GrdTree -- captures lef-to-right match semantics | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics | Empty -- For -XEmptyCase, neutral element of Sequence ``` Then we have a function `checkGrdTree` that matches a given `GrdTree` against an incoming set of values, represented by `Deltas`: ```haskell checkGrdTree :: GrdTree -> Deltas -> CheckResult ... ``` Throttling is isolated to the `Sequence` case and becomes as easy as one would expect: When the union of uncovered values becomes too big, just return the original incoming `Deltas` instead (which is always a superset of the union, thus a sound approximation). The returned `CheckResult` contains two things: 1. The set of values that were not covered by any of the clauses, for exhaustivity warnings. 2. The `AnnotatedTree` that enriches the syntactic structure of the input program with divergence and inaccessibility information. This is `AnnotatedTree`: ```haskell data AnnotatedTree = AccessibleRhs !RhsInfo | InaccessibleRhs !RhsInfo | MayDiverge !AnnotatedTree | SequenceAnn !AnnotatedTree !AnnotatedTree | EmptyAnn ``` Crucially, `MayDiverge` asserts that the tree may force diverging values, so not all of its wrapped clauses can be redundant. While the set of uncovered values can be used to generate the missing equations for warning messages, redundant and proper inaccessible equations can be extracted from `AnnotatedTree` by `redundantAndInaccessibleRhss`. For this to work properly, the interface to the Oracle had to change. There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a whole bunch of `PmCt` variants to replace the different oracle functions from before. The new `AnnotatedTree` structure allows for more accurate warning reporting (as evidenced by a number of changes spread throughout GHC's code base), thus we fix #17465. Fixes #17646 on the go. Metric Decrease: T11822 T9233 PmSeriesS haddock.compiler - - - - - 86966d48 by Sebastian Graf at 2020-01-25T05:21:05-05:00 PmCheck: Properly handle constructor-bound type variables In https://gitlab.haskell.org/ghc/ghc/merge_requests/2192#note_246551 Simon convinced me that ignoring type variables existentially bound by data constructors have to be the same way as value binders. Sadly I couldn't think of a regression test, but I'm confident that this change strictly improves on the status quo. - - - - - c3fde723 by Ryan Scott at 2020-01-25T05:21:40-05:00 Handle local fixity declarations in DsMeta properly `DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the effect of causing local fixity declarations to be dropped when quoted in Template Haskell. But there is no good reason for this state of affairs, as the code in `DsMeta.repFixD` (which handles top-level fixity declarations) handles local fixity declarations just fine. This patch factors out the necessary parts of `repFixD` so that they can be used in `rep_sig` as well. There was one minor complication: the fixity signatures for class methods in each `HsGroup` were stored both in `FixSig`s _and_ the list of `LFixitySig`s for top-level fixity signatures, so I needed to take action to prevent fixity signatures for class methods being converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting these fixity signatures in two places and added `Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls` to explain the new design. Fixes #17608. Bumps the Haddock submodule. - - - - - 6e2d9ee2 by Sylvain Henry at 2020-01-25T05:22:20-05:00 Module hierarchy: Cmm (cf #13009) - - - - - 8b726534 by PHO at 2020-01-25T05:23:01-05:00 Fix rts allocateExec() on NetBSD Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page mapping both writable and executable at the same time. Use libffi which knows how to work around it. - - - - - 6eb566a0 by Xavier Denis at 2020-01-25T05:23:39-05:00 Add ghc-in-ghci for stack based builds - - - - - b1a32170 by Xavier Denis at 2020-01-25T05:23:39-05:00 Create ghci.cabal.sh - - - - - 0a5e4f5f by Sylvain Henry at 2020-01-25T05:24:19-05:00 Split glasgow_exts into several files (#17316) - - - - - b3e5c678 by Ben Gamari at 2020-01-25T05:24:57-05:00 hadrian: Throw error on duplicate-named flavours Throw an error if the user requests a flavour for which there is more than one match. Fixes #17156. - - - - - 0940b59a by Ryan Scott at 2020-01-25T08:15:05-05:00 Do not bring visible foralls into scope in hsScopedTvs Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended that visible dependent quantification could not possibly happen at the term level, and cemented that assumption with an `ASSERT`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) = ASSERT( vis_flag == ForallInvis ) ... ``` It turns out that this assumption is wrong. You can end up tripping this `ASSERT` if you stick it to the man and write a type for a term that uses visible dependent quantification anyway, like in this example: ```hs {-# LANGUAGE ScopedTypeVariables #-} x :: forall a -> a -> a x = x ``` That won't typecheck, but that's not the point. Before the typechecker has a chance to reject this, the renamer will try to use `hsScopedTvs` to bring `a` into scope over the body of `x`, since `a` is quantified by a `forall`. This, in turn, causes the `ASSERT` to fail. Bummer. Instead of walking on this dangerous ground, this patch makes GHC adopt a more hardline stance by pattern-matching directly on `ForallInvis` in `hsScopedTvs`: ```hs hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ... ``` Now `a` will not be brought over the body of `x` at all (which is how it should be), there's no chance of the `ASSERT` failing anymore (as it's gone), and best of all, the behavior of `hsScopedTvs` does not change. Everyone wins! Fixes #17687. - - - - - 1132602f by Ryan Scott at 2020-01-27T10:03:42-05:00 Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase Richard points out in #17688 that we use `splitLHsForAllTy` and `splitLHsSigmaTy` in places that we ought to be using the corresponding `-Invis` variants instead, identifying two bugs that are caused by this oversight: * Certain TH-quoted type signatures, such as those that appear in quoted `SPECIALISE` pragmas, silently turn visible `forall`s into invisible `forall`s. * When quoted, the type `forall a -> (a ~ a) => a` will turn into `forall a -> a` due to a bug in `DsMeta.repForall` that drops contexts that follow visible `forall`s. These are both ultimately caused by the fact that `splitLHsForAllTy` and `splitLHsSigmaTy` split apart visible `forall`s in addition to invisible ones. This patch cleans things up: * We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis` throughout the codebase. Relatedly, the `splitLHsForAllTy` and `splitLHsSigmaTy` have been removed, as they are easy to misuse. * `DsMeta.repForall` now only handles invisible `forall`s to reduce the chance for confusion with visible `forall`s, which need to be handled differently. I also renamed it from `repForall` to `repForallT` to emphasize that its distinguishing characteristic is the fact that it desugars down to `L.H.TH.Syntax.ForallT`. Fixes #17688. - - - - - 97d0b0a3 by Matthew Pickering at 2020-01-27T10:04:19-05:00 Make Block.h compile with c++ compilers - - - - - 4bada77d by Tom Ellis at 2020-01-27T12:30:46-05:00 Disable two warnings for files that trigger them incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a future date, so prepare for that by disabling those warnings on files that trigger them. - - - - - 0188404a by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to stage 2 build - - - - - acae02c1 by Tom Ellis at 2020-01-27T12:30:46-05:00 Add two warnings to Hadrian - - - - - bf38a20e by Sylvain Henry at 2020-01-31T02:46:15-05:00 Call `interpretPackageEnv` from `setSessionDynFlags` interpretPackageEnv modifies the flags by reading the dreaded package environments. It is much less surprising to call it from `setSessionDynFlags` instead of reading package environments as a side-effect of `initPackages`. - - - - - 29c701c1 by Sylvain Henry at 2020-01-31T02:46:15-05:00 Refactor package related code The package terminology is a bit of a mess. Cabal packages contain components. Instances of these components when built with some flags/options/dependencies are called units. Units are registered into package databases and their metadata are called PackageConfig. GHC only knows about package databases containing units. It is a sad mismatch not fixed by this patch (we would have to rename parameters such as `package-id <unit-id>` which would affect users). This patch however fixes the following internal names: - Renames PackageConfig into UnitInfo. - Rename systemPackageConfig into globalPackageDatabase[Path] - Rename PkgConfXX into PkgDbXX - Rename pkgIdMap into unitIdMap - Rename ModuleToPkgDbAll into ModuleNameProvidersMap - Rename lookupPackage into lookupUnit - Add comments on DynFlags package related fields It also introduces a new `PackageDatabase` datatype instead of explicitly passing the following tuple: `(FilePath,[PackageConfig])`. The `pkgDatabase` field in `DynFlags` now contains the unit info for each unit of each package database exactly as they have been read from disk. Previously the command-line flag `-distrust-all-packages` would modify these unit info. Now this flag only affects the "dynamic" consolidated package state found in `pkgState` field. It makes sense because `initPackages` could be called first with this `distrust-all-packages` flag set and then again (using ghc-api) without and it should work (package databases are not read again from disk when `initPackages` is called the second time). Bump haddock submodule - - - - - 942c7148 by Ben Gamari at 2020-01-31T02:46:54-05:00 rename: Eliminate usage of mkVarOccUnique Replacing it with `newSysName`. Fixes #17061. - - - - - 41117d71 by Ben Gamari at 2020-01-31T02:47:31-05:00 base: Use one-shot kqueue on macOS The underlying reason requiring that one-shot usage be disabled (#13903) has been fixed. Closes #15768. - - - - - 01b15b83 by Ben Gamari at 2020-01-31T02:48:08-05:00 testsuite: Don't crash on encoding failure in print If the user doesn't use a Unicode locale then the testsuite driver would previously throw framework failures due to encoding failures. We now rather use the `replace` error-handling strategy. - - - - - c846618a by Ömer Sinan Ağacan at 2020-01-31T12:21:10+03:00 Do CafInfo/SRT analysis in Cmm This patch removes all CafInfo predictions and various hacks to preserve predicted CafInfos from the compiler and assigns final CafInfos to interface Ids after code generation. SRT analysis is extended to support static data, and Cmm generator is modified to allow generating static_link fields after SRT analysis. This also fixes `-fcatch-bottoms`, which introduces error calls in case expressions in CorePrep, which runs *after* CoreTidy (which is where we decide on CafInfos) and turns previously non-CAFFY things into CAFFY. Fixes #17648 Fixes #9718 Evaluation ========== NoFib ----- Boot with: `make boot mode=fast` Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1` -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.0% 0.0% -0.0% -0.0% -0.0% CSD -0.0% 0.0% -0.0% -0.0% -0.0% FS -0.0% 0.0% -0.0% -0.0% -0.0% S -0.0% 0.0% -0.0% -0.0% -0.0% VS -0.0% 0.0% -0.0% -0.0% -0.0% VSD -0.0% 0.0% -0.0% -0.0% -0.5% VSM -0.0% 0.0% -0.0% -0.0% -0.0% anna -0.1% 0.0% -0.0% -0.0% -0.0% ansi -0.0% 0.0% -0.0% -0.0% -0.0% atom -0.0% 0.0% -0.0% -0.0% -0.0% awards -0.0% 0.0% -0.0% -0.0% -0.0% banner -0.0% 0.0% -0.0% -0.0% -0.0% bernouilli -0.0% 0.0% -0.0% -0.0% -0.0% binary-trees -0.0% 0.0% -0.0% -0.0% -0.0% boyer -0.0% 0.0% -0.0% -0.0% -0.0% boyer2 -0.0% 0.0% -0.0% -0.0% -0.0% bspt -0.0% 0.0% -0.0% -0.0% -0.0% cacheprof -0.0% 0.0% -0.0% -0.0% -0.0% calendar -0.0% 0.0% -0.0% -0.0% -0.0% cichelli -0.0% 0.0% -0.0% -0.0% -0.0% circsim -0.0% 0.0% -0.0% -0.0% -0.0% clausify -0.0% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.0% 0.0% -0.0% -0.0% -0.0% compress -0.0% 0.0% -0.0% -0.0% -0.0% compress2 -0.0% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.0% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.0% 0.0% -0.0% -0.0% -0.0% cse -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.0% 0.0% -0.0% -0.0% -0.0% dom-lt -0.0% 0.0% -0.0% -0.0% -0.0% eliza -0.0% 0.0% -0.0% -0.0% -0.0% event -0.0% 0.0% -0.0% -0.0% -0.0% exact-reals -0.0% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.0% 0.0% -0.0% -0.0% -0.0% expert -0.0% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.0% 0.0% -0.0% -0.0% -0.0% fasta -0.0% 0.0% -0.0% -0.0% -0.0% fem -0.0% 0.0% -0.0% -0.0% -0.0% fft -0.0% 0.0% -0.0% -0.0% -0.0% fft2 -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% fish -0.0% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.0% 0.0% -0.0% -0.0% -0.0% gamteb -0.0% 0.0% -0.0% -0.0% -0.0% gcd -0.0% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.0% 0.0% -0.0% -0.0% -0.0% genfft -0.0% 0.0% -0.0% -0.0% -0.0% gg -0.0% 0.0% -0.0% -0.0% -0.0% grep -0.0% 0.0% -0.0% -0.0% -0.0% hidden -0.0% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.0% 0.0% -0.0% -0.0% -0.0% infer -0.0% 0.0% -0.0% -0.0% -0.0% integer -0.0% 0.0% -0.0% -0.0% -0.0% integrate -0.0% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.0% 0.0% -0.0% -0.0% -0.0% kahan -0.0% 0.0% -0.0% -0.0% -0.0% knights -0.0% 0.0% -0.0% -0.0% -0.0% lambda -0.0% 0.0% -0.0% -0.0% -0.0% last-piece -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% life -0.0% 0.0% -0.0% -0.0% -0.0% lift -0.0% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.0% 0.0% -0.0% -0.0% -0.0% listcopy -0.0% 0.0% -0.0% -0.0% -0.0% maillist -0.0% 0.0% -0.0% -0.0% -0.0% mandel -0.0% 0.0% -0.0% -0.0% -0.0% mandel2 -0.0% 0.0% -0.0% -0.0% -0.0% mate -0.0% 0.0% -0.0% -0.0% -0.0% minimax -0.0% 0.0% -0.0% -0.0% -0.0% mkhprog -0.0% 0.0% -0.0% -0.0% -0.0% multiplier -0.0% 0.0% -0.0% -0.0% -0.0% n-body -0.0% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.0% 0.0% -0.0% -0.0% -0.0% para -0.0% 0.0% -0.0% -0.0% -0.0% paraffins -0.0% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.0% 0.0% -0.0% -0.0% -0.0% pidigits -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% pretty -0.0% 0.0% -0.3% -0.4% -0.4% primes -0.0% 0.0% -0.0% -0.0% -0.0% primetest -0.0% 0.0% -0.0% -0.0% -0.0% prolog -0.0% 0.0% -0.0% -0.0% -0.0% puzzle -0.0% 0.0% -0.0% -0.0% -0.0% queens -0.0% 0.0% -0.0% -0.0% -0.0% reptile -0.0% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.0% 0.0% -0.0% -0.0% -0.0% rewrite -0.0% 0.0% -0.0% -0.0% -0.0% rfib -0.0% 0.0% -0.0% -0.0% -0.0% rsa -0.0% 0.0% -0.0% -0.0% -0.0% scc -0.0% 0.0% -0.3% -0.5% -0.4% sched -0.0% 0.0% -0.0% -0.0% -0.0% scs -0.0% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.0% 0.0% -0.0% -0.0% -0.0% sorting -0.0% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.0% 0.0% -0.0% -0.0% -0.0% sphere -0.0% 0.0% -0.0% -0.0% -0.0% symalg -0.0% 0.0% -0.0% -0.0% -0.0% tak -0.0% 0.0% -0.0% -0.0% -0.0% transform -0.0% 0.0% -0.0% -0.0% -0.0% treejoin -0.0% 0.0% -0.0% -0.0% -0.0% typecheck -0.0% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.0% 0.0% -0.0% -0.0% -0.0% wave4main -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.0% 0.0% -0.0% -0.0% -0.0% x2n1 -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.3% -0.5% -0.5% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% -0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- circsim -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.0% 0.0% -0.0% -0.0% -0.0% fibheaps -0.0% 0.0% -0.0% -0.0% -0.0% gc_bench -0.0% 0.0% -0.0% -0.0% -0.0% hash -0.0% 0.0% -0.0% -0.0% -0.0% lcss -0.0% 0.0% -0.0% -0.0% -0.0% power -0.0% 0.0% -0.0% -0.0% -0.0% spellcheck -0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.0% -0.0% -0.0% Max -0.0% 0.0% -0.0% -0.0% -0.0% Geometric Mean -0.0% +0.0% -0.0% -0.0% -0.0% Manual inspection of programs in testsuite/tests/programs --------------------------------------------------------- I built these programs with a bunch of dump flags and `-O` and compared STG, Cmm, and Asm dumps and file sizes. (Below the numbers in parenthesis show number of modules in the program) These programs have identical compiler (same .hi and .o sizes, STG, and Cmm and Asm dumps): - Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3), andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2), jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4), jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1), bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1), strict_anns (1), thurston-module-arith (2), okeefe_neural (1), joao-circular (6), 10queens (1) Programs with different compiler outputs: - jl_defaults (1): For some reason GHC HEAD marks a lot of top-level `[Int]` closures as CAFFY for no reason. With this patch we no longer make them CAFFY and generate less SRT entries. For some reason Main.o is slightly larger with this patch (1.3%) and the executable sizes are the same. (I'd expect both to be smaller) - launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the executable sizes are the same. - galois_raytrace (13): Differences are in the Parse module. There are a lot, but some of the changes are caused by the fact that for some reason (I think a bug) GHC HEAD marks the dictionary for `Functor Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the same. - north_array: We now generate less SRT entries because some of array primops used in this program like `NewArrayOp` get eliminated during Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24% larger (9224 bytes from 9000 bytes), executable sizes are the same. - seward-space-leak: Difference in this program is better shown by this smaller example: module Lib where data CDS = Case [CDS] [(Int, CDS)] | Call CDS CDS instance Eq CDS where Case sels1 rets1 == Case sels2 rets2 = sels1 == sels2 && rets1 == rets2 Call a1 b1 == Call a2 b2 = a1 == a2 && b1 == b2 _ == _ = False In this program GHC HEAD builds a new SRT for the recursive group of `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==` in its SRT field, and `==` uses the SRT object as its SRT. With this patch we use the closure for `/=` as the SRT and add `==` there. Then `/=` gets an empty SRT field and `==` points to `/=` in its SRT field. This change looks fine to me. Main.o gets 0.07% larger, executable sizes are identical. head.hackage ------------ head.hackage's CI script builds 428 packages from Hackage using this patch with no failures. Compiler performance -------------------- The compiler perf tests report that the compiler allocates slightly more (worst case observed so far is 4%). However most programs in the test suite are small, single file programs. To benchmark compiler performance on something more realistic I build Cabal (the library, 236 modules) with different optimisation levels. For the "max residency" row I run GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows are generated with just `-s`. (This is because `-i0` causes running GC much more frequently and as a result "bytes copied" gets inflated by more than 25x in some cases) * -O0 | | GHC HEAD | This MR | Diff | | --------------- | -------------- | -------------- | ------ | | Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% | | Bytes copied | 4,926,037,184 | 4,990,638,760 | +1.31% | | Max residency | 421,225,624 | 424,324,264 | +0.73% | * -O1 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% | | Bytes copied | 26,943,452,560 | 27,089,972,296 | +0.54% | | Max residency | 982,643,440 | 991,663,432 | +0.91% | * -O2 | | GHC HEAD | This MR | Diff | | --------------- | --------------- | --------------- | ------ | | Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% | | Bytes copied | 37,044,237,616 | 36,121,690,472 | -2.49% | | Max residency | 1,071,600,328 | 1,086,396,256 | +1.38% | Extra compiler allocations -------------------------- Runtime allocations of programs are as reported above (NoFib section). The compiler now allocates more than before. Main source of allocation in this patch compared to base commit is the new SRT algorithm (GHC.Cmm.Info.Build). Below is some of the extra work we do with this patch, numbers generated by profiled stage 2 compiler when building a pathological case (the test 'ManyConstructors') with '-O2': - We now sort the final STG for a module, which means traversing the entire program, generating free variable set for each top-level binding, doing SCC analysis, and re-ordering the program. In ManyConstructors this step allocates 97,889,952 bytes. - We now do SRT analysis on static data, which in a program like ManyConstructors causes analysing 10,000 bindings that we would previously just skip. This step allocates 70,898,352 bytes. - We now maintain an SRT map for the entire module as we compile Cmm groups: data ModuleSRTInfo = ModuleSRTInfo { ... , moduleSRTMap :: SRTMap } (SRTMap is just a strict Map from the 'containers' library) This map gets an entry for most bindings in a module (exceptions are THUNKs and CAFFY static functions). For ManyConstructors this map gets 50015 entries. - Once we're done with code generation we generate a NameSet from SRTMap for the non-CAFFY names in the current module. This set gets the same number of entries as the SRTMap. - Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using the NameSet generated in the previous step. This usually does the least amount of allocation among the work listed here. Only place with this patch where we do less work in the CAF analysis in the tidying pass (CoreTidy). However that doesn't save us much, as the pass still needs to traverse the whole program and update IdInfos for other reasons. Only thing we don't here do is the `hasCafRefs` pass over the RHS of bindings, which is a stateless pass that returns a boolean value, so it doesn't allocate much. (Metric changes blow are all increased allocations) Metric changes -------------- Metric Increase: ManyAlternatives ManyConstructors T13035 T14683 T1969 T9961 - - - - - 2a87a565 by Andreas Klebinger at 2020-01-31T12:21:10+03:00 A few optimizations in STG and Cmm parts: (Guided by the profiler output) - Add a few bang patterns, INLINABLE annotations, and a seqList in a few places in Cmm and STG parts. - Do not add external variables as dependencies in STG dependency analysis (GHC.Stg.DepAnal). - - - - - bef704b6 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve skolemisation This patch avoids skolemiseUnboundMetaTyVar making up a fresh Name when it doesn't need to. See Note [Skolemising and identity] Improves error messsages for partial type signatures. - - - - - cd110423 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Improve pretty-printing for TyConBinders In particular, show their kinds. - - - - - 913287a0 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00 Fix scoping of TyCon binders in TcTyClsDecls This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule. - - - - - 58ed6c4a by Ben Gamari at 2020-02-01T02:29:23-05:00 rts/M32Alloc: Don't attempt to unmap non-existent pages The m32 allocator's `pages` list may contain NULLs in the case that the page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't like it if we pass them NULL. Don't do that. - - - - - 859db7d6 by Ömer Sinan Ağacan at 2020-02-01T14:18:49+03:00 Improve/fix -fcatch-bottoms documentation Old documentation suggests that -fcatch-bottoms only adds a default alternative to bottoming case expression, but that's not true. We use a very simplistic "is exhaustive" check and add default alternatives to any case expression that does not cover all constructors of the type. In case of GADTs this simple check assumes all constructors should be covered, even the ones ruled out by the type of the scrutinee. Update the documentation to reflect this. (Originally noticed in #17648) [ci skip] - - - - - 54dfa94a by John Ericson at 2020-02-03T21:14:24-05:00 Fix docs for FrontendResult Other variant was removed in ac1a379363618a6f2f17fff65ce9129164b6ef30 but docs were no changed. - - - - - 5e63d9c0 by John Ericson at 2020-02-03T21:15:02-05:00 Refactor HscMain.finish I found the old control flow a bit hard to follow; I rewrote it to first decide whether to desugar, and then use that choice when computing whether to simplify / what sort of interface file to write. I hope eventually we will always write post-tc interface files, which will make the logic of this function even simpler, and continue the thrust of this refactor. - - - - - e580e5b8 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 Do not build StgCRunAsm.S for unregisterised builds For unregisterised builds StgRun/StgReturn are implemented via a mini interpreter in StgCRun.c and therefore would collide with the implementations in StgCRunAsm.S. - - - - - e3b0bd97 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00 fixup! fixup! Do not build StgCRunAsm.S for unregisterised builds - - - - - eb629fab by John Ericson at 2020-02-04T09:29:38-05:00 Delete some superfluous helper functions in HscMain The driver code is some of the nastiest in GHC, and I am worried about being able to untangle all the tech debt. In `HscMain` we have a number of helpers which are either not-used or little used. I delete them so we can reduce cognative load, distilling the essential complexity away from the cruft. - - - - - c90eca55 by Sebastian Graf at 2020-02-05T09:21:29-05:00 PmCheck: Record type constraints arising from existentials in `PmCoreCt`s In #17703 (a follow-up of !2192), we established that contrary to my belief, type constraints arising from existentials in code like ```hs data Ex where Ex :: a -> Ex f _ | let x = Ex @Int 15 = case x of Ex -> ... ``` are in fact useful. This commit makes a number of refactorings and improvements to comments, but fundamentally changes `addCoreCt.core_expr` to record the type constraint `a ~ Int` in addition to `x ~ Ex @a y` and `y ~ 15`. Fixes #17703. - - - - - 6d3b5d57 by Ömer Sinan Ağacan at 2020-02-05T09:22:10-05:00 testlib: Extend existing *_opts in extra_*_opts Previously we'd override the existing {run,hc} opts in extra_{run,hc}_opts, which caused flakiness in T1969, see #17712. extra_{run,hc}_opts now extends {run,hc} opts, instead of overriding. Also we shrank the allocation area for T1969 in order to increase residency sampling frequency. Fixes #17712 - - - - - 9c89a48d by Ömer Sinan Ağacan at 2020-02-05T09:22:52-05:00 Remove CafInfo-related code from STG lambda lift pass After c846618ae0 we don't have accurate CafInfos for Ids in the current module and we're free to introduce new CAFFY or non-CAFFY bindings or change CafInfos of existing binders; so no we no longer need to maintain CafInfos in Core or STG passes. - - - - - 70ddb8bf by Ryan Scott at 2020-02-05T09:23:30-05:00 Add regression test for #17773 - - - - - e8004e5d by Ben Gamari at 2020-02-05T13:55:19-05:00 gitlab-ci: Allow Windows builds to fail again Due to T7702 and the process issues described in #17777. - - - - - 29b72c00 by Ben Gamari at 2020-02-06T11:55:41-05:00 VarSet: Introduce nonDetFoldVarSet - - - - - c4e6b35d by Ben Gamari at 2020-02-06T11:55:41-05:00 Move closeOverKinds and friends to TyCoFVs - - - - - ed2f0e5c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Reform the free variable finders for types This patch delivers on (much of) #17509. * Introduces the shallow vs deep free variable distinction * Introduce TyCoRep.foldType, foldType :: Monoid a => TyCoFolder env a -> env -> Type -> a and use it in the free variable finders. * Substitution in TyCoSubst * ASSERTs are on for checkValidSubst * checkValidSubst uses shallowTyCoVarsOfTypes etc Quite a few things still to do * We could use foldType in lots of other places * We could use mapType for substitution. (Check that we get good code!) * Some (but not yet all) clients of substitution can now save time by using shallowTyCoVarsOfTypes * All calls to tyCoVarsOfTypes should be inspected; most of them should be shallow. Maybe. * Currently shallowTyCoVarsOfTypes still returns unification variables, but not CoVarHoles. Reason: we need to return unification variables in some of the calls in TcSimplify, eg when promoting. * We should do the same thing for tyCoFVsOfTypes, which is currently unchanged. * tyCoFVsOfTypes returns CoVarHoles, because of the use in TcSimplify.mkResidualConstraints. See Note [Emitting the residual implication in simplifyInfer] * #17509 talks about "relevant" variables too. - - - - - 01a1f4fb by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for noFreeVarsOfType - - - - - 0e59afd6 by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Simplify closeOverKinds - - - - - 9ca5c88e by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for coVarsOfType - - - - - 5541b87c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00 Use foldTyCo for exactTyCoVarsOfType This entailed * Adding a tcf_view field to TyCoFolder * Moving exactTyCoVarsOtType to TcType. It properly belongs there, since only the typechecker calls this function. But it also means that we can "see" and inline tcView. Metric Decrease: T14683 - - - - - 7c122851 by Simon Peyton Jones at 2020-02-06T11:56:02-05:00 Comments only - - - - - 588acb99 by Adam Sandberg Eriksson at 2020-02-08T10:15:38-05:00 slightly better named cost-centres for simple pattern bindings #17006 ``` main = do print $ g [1..100] a where g xs x = map (`mod` x) xs a :: Int = 324 ``` The above program previously attributed the cost of computing 324 to a cost centre named `(...)`, with this change the cost is attributed to `a` instead. This change only affects simple pattern bindings (decorated variables: type signatures, parens, ~ annotations and ! annotations). - - - - - 309f8cfd by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Remove unnecessary parentheses - - - - - 7755ffc2 by Richard Eisenberg at 2020-02-08T10:16:33-05:00 Introduce IsPass; refactor wrappers. There are two main payloads of this patch: 1. This introduces IsPass, which allows e.g. printing code to ask what pass it is running in (Renamed vs Typechecked) and thus print extension fields. See Note [IsPass] in Hs.Extension 2. This moves the HsWrap constructor into an extension field, where it rightly belongs. This is done for HsExpr and HsCmd, but not for HsPat, which is left as an exercise for the reader. There is also some refactoring around SyntaxExprs, but this is really just incidental. This patch subsumes !1721 (sorry @chreekat). Along the way, there is a bit of refactoring in GHC.Hs.Extension, including the removal of NameOrRdrName in favor of NoGhcTc. This meant that we had no real need for GHC.Hs.PlaceHolder, so I got rid of it. Updates haddock submodule. ------------------------- Metric Decrease: haddock.compiler ------------------------- - - - - - 7d452be4 by Dylan Yudaken at 2020-02-08T10:17:17-05:00 Fix hs_try_putmvar losing track of running cap If hs_try_putmvar was called through an unsafe import, it would lose track of the running cap causing a deadlock - - - - - c2e301ae by Ben Gamari at 2020-02-08T10:17:55-05:00 compiler: Qualify imports of Data.List - - - - - aede171a by Ben Gamari at 2020-02-08T10:17:55-05:00 testsuite: Fix -Wcompat-unqualified-imports issues - - - - - 4435a8e0 by Ben Gamari at 2020-02-08T10:17:55-05:00 Introduce -Wcompat-unqualified-imports This implements the warning proposed in option (B) of the Data.List.singleton CLC [discussion][]. This warning, which is included in `-Wcompat` is intended to help users identify imports of modules that will change incompatibly in future GHC releases. This currently only includes `Data.List` due to the expected specialisation and addition of `Data.List.singleton`. Fixes #17244. [discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ - - - - - 28b5349a by Ben Gamari at 2020-02-08T10:17:55-05:00 Bump stm and process submodules - - - - - 7d04b9f2 by Ben Gamari at 2020-02-08T10:18:31-05:00 hadrian: Allow override of Cabal configuration in hadrian.settings Fixes #17612 by adding a `cabal.configure.opts` key for `hadrian.settings`. - - - - - 88bf81aa by Andreas Klebinger at 2020-02-08T10:19:10-05:00 Optimize unpackCString# to allocate less. unpackCString# is a recursive function which for each iteration returns a Cons cell containing the current Char, and a thunk for unpacking the rest of the string. In this patch we change from storing addr + offset inside this thunk to storing only the addr, simply incrementing the address on each iteration. This saves one word of allocation per unpacked character. For a program like "main = print "<largishString>" this amounts to 2-3% fewer % in bytes allocated. I also removed the now redundant local unpack definitions. This removes one call per unpack operation. - - - - - bec76733 by Ben Gamari at 2020-02-08T10:19:57-05:00 Fix GhcThreaded setting This adopts a patch from NetBSD's packaging fixing the `GhcThreaded` option of the make build system. In addition we introduce a `ghcThreaded` option in hadrian's `Flavour` type. Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`. Previously it would incorrectly claim `Use Threaded = True` if we were building the `threaded` runtime way. However, this is inconsistent with the `make` build system, which defines it to be whether the `ghc` executable is linked against the threaded runtime. Fixes #17692. - - - - - 545cf1e1 by Ben Gamari at 2020-02-08T10:20:37-05:00 hadrian: Depend upon libray dependencies when configuring packages This will hopefully fix #17631. - - - - - 047d3d75 by Ben Gamari at 2020-02-08T10:21:16-05:00 testsuite: Add test for #15316 This is the full testcase for T15316. - - - - - 768e5866 by Julien Debon at 2020-02-08T10:22:07-05:00 doc(Data.List): Add some examples to Data.List - - - - - 3900cb83 by Julien Debon at 2020-02-08T10:22:07-05:00 Apply suggestion to libraries/base/GHC/List.hs - - - - - bd666766 by Ben Gamari at 2020-02-08T10:22:45-05:00 users-guide: Clarify that bundled patsyns were introduced in GHC 8.0 Closes #17094. - - - - - 95741ea1 by Pepe Iborra at 2020-02-08T10:23:23-05:00 Update to hie-bios 0.3.2 style program cradle - - - - - fb5c1912 by Sylvain Henry at 2020-02-08T10:24:07-05:00 Remove redundant case This alternative is redundant and triggers no warning when building with 8.6.5 - - - - - 5d83d948 by Matthew Pickering at 2020-02-08T10:24:43-05:00 Add mkHieFileWithSource which doesn't read the source file from disk cc/ @pepeiborra - - - - - dfdae56d by Andreas Klebinger at 2020-02-08T10:25:20-05:00 Rename ghcAssert to stgAssert in hp2ps/Main.h. This fixes #17763 - - - - - 658f7ac6 by Ben Gamari at 2020-02-08T10:26:00-05:00 includes: Avoid using single-line comments in HsFFI.h While single-line comments are supported by C99, dtrace on SmartOS apparently doesn't support them yet. - - - - - c95920a6 by Ömer Sinan Ağacan at 2020-02-08T10:26:42-05:00 Import qualified Prelude in parser This is in preparation of backwards-incompatible changes in happy. See https://github.com/simonmar/happy/issues/166 - - - - - b6dc319a by Ömer Sinan Ağacan at 2020-02-08T10:27:23-05:00 Add regression test for #12760 The bug seems to be fixed in the meantime, make sure it stays fixed. Closes #12760 - - - - - b3857b62 by Ben Gamari at 2020-02-08T10:28:03-05:00 base: Drop out-of-date comment The comment in GHC.Base claimed that ($) couldn't be used in that module as it was wired-in. However, this is no longer true; ($) is merely known key and is defined in Haskell (with a RuntimeRep-polymorphic type) in GHC.Base. The one piece of magic that ($) retains is that it a special typing rule to allow type inference with higher-rank types (e.g. `runST $ blah`; see Note [Typing rule for ($)] in TcExpr). - - - - - 1183ae94 by Daniel Gröber at 2020-02-08T10:29:00-05:00 rts: Fix Arena blocks accounting for MBlock sized allocations When requesting more than BLOCKS_PER_MBLOCK blocks allocGroup can return a different number of blocks than requested. Here we use the number of requested blocks, however arenaFree will subtract the actual number of blocks we got from arena_blocks (possibly) resulting in a negative value and triggering ASSERT(arena_blocks >= 0). - - - - - 97d59db5 by Daniel Gröber at 2020-02-08T10:29:48-05:00 rts: Fix need_prealloc being reset when retainer profiling is on - - - - - 1f630025 by Krzysztof Gogolewski at 2020-02-09T02:52:27-05:00 Add a test for #15712 - - - - - 2ac784ab by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Add --test-metrics argument Allowing the test metric output to be captured to a file, a la the METRIC_FILE environment variable of the make build system. - - - - - f432d8c6 by Ben Gamari at 2020-02-09T02:53:05-05:00 hadrian: Fix --test-summary argument This appears to be a cut-and-paste error. - - - - - a906595f by Arnaud Spiwack at 2020-02-09T02:53:50-05:00 Fix an outdated note link This link appears to have been forgotten in 0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 . - - - - - 3ae83da1 by Alp Mestanogullari at 2020-02-09T02:54:28-05:00 hadrian: Windows fixes (bindists, CI) This commit implements a few Windows-specific fixes which get us from a CI job that can't even get as far as starting the testsuite driver, to a state where we can run the entire testssuite (but have test failures to fix). - Don't forget about a potential extension for the haddock program, when preparing the bindist. - Build the timeout program, used by the testsuite driver on Windows in place of the Python script used elsewhere, using the boot compiler. We could alternatively build it with the compiler that we're going to test but this would be a lot more tedious to write. - Implement a wrapper-script less installation procedure for Windows, in `hadrian/bindist/Makefile. - Make dependencies a bit more accurate in the aforementioned Makefile. - Update Windows/Hadrian CI job accordingly. This patch fixes #17486. - - - - - 82f9be8c by Roland Senn at 2020-02-09T02:55:06-05:00 Fix #14628: Panic (No skolem Info) in GHCi This patch implements the [sugggestion from Simon (PJ)](https://gitlab.haskell.org/ghc/ghc/issues/14628#note_146559): - Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`. - If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`. - In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`. The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`) to a *"Couldn't match type ‘x’ with ‘y’"* error message. The `getSkolemInfo` function didn't find any Implication value and paniced. With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s. As the panic occured while processing an error message, we don't need to implement any new error message! - - - - - b2e18e26 by Andreas Klebinger at 2020-02-09T02:55:46-05:00 Fix -ddump-stg-final. Once again make sure this dumps the STG used for codegen. - - - - - 414e2f62 by Sylvain Henry at 2020-02-09T02:56:26-05:00 Force -fPIC for intree GMP (fix #17799) Configure intree GMP with `--with-pic` instead of patching it. Moreover the correct patching was only done for x86_64/darwin (see #17799). - - - - - f0fd72ee by Sebastian Graf at 2020-02-09T17:22:38-05:00 8.10 Release notes for improvements to the pattern-match checker [skip ci] A little late to the game, but better late than never. - - - - - 00dc0f7e by Ömer Sinan Ağacan at 2020-02-09T17:23:17-05:00 Add regression test for #13142 Closes #13142 - - - - - f3e737bb by Sebastian Graf at 2020-02-10T20:04:09-05:00 Fix long distance info for record updates For record updates where the `record_expr` is a variable, as in #17783: ```hs data PartialRec = No | Yes { a :: Int, b :: Bool } update No = No update r@(Yes {}) = r { b = False } ``` We should make use of long distance info in `-Wincomplete-record-updates` checking. But the call to `matchWrapper` in the `RecUpd` case didn't specify a scrutinee expression, which would correspond to the `record_expr` `r` here. That is fixed now. Fixes #17783. - - - - - 5670881d by Tamar Christina at 2020-02-10T20:05:04-05:00 Fs: Fix UNC remapping code. - - - - - 375b3c45 by Oleg Grenrus at 2020-02-11T05:07:30-05:00 Add singleton to Data.OldList - - - - - de32beff by Richard Eisenberg at 2020-02-11T05:08:10-05:00 Do not create nested quantified constraints Previously, we would accidentally make constraints like forall a. C a => forall b. D b => E a b c as we traversed superclasses. No longer! This patch also expands Note [Eagerly expand given superclasses] to work over quantified constraints; necessary for T16502b. Close #17202 and #16502. test cases: typecheck/should_compile/T{17202,16502{,b}} - - - - - e319570e by Ben Gamari at 2020-02-11T05:08:47-05:00 rts: Use nanosleep instead of usleep usleep was removed in POSIX.1-2008. - - - - - b75e7486 by Ben Gamari at 2020-02-11T05:09:24-05:00 rts: Remove incorrect assertions around MSG_THROWTO messages Previously we would assert that threads which are sending a `MSG_THROWTO` message must have their blocking status be blocked on the message. In the usual case of a thread throwing to another thread this is guaranteed by `stg_killThreadzh`. However, `throwToSelf`, used by the GC to kill threads which ran out of heap, failed to guarantee this. Noted while debugging #17785. - - - - - aba51b65 by Sylvain Henry at 2020-02-11T05:10:04-05:00 Add arithmetic exception primops (#14664) - - - - - b157399f by Ben Gamari at 2020-02-11T05:10:40-05:00 configure: Don't assume Gnu linker on Solaris Compl Yue noticed that the linker was dumping the link map on SmartOS. This is because Smartos uses the Solaris linker, which uses the `-64` flag, not `-m64` like Gnu ld, to indicate that it should link for 64-bits. Fix the configure script to handle the Solaris linker correctly. - - - - - d8d73d77 by Simon Peyton Jones at 2020-02-11T05:11:18-05:00 Notes only: telescopes This documentation-only patch fixes #17793 - - - - - 58a4ddef by Alp Mestanogullari at 2020-02-11T05:12:17-05:00 hadrian: build (and ship) iserv on Windows - - - - - 82023524 by Matthew Pickering at 2020-02-11T18:04:17-05:00 TemplateHaskellQuotes: Allow nested splices There is no issue with nested splices as they do not require any compile time code execution. All execution is delayed until the top-level splice. - - - - - 50e24edd by Ömer Sinan Ağacan at 2020-02-11T18:04:57-05:00 Remove Hadrian's copy of (Data.Functor.<&>) The function was added to base with base-4.11 (GHC 8.4) - - - - - f82a2f90 by Sylvain Henry at 2020-02-12T01:56:46-05:00 Document GMP build [skip ci] - - - - - da7f7479 by Sylvain Henry at 2020-02-12T01:57:27-05:00 Module hierarchy: ByteCode and Runtime (cf #13009) Update haddock submodule - - - - - 04f51297 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Fix naming of tests for #12923 - - - - - 31fc3321 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00 Add regression test for #12926 Closes #12926 - - - - - f0c0ee7d by Krzysztof Gogolewski at 2020-02-12T01:58:51-05:00 Fix order of arguments in specializer (#17801) See https://gitlab.haskell.org/ghc/ghc/issues/17801#note_253330 No regression test, as it's hard to trigger. - - - - - 059c3c9d by Sebastian Graf at 2020-02-12T11:00:58+01:00 Separate CPR analysis from the Demand analyser The reasons for that can be found in the wiki: https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr We now run CPR after demand analysis (except for after the final demand analysis run just before code gen). CPR got its own dump flags (`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`. As explained on the wiki page, this step is necessary for a sane Nested CPR analysis. And it has quite positive impact on compiler performance: Metric Decrease: T9233 T9675 T9961 T15263 - - - - - f5ffd8d9 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Expose GHC.Unicode.unicodeVersion This exposes a Data.Version.Version representing the version of the Unicode database used by `base`. This should clear up some confusion I have seen in tickets regarding with which Unicode versions a given GHC can be expected to work. While in town I also regenerated (but did not update) the Unicode database with database 12.0.0. Strangely, the file cited in the README no longer existed. Consequently, I used https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt and was slightly surprised to find that there were a few changes. - - - - - 6c2585e0 by Ben Gamari at 2020-02-12T17:22:37-05:00 base: Update Unicode database to 12.1.0 Using `curl https://www.unicode.org/Public/12.1.0/ucd/UnicodeData.txt | libraries/base/cbits/ubconfc 12.1.0`. - - - - - df084681 by Krzysztof Gogolewski at 2020-02-12T23:58:52+01:00 Always display inferred variables using braces We now always show "forall {a}. T" for inferred variables, previously this was controlled by -fprint-explicit-foralls. This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179. Part of GHC ticket #16320. Furthermore, when printing a levity restriction error, we now display the HsWrap of the expression. This lets users see the full elaboration with -fprint-typechecker-elaboration (see also #17670) - - - - - 16d643cf by Sylvain Henry at 2020-02-13T09:16:04-05:00 Remove -ddump-srts flag This flag is deemed not useful. - - - - - fa28ae95 by Sylvain Henry at 2020-02-13T09:16:04-05:00 Fix flag documentation (#17826) - - - - - 1bfd8259 by Sylvain Henry at 2020-02-13T09:16:43-05:00 Ensure that Hadrian is built correctly before using it When Hadrian failed to build, the script would pick a previously built Hadrian (if available) instead of failing. - - - - - cd6e786a by Ömer Sinan Ağacan at 2020-02-14T05:29:56-05:00 Add test for #17648 - - - - - 9f2c3677 by Sylvain Henry at 2020-02-14T05:30:39-05:00 GMP expects the Target platform as --host parameter - - - - - aa6086fd by Oleg Grenrus at 2020-02-14T05:31:16-05:00 Add explicit LANGUAGE Safe to template-haskell (cherry picked from commit a5e0f376821ca882880b03b07b451aa574e289ec) - - - - - af6a0c36 by Ben Gamari at 2020-02-14T05:31:53-05:00 hadrian: Add execution and target architecture to stage-compilation figure - - - - - cf739945 by Sylvain Henry at 2020-02-14T05:32:37-05:00 Module hierarchy: HsToCore (cf #13009) - - - - - 719db318 by Simon Peyton Jones at 2020-02-14T05:33:16-05:00 De-duplicate overlapping Notes Documentation only. Fixes #17827 - - - - - 7550417a by Sylvain Henry at 2020-02-14T05:33:56-05:00 Hadrian: drop Sphinx flag checking for PDF documentation (#17825) It seems that Sphinx produces the ghc-flags.txt in doc/users_guide/_build rather than pdfRoot. We could copy ghc-flags.txt into pdfRoot (like happens naturally in the HTML case) but the benefit is pretty small. Let's just only check the HTML case. - - - - - 813842f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 make: Be more selective in building windows-extra-src tarball - - - - - 0725f4bb by Ben Gamari at 2020-02-14T10:16:36-05:00 Rework handling of win32 toolchain tarballs - - - - - 565ce7ae by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Consolidate CI logic This moves nearly all of the CI logic to .gitlab/ci.sh. This improves things in a number of ways: * it's harder for inconsistencies to arise between architectures * it's easier to share logic between architectures * on Windows, it's easier to ensure that all CI steps are executed from within a properly initialized mingw session. While in town I also add a FreeBSD build job and update the Windows job to use the gitlab-runner PowerShell executor, since cmd.exe will be deprecated soon (fixing #17699). - - - - - 9cbace74 by Ben Gamari at 2020-02-14T10:16:36-05:00 gitlab-ci: Deduplicate nightly job configuration - - - - - 6e837144 by Ben Gamari at 2020-02-14T10:16:36-05:00 integer-gmp: Fix unused command-line argument -L is only needed during linking. - - - - - e5ee07ab by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Don't ask sed to operate in-place on symlinks Some sed implementations (e.g. FreeBSD) refuse to operate in-place on symlinks. - - - - - 71e5e68f by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Disable tests that assume name of libstdc++ on FreeBSD - - - - - 7b2da0f4 by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite: Mark T6132 as broken on FreeBSD - - - - - 8ef7a15a by Ben Gamari at 2020-02-14T10:16:36-05:00 testsuite/T16930: Don't rely on gnu grep specific --include In BSD grep this flag only affects directory recursion. - - - - - 6060003e by Ben Gamari at 2020-02-14T10:16:36-05:00 Pass -Wno-unused-command-line-arguments during link on FreeBSD FreeBSD cc throws a warning if we pass -pthread without actually using any pthread symbols. - - - - - 97497bae by Ben Gamari at 2020-02-14T10:16:36-05:00 base: Always clamp reads/writes to 2GB in length Previously we did this only on Darwin due to #17414. However, even on other platforms >2GB writes are on shaky ground. POSIX explicitly says that the result is implementation-specified and Linux will write at most 0x7ffff000, even on 64-bit platforms. Moreover, getting the sign of the syscall result correct is tricky, as demonstrated by the fact that T17414 currently fails on FreeBSD. For simplicity we now just uniformly clamp to 0x7ffff000 on all platforms. - - - - - 49be2a3f by Ben Gamari at 2020-02-14T10:16:36-05:00 configure: Fix sphinx version test The check for the "v" prefix is redundant. - - - - - f7f7a556 by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix unknown link targets - - - - - a204102c by Ben Gamari at 2020-02-14T10:16:37-05:00 docs/compare-flags: Don't use python f-strings - - - - - 92e15a37 by Ben Gamari at 2020-02-14T10:16:37-05:00 gitlab-ci: Fix various shellcheck warnings - - - - - 459f7c6e by Ben Gamari at 2020-02-14T10:16:37-05:00 hadrian: Drop empty arguments from target list Fixes #17748. - - - - - c06df28d by Ben Gamari at 2020-02-14T10:16:37-05:00 users-guide: Fix "invalid file" failure I have no idea how this worked previously. Different Python version? - - - - - 3fe8444f by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Mark T7702 as fragile on Windows Due to #16799. There was previously an attempt to mark it as broken but the `opsys` name was incorrect. - - - - - fe02f781 by Ben Gamari at 2020-02-14T10:16:59-05:00 testsuite: Assert the opsys names are known Previously opsys would take any string. This meant it was very easy for a typo to silently render the predicate ineffective. Fix this by checking the given operating system name against a list of known values. - - - - - 149e2a3a by Ben Gamari at 2020-02-14T10:16:59-05:00 compare-flags: Don't rely on encoding flag of subprocess.check_output Apparently it isn't supported by some slightly older Python versions. - - - - - 798d59f6 by Ben Gamari at 2020-02-14T10:16:59-05:00 rts: Add more debug output to failed path in onIOComplete This will help track down #17035. - - - - - e35f3f98 by Ben Gamari at 2020-02-14T10:16:59-05:00 gitlab-ci: Allow i386 Windows builds to fail again Due to the resistance of #17736 to resolution. - - - - - 261a3cf8 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Build integer-simple job in the validate flavour - - - - - b613a961 by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Always use mingw64 python on Windows - - - - - 1bc8c8cd by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Allow Windows build to fail due to #17777 The fact that `exec` isn't POSIX compliant means that things can break in arbitrarily bad ways. Sometimes things happen to work correctly but sadly this isn't always the case. - - - - - ac63020d by Ben Gamari at 2020-02-14T10:17:00-05:00 gitlab-ci: Drop unnecessary GHC_VERSION check - - - - - 6926f369 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump process submodule Folds in the second part of Phyx's Windows process exit fixes [1], hopefully finally resolving issue #17480. [1] https://github.com/haskell/process/pull/160 - - - - - 584eee71 by Tamar Christina at 2020-02-14T10:17:00-05:00 SysTools: Use "process job" when spawning processes on Windows GHC should make calls using process jobs when calling out to GCC and LD. The reason is these use the exec () family of posix functions. Window's process model doesn't allow replacement of processes so this is emulated by creating a new process and immediately exiting the old one. Because of this when using normal Windows wait functions you would return even without the child process having finished. In this case if you are depending on data from the child you will enter a race condition. The usual fix for this is to use process jobs and wait for the termination of all children that have ever been spawn by the process you called. But also waiting for the freeing of all resources. - - - - - ecabfa28 by Tamar Christina at 2020-02-14T10:17:00-05:00 Revert "compiler: Disable atomic renaming on Windows" The original reason this was disabled should be fixed by the previous commit. This reverts commit 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb. - - - - - 06d60c66 by Ben Gamari at 2020-02-14T10:17:00-05:00 Bump Cabal submodule - - - - - 8cabb384 by Ben Gamari at 2020-02-14T10:17:00-05:00 compare-flags: Fix output - - - - - 8cf646d3 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Document -ddump-srts - - - - - 932307a5 by Ben Gamari at 2020-02-14T10:17:00-05:00 users-guide: Fix broken reference - - - - - e77818de by Ben Gamari at 2020-02-15T09:26:55-05:00 Accept performance changes These manifested in the integer-simple job. Metric Decrease: T12227 T5549 T14936 T4830 Conversions T5237 T8766 T4801 T10359 Metric Increase: T12234 T6048 T3294 T14683 T3064 T9872b T9872c T783 T5837 T10678 T14697 T5631 T9203 T13719 T12707 T13056 T9630 T10547 T9872d T1969 WWRec T10370 T5321FD haddock.Cabal T5642 T9872a T15263 T12425 MultiLayerModules T5205 T9233 T13379 haddock.base T9020 T13035 T12150 T9961 - - - - - 785008c1 by Ben Gamari at 2020-02-15T09:30:13-05:00 testsuite: Sort test names in expected change output - - - - - 9e851472 by Ömer Sinan Ağacan at 2020-02-16T10:38:41+03:00 Revert "users-guide: Document -ddump-srts" This reverts commit 8cf646d36b02b8ea1c289cb52781c9171853b514. The flag was removed by 16d643cf. [ci skip] - - - - - 9792c816 by Ben Gamari at 2020-02-16T09:47:08-05:00 testsuite: Probe whether symlinks are usable on Windows Closes #17706. - - - - - ee1e5342 by Vladislav Zavialov at 2020-02-16T09:47:44-05:00 Fix the "unused terminals: 2" warning in Parser.y - - - - - b4a8ce52 by Roland Senn at 2020-02-18T20:14:42-05:00 If a :reload finds syntax errors in the module graph, remove the loaded modules. (Fixes #17549) The processing in `compiler/main/GhcMake.hs` computes the ModuleGraph. If it finds errors in the module header or in the import specifications, then the new module graph is incomplete and should not be used. The code before #17549 just reported the errors and left the old ModuleGraph in place. The new code of this MR replaces the old ModuleGraph with an empty one. - - - - - d7029cc0 by Sylvain Henry at 2020-02-18T20:15:30-05:00 Hadrian: refactor GMP in-tree build support (#17756) * Hadrian doesn't use integer-gmp/config.mk file anymore to determine if building GMP in-tree is required. "config.mk" is created by Cabal when the integer-gmp package is configured and this file is still untracked by Hadrian. This led to a tricky configure "race" because "config.mk" is built by the "setup-config" rule, but this rule is also used to find dependencies, in particular the "ghc-gmp.h" header, but the creation of this file was depending (without being tracked) on "config.mk". Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed to the top-level configure script. * in-tree GMP isn't built once for all in a fixed stage (Stage1) anymore. It is built per stage which is required if we build a cross-compiler * switching between in-tree and external GMP is now supported without having to clean the build directory first. * "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It helps ensuring that the build system generates "ghc-gmp.h". * build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp" - - - - - 40d917fb by Vladislav Zavialov at 2020-02-18T20:16:07-05:00 Remove the MonadFail P instance There were two issues with this instance: * its existence meant that a pattern match failure in the P monad would produce a user-visible parse error, but the error message would not be helpful to the user * due to the MFP migration strategy, we had to use CPP in Lexer.x, and that created issues for #17750 Updates haddock submodule. - - - - - 5a1ce45d by Joshua Price at 2020-02-18T20:16:47-05:00 Fix unboxed tuple size limit (#17837) - - - - - 192caf58 by Vladislav Zavialov at 2020-02-18T20:17:24-05:00 Fix testsuite driver output (#17847) - - - - - 1500f089 by Sylvain Henry at 2020-02-18T20:18:12-05:00 Modules: Llvm (#13009) - - - - - d53e81c0 by Niklas Hambüchen at 2020-02-20T10:36:22-05:00 8.10 Release notes for atomic .o writes [skip ci] - - - - - 19680ee5 by Niklas Hambüchen at 2020-02-20T10:37:53-05:00 8.10 Release notes for --disable-delayed-os-memory-return [skip ci] - - - - - 74ad75e8 by Simon Peyton Jones at 2020-02-20T21:17:57-05:00 Re-implement unsafe coercions in terms of unsafe equality proofs (Commit message written by Omer, most of the code is written by Simon and Richard) See Note [Implementing unsafeCoerce] for how unsafe equality proofs and the new unsafeCoerce# are implemented. New notes added: - [Checking for levity polymorphism] in CoreLint.hs - [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs - [Patching magic definitions] in Desugar.hs - [Wiring in unsafeCoerce#] in Desugar.hs Only breaking change in this patch is unsafeCoerce# is not exported from GHC.Exts, instead of GHC.Prim. Fixes #17443 Fixes #16893 NoFib ----- -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.1% 0.0% -0.0% -0.0% -0.0% CSD -0.1% 0.0% -0.0% -0.0% -0.0% FS -0.1% 0.0% -0.0% -0.0% -0.0% S -0.1% 0.0% -0.0% -0.0% -0.0% VS -0.1% 0.0% -0.0% -0.0% -0.0% VSD -0.1% 0.0% -0.0% -0.0% -0.1% VSM -0.1% 0.0% -0.0% -0.0% -0.0% anna -0.0% 0.0% -0.0% -0.0% -0.0% ansi -0.1% 0.0% -0.0% -0.0% -0.0% atom -0.1% 0.0% -0.0% -0.0% -0.0% awards -0.1% 0.0% -0.0% -0.0% -0.0% banner -0.1% 0.0% -0.0% -0.0% -0.0% bernouilli -0.1% 0.0% -0.0% -0.0% -0.0% binary-trees -0.1% 0.0% -0.0% -0.0% -0.0% boyer -0.1% 0.0% -0.0% -0.0% -0.0% boyer2 -0.1% 0.0% -0.0% -0.0% -0.0% bspt -0.1% 0.0% -0.0% -0.0% -0.0% cacheprof -0.1% 0.0% -0.0% -0.0% -0.0% calendar -0.1% 0.0% -0.0% -0.0% -0.0% cichelli -0.1% 0.0% -0.0% -0.0% -0.0% circsim -0.1% 0.0% -0.0% -0.0% -0.0% clausify -0.1% 0.0% -0.0% -0.0% -0.0% comp_lab_zift -0.1% 0.0% -0.0% -0.0% -0.0% compress -0.1% 0.0% -0.0% -0.0% -0.0% compress2 -0.1% 0.0% -0.0% -0.0% -0.0% constraints -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm1 -0.1% 0.0% -0.0% -0.0% -0.0% cryptarithm2 -0.1% 0.0% -0.0% -0.0% -0.0% cse -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e1 -0.1% 0.0% -0.0% -0.0% -0.0% digits-of-e2 -0.1% 0.0% -0.0% -0.0% -0.0% dom-lt -0.1% 0.0% -0.0% -0.0% -0.0% eliza -0.1% 0.0% -0.0% -0.0% -0.0% event -0.1% 0.0% -0.0% -0.0% -0.0% exact-reals -0.1% 0.0% -0.0% -0.0% -0.0% exp3_8 -0.1% 0.0% -0.0% -0.0% -0.0% expert -0.1% 0.0% -0.0% -0.0% -0.0% fannkuch-redux -0.1% 0.0% -0.0% -0.0% -0.0% fasta -0.1% 0.0% -0.5% -0.3% -0.4% fem -0.1% 0.0% -0.0% -0.0% -0.0% fft -0.1% 0.0% -0.0% -0.0% -0.0% fft2 -0.1% 0.0% -0.0% -0.0% -0.0% fibheaps -0.1% 0.0% -0.0% -0.0% -0.0% fish -0.1% 0.0% -0.0% -0.0% -0.0% fluid -0.1% 0.0% -0.0% -0.0% -0.0% fulsom -0.1% 0.0% +0.0% +0.0% +0.0% gamteb -0.1% 0.0% -0.0% -0.0% -0.0% gcd -0.1% 0.0% -0.0% -0.0% -0.0% gen_regexps -0.1% 0.0% -0.0% -0.0% -0.0% genfft -0.1% 0.0% -0.0% -0.0% -0.0% gg -0.1% 0.0% -0.0% -0.0% -0.0% grep -0.1% 0.0% -0.0% -0.0% -0.0% hidden -0.1% 0.0% -0.0% -0.0% -0.0% hpg -0.1% 0.0% -0.0% -0.0% -0.0% ida -0.1% 0.0% -0.0% -0.0% -0.0% infer -0.1% 0.0% -0.0% -0.0% -0.0% integer -0.1% 0.0% -0.0% -0.0% -0.0% integrate -0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide -0.1% 0.0% -0.0% -0.0% -0.0% kahan -0.1% 0.0% -0.0% -0.0% -0.0% knights -0.1% 0.0% -0.0% -0.0% -0.0% lambda -0.1% 0.0% -0.0% -0.0% -0.0% last-piece -0.1% 0.0% -0.0% -0.0% -0.0% lcss -0.1% 0.0% -0.0% -0.0% -0.0% life -0.1% 0.0% -0.0% -0.0% -0.0% lift -0.1% 0.0% -0.0% -0.0% -0.0% linear -0.1% 0.0% -0.0% -0.0% -0.0% listcompr -0.1% 0.0% -0.0% -0.0% -0.0% listcopy -0.1% 0.0% -0.0% -0.0% -0.0% maillist -0.1% 0.0% -0.0% -0.0% -0.0% mandel -0.1% 0.0% -0.0% -0.0% -0.0% mandel2 -0.1% 0.0% -0.0% -0.0% -0.0% mate -0.1% 0.0% -0.0% -0.0% -0.0% minimax -0.1% 0.0% -0.0% -0.0% -0.0% mkhprog -0.1% 0.0% -0.0% -0.0% -0.0% multiplier -0.1% 0.0% -0.0% -0.0% -0.0% n-body -0.1% 0.0% -0.0% -0.0% -0.0% nucleic2 -0.1% 0.0% -0.0% -0.0% -0.0% para -0.1% 0.0% -0.0% -0.0% -0.0% paraffins -0.1% 0.0% -0.0% -0.0% -0.0% parser -0.1% 0.0% -0.0% -0.0% -0.0% parstof -0.1% 0.0% -0.0% -0.0% -0.0% pic -0.1% 0.0% -0.0% -0.0% -0.0% pidigits -0.1% 0.0% -0.0% -0.0% -0.0% power -0.1% 0.0% -0.0% -0.0% -0.0% pretty -0.1% 0.0% -0.1% -0.1% -0.1% primes -0.1% 0.0% -0.0% -0.0% -0.0% primetest -0.1% 0.0% -0.0% -0.0% -0.0% prolog -0.1% 0.0% -0.0% -0.0% -0.0% puzzle -0.1% 0.0% -0.0% -0.0% -0.0% queens -0.1% 0.0% -0.0% -0.0% -0.0% reptile -0.1% 0.0% -0.0% -0.0% -0.0% reverse-complem -0.1% 0.0% -0.0% -0.0% -0.0% rewrite -0.1% 0.0% -0.0% -0.0% -0.0% rfib -0.1% 0.0% -0.0% -0.0% -0.0% rsa -0.1% 0.0% -0.0% -0.0% -0.0% scc -0.1% 0.0% -0.1% -0.1% -0.1% sched -0.1% 0.0% -0.0% -0.0% -0.0% scs -0.1% 0.0% -0.0% -0.0% -0.0% simple -0.1% 0.0% -0.0% -0.0% -0.0% solid -0.1% 0.0% -0.0% -0.0% -0.0% sorting -0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm -0.1% 0.0% -0.0% -0.0% -0.0% sphere -0.1% 0.0% -0.0% -0.0% -0.0% symalg -0.1% 0.0% -0.0% -0.0% -0.0% tak -0.1% 0.0% -0.0% -0.0% -0.0% transform -0.1% 0.0% -0.0% -0.0% -0.0% treejoin -0.1% 0.0% -0.0% -0.0% -0.0% typecheck -0.1% 0.0% -0.0% -0.0% -0.0% veritas -0.0% 0.0% -0.0% -0.0% -0.0% wang -0.1% 0.0% -0.0% -0.0% -0.0% wave4main -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 -0.1% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 -0.1% 0.0% -0.0% -0.0% -0.0% x2n1 -0.1% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min -0.1% 0.0% -0.5% -0.3% -0.4% Max -0.0% 0.0% +0.0% +0.0% +0.0% Geometric Mean -0.1% -0.0% -0.0% -0.0% -0.0% Test changes ------------ - break006 is marked as broken, see #17833 - The compiler allocates less when building T14683 (an unsafeCoerce#- heavy happy-generated code) on 64-platforms. Allocates more on 32-bit platforms. - Rest of the increases are tiny amounts (still enough to pass the threshold) in micro-benchmarks. I briefly looked at each one in a profiling build: most of the increased allocations seem to be because of random changes in the generated code. Metric Decrease: T14683 Metric Increase: T12150 T12234 T12425 T13035 T14683 T5837 T6048 Co-Authored-By: Richard Eisenberg <rae at cs.brynmawr.edu> Co-Authored-By: Ömer Sinan Ağacan <omeragacan at gmail.com> - - - - - 6880d6aa by Sylvain Henry at 2020-02-20T21:18:48-05:00 Disentangle DynFlags and SDoc Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly CodeGen related (e.g. depend on target platform constants) and will be fixed separately. Metric Decrease: T12425 T9961 WWRec T1969 T14683 - - - - - 70a90110 by Julien Debon at 2020-02-20T21:19:27-05:00 doc(List): Add examples to GHC.List * Add examples * Cleanup documentation * Clarify merge process and Marge bot - - - - - c8439fc7 by Peter Trommler at 2020-02-20T21:20:05-05:00 Fix testsuite on powerpc64le Remove expect broken on recomp tests, #11260 was closed by !2264 and #11323 most likely by !2264 as well. GHCi scripts tests work on GHCi but not the external interpreter, adjust test configuration accordingly. Fixes unexpected passes. Mark test requiring DWARF expect fail on powerpc64[le] for #11261. - - - - - 65b7256a by Ömer Sinan Ağacan at 2020-02-20T21:20:45-05:00 Use concatMap(M) instead of `concat . map` and the monadic variant - - - - - 8b76d457 by Roland Senn at 2020-02-20T21:21:28-05:00 Fix #17832: Weird handling of exports named main in 8.10-rc1 Switching from `lookupGlobalOccRn_maybe` to `lookupInfoOccRn` to check whether a `main` function is in scope. Unfortunately `lookupGlobalOccRn_maybe` complains if there are multiple `main` functions in scope. - - - - - 466e1ad5 by Krzysztof Gogolewski at 2020-02-20T21:22:11-05:00 Use TTG for HsSplicedT constructor The constructor HsSplicedT occurs only in the GhcTc pass. This enforces this fact statically via TTG. - - - - - 4e622fca by Alexis King at 2020-02-20T21:22:49-05:00 Normalize types when dropping absent arguments from workers fixes #17852 - - - - - a533e547 by Adam Sandberg Eriksson at 2020-02-20T21:23:31-05:00 Mention users guide and release notes in merge request template - - - - - 05251b17 by Ben Gamari at 2020-02-20T21:24:08-05:00 gitlab-ci: Fix typo in BIN_DIST_PREP_TAR_COMP variable name - - - - - f44c7e67 by Ben Gamari at 2020-02-20T21:24:46-05:00 gitlab-ci: Avoid duplicating ~/.cabal contents with every build Previously our attempt to cache the cabal store would `cp cabal-cache ~/.cabal`. However, if the latter already existed this meant that we would end up with ~/.cabal/cabal-cache. Not only would this not help caching but it would exponentially grow the size of ~/.cabal. Not good! - - - - - c5ec9965 by Ben Gamari at 2020-02-20T21:56:13-05:00 GHC.Hs.Extension: Use Type instead of * - - - - - 89cb4cc4 by Ben Gamari at 2020-02-20T21:56:13-05:00 Use Type instead of * in GHC - - - - - 04eb0d6c by Ben Gamari at 2020-02-20T21:56:13-05:00 Enable -Wstar-is-type in -Wall As noted in [proposal 0143][proposal] this is supposed to happen in 8.12. Also fix an incorrect claim in the users guide that -Wstar-is-type is enabled by default. [proposal]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0143-remove-star-kind.rst - - - - - 6de966f1 by Andreas Klebinger at 2020-02-20T21:56:15-05:00 Fix #17724 by having occAnal preserve used bindings. It sometimes happened that occAnal would remove bindings as dead code by relying on bindings to be in dependency order. The fix was contributed by SPJ. - - - - - abd7f962 by Ben Gamari at 2020-02-20T21:56:15-05:00 users-guide: Mention dependency on `exceptions` in release notes Fixes #17845. - - - - - 58175379 by Sylvain Henry at 2020-02-20T21:56:20-05:00 Hadrian: minor GMP refactoring Somehow I forgot to totally remove `gmpContext` in d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds some additional comments. - - - - - 33fa8d94 by Ryan Scott at 2020-02-20T21:56:21-05:00 Generalize liftData to work over any Quote (#17857) The Overloaded Quotations proposal generalized the type of `lift` to work over any `Quote`, but not the type of `liftData`, leading to #17857. Thankfully, generalizing `liftData` is extremely straightforward. Fixes #17857. - - - - - 3cea6795 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Make: fix sdist target (#17848) - - - - - e2cce997 by Sylvain Henry at 2020-02-20T21:56:23-05:00 Hadrian: fix source-dist target (#17849) - - - - - 0a4c89b2 by Matthew Pickering at 2020-02-21T20:44:45-05:00 Special case `mkTyConApp liftedTypeKind []` We really need to make sure that these are shared because otherwise GHC will allocate thousands of identical `TyConApp` nodes. See #17292 ------------------------- Metric Decrease: haddock.Cabal T14683 ------------------------- - - - - - 0482f58a by Matthew Pickering at 2020-02-21T20:45:21-05:00 TH: wrapGenSyns, don't split the element type too much The invariant which allowed the pervious method of splitting the type of the body to find the type of the elements didn't work in the new overloaded quotation world as the type can be something like `WriterT () m a` rather than `Q a` like before. Fixes #17839 - - - - - be7068a6 by Vladislav Zavialov at 2020-02-21T20:45:59-05:00 Parser API annotations: RealSrcLoc During parsing, GHC collects lexical information about AST nodes and stores it in a map. It is needed to faithfully restore original source code, e.g. compare these expressions: a = b a = b The position of the equality sign is not recorded in the AST, so it must be stored elsewhere. This system is described in Note [Api annotations]. Before this patch, the mapping was represented by: Map (SrcSpan, AnnKeywordId) SrcSpan After this patch, the mapping is represented by: Map (RealSrcSpan, AnnKeywordId) RealSrcSpan The motivation behind this change is to avoid using the Ord SrcSpan instance (required by Map here), as it interferes with #17632 (see the discussion there). SrcSpan is isomorphic to Either String RealSrcSpan, but we shouldn't use those strings as Map keys. Those strings are intended as hints to the user, e.g. "<interactive>" or "<compiler-generated code>", so they are not a valid way to identify nodes in the source code. - - - - - 240f5bf6 by Sylvain Henry at 2020-02-21T20:46:40-05:00 Modules: Driver (#13009) submodule updates: nofib, haddock - - - - - 9d094111 by Sylvain Henry at 2020-02-21T20:47:19-05:00 Hadrian: `docs` rule needs `configure` (#17840) - - - - - 1674353a by Ben Gamari at 2020-02-23T17:31:19-05:00 fs: Port fixes from ghc-jailbreak repository * Override rename, unlink, and remove * Factor out wchar conversion - - - - - 853210f2 by Adam Sandberg Ericsson at 2020-02-23T17:32:03-05:00 show gcc linker options in configure summary - - - - - 2831544a by Adam Sandberg Ericsson at 2020-02-23T17:32:44-05:00 hadrian: docs depend on stage1 ghc - - - - - 1d9df9e0 by Adam Sandberg Ericsson at 2020-02-23T17:33:23-05:00 ci: after 5ce63d52fed the linux bindist for doc-tarball has changed name - - - - - 26e8fff3 by Vladislav Zavialov at 2020-02-24T02:05:30-05:00 Remove Ord SrcLoc, Ord SrcSpan Before this patch, GHC relied on Ord SrcSpan to identify source elements, by using SrcSpan as Map keys: blackList :: Map SrcSpan () -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map SrcSpan Name -- compiler/GHC/HsToCore/Docs.hs Firstly, this design is not valid in presence of UnhelpfulSpan, as it distinguishes between UnhelpfulSpan "X" and UnhelpfulSpan "Y", but those strings are messages for the user, unfit to serve as identifiers for source elements. Secondly, this design made it hard to extend SrcSpan with additional data. Recall that the definition of SrcSpan is: data SrcSpan = RealSrcSpan !RealSrcSpan | UnhelpfulSpan !FastString Say we want to extend the RealSrcSpan constructor with additional information: data SrcSpan = RealSrcSpan !RealSrcSpan !AdditionalInformation | UnhelpfulSpan !FastString getAdditionalInformation :: SrcSpan -> AdditionalInformation getAdditionalInformation (RealSrcSpan _ a) = a Now, in order for Map SrcSpan to keep working correctly, we must *ignore* additional information when comparing SrcSpan values: instance Ord SrcSpan where compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2 ... However, this would violate an important law: a == b therefore f a == f b Ignoring AdditionalInformation in comparisons would mean that with f=getAdditionalInformation, the law above does not hold. A more robust design is to avoid Ord SrcSpan altogether, which is what this patch implements. The mappings are changed to use RealSrcSpan instead: blackList :: Set RealSrcSpan -- compiler/GHC/HsToCore/Coverage.hs instanceMap :: Map RealSrcSpan Name -- compiler/GHC/HsToCore/Docs.hs All SrcSpan comparisons are now done with explicit comparison strategies: SrcLoc.leftmost_smallest SrcLoc.leftmost_largest SrcLoc.rightmost_smallest These strategies are not subject to the law mentioned above and can easily discard both the string stored in UnhelpfulSpan and AdditionalInformation. Updates haddock submodule. - - - - - 5aa6c188 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Shuffle text - - - - - e3f17413 by Ben Gamari at 2020-02-24T02:06:09-05:00 users-guide: Drop old release notes - - - - - 84dd9610 by Ben Gamari at 2020-02-24T02:06:09-05:00 Bump directory submodule to 1.3.6.0 - - - - - e295a024 by Stefan Pavikevik at 2020-02-24T20:53:44-05:00 check for safe arguments, raising error when invalid (fix #17720) - - - - - 354e2787 by Krzysztof Gogolewski at 2020-02-24T20:54:35-05:00 Comments, small refactor * Remove outdated Note [HsForAllTy tyvar binders] and [Context quantification]. Since the wildcard refactor 1e041b7382, HsForAllTy no longer has an flag controlling explicity. The field `hsq_implicit` is gone too. The current situation is covered by Note [HsType binders] which is already linked from LHsQTyVars. * Small refactor in CoreLint, extracting common code to a function * Remove "not so sure about WpFun" in TcEvidence, per Richard's comment https://gitlab.haskell.org/ghc/ghc/merge_requests/852#note_223226 * Use mkIfThenElse in Foreign/Call, as it does exactly what we need. - - - - - 1b1067d1 by Sylvain Henry at 2020-02-24T20:55:25-05:00 Modules: CmmToAsm (#13009) - - - - - 621468f6 by Alexis King at 2020-02-26T15:08:09-05:00 Treat coercions as arguments for floating and inlining This reverts commit 8924224ecfa065ebc67b96a90d01cf9d2edd0e77 and fixes #17787. - - - - - def486c9 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Allow libnuma library path to be specified - - - - - ed03d4e7 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Refactor gmp arguments Move the gmp configuration to its own binding. - - - - - 09b88384 by Ben Gamari at 2020-02-26T15:08:47-05:00 hadrian: Tell Cabal about integer-gmp library location - - - - - 161e08c5 by Krzysztof Gogolewski at 2020-02-26T15:09:30-05:00 Remove dead code * FailablePattern can no longer be created since ab51bee40c82 Therefore, Opt_WarnMissingMonadFailInstances has no effect anymore. * XWrap is no longer used, it was moved to an extension field - - - - - e0d09db3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Use 8.8.3 to bootstrap on Windows This should fix #17861. - - - - - 972bcf3a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Fix symlink test Needs to `write` bytes, not str. - - - - - 273e60de by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add shell subcommand for debugging within CI environment - - - - - 43b13ed3 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Fix colors on Darwin Darwin sh doesn't support \e. - - - - - 217546a7 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Flush stdout buffers in InitEventLogging Otherwise we are sensitive to libc's buffering strategy. Similar to the issue fixed in 543dfaab166c81f46ac4af76918ce32190aaab22. - - - - - c7d4fa55 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Add run_hadrian subcommand I've ruined two trees already by failing to pass --flavour to hadrian. Let's factor this out so it can be reused during troubleshooting. - - - - - 7dc54873 by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Allow tests to be marked as broken on the command line This allows us to work-around distribution-specific breakage easily. - - - - - 25e2458e by Ben Gamari at 2020-02-26T15:10:09-05:00 hadrian: Add --broken-test flag This exposes the flag of the same name supported by the testsuite driver. - - - - - 55769996 by Ben Gamari at 2020-02-26T15:10:09-05:00 gitlab-ci: Mark some tests as broken on Alpine - - - - - 9ee7f87d by Ben Gamari at 2020-02-26T15:10:09-05:00 SysTools: Don't use process jobs if they are broken - - - - - bfaa3961 by Ben Gamari at 2020-02-26T15:10:09-05:00 Bump hsc2hs submodule Fixes name of C compiler. - - - - - b2b49a0a by Ben Gamari at 2020-02-26T15:10:09-05:00 testsuite: Make hasMetricsFile RHS more descriptive - - - - - 817f93ea by Sylvain Henry at 2020-02-26T15:10:58-05:00 Modules: Core (#13009) Update haddock submodule - - - - - 74311e10 by Sebastian Graf at 2020-02-27T16:22:45-05:00 PmCheck: Implement Long-distance information with Covered sets Consider ```hs data T = A | B | C f :: T -> Int f A = 1 f x = case x of A -> 2 B -> 3 C -> 4 ``` Clearly, the RHS returning 2 is redundant. But we don't currently see that, because our approximation to the covered set of the inner case expression just picks up the positive information from surrounding pattern matches. It lacks the context sensivity that `x` can't be `A` anymore! Therefore, we adopt the conceptually and practically superior approach of reusing the covered set of a particular GRHS from an outer pattern match. In this case, we begin checking the `case` expression with the covered set of `f`s second clause, which encodes the information that `x` can't be `A` anymore. After this MR, we will successfully warn about the RHS returning 2 being redundant. Perhaps surprisingly, this was a great simplification to the code of both the coverage checker and the desugarer. Found a redundant case alternative in `unix` submodule, so we have to bump it with a fix. Metric Decrease: T12227 - - - - - 59c023ba by Adam Sandberg Ericsson at 2020-02-27T16:23:25-05:00 configure: correctly generate LIBRARY_template_haskell_VERSION - - - - - 9be82389 by Krzysztof Gogolewski at 2020-02-28T02:35:35-05:00 boot: Remove remote origin check Previously, we used relative paths in submodules. When cloning from GitHub, they had to be manually tweaked. Since a76b233d we use absolute paths, so this workaround can be removed. - - - - - f4b6b594 by Ben Gamari at 2020-02-28T02:36:12-05:00 nonmoving: Fix marking in compact regions Previously we were tracing the object we were asked to mark, even if it lives in a compact region. However, there is no need to do this; we need only to mark the region itself as live. I have seen a segfault due to this due to the concurrent mark seeing a an object in the process of being compacted by the mutator. - - - - - f97d1fb6 by Alp Mestanogullari at 2020-02-28T02:36:59-05:00 base: use an explicit import list in System.Environment.ExecutablePath This was making -Werror builds fail on Windows (at least with Hadrian). - - - - - 66f5d6d6 by Simon Peyton Jones at 2020-02-28T22:03:23-05:00 Improve error handling for VTA + deferred type errors This fixes #17792 See Note [VTA for out-of-scope functions] in TcExpr - - - - - 37f12603 by Ilias Tsitsimpis at 2020-02-28T22:04:04-05:00 llvm-targets: Add arm-unknown-linux-gnueabi Add arm-unknown-linux-gnueabi, which is used by Debian's ARM EABI port (armel), as an LLVM target. - - - - - 327b29e1 by Vladislav Zavialov at 2020-02-29T05:06:31-05:00 Monotonic locations (#17632) When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the tool may insert #line pragmas to adjust the locations reported to the user. As the result, the locations recorded in RealSrcLoc are not monotonic. Elements that appear later in the StringBuffer are not guaranteed to have a higher line/column number. In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily modify locations. This lack of guarantees makes ideas such as #17544 infeasible. This patch adds an additional bit of information to every SrcLoc: newtype BufPos = BufPos { bufPos :: Int } A BufPos represents the location in the StringBuffer, unaffected by any pragmas. Updates haddock submodule. Metric Increase: haddock.Cabal haddock.base haddock.compiler MultiLayerModules Naperian parsing001 T12150 - - - - - 99d2de86 by Ben Gamari at 2020-02-29T05:07:10-05:00 plugins: Ensure that loadInterface plugins can see annotations loadInterface replaces the `mi_decls`, `mi_insts`, `mi_fam_insts`, `mi_rules`, `mi_anns` fields of ModIface with `undefined` before inserting the interface into the EPS. However, we still want to give loadInterface plugins access to these fields. Consequently, we want to pass the unmodified `ModIface` the plugin. - - - - - a999ee96 by Xavier Denis at 2020-02-29T05:07:50-05:00 Rename ghci.sh and build.sh to ghci and build respectively Convert hadrian buildscripts to unsuffixed, dashed form final cleanups - - - - - b5fb58fd by Ömer Sinan Ağacan at 2020-02-29T05:08:36-05:00 Document and refactor a few things around bitmap scavenging - Added a few comments in StgPAP - Added a few comments and assertions in scavenge_small_bitmap and walk_large_bitmap - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted dead code, used PlatformWordSize type. - - - - - 18757cab by Sylvain Henry at 2020-02-29T05:09:25-05:00 Refactor runtime interpreter code In #14335 we want to be able to use both the internal interpreter (for the plugins) and the external interpreter (for TH and GHCi) at the same time. This patch performs some preliminary refactoring: the `hsc_interp` field of HscEnv replaces `hsc_iserv` and is now used to indicate which interpreter (internal, external) to use to execute TH and GHCi. Opt_ExternalInterpreter flag and iserv options in DynFlags are now queried only when we set the session DynFlags. It should help making GHC multi-target in the future by selecting an interpreter according to the selected target. - - - - - b86a6395 by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct relative links to haddocks from users guide (fixes #17866) - - - - - 0f55df7f by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00 docs: correct link to th haddocks from users guide - - - - - 252e5117 by Jean-Baptiste Mazon at 2020-02-29T05:10:46-05:00 rts: enforce POSIX numeric locale for heap profiles - - - - - 34c7d230 by Sylvain Henry at 2020-02-29T05:11:27-05:00 Fix Hadrian's ``--configure`` (fix #17883) - - - - - 04d30137 by Ömer Sinan Ağacan at 2020-02-29T05:12:06-05:00 Simplify IfaceIdInfo type IfaceIdInfo type is confusing: there's practically no difference between `NoInfo` and `HasInfo []`. The comments say NoInfo is used when -fomit-interface-pragmas is enabled, but we don't need to distinguish `NoInfo` from `HasInfo []` in when reading the interface so the distinction is not important. This patch simplifies the type by removing NoInfo. When we have no info we use an empty list. With this change we no longer read the info list lazily when reading an IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is read lazily, so I doubt this is going to be a problem. - - - - - 3979485b by Roland Senn at 2020-02-29T17:36:59+01:00 Show breakpoint locations of breakpoints which were ignored during :force (#2950) GHCi is split up into 2 major parts: The user-interface (UI) and the byte-code interpreter. With `-fexternal-interpreter` they even run in different processes. Communication between the UI and the Interpreter (called `iserv`) is done using messages over a pipe. This is called `Remote GHCI` and explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`. To process a `:force` command the UI sends a `Seq` message to the `iserv` process. Then `iserv` does the effective evaluation of the value. When during this process a breakpoint is hit, the `iserv` process has no additional information to enhance the `Ignoring breakpoint` output with the breakpoint location. To be able to print additional breakpoint information, there are 2 possible implementation choices: 1. Store the needed information in the `iserv` process. 2. Print the `Ignoring breakpoint` from the UI process. For option 1 we need to store the breakpoint info redundantely in 2 places and this is bad. Therfore option 2 was implemented in this MR: - The user enters a `force` command - The UI sends a `Seq` message to the `iserv` process. - If processing of the `Seq` message hits a breakpoint, the `iserv` process returns control to the UI process. - The UI looks up the source location of the breakpoint, and prints the enhanced `Ignoring breakpoint` output. - The UI sends a `ResumeSeq` message to the `iserv` process, to continue forcing. - - - - - 3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00 Remove dead code * The names in PrelName and THNames are no longer used since TH merged types and kinds, Typeable is kind-polymorphic, .net support was removed * unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3 - - - - - dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00 Do not define hs_atomic{read,write}64() on non-64bit Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886. - - - - - 7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00 Set `ImpredicativeTypes` during :print command. (#14828) If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the type of <term> has nested `forall`s or `=>`s. This is because the GHCi debugger's internals will attempt to unify a metavariable with the type of <term> and then display the result, but if the type has nested `forall`s or `=>`s, then unification will fail. As a result, `:print` will bail out and the unhelpful result will be `<term> = (_t1::t1)` (where `t1` is a metavariable). Beware: <term> can have nested `forall`s even if its definition doesn't use RankNTypes! Here is an example from #14828: class Functor f where fmap :: (a -> b) -> f a -> f b Somewhat surprisingly, `:print fmap` considers the type of fmap to have nested foralls. This is because the GHCi debugger sees the type `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`. We could envision deeply instantiating this type to get the type `forall f a b. Functor f => (a -> b) -> f a -> f b`, but this trick wouldn't work for higher-rank types. Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using `:print` and friends in the GHCi debugger. This is allows metavariables to unify with types that have nested (or higher-rank) `forall`s/`=>`s, which makes `:print fmap` display as `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected. Although ImpredicativeTypes is a somewhat unpredictable from a type inference perspective, there is no danger in using it in the GHCi debugger, since all of the terms that the GHCi debugger deals with have already been typechecked. - - - - - 2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00 Use configure script to detect that we should use in-tree GMP on Windows - - - - - 8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00 Be explicit about how stack usage of mvar primops are covered. This fixes #17893 [skip-ci] - - - - - cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Add getCurrentThreadCPUTime helper - - - - - ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00 nonmoving-gc: Track time usage of nonmoving marking - - - - - 022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00 Stats: Add sync pauses to +RTS -S output - - - - - 06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00 rts: Report nonmoving collector statistics in machine-readable output - - - - - 70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00 nonmoving: Fix collection of sparks Previously sparks living in the non-moving heap would be promptly GC'd by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag, which non-moving heap blocks do not have set. Fix this by implementing proper support in pruneSparkQueue for determining reachability in the non-moving heap. The story is told in Note [Spark management in the nonmoving heap]. - - - - - 9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00 gitlab-ci: Disable Sphinx documentation in Alpine build - - - - - 8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 Fix Windows breakage by not touching locales on Windows - - - - - b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: ensure C numerics in heap profiles using Windows locales if needed - - - - - 7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00 rts: refactor and comment profile locales - - - - - 5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00 Use InstanceSigs in GND/DerivingVia-generated code (#17899) Aside from making the generated code easier to read when `-ddump-deriv` is enabled, this makes the error message in `T15073` substantially simpler (see the updated `T15073` expected stderr). Fixes #17899. - - - - - 70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00 SysTools: Ensure that error parser can handle absolute paths on Windows This fixes #17786, where the error parser fails to correctly handle the drive name in absolute Windows paths. Unfortunately I couldn't find a satisfactory way to test this. - - - - - 85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00 testsuite: Add test for #17786 This isn't pretty but it's perhaps better than nothing. - - - - - ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00 Hadrian: track missing configure results - - - - - ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00 Add regression test for T17904 Closes #17904 - - - - - 5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00 anyRewritableTyVar now looks in RuntimeReps Previously, anyRewritableTyVar looked only at the arg and res of `arg -> res`, but their RuntimeReps are also subject to rewriting. Easy to fix. Test case: typecheck/should_compile/T17024 Fixes #17024. - - - - - 5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00 Clarify a Lint message When developing a plugin I had a shadowing problem, where I generated code app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B} This is obviously wrong, since the occurrence of `f` to the right of the arrow refers to the `x` binder (they share a Unique). However, it is rather confusing when Lint reports Mismatch in type between binder and occurrence Var: x{v rB7} since it is printing the binder, rather than the occurrence. It is rather easy to read this as claiming there is something wrong with the `x` occurrence! We change the report to explicitly print both the binder and the occurrence variables. - - - - - 7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00 Comments only Clarify code added in #17852 and MR !2724 - - - - - 3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00 Misc cleanup - Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole - - - - - abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00 Typos in comments [skip ci] - - - - - bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00 rts: Prefer darwin-specific getCurrentThreadCPUTime macOS Catalina now supports a non-POSIX-compliant version of clock_gettime which cannot use the clock_gettime codepath. Fixes #17906. - - - - - 20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00 Split GHC.Iface.Utils module * GHC.Iface.Recomp: recompilation avoidance stuff * GHC.Iface.Make: mkIface* Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and renamed it `writeIface` for consistency. - - - - - 1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00 Fixed a minor typo in codegen.rst - - - - - 0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00 Re-quantify when generalising over rewrite rule types Previously, `tcRules` would check for naughty quantification candidates (see `Note [Naughty quantification candidates]` in `TcMType`) when generalising over the type of a rewrite rule. This caused sensible-looking rewrite rules (like those in #17710) to be rejected. A more permissing (and easier-to-implement) approach is to do what is described in `Note [Generalising in tcTyFamInstEqnGuts]` in `TcTyClsDecls`: just re-quantify all the type variable binders, regardless of the order in which the user specified them. After all, the notion of type variable specificity has no real meaning in rewrite rules, since one cannot "visibly apply" a rewrite rule. I have written up this wisdom in `Note [Re-quantify type variables in rules]` in `TcRules`. As a result of this patch, compiling the `ExplicitForAllRules1` test case now generates one fewer warning than it used to. As far as I can tell, this is benign, since the thing that the disappearing warning talked about was also mentioned in an entirely separate warning. Fixes #17710. - - - - - 336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00 testsuite: Mark ghci056 and ghcilink004 as fragile in unreg As noted in #17018. Also fix fragile declaration of T13786, which only runs in the normal way. - - - - - c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00 Deepen call stack for isIn I see quite a few warnings like: WARNING: file compiler/utils/Util.hs, line 593 Over-long elem in unionLists But the call stack is uninformative. Better to add HasDebugCallStack to isIn. Ditto isn'tIn. - - - - - 3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00 Zero any slop after compaction in compacting GC In copying GC, with the relevant debug flags enabled, we release the old blocks after a GC, and the block allocator zeroes the space before releasing a block. This effectively zeros the old heap. In compacting GC we reuse the blocks and previously we didn't zero the unused space in a compacting generation after compaction. With this patch we zero the slop between the free pointer and the end of the block when we're done with compaction and when switching to a new block (because the current block doesn't have enough space for the next object we're shifting). - - - - - 8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor GHC.Driver.Session (Ways and Flags) * extract flags and ways into their own modules (with some renaming) * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases * when GHC uses dynamic linking (WayDyn), `interpWays` was only reporting WayDyn even if the host was profiled (WayProf). Now it returns both as expected (might fix #16803). * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for differently ordered lists. Now we sort and nub the list to fix this. - - - - - bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Refactor interpreterDynamic and interpreterProfiled * `interpreterDynamic` and `interpreterProfiled` now take `Interp` parameters instead of DynFlags * slight refactoring of `ExternalInterp` so that we can read the iserv configuration (which is pure) without reading an MVar. - - - - - a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00 Use a Set to represent Ways Should make `member` queries faster and avoid messing up with missing `nubSort`. Metric Increase: hie002 - - - - - cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00 Make DeriveFunctor-generated code require fewer beta reductions Issue #17880 demonstrates that `DeriveFunctor`-generated code is surprisingly fragile when rank-_n_ types are involved. The culprit is that `$fmap` (the algorithm used to generate `fmap` implementations) was too keen on applying arguments with rank-_n_ types to lambdas, which fail to typecheck more often than not. In this patch, I change `$fmap` (both the specification and the implementation) to produce code that avoids creating as many lambdas, avoiding problems when rank-_n_ field types arise. See the comments titled "Functor instances" in `TcGenFunctor` for a more detailed description. Not only does this fix #17880, but it also ensures that the code that `DeriveFunctor` generates will continue to work after simplified subsumption is implemented (see #17775). What is truly amazing is that #17880 is actually a regression (introduced in GHC 7.6.3) caused by commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to that commit, the version of `$fmap` that was used was almost identical to the one used in this patch! Why did that commit change `$fmap` then? It was to avoid severe performance issues that would arise for recursive `fmap` implementations, such as in the example below: ```hs data List a = Nil | Cons a (List a) deriving Functor -- ===> instance Functor List where fmap f Nil = Nil fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs) ``` The fact that `\y -> f y` was eta expanded caused significant performance overheads. Commit 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance issue, but it went too far. As a result, this patch partially reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e. To ensure that the performance issues pre-#7436 do not resurface, I have taken some precautionary measures: * I have added a special case to `$fmap` for situations where the last type variable in an application of some type occurs directly. If this special case fires, we avoid creating a lambda expression. This ensures that we generate `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived `Functor List` instance above. For more details, see `Note [Avoid unnecessary eta expansion in derived fmap implementations]` in `TcGenFunctor`. * I have added a `T7436b` test case to ensure that the performance of this derived `Functor List`-style code does not regress. When implementing this, I discovered that `$replace`, the algorithm which generates implementations of `(<$)`, has a special case that is very similar to the `$fmap` special case described above. `$replace` marked this special case with a custom `Replacer` data type, which was a bit overkill. In order to use the same machinery for both `Functor` methods, I ripped out `Replacer` and instead implemented a simple way to detect the special case. See the updated commentary in `Note [Deriving <$]` for more details. - - - - - 1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Properly parenthesise LastStmt After ApplicatveDo strips the last `return` during renaming, the pretty printer has to restore it. However, if the return was followed by `$`, the dollar was stripped too and not restored. For example, the last stamement in: ``` foo = do x <- ... ... return $ f x ``` would be printed as: ``` return f x ``` This commit preserved the dolar, so it becomes: ``` return $ f x ``` - - - - - 5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00 pretty-printer: Do not print ApplicativeDo join * Do not print `join` in ApplictiveStmt, unless ppr-debug * Print parens around multiple parallel binds When ApplicativeDo is enabled, the renamer analyses the statements of a `do` block and in certain cases marks them as needing to be rewritten using `join`. For example, if you have: ``` foo = do a <- e1 b <- e2 doSomething a b ``` it will be desugared into: ``` foo = join (doSomething <$> e1 <*> e2) ``` After renaming but before desugaring the expression is stored essentially as: ``` foo = do [will need join] (a <- e1 | b <- e2) [no return] doSomething a b ``` Before this change, the pretty printer would print a call to `join`, even though it is not needed at this stage at all. The expression will be actually rewritten into one using join only at desugaring, at which point a literal call to join will be inserted. - - - - - 3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00 Expose compulsory unfoldings always The unsafeCoerce# patch requires that unsafeCoerce# has a compulsory unfolding that is always available. So we have to be careful to expose compulsory unfoldings unconditionally and consistently. We didn't get this quite right: #17871. This patch fixes it. No real surprises here. See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy - - - - - 6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00 hadrian: improve dependency tracking for the check-* programs The code in Rules.Register responsible for finding all the build artifacts that Cabal installs when registering a library (static/shared libs, .hi files, ...) was looking in the wrong place. This patch fixes that logic and makes sure we gather all those artifacts in a list to declare that the rule for a given `.conf` file, our proxy for "Hadrian, please install this package in the package db for this stage", also produces those artifacts under the said package database. We also were completely missing some logic to declare that the check-* programs have dependencies besides their source code, at least when testing an in-tree compiler. Finally, this patch also removes redundant packages from 'testsuitePackages', since they should already be covered by the stage<N>Packages lists from Settings.Default. With this patch, after a complete build and freezing stage 1, a change to `compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it, and rebuilding the few programs that depend on it, _including_ `check-ppr` and `check-api-annotations` (therefore fixing #17273). - - - - - 44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00 Rename isDllName I wanted to fix the dangling comment in `isDllName` ("This is the cause of #", #8696 is already mentioned earlier). I took the opportunity to change the function name to better reflect what it does. - - - - - 2f292db8 by Paavo at 2020-03-13T02:31:03-04:00 Update documentation for closureSize - - - - - f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00 gitlab-ci: Rework triggering of release builds Use a push option instead of tagging. - - - - - 7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00 gitlab-ci: Distinguish integer-simple test envs Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes. - - - - - c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00 Fix Lint Ticket #17590 pointed out a bug in the way the linter dealt with type lets, exposed by the new uniqAway story. The fix is described in Note [Linting type lets]. I ended up putting the in-scope Ids in a different env field, le_ids, rather than (as before) sneaking them into the TCvSubst. Surprisingly tiresome, but done. Metric Decrease: hie002 - - - - - b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00 Hadrian: fix absolute buildroot support (#17822) Shake's "**" wildcard doesn't match absolute root. We must use "//" instead. - - - - - 4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00 Make: refactor GMP rules Document and use simpler rules for the ghc-gmp.h header. - - - - - 7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00 Use correct option name (-opti) (fix #17314) s/pgmo/opti - - - - - 8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script. Previously it was possible to override the stage0 C compiler via `CC_STAGE0`, but you couldn't override `ld` or `ar` in stage0. This change allows overriding them by setting `LD_STAGE0` or `AR_STAGE0`, respectively. Our team uses this feature internally to take more control of our GHC build and make it run more hermetically. - - - - - 7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00 Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0. - - - - - 20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00 nonmoving: Don't traverse filled segment list in pause The non-moving collector would previously walk the entire filled segment list during the preparatory pause. However, this is far more work than is strictly necessary. We can rather get away with merely collecting the allocators' filled segment list heads and process the lists themselves during the concurrent phase. This can significantly reduce the maximum gen1 GC pause time in programs with high rates of long-lived allocations. - - - - - fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00 nonmoving: Remove redundant bitmap clearing nonmovingSweep already clears the bitmap in the sweep loop. There is no reason to do so a second time. - - - - - 2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Simple refactor of cheapEqExpr No change in functionality. Just seems tidier (and signficantly more efficient) to deal with ticks directly than to call stripTicksTopE. - - - - - 88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00 Improve CSE.combineAlts This patch improves the way that CSE combines identical alternatives. See #17901. I'm still not happy about the duplication between CSE.combineAlts and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those functions. But this patch is a step forward. Metric Decrease: T12425 T5642 - - - - - 8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00 gitlab-ci: Add integer-simple release build for Windows Closes #16144. - - - - - e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Wrap an implication around class-sig kind errors Ticket #17841 showed that we can get a kind error in a class signature, but lack an enclosing implication that binds its skolems. This patch * Adds the wrapping implication: the new call to checkTvConstraints in tcClassDecl1 * Simplifies the API to checkTvConstraints, which was not otherwise called at all. * Simplifies TcErrors.report_unsolved by *not* initialising the TidyEnv from the typechecker lexical envt. It's enough to do so from the free vars of the unsolved constraints; and we get silly renamings if we add variables twice: once from the lexical scope and once from the implication constraint. - - - - - 73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00 Refactoring in TcSMonad This patch is just refactoring: no change in behaviour. I removed the rather complicated checkConstraintsTcS checkTvConstraintsTcS in favour of simpler functions emitImplicationTcS emitTvImplicationTcS pushLevelNoWorkList The last of these is a little strange, but overall it's much better I think. - - - - - 93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00 base: Make `open` calls interruptible As noted in #17912, `open` system calls were `safe` rather than `interruptible`. Consequently, the program could not be interrupted with SIGINT if stuck in a slow open operation. Fix this by marking `c_safe_open` as interruptible. - - - - - bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00 Remove second tcLookupTcTyCon in tcDataDefn Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row: 1. in bindTyClTyVars itself 2. in the continuation passed to it Now bindTyClTyVars passes the TcTyCon to the continuation, making the second lookup unnecessary. - - - - - 3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00 Enable stage1 build of haddock The submodule has already been bumped to contain the fix. - - - - - 49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00 rts: Fix printClosure when printing fwd ptrs - - - - - 1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00 Remove unused field var_inline (#17915) - - - - - d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00 Document restriction on SCC pragma syntax Currently, the names of cost centres must be quoted or be lowercase identifiers. Fixes #17916. - - - - - b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00 Remove some dead code >From the notes.ghc.drop list found using weeder in #17713 - - - - - dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00 Note platform-specific Foreign.C.Types in context Also fix the markup in the general note at the top of the module. Haddock (usability trade-off), does not support multi-line emphasised text. - - - - - 2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00 Refactor CmmToAsm (disentangle DynFlags) This patch disentangles a bit more DynFlags from the native code generator (CmmToAsm). In more details: - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the configuration of a native code generation session - explicitly pass NCGConfig/Platform arguments when necessary - as a consequence `sdocWithPlatform` is gone and there are only a few `sdocWithDynFlags` left - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig) There are still some places where DynFlags is used, especially because of pretty-printing (CLabel), because of Cmm helpers (such as `cmmExprType`) and because of `Outputable` instance for the instructions. These are left for future refactoring as this patch is already big. - - - - - c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00 Add a -no-haddock flag. This flag undoes the effect of a previous "-haddock" flag. Having both flags makes it easier for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC). I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list. - - - - - cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00 Fix global_link of TSOs for threads reachable via dead weaks Fixes #17785 Here's how the problem occurs: - In generation 0 we have a TSO that is finished (i.e. it has no more work to do or it is killed). - The TSO only becomes reachable after collectDeadWeakPtrs(). - After collectDeadWeakPtrs() we switch to WeakDone phase where we don't move TSOs to different lists anymore (like the next gen's thread list or the resurrected_threads list). - So the TSO will never be moved to a generation's thread list, but it will be promoted to generation 1. - Generation 1 collected via mark-compact, and because the TSO is reachable it is marked, and its `global_link` field, which is bogus at this point (because the TSO is not in a list), will be threaded. - Chaos ensues. In other words, when these conditions hold: - A TSO is reachable only after collectDeadWeakPtrs() - It's finished (what_next is ThreadComplete or ThreadKilled) - It's retained by mark-compact collector (moving collector doesn't evacuate the global_list field) We end up doing random mutations on the heap because the TSO's global_list field is not valid, but it still looks like a heap pointer so we thread it during compacting GC. The fix is simple: when we traverse old_threads lists to resurrect unreachable threads the threads that won't be resurrected currently stays on the old_threads lists. Those threads will never be visited again by MarkWeak so we now reset the global_list fields. This way compacting GC does not thread pointers to nowhere. Testing ------- The reproducer in #17785 is quite large and hard to build, because of the dependencies, so I'm not adding a regression test. In my testing the reproducer would take a less than 5 seconds to run, and once in every ~5 runs would fail with a segfault or an assertion error. In other cases it also fails with a test failure. Because the tests never fail with the bug fix, assuming the code is correct, this also means that this bug can sometimes lead to incorrect runtime results. After the fix I was able to run the reproducer repeatedly for about an hour, with no runtime crashes or test failures. To run the reproducer clone the git repo: $ git clone https://github.com/osa1/streamly --branch ghc-segfault Then clone primitive and atomic-primops from their git repos and point to the clones in cabal.project.local. The project should then be buildable using GHC HEAD. Run the executable `properties` with `+RTS -c -DZ`. In addition to the reproducer above I run the test suite using: $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \ -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr' This enables compacting GC always in both GHC when building the test programs and when running the test programs, and also enables sanity checking when running the test programs. These set of flags are not compatible for all tests so there are some failures, but I got the same set of failures with this patch compared to GHC HEAD. - - - - - 818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00 base: add strict IO functions: readFile', getContents', hGetContents' - - - - - 18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00 Modules: Core (#13009) Update submodule: haddock - - - - - 92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00 Update sanity checking for TSOs: - Remove an invalid assumption about GC checking what_next field. The GC doesn't care about what_next at all, if a TSO is reachable then all its pointers are followed (other than global_tso, which is only followed by compacting GC). - Remove checkSTACK in checkTSO: TSO stacks will be visited in checkHeapChain, or checkLargeObjects etc. - Add an assertion in checkTSO to check that the global_link field is sane. - Did some refactor to remove forward decls in checkGlobalTSOList and added braces around single-statement if statements. - - - - - e1aa4052 by PHO at 2020-03-17T07:36:09-04:00 Don't use non-portable operator "==" in configure.ac The test operator "==" is a Bash extension and produces a wrong result if /bin/sh is not Bash. - - - - - 89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00 Document the units of -ddump-timings Right now, in the output of -ddump-timings to a file, you can't tell what the units are: ``` CodeGen [TemplateTestImports]: alloc=22454880 time=14.597 ``` I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`: ``` when (verbosity dflags >= 2 && prtimings == PrintTimings) $ liftIO $ logInfo dflags (defaultUserStyle dflags) (text "!!!" <+> what <> colon <+> text "finished in" <+> doublePrec 2 time <+> text "milliseconds" <> comma <+> text "allocated" <+> doublePrec 3 (realToFrac alloc / 1024 / 1024) <+> text "megabytes") ``` which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB) - - - - - beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00 Implement mapTyCo like foldTyCo This patch makes mapType use the successful idiom described in TyCoRep Note [Specialising foldType] I have not yet changed any functions to use mapType, though there may be some suitable candidates. This patch should be a no-op in terms of functionality but, because it inlines the mapper itself, I'm hoping that there may be some modest perf improvements. Metric Decrease: T5631 T5642 T3064 T9020 T14683 hie002 haddock.Cabal haddock.base haddock.compiler - - - - - 5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00 Don't update ModDetails with CafInfos when opts are disabled This is consistent with the interface file behavior where we omit HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0). ModDetails and ModIface are just different representations of the same thing, so they really need to be in sync. This patch does the right thing and does not need too much explanation, but here's an example of a problem not doing this causes in !2842: -- MyInteger.hs module MyInteger ( MyInteger (MyInteger) , ToMyInteger (toMyInteger) ) where newtype MyInteger = MyInteger Integer class ToMyInteger a where toMyInteger :: a -> MyInteger instance ToMyInteger Integer where toMyInteger = MyInteger {- . succ -} -- Main.hs module Main ( main ) where import MyInteger (MyInteger (MyInteger), toMyInteger) main :: IO () main = do let (MyInteger i) = (id . toMyInteger) (41 :: Integer) print i If I build this with -O0, without this fix, we generate a ModDetails with accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the value: R3 = MyInteger.$fToMyIntegerInteger_closure + 1; R2 = GHC.Base.id_closure; R1 = GHC.Base.._closure; Sp = Sp - 16; call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24; Now we change the definition by uncommenting the `succ` part and it becomes a thunk: MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)] :: MyInteger.ToMyInteger GHC.Integer.Type.Integer [GblId[DFunId(nt)]] = {} \u [] $ctoMyInteger_rEA; and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the use site: we can no longer tag it. But becuase the interface fingerprint does not change (because ModIface does not change) we don't rebuild Main and tag the thunk. (1.2% increase in allocations when building T12545 on armv7 because we generate more code without CafInfos) Metric Increase: T12545 - - - - - 5b632dad by Paavo at 2020-03-17T07:38:48-04:00 Add example for Data.Semigroup.diff - - - - - 4d85d68b by Paavo at 2020-03-17T07:38:48-04:00 Clean up - - - - - 75168d07 by Paavo at 2020-03-17T07:38:48-04:00 Make example collapsible - - - - - 53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00 Fix #17021 by checking more return kinds All the details are in new Note [Datatype return kinds] in TcTyClsDecls. Test case: typecheck/should_fail/T17021{,b} typecheck/should_compile/T17021a Updates haddock submodule - - - - - 528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00 Modules: Core operations (#13009) - - - - - 4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00 Add release note about fix to #16502. We thought we needed to update the manual, but the fix for #16502 actually brings the implementation in line with the manual. So we just alert users of how to update their code. - - - - - 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - adde625d by Ben Gamari at 2020-10-26T10:35:20-04:00 nativeGen/dwarf: Fix procedure end addresses Previously the `.debug_aranges` and `.debug_info` (DIE) DWARF information would claim that procedures (represented with a `DW_TAG_subprogram` DIE) would only span the range covered by their entry block. This omitted all of the continuation blocks (represented by `DW_TAG_lexical_block` DIEs), confusing `perf`. Fix this by introducing a end-of-procedure label and using this as the `DW_AT_high_pc` of procedure `DW_TAG_subprogram` DIEs Fixes #17605. - - - - - 859a19ef by Ben Gamari at 2020-10-26T10:43:57-04:00 nativeGen/dwarf: Only produce DW_AT_source_note DIEs in -g3 Standard debugging tools don't know how to understand these so let's not produce them unless asked. - - - - - 86e75555 by Ben Gamari at 2020-10-26T10:43:57-04:00 nativeGen/dwarf: Use DW_AT_linkage instead of DW_AT_MIPS_linkage - - - - - dd153e57 by Ben Gamari at 2020-10-26T10:43:57-04:00 gitlab-ci: Add DWARF release jobs for Debian 10, Fedora27 - - - - - 20 changed files: - .ghcid - + .git-ignore-revs - .gitignore - .gitlab-ci.yml - + .gitlab/ci.sh - + .gitlab/common.sh - − .gitlab/darwin-init.sh - .gitlab/linters/check-cpp.py - .gitlab/merge_request_templates/merge-request.md - − .gitlab/prepare-system.sh - .gitlab/test-metrics.sh - − .gitlab/win32-init.sh - .gitmodules - CODEOWNERS - HACKING.md - Makefile - README.md - aclocal.m4 - boot - + compiler/.hlint.yaml The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62476ed4ddea34085c09c74501989066b113a24b...dd153e5796e4fbe57c2ee9a989f4541d6f63b898 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62476ed4ddea34085c09c74501989066b113a24b...dd153e5796e4fbe57c2ee9a989f4541d6f63b898 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 15:13:15 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 11:13:15 -0400 Subject: [Git][ghc/ghc][wip/local-symbols-2] 1233 commits: Update "GHC differences to the FFI Chapter" in user guide. Message-ID: <5f96e78ba8bcd_8973fa3d9d7667835311a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/local-symbols-2 at Glasgow Haskell Compiler / GHC Commits: 5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00 Update "GHC differences to the FFI Chapter" in user guide. The old entry had a heavy focus on how things had been. Which is not what I generally look for in a user guide. I also added a small section on behaviour of nested safe ffi calls. [skip-ci] - - - - - b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00 PmCheck: Use ConLikeSet to model negative info In #17911, Simon recognised many warnings stemming from over-long list unions while coverage checking Cabal's `LicenseId` module. This patch introduces a new `PmAltConSet` type which uses a `UniqDSet` instead of an association list for `ConLike`s. For `PmLit`s, it will still use an assocation list, though, because a similar map data structure would entail a lot of busy work. Fixes #17911. - - - - - 64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00 Refactoring: use Platform instead of DynFlags when possible Metric Decrease: ManyConstructors T12707 T13035 T1969 - - - - - cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00 FastString: fix eager reading of string ptr in hashStr This read causes NULL dereferencing when len is 0. Fixes #17909 In the reproducer in #17909 this bug is triggered as follows: - SimplOpt.dealWithStringLiteral is called with a single-char string ("=" in #17909) - tailFS gets called on the FastString of the single-char string. - tailFS checks the length of the string, which is 1, and calls mkFastStringByteString on the tail of the ByteString, which is an empty ByteString as the original ByteString has only one char. - ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty ByteString, which is passed to mkFastStringWith. - mkFastStringWith gets hash of the NULL pointer via hashStr, which fails on empty strings because of this bug. - - - - - 73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00 Simplify treatment of heterogeneous equality Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for a unification. But we needn't do this. Instead, we now spit out a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original Wanted. This means that we retain the connection between the spat-out constraint and the original. The problem with this new approach is that we cannot use the casted equality for substitution; it's too like wanteds-rewriting- wanteds. So, we forbid CTyEqCans that mention coercion holes. All the details are in Note [Equalities with incompatible kinds] in TcCanonical. There are a few knock-on effects, documented where they occur. While debugging an error in this patch, Simon and I ran into infelicities in how patterns and matches are printed; we made small improvements. This patch includes mitigations for #17828, which causes spurious pattern-match warnings. When #17828 is fixed, these lines should be removed. - - - - - faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00 Hadrian: ignore in-tree GMP objects with ``--lint`` - - - - - 9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00 Update core spec to reflect changes to Core. Key changes: * Adds a new rule for forall-coercions over coercion variables, which was implemented but conspicuously missing from the spec. * Adds treatment for FunCo. * Adds treatment for ForAllTy over coercion variables. * Improves commentary (including restoring a Note lost in 03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source. No changes to running code. - - - - - 7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00 Fix event message in withTiming' This typo caused generating 'end' events without the corresponding 'begin' events. - - - - - 1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00 fs.h: Add missing declarations on Windows - - - - - 3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump process submodule Avoids redundant case alternative warning. - - - - - 3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Normalize slashes in ghc-api annotations output Enable `normalise_slashes` on `annotations`, `listcomps`, and `parseTree` to fix Windows failures. - - - - - 25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - 7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00 testsuite: Fix TOP of T17786 - - - - - aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00 testsuite: Update expected output on Windows - - - - - dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00 hadrian: Fix executable extension passed to testsuite driver - - - - - 58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00 gitlab-ci: Require that Windows-hadrian job passes - - - - - 8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00 hadrian: Eliminate redundant .exe from GHC path Previously we were invoking: bash -c "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe" - - - - - 373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00 Bump hsc2hs submodule - - - - - abc02b40 by Hécate at 2020-03-22T22:38:33-04:00 Annotate the non-total function in Data.Foldable as such - - - - - 19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00 Fix ApplicativeDo regression #17835 A previous fix for #15344 made sure that monadic 'fail' is used properly when translating ApplicativeDo. However, it didn't properly account for when a 'fail' will be inserted which resulted in some programs failing with a type error. - - - - - 2643ba46 by Paavo at 2020-03-24T08:31:32-04:00 Add example and doc for Arg (Fixes #17153) - - - - - 703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00 Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453) - Provide the export list of the `Main` module as parameter to the `compiler/typecheck/TcRnDriver.hs:check_main` function. - Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`. It returns the list `mains_all` of all the main functions in scope. - Select from this list `mains_all` all `main` functions that are in the export list of the `Main` module. - If this new list contains exactly one single `main` function, then typechecking continues. - Otherwise issue an appropriate error message. - - - - - 3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00 Remove -fkill-absence and -fkill-one-shot flags They seem to be a benchmarking vestige of the Cardinality paper and probably shouldn't have been merged to HEAD in the first place. - - - - - 262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00 Do not panic on linker errors - - - - - 0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00 DynFlags refactoring III Use Platform instead of DynFlags when possible: * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al. * no more DynFlags in PreRules: added a new `RuleOpts` datatype * don't use `wORD_SIZE` in the compiler * make `wordAlignment` use `Platform` * make `dOUBLE_SIZE` a constant Metric Decrease: T13035 T1969 - - - - - 7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: fix a typo in liftA doc This change removes an extra '|' that should not be rendered in the liftA documentation. Tracking: #17929 - - - - - 1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add Control.Applicative optional example This change adds an optional example. Tracking: #17929 - - - - - 6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00 Base: add markup around Except - - - - - eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00 Remove unused `ghciTablesNextToCode` from compiler proper - - - - - f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00 Prepare to use run-time tablesNextToCode in compiler exclusively Factor out CPP as much as possible to prepare for runtime determinattion. Progress towards #15548 - - - - - 1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00 Use run-time tablesNextToCode in compiler exclusively (#15548) Summary: - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely. The field within `PlatformMisc` within `DynFlags` is used instead. - The field is still not exposed as a CLI flag. We might consider some way to ensure the right RTS / libraries are used before doing that. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082 - - - - - 1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00 Modules: Types (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - 1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00 Remove GHC.Types.Unique.Map module This module isn't used anywhere in GHC. - - - - - f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00 Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput - - - - - 54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00 Demand analysis: simplify the demand for a RHS Ticket #17932 showed that we were using a stupid demand for the RHS of a let-binding, when the result is a product. This was the result of a "fix" in 2013, which (happily) turns out to no longer be necessary. So I just deleted the code, which simplifies the demand analyser, and fixes #17932. That in turn uncovered that the anticipation of worker/wrapper in CPR analysis was inaccurate, hence the logic that decides whether to unbox an argument in WW was extracted into a function `wantToUnbox`, now consulted by CPR analysis. I tried nofib, and got 0.0% perf changes. All this came up when messing about with !2873 (ticket #17917), but is idependent of it. Unfortunately, this patch regresses #4267 and realised that it is now blocked on #16335. - - - - - 03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 on Windows Fixes line ending normalization issue. - - - - - 1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Fix T17786 Fix missing quoting and expected exit code. - - - - - ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00 Store ComponentId details As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state. - - - - - 7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00 testsuite: Remove test that dlopens a PIE object. glibc 2.30 disallowed dlopening PIE objects, so just remove the test. Fixes #17952. - - - - - 6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Correct haddocks for testBit in Data.Bits It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing. - - - - - c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00 Apply suggestion to libraries/base/Data/Bits.hs - - - - - 64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00 gitlab-ci: Add FreeBSD release job - - - - - a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00 Run checkNewDataCon before constraint-solving newtype constructors Within `checkValidDataCon`, we used to run `checkValidType` on the argument types of a newtype constructor before running `checkNewDataCon`, which ensures that the user does not attempt non-sensical things such as newtypes with multiple arguments or constraints. This works out in most situations, but this falls over on a corner case revealed in #17955: ```hs newtype T = Coercible () T => T () ``` `checkValidType`, among other things, peforms an ambiguity check on the context of a data constructor, and that it turn invokes the constraint solver. It turns out that there is a special case in the constraint solver for representational equalities (read: `Coercible` constraints) that causes newtypes to be unwrapped (see `Note [Unwrap newtypes first]` in `TcCanonical`). This special case does not know how to cope with an ill formed newtype like `T`, so it ends up panicking. The solution is surprisingly simple: just invoke `checkNewDataCon` before `checkValidType` to ensure that the illicit newtype constructor context is detected before the constraint solver can run amok with it. Fixes #17955. - - - - - 45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00 Minor cleanup - Simplify mkBuildExpr, the function newTyVars was called only on a one-element list. - TTG: use noExtCon in more places. This is more future-proof. - In zonkExpr, panic instead of printing a warning. - - - - - f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00 Expect T4267 to pass Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to fail, but it passes on CI. - - - - - 57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00 Require GHC 8.8 as the minimum compiler for bootstrapping This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former. - - - - - 33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00 Add regression test for #17963 The panic in #17963 happened to be fixed by commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a regression test to ensure that it remains fixed. Fixes #17963. - - - - - 09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00 Simplify stderrSupportsAnsiColors The combinator andM is used only once, and the code is shorter and simpler if you inline it. - - - - - 95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00 base: Ensure that encoding global variables aren't inlined As noted in #17970, these (e.g. `getFileSystemEncoding` and `setFileSystemEncoding`) previously had unfoldings, which would break their global-ness. While not strictly necessary, I also add a NOINLINE on `initLocaleEncoding` since it is used in `System.IO`, ensuring that we only system's query the locale encoding once. Fixes #17970. - - - - - 982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00 Update hadrian index revision. Required in order to build hadrian using ghc-8.10 - - - - - 4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00 integer-gmp: Bump version and add changelog entry - - - - - 9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00 Clean up "Eta reduction for data families" Notes Before, there were two distinct Notes named "Eta reduction for data families". This renames one of them to "Implementing eta reduction for data families" to disambiguate the two and fixes references in other parts of the codebase to ensure that they are pointing to the right place. Fixes #17313. [ci skip] - - - - - 7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00 Fix the changelog/@since information for hGetContents'/getContents'/readFile' Fixes #17979. [ci skip] - - - - - 0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00 Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957) Metric Decrease: T13035 T1969 - - - - - 7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00 PmCheck: Adjust recursion depth for inhabitation test In #17977, we ran into the reduction depth limit of the typechecker. That was only a symptom of a much broader issue: The recursion depth of the coverage checker for trying to instantiate strict fields in the `nonVoid` test was far too high (100, the `defaultMaxTcBound`). As a result, we were performing quite poorly on `T17977`. Short of a proper termination analysis to prove emptyness of a type, we just arbitrarily default to a much lower recursion limit of 3. Fixes #17977. - - - - - 3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00 Make hadrian pass on the no-colour setting to GHC. Fixes #17983. - - - - - b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00 Re-engineer the binder-swap transformation The binder-swap transformation is implemented by the occurrence analyser -- see Note [Binder swap] in OccurAnal. However it had a very nasty corner in it, for the case where the case scrutinee was a GlobalId. This led to trouble and hacks, and ultimately to #16296. This patch re-engineers how the occurrence analyser implements the binder-swap, by actually carrying out a substitution rather than by adding a let-binding. It's all described in Note [The binder-swap substitution]. I did a few other things along the way * Fix a bug in StgCse, which could allow a loop breaker to be CSE'd away. See Note [Care with loop breakers] in StgCse. I think it can only show up if occurrence analyser sets up bad loop breakers, but still. * Better commenting in SimplUtils.prepareAlts * A little refactoring in CoreUnfold; nothing significant e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding * Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding * Move mkRuleInfo to CoreFVs We observed respectively 4.6% and 5.9% allocation decreases for the following tests: Metric Decrease: T9961 haddock.base - - - - - 42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00 Preserve precise exceptions in strictness analysis Fix #13380 and #17676 by 1. Changing `raiseIO#` to have `topDiv` instead of `botDiv` 2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it as if it still had `botDiv`, to recover dead code elimination. This is the first commit of the plan outlined in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886. - - - - - 0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00 Fix a pointer format string in RTS - - - - - 5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00 Remove unused closure stg_IND_direct - - - - - 88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00 Session: Memoize stderrSupportsAnsiColors Not only is this a reasonable efficiency measure but it avoids making reentrant calls into ncurses, which is not thread-safe. See #17922. - - - - - 27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00 Make Hadrian build with Cabal-3.2 GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate. - - - - - 49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00 Update Stack resolver for hadrian/build-stack Broken by 57b888c0e90be7189285a6b078c30b26d0923809 - - - - - 30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00 Fix two ASSERT buglets in reifyDataCon Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but `arg_tys` is not meaningful for GADT constructors. In fact, it's worse than non-meaningful, since using `arg_tys` when reifying a GADT constructor can lead to failed `ASSERT`ions, as #17305 demonstrates. This patch applies the simplest possible fix to the immediate problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as the former makes sure to give something meaningful for GADT constructors. This makes the panic go away at the very least. There is still an underlying issue with the way the internals of `reifyDataCon` work, as described in https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we leave that as future work, since fixing the underlying issue is much trickier (see https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087). - - - - - ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00 Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie flag to dump pretty printed contents of the .hie file Metric Increase: hie002 Because of the regression on i386: compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10: Expected hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10% Lower bound hie002 (normal) compile_time/bytes allocated: 524713399 Upper bound hie002 (normal) compile_time/bytes allocated: 641316377 Actual hie002 (normal) compile_time/bytes allocated: 877986292 Deviation hie002 (normal) compile_time/bytes allocated: 50.6 % *** unexpected stat test failure for hie002(normal) - - - - - 9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00 Improve and refactor StgToCmm codegen for DataCons. We now differentiate three cases of constructor bindings: 1)Bindings which we can "replace" with a reference to an existing closure. Reference the replacement closure when accessing the binding. 2)Bindings which we can "replace" as above. But we still generate a closure which will be referenced by modules importing this binding. 3)For any other binding generate a closure. Then reference it. Before this patch 1) did only apply to local bindings and we didn't do 2) at all. - - - - - a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00 Add singleton to NonEmpty in libraries/base This adds a definition to construct a singleton non-empty list (Data.List.NonEmpty) according to issue #17851. - - - - - f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Testsuite: measure compiler stats for T16190 We were mistakenly measuring program stats - - - - - a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Move blob handling into StgToCmm Move handling of big literal strings from CmmToAsm to StgToCmm. It avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move this handling even higher in the pipeline in the future (cf #17960): this patch will make it easier. - - - - - cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00 Refactor CmmStatics In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype (before SRT generation) and `RawCmmStatics` datatype (after SRT generation). This patch removes this redundant code by using a single GADT for (Raw)CmmStatics. - - - - - 9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00 Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs - - - - - 1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00 Turn newlines into spaces for hadrian/ghci. The newlines break the command on windows. - - - - - 4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00 Major improvements to the specialiser This patch is joint work of Alexis King and Simon PJ. It does some significant refactoring of the type-class specialiser. Main highlights: * We can specialise functions with types like f :: Eq a => a -> Ord b => b => blah where the classes aren't all at the front (#16473). Here we can correctly specialise 'f' based on a call like f @Int @Bool dEqInt x dOrdBool This change really happened in an earlier patch commit 2d0cf6252957b8980d89481ecd0b79891da4b14b Author: Sandy Maguire <sandy at sandymaguire.me> Date: Thu May 16 12:12:10 2019 -0400 work that this new patch builds directly on that work, and refactors it a bit. * We can specialise functions with implicit parameters (#17930) g :: (?foo :: Bool, Show a) => a -> String Previously we could not, but now they behave just like a non-class argument as in 'f' above. * We can specialise under-saturated calls, where some (but not all of the dictionary arguments are provided (#17966). For example, we can specialise the above 'f' based on a call map (f @Int dEqInt) xs even though we don't (and can't) give Ord dictionary. This may sound exotic, but #17966 is a program from the wild, and showed significant perf loss for functions like f, if you need saturation of all dictionaries. * We fix a buglet in which a floated dictionary had a bogus demand (#17810), by using zapIdDemandInfo in the NonRec case of specBind. * A tiny side benefit: we can drop dead arguments to specialised functions; see Note [Drop dead args from specialisations] * Fixed a bug in deciding what dictionaries are "interesting"; see Note [Keep the old dictionaries interesting] This is all achieved by by building on Sandy Macguire's work in defining SpecArg, which mkCallUDs uses to describe the arguments of the call. Main changes: * Main work is in specHeader, which marched down the [InBndr] from the function definition and the [SpecArg] from the call site, together. * specCalls no longer has an arity check; the entire mechanism now handles unders-saturated calls fine. * mkCallUDs decides on an argument-by-argument basis whether to specialise a particular dictionary argument; this is new. See mk_spec_arg in mkCallUDs. It looks as if there are many more lines of code, but I think that all the extra lines are comments! - - - - - 40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00 Revert accidental change in 9462452 [ci skip] - - - - - bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00 Enable ImpredicativeTypes internally when typechecking selector bindings This is necessary for certain record selectors with higher-rank types, such as the examples in #18005. See `Note [Impredicative record selectors]` in `TcTyDecls`. Fixes #18005. - - - - - dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00 Don't override proc CafInfos in ticky builds Fixes #17947 When we have a ticky label for a proc, IdLabels for the ticky counter and proc entry share the same Name. This caused overriding proc CafInfos with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis. We now ignore the ticky labels when building SRTMaps. This makes sense because: - When building the current module they don't need to be in SRTMaps as they're initialized as non-CAFFY (see mkRednCountsLabel), so they don't take part in the dependency analysis and they're never added to SRTs. (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency, non-CAFFY uses are not considered as dependencies for the algorithm) - They don't appear in the interfaces as they're not exported, so it doesn't matter for cross-module concerns whether they're in the SRTMap or not. See also the new Note [Ticky labels in SRT analysis]. - - - - - cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Fix an tricky specialiser loop Issue #17151 was a very tricky example of a bug in which the specialiser accidentally constructs a recurive dictionary, so that everything turns into bottom. I have fixed variants of this bug at least twice before: see Note [Avoiding loops]. It was a bit of a struggle to isolate the problem, greatly aided by the work that Alexey Kuleshevich did in distilling a test case. Once I'd understood the problem, it was not difficult to fix, though it did lead me a bit of refactoring in specImports. - - - - - e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00 Refactoring only This refactors DictBinds into a data type rather than a pair. No change in behaviour, just better code - - - - - f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00 rts: ProfHeap: Fix memory leak when not compiled with profiling If we're doing heap profiling on an unprofiled executable we keep allocating new space in initEra via nextEra on each profiler run but we don't have a corresponding freeEra call. We do free the last era in endHeapProfiling but previous eras will have been overwritten by initEra and will never get free()ed. Metric Decrease: space_leak_001 - - - - - bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00 Re-export GHC.Magic.noinline from base - - - - - 3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00 simplifier: Kill off ufKeenessFactor We used to have another factor, ufKeenessFactor, which would scale the discounts before they were subtracted from the size. This was justified with the following comment: -- We multiple the raw discounts (args_discount and result_discount) -- ty opt_UnfoldingKeenessFactor because the former have to do with -- *size* whereas the discounts imply that there's some extra -- *efficiency* to be gained (e.g. beta reductions, case reductions) -- by inlining. However, this is highly suspect since it means that we subtract a *scaled* size from an absolute size, resulting in crazy (e.g. negative) scores in some cases (#15304). We consequently killed off ufKeenessFactor and bumped up the ufUseThreshold to compensate. Adjustment of unfolding use threshold ===================================== Since this removes a discount from our inlining heuristic, I revisited our default choice of -funfolding-use-threshold to minimize the change in overall inlining behavior. Specifically, I measured runtime allocations and executable size of nofib and the testsuite performance tests built using compilers (and core libraries) built with several values of -funfolding-use-threshold. This comes as a result of a quantitative comparison of testsuite performance and code size as a function of ufUseThreshold, comparing GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set consisted of nofib and the testsuite performance tests. A full summary of these measurements are found in the description of !2608 Comparing executable sizes (relative to the base commit) across all nofib tests, we see that sizes are similar to the baseline: gmean min max median thresh 50 -6.36% -7.04% -4.82% -6.46% 60 -5.04% -5.97% -3.83% -5.11% 70 -2.90% -3.84% -2.31% -2.92% 80 -0.75% -2.16% -0.42% -0.73% 90 +0.24% -0.41% +0.55% +0.26% 100 +1.36% +0.80% +1.64% +1.37% baseline +0.00% +0.00% +0.00% +0.00% Likewise, looking at runtime allocations we see that 80 gives slightly better optimisation than the baseline: gmean min max median thresh 50 +0.16% -0.16% +4.43% +0.00% 60 +0.09% -0.00% +3.10% +0.00% 70 +0.04% -0.09% +2.29% +0.00% 80 +0.02% -1.17% +2.29% +0.00% 90 -0.02% -2.59% +1.86% +0.00% 100 +0.00% -2.59% +7.51% -0.00% baseline +0.00% +0.00% +0.00% +0.00% Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is worker-wrappered as the test expects. This makes me wonder whether the inlining heuristic is now too liberal as `upd` is quite a large function. The same measure was taken in T12600. Wall clock time compiling Cabal with -O0 thresh 50 60 70 80 90 100 baseline build-Cabal 93.88 89.58 92.59 90.09 100.26 94.81 89.13 Also, this change happens to avoid the spurious test output in `plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308). Metric Decrease: hie002 T12234 T13035 T13719 T14683 T4801 T5631 T5642 T9020 T9872d T9961 Metric Increase: T12150 T12425 T13701 T14697 T15426 T1969 T3064 T5837 T6048 T9203 T9872a T9872b T9872c T9872d haddock.Cabal haddock.base haddock.compiler - - - - - 255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00 Modules: type-checker (#13009) Update Haddock submodule - - - - - 04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00 Make NoExtCon fields strict This changes every unused TTG extension constructor to be strict in its field so that the pattern-match coverage checker is smart enough any such constructors are unreachable in pattern matches. This lets us remove nearly every use of `noExtCon` in the GHC API. The only ones we cannot remove are ones underneath uses of `ghcPass`, but that is only because GHC 8.8's and 8.10's coverage checkers weren't smart enough to perform this kind of reasoning. GHC HEAD's coverage checker, on the other hand, _is_ smart enough, so we guard these uses of `noExtCon` with CPP for now. Bumps the `haddock` submodule. Fixes #17992. - - - - - 7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00 Handle promoted data constructors in typeToLHsType correctly Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have `typeToLHsType` pick between `Promoted` and `NotPromoted` by checking if a type constructor is promoted using `isPromotedDataCon`. Fixes #18020. - - - - - ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00 hadrian: Use --export-dynamic when linking iserv As noticed in #17962, the make build system currently does this (see 3ce0e0ba) but the change was never ported to Hadrian. - - - - - fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00 iserv: Don't pass --export-dynamic on FreeBSD This is definitely a hack but it's probably the best we can do for now. Hadrian does the right thing here by passing --export-dynamic only to the linker. - - - - - 39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00 Fix CNF handling in compacting GC Fixes #17937 Previously compacting GC simply ignored CNFs. This is mostly fine as most (see "What about small compacts?" below) CNF objects don't have outgoing pointers, and are "large" (allocated in large blocks) and large objects are not moved or compacted. However if we do GC *during* sharing-preserving compaction then the CNF will have a hash table mapping objects that have been moved to the CNF to their location in the CNF, to be able to preserve sharing. This case is handled in the copying collector, in `scavenge_compact`, where we evacuate hash table entries and then rehash the table. Compacting GC ignored this case. We now visit CNFs in all generations when threading pointers to the compacted heap and thread hash table keys. A visited CNF is added to the list `nfdata_chain`. After compaction is done, we re-visit the CNFs in that list and rehash the tables. The overhead is minimal: the list is static in `Compact.c`, and link field is added to `StgCompactNFData` closure. Programs that don't use CNFs should not be affected. To test this CNF tests are now also run in a new way 'compacting_gc', which just passes `-c` to the RTS, enabling compacting GC for the oldest generation. Before this patch the result would be: Unexpected failures: compact_gc.run compact_gc [bad exit code (139)] (compacting_gc) compact_huge_array.run compact_huge_array [bad exit code (1)] (compacting_gc) With this patch all tests pass. I can also pass `-c -DS` without any failures. What about small compacts? Small CNFs are still not handled by the compacting GC. However so far I'm unable to write a test that triggers a runtime panic ("update_fwd: unknown/strange object") by allocating a small CNF in a compated heap. It's possible that I'm missing something and it's not possible to have a small CNF. NoFib Results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS +0.1% 0.0% 0.0% +0.0% +0.0% CSD +0.1% 0.0% 0.0% 0.0% 0.0% FS +0.1% 0.0% 0.0% 0.0% 0.0% S +0.1% 0.0% 0.0% 0.0% 0.0% VS +0.1% 0.0% 0.0% 0.0% 0.0% VSD +0.1% 0.0% +0.0% +0.0% -0.0% VSM +0.1% 0.0% +0.0% -0.0% 0.0% anna +0.0% 0.0% -0.0% -0.0% -0.0% ansi +0.1% 0.0% +0.0% +0.0% +0.0% atom +0.1% 0.0% +0.0% +0.0% +0.0% awards +0.1% 0.0% +0.0% +0.0% +0.0% banner +0.1% 0.0% +0.0% +0.0% +0.0% bernouilli +0.1% 0.0% 0.0% -0.0% +0.0% binary-trees +0.1% 0.0% -0.0% -0.0% 0.0% boyer +0.1% 0.0% +0.0% +0.0% +0.0% boyer2 +0.1% 0.0% +0.0% +0.0% +0.0% bspt +0.1% 0.0% -0.0% -0.0% -0.0% cacheprof +0.1% 0.0% -0.0% -0.0% -0.0% calendar +0.1% 0.0% +0.0% +0.0% +0.0% cichelli +0.1% 0.0% +0.0% +0.0% +0.0% circsim +0.1% 0.0% +0.0% +0.0% +0.0% clausify +0.1% 0.0% -0.0% +0.0% +0.0% comp_lab_zift +0.1% 0.0% +0.0% +0.0% +0.0% compress +0.1% 0.0% +0.0% +0.0% 0.0% compress2 +0.1% 0.0% -0.0% 0.0% 0.0% constraints +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 +0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm2 +0.1% 0.0% +0.0% +0.0% +0.0% cse +0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e1 +0.1% 0.0% +0.0% -0.0% -0.0% digits-of-e2 +0.1% 0.0% -0.0% -0.0% -0.0% dom-lt +0.1% 0.0% +0.0% +0.0% +0.0% eliza +0.1% 0.0% +0.0% +0.0% +0.0% event +0.1% 0.0% +0.0% +0.0% +0.0% exact-reals +0.1% 0.0% +0.0% +0.0% +0.0% exp3_8 +0.1% 0.0% +0.0% -0.0% 0.0% expert +0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux +0.1% 0.0% -0.0% 0.0% 0.0% fasta +0.1% 0.0% -0.0% +0.0% +0.0% fem +0.1% 0.0% -0.0% +0.0% 0.0% fft +0.1% 0.0% -0.0% +0.0% +0.0% fft2 +0.1% 0.0% +0.0% +0.0% +0.0% fibheaps +0.1% 0.0% +0.0% +0.0% +0.0% fish +0.1% 0.0% +0.0% +0.0% +0.0% fluid +0.0% 0.0% +0.0% +0.0% +0.0% fulsom +0.1% 0.0% -0.0% +0.0% 0.0% gamteb +0.1% 0.0% +0.0% +0.0% 0.0% gcd +0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps +0.1% 0.0% -0.0% +0.0% 0.0% genfft +0.1% 0.0% +0.0% +0.0% +0.0% gg +0.1% 0.0% 0.0% +0.0% +0.0% grep +0.1% 0.0% -0.0% +0.0% +0.0% hidden +0.1% 0.0% +0.0% -0.0% 0.0% hpg +0.1% 0.0% -0.0% -0.0% -0.0% ida +0.1% 0.0% +0.0% +0.0% +0.0% infer +0.1% 0.0% +0.0% 0.0% -0.0% integer +0.1% 0.0% +0.0% +0.0% +0.0% integrate +0.1% 0.0% -0.0% -0.0% -0.0% k-nucleotide +0.1% 0.0% +0.0% +0.0% 0.0% kahan +0.1% 0.0% +0.0% +0.0% +0.0% knights +0.1% 0.0% -0.0% -0.0% -0.0% lambda +0.1% 0.0% +0.0% +0.0% -0.0% last-piece +0.1% 0.0% +0.0% 0.0% 0.0% lcss +0.1% 0.0% +0.0% +0.0% 0.0% life +0.1% 0.0% -0.0% +0.0% +0.0% lift +0.1% 0.0% +0.0% +0.0% +0.0% linear +0.1% 0.0% -0.0% +0.0% 0.0% listcompr +0.1% 0.0% +0.0% +0.0% +0.0% listcopy +0.1% 0.0% +0.0% +0.0% +0.0% maillist +0.1% 0.0% +0.0% -0.0% -0.0% mandel +0.1% 0.0% +0.0% +0.0% 0.0% mandel2 +0.1% 0.0% +0.0% +0.0% +0.0% mate +0.1% 0.0% +0.0% 0.0% +0.0% minimax +0.1% 0.0% -0.0% 0.0% -0.0% mkhprog +0.1% 0.0% +0.0% +0.0% +0.0% multiplier +0.1% 0.0% +0.0% 0.0% 0.0% n-body +0.1% 0.0% +0.0% +0.0% +0.0% nucleic2 +0.1% 0.0% +0.0% +0.0% +0.0% para +0.1% 0.0% 0.0% +0.0% +0.0% paraffins +0.1% 0.0% +0.0% -0.0% 0.0% parser +0.1% 0.0% -0.0% -0.0% -0.0% parstof +0.1% 0.0% +0.0% +0.0% +0.0% pic +0.1% 0.0% -0.0% -0.0% 0.0% pidigits +0.1% 0.0% +0.0% -0.0% -0.0% power +0.1% 0.0% +0.0% +0.0% +0.0% pretty +0.1% 0.0% -0.0% -0.0% -0.1% primes +0.1% 0.0% -0.0% -0.0% -0.0% primetest +0.1% 0.0% -0.0% -0.0% -0.0% prolog +0.1% 0.0% -0.0% -0.0% -0.0% puzzle +0.1% 0.0% -0.0% -0.0% -0.0% queens +0.1% 0.0% +0.0% +0.0% +0.0% reptile +0.1% 0.0% -0.0% -0.0% +0.0% reverse-complem +0.1% 0.0% +0.0% 0.0% -0.0% rewrite +0.1% 0.0% -0.0% -0.0% -0.0% rfib +0.1% 0.0% +0.0% +0.0% +0.0% rsa +0.1% 0.0% -0.0% +0.0% -0.0% scc +0.1% 0.0% -0.0% -0.0% -0.1% sched +0.1% 0.0% +0.0% +0.0% +0.0% scs +0.1% 0.0% +0.0% +0.0% +0.0% simple +0.1% 0.0% -0.0% -0.0% -0.0% solid +0.1% 0.0% +0.0% +0.0% +0.0% sorting +0.1% 0.0% -0.0% -0.0% -0.0% spectral-norm +0.1% 0.0% +0.0% +0.0% +0.0% sphere +0.1% 0.0% -0.0% -0.0% -0.0% symalg +0.1% 0.0% -0.0% -0.0% -0.0% tak +0.1% 0.0% +0.0% +0.0% +0.0% transform +0.1% 0.0% +0.0% +0.0% +0.0% treejoin +0.1% 0.0% +0.0% -0.0% -0.0% typecheck +0.1% 0.0% +0.0% +0.0% +0.0% veritas +0.0% 0.0% +0.0% +0.0% +0.0% wang +0.1% 0.0% 0.0% +0.0% +0.0% wave4main +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve1 +0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 +0.1% 0.0% +0.0% +0.0% +0.0% x2n1 +0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min +0.0% 0.0% -0.0% -0.0% -0.1% Max +0.1% 0.0% +0.0% +0.0% +0.0% Geometric Mean +0.1% -0.0% -0.0% -0.0% -0.0% Bumping numbers of nonsensical perf tests: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 It's simply not possible for this patch to increase allocations, and I've wasted enough time on these test in the past (see #17686). I think these tests should not be perf tests, but for now I'll bump the numbers. - - - - - dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00 Rts: show errno on failure (#18033) - - - - - 045139f4 by Hécate at 2020-04-09T23:10:44-04:00 Add an example to liftIO and explain its purpose - - - - - 101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00 Special case `isConstraintKindCon` on `AlgTyCon` Previously, the `tyConUnique` record selector would unfold into a huge case expression that would be inlined in all call sites, such as the `INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code a lot more compact, but have to move it to GHC.Core.TyCon. Metric Decrease: T12150 T12234 - - - - - f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00 DmdAnal: No need to attach a StrictSig to DataCon workers In GHC.Types.Id.Make we were giving a strictness signature to every data constructor wrapper Id that we weren't looking at in demand analysis anyway. We used to use its CPR info, but that has its own CPR signature now. `Note [Data-con worker strictness]` then felt very out of place, so I moved it to GHC.Core.DataCon. - - - - - 75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00 Hadrian: fix --summary - - - - - 723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00 testsuite: Move no_lint to the top level, tweak hie002 - We don't want to benchmark linting so disable lints in hie002 perf test - Move no_lint to the top-level to be able to use it in tests other than those in `testsuite/tests/perf/compiler`. - Filter out -dstg-lint in no_lint. - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit Metric Decrease: hie002 ManyConstructors T12150 T12234 T13035 T1969 T4801 T9233 T9961 - - - - - bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00 Testsuite: mark T11531 fragile The test depends on a link editor allowing undefined symbols in an ELF shared object. This is the standard but it seems some distributions patch their link editor. See the report by @hsyl20 in #11531. Fixes #11531 - - - - - 0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00 testsuite: Fix comment for a language extension [skip ci] - - - - - cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00 Significant refactor of Lint This refactoring of Lint was triggered by #17923, which is fixed by this patch. The main change is this. Instead of lintType :: Type -> LintM LintedKind we now have lintType :: Type -> LintM LintedType Previously, all of typeKind was effectively duplicate in lintType. Moreover, since we have an ambient substitution, we still had to apply the substition here and there, sometimes more than once. It was all very tricky, in the end, and made my head hurt. Now, lintType returns a fully linted type, with all substitutions performed on it. This is much simpler. The same thing is needed for Coercions. Instead of lintCoercion :: OutCoercion -> LintM (LintedKind, LintedKind, LintedType, LintedType, Role) we now have lintCoercion :: Coercion -> LintM LintedCoercion Much simpler! The code is shorter and less bug-prone. There are a lot of knock on effects. But life is now better. Metric Decrease: T1969 - - - - - 0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00 Implement extensible interface files - - - - - 54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00 Use conLikeUserTyVarBinders to quantify field selector types This patch: 1. Writes up a specification for how the types of top-level field selectors should be determined in a new section of the GHC User's Guide, and 2. Makes GHC actually implement that specification by using `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the order and specificity of type variables written by the user. Fixes #18023. - - - - - 35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00 hadrian: Don't --export-dynamic on Darwin When fixing #17962 I neglected to consider that --export-dynamic is only supported on ELF platforms. - - - - - e8029816 by Alexis King at 2020-04-12T11:23:27-04:00 Add an INLINE pragma to Control.Category.>>> This fixes #18013 by adding INLINE pragmas to both Control.Category.>>> and GHC.Desugar.>>>. The functional change in this patch is tiny (just two lines of pragmas!), but an accompanying Note explains in gory detail what’s going on. - - - - - 0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00 Change zipWith to zipWithEqual in a few places - - - - - 074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00 Small change to the windows ticker. We already have a function to go from time to ms so use it. Also expand on the state of timer resolution. - - - - - b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00 hadrian: get rid of unnecessary levels of nesting in source-dist - - - - - d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00 doc (Foldable): Add examples to Data.Foldable See #17929 - - - - - 5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00 StgCRun: Enable unwinding only on Linux It's broken on macOS due and SmartOS due to assembler differences (#15207) so let's be conservative in enabling it. Also, refactor things to make the intent clearer. - - - - - 27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00 rts: Don't mark evacuate_large as inline This function has two callsites and is quite large. GCC consequently decides not to inline and warns instead. Given the situation, I can't blame it. Let's just remove the inline specifier. - - - - - 9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00 base: Enable large file support for OFD locking impl. Not only is this a good idea in general but this should also avoid issue #17950 by ensuring that off_t is 64-bits. - - - - - 7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00 Hadrian: Make -i paths absolute The primary reason for this change is that ghcide does not work with relative paths. It also matches what cabal and stack do, they always pass absolute paths. - - - - - 41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00 Zero out pinned block alignment slop when profiling The heap profiler currently cannot traverse pinned blocks because of alignment slop. This used to just be a minor annoyance as the whole block is accounted into a special cost center rather than the respective object's CCS, cf. #7275. However for the new root profiler we would like to be able to visit _every_ closure on the heap. We need to do this so we can get rid of the current 'flip' bit hack in the heap traversal code. Since info pointers are always non-zero we can in principle skip all the slop in the profiler if we can rely on it being zeroed. This assumption caused problems in the past though, commit a586b33f8e ("rts: Correct handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use the same trick for BF_LARGE objects but neglected to take into account that shrink*Array# functions don't ensure that slop is zeroed when not compiling with profiling. Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix as we will only be assuming slop is zeroed when profiling is on. This commit also reduces the ammount of slop we introduce in the first place by calculating the needed alignment before doing the allocation for small objects where we know the next available address. For large objects we don't know how much alignment we'll have to do yet since those details are hidden behind the allocateMightFail function so there we continue to allocate the maximum additional words we'll need to do the alignment. So we don't have to duplicate all this logic in the cmm code we pull it into the RTS allocatePinned function instead. Metric Decrease: T7257 haddock.Cabal haddock.base - - - - - 15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Expand and add more notes regarding slop - - - - - caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: allocatePinned: Fix confusion about word/byte units - - - - - c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00 rts: Underline some Notes as is conventional - - - - - e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Fix nomenclature in OVERWRITING_CLOSURE macros The additional commentary introduced by commit 8916e64e5437 ("Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got this wrong. We set 'prim' to true in overwritingClosureOfs because we _don't_ want to call LDV_recordDead(). The reason is because of this "inherently used" distinction made in the LDV profiler so I rename the variable to be more appropriate. - - - - - 1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00 Remove call to LDV_RECORD_CREATE for array resizing - - - - - 19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00 rts: Assert LDV_recordDead is not called for inherently used closures The comments make it clear LDV_recordDead should not be called for inhererently used closures, so add an assertion to codify this fact. - - - - - 0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00 Bump template-haskell version to 2.17.0.0 This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #17645. Fixes #17696. Note that the new `text` commit includes a fair number of additions to the Haddocks in that library. As a result, Haddock has to do more work during the `haddock.Cabal` test case, increasing the number of allocations it requires. Therefore, ------------------------- Metric Increase: haddock.Cabal ------------------------- - - - - - 22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00 Fix #18052 by using pprPrefixOcc in more places This fixes several small oversights in the choice of pretty-printing function to use. Fixes #18052. - - - - - ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00 rts: ProfHeap: Fix wrong time in last heap profile sample We've had this longstanding issue in the heap profiler, where the time of the last sample in the profile is sometimes way off causing the rendered graph to be quite useless for long runs. It seems to me the problem is that we use mut_user_time() for the last sample as opposed to getRTSStats(), which we use when calling heapProfile() in GC.c. The former is equivalent to getProcessCPUTime() but the latter does some additional stuff: getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns - stats.nonmoving_gc_cpu_ns So to fix this just use getRTSStats() in both places. - - - - - 85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00 Hadrian: fix dyn_o/dyn_hi rule (#17534) - - - - - bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00 Fix #18065 by fixing an InstCo oversight in Core Lint There was a small thinko in Core Lint's treatment of `InstCo` coercions that ultimately led to #18065. The fix: add an apostrophe. That's it! Fixes #18065. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> - - - - - a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00 Change the fail operator argument of BindStmt to be a Maybe Don't use noSyntaxExpr for it. There is no good way to defensively case on that, nor is it clear one ought to do so. - - - - - 79e27144 by John Ericson at 2020-04-17T13:08:47-04:00 Use trees that grow for rebindable operators for `<-` binds Also add more documentation. - - - - - 18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00 Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker - - - - - 84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00 Add a missing zonk in tcHsPartialType I omitted a vital zonk when refactoring tcHsPartialType in commit 48fb3482f8cbc8a4b37161021e846105f980eed4 Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Wed Jun 5 08:55:17 2019 +0100 Fix typechecking of partial type signatures This patch fixes it and adds commentary to explain why. Fixes #18008 - - - - - 2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1 - - - - - 434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Enable FreeBSD job for so-labelled MRs - - - - - ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00 gitlab-ci: Use rules syntax for conditional jobs - - - - - e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00 Bump hsc2hs submodule - - - - - 15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00 Improve prepForeignCall error reporting Show parameters and description of the error code when ffi_prep_cif fails. This may be helpful for debugging #17018. - - - - - 3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00 GHC.Core.Opt renaming * GHC.Core.Op => GHC.Core.Opt * GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver * GHC.Core.Opt.Tidy => GHC.Core.Tidy * GHC.Core.Opt.WorkWrap.Lib => GHC.Core.Opt.WorkWrap.Utils As discussed in: * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650 - - - - - 15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00 Modules (#13009) * SysTools * Parser * GHC.Builtin * GHC.Iface.Recomp * Settings Update Haddock submodule Metric Decrease: Naperian parsing001 - - - - - eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00 Add missing addInScope call for letrec binders in OccurAnal This fixes #18044, where a shadowed variable was incorrectly substituted by the binder swap on the RHS of a floated-in letrec. This can only happen when the uniques line up *just* right, so writing a regression test would be very difficult, but at least the fix is small and straightforward. - - - - - 36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00 Derive Ord instance for Extension Metric Increase: T12150 T12234 - - - - - b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00 Fix a buglet in redundant-constraint warnings Ticket #18036 pointed out that we were reporting a redundant constraint when it really really wasn't. Turned out to be a buglet in the SkolemInfo for the relevant implication constraint. Easily fixed! - - - - - d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00 Mark T12010 fragile on 32-bit - - - - - bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00 docs: drop note about not supporting shared libraries on unix systems [skip ci] - - - - - 6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Use ParserFlags in GHC.Runtime.Eval (#17957) Instead of passing `DynFlags` to functions such as `isStmt` and `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much simpler structure that can be created purely with `mkParserFlags'`. - - - - - 70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00 GHC.Runtime: avoid DynFlags (#17957) * add `getPlatform :: TcM Platform` helper * remove unused `DynFlags` parameter from `emptyPLS` - - - - - 35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid DynFlags in Ppr code (#17957) * replace `DynFlags` parameters with `SDocContext` parameters for a few Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`, `printSDocLn`, `showSDocOneLine`. * remove the use of `pprCols :: DynFlags -> Int` in Outputable. We already have the information via `sdocLineLength :: SDocContext -> Int` - - - - - ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid using sdocWithDynFlags (#17957) Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'` and from `GHC.Driver.CodeOutput.profilingInitCode` - - - - - f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00 Avoid `sdocWithDynFlags` in `pprCLbl` (#17957) * add a `DynFlags` parameter to `pprCLbl` * put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid `DynFlags` parameters - - - - - 747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00 CmmToAsm DynFlags refactoring (#17957) * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used to test the global `ExternalDynamicRefs` flag. Now we test it outside of `isDynLinkName` * Add new fields into `NCGConfig`: current unit id, sse/bmi versions, externalDynamicRefs, etc. * Replace many uses of `DynFlags` by `NCGConfig` * Moved `BMI/SSE` datatypes into `GHC.Platform` - - - - - ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00 stg-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Stg/Syntax.hs <= stgSyn/StgSyn.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs This patch also updates old file path [2]: * utils/genapply/Main.hs <= utils/genapply/GenApply.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: commit 0cc4aad36f [skip ci] - - - - - e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00 Refactor the `MatchResult` type in the desugarer This way, it does a better job of proving whether or not the fail operator is used. - - - - - dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00 Remove panic in dsHandleMonadicFailure Rework dsHandleMonadicFailure to be correct by construction instead of using an unreachable panic. - - - - - cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00 Inline `adjustMatchResult` It is just `fmap` - - - - - 72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00 Generalize type of `matchCanFail` - - - - - 401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00 `MatchResult'` -> `MatchResult` Inline `MatchResult` alias accordingly. - - - - - 6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00 Mark DataCon wrappers CONLIKE Now that DataCon wrappers don’t inline until phase 0 (see commit b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that case-of-known-constructor and RULE matching be able to see saturated applications of DataCon wrappers in unfoldings. Making them conlike is a natural way to do it, since they are, in fact, precisely the sort of thing the CONLIKE pragma exists to solve. Fixes #18012. This also bumps the version of the parsec submodule to incorporate a patch that avoids a metric increase on the haddock perf tests. The increase was not really a flaw in this patch, as parsec was implicitly relying on inlining heuristics. The patch to parsec just adds some INLINABLE pragmas, and we get a nice performance bump out of it (well beyond the performance we lost from this patch). Metric Decrease: T12234 WWRec haddock.Cabal haddock.base haddock.compiler - - - - - 48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00 Fix tab-completion for :break (#17989) In tab-completion for the `:break` command, only those identifiers should be shown, that are accepted in the `:break` command. Hence these identifiers must be - defined in an interpreted module - top-level - currently in scope - listed in a `ModBreaks` value as a possible breakpoint. The identifiers my be qualified or unqualified. To get all possible top-level breakpoints for tab-completeion with the correct qualification do: 1. Build the list called `pifsBreaks` of all pairs of (Identifier, module-filename) from the `ModBreaks` values. Here all identifiers are unqualified. 2. Build the list called `pifInscope` of all pairs of (Identifiers, module-filename) with identifiers from the `GlobalRdrEnv`. Take only those identifiers that are in scope and have the correct prefix. Here the identifiers may be qualified. 3. From the `pifInscope` list seclect all pairs that can be found in the `pifsBreaks` list, by comparing only the unqualified part of the identifier. The remaining identifiers can be used for tab-completion. This ensures, that we show only identifiers, that can be used in a `:break` command. - - - - - 34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00 PPC NCG: Add DWARF constants and debug labels Fixes #11261 - - - - - ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00 Do eager instantation in terms This patch implements eager instantiation, a small but critical change to the type inference engine, #17173. The main change is this: When inferring types, always return an instantiated type (for now, deeply instantiated; in future shallowly instantiated) There is more discussion in https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html There is quite a bit of refactoring in this patch: * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk has entirely gone. So tcInferInst and tcInferNoInst have collapsed into tcInfer. * Type inference of applications, via tcInferApp and tcInferAppHead, are substantially refactored, preparing the way for Quick Look impredicativity. * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs are beatifully dual. We can see the zipper! * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return a wrapper * In HsExpr, HsTypeApp now contains the the actual type argument, and is used in desugaring, rather than putting it in a mysterious wrapper. * I struggled a bit with good error reporting in Unify.matchActualFunTysPart. It's a little bit simpler than before, but still not great. Some smaller things * Rename tcPolyExpr --> tcCheckExpr tcMonoExpr --> tcLExpr * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat Metric Decrease: T9961 Reduction of 1.6% in comiler allocation on T9961, I think. - - - - - 6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00 rts: Ensure that sigaction structs are initialized I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless. - - - - - c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00 Add "ddump-cmm-opt" as alias for "ddump-opt-cmm". - - - - - 4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00 llvmGen: Remove -fast-llvm flag Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for the LLVM code generator introduced in 22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this, the motivation for this flag was to avoid potential incompatibilities between LLVM and the assembler/linker toolchain by making LLVM responsible for machine-code generation. Unfortunately, this cannot possibly work: the LLVM backend's mangler performs a number of transforms on the assembler generated by LLVM that are necessary for correctness. These are currently: * mangling Haskell functions' symbol types to be `object` instead of `function` on ELF platforms (necessary for tables-next-to-code) * mangling AVX instructions to ensure that we don't assume alignment (which LLVM otherwise does) * mangling Darwin's subsections-via-symbols directives Given that these are all necessary I don't believe that we can support `-fast-llvm`. Let's rather remove it. - - - - - 831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00 Fix build warning; add more informative information to the linker; fix linker for empty sections - - - - - c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00 Update commentary and slightly refactor GHC.Tc.Deriv.Infer There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that has been modernized. Along the way, I removed the `bad` constraints in `simplifyDeriv`, which did not serve any useful purpose (besides being printed in debugging output). Fixes #18073. - - - - - 125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00 Remove leftover comment in tcRnModule', redundant bind The code for the comment was moved in dc8c03b2a5c but the comment was forgotten. - - - - - 8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00 RTS: workaround a Linux kernel bug in timerfd Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335. This is currently undocumented behavior and documentation "won't happen anytime soon" (https://lkml.org/lkml/2020/2/13/295). With this patch, we just ignore the result instead of crashing. It may fix #18033 but we can't be sure because we don't have enough information. See also this discussion about the kernel bug: https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9 - - - - - cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00 Create di_scoped_tvs for associated data family instances properly See `Note [Associated data family instances and di_scoped_tvs]` in `GHC.Tc.TyCl.Instance`, which explains all of the moving parts. Fixes #18055. - - - - - 339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00 hadrian/ghci: Allow arguments to be passed to GHCi Previously the arguments passed to hadrian/ghci were passed both to `hadrian` and GHCi. This is rather odd given that there are essentially not arguments in the intersection of the two. Let's just pass them to GHCi; this allows `hadrian/ghci -Werror`. - - - - - 5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00 testsuite: Don't attempt to read .std{err,out} files if they don't exist Simon reports that he was previously seeing framework failures due to an attempt to read the non-existing T13456.stderr. While I don't know exactly what this is due to, it does seem like a non-existing .std{out,err} file should be equivalent to an empty file. Teach the testsuite driver to treat it as such. - - - - - c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00 Trees That Grow refactor for `ConPat` and `CoPat` - `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule. - - - - - 72da0c29 by mniip at 2020-04-23T18:33:21-04:00 Add :doc to GHC.Prim - - - - - 2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00 Include docs for non-primop entries in primops.txt as well - - - - - 0ac29c88 by mniip at 2020-04-23T18:33:21-04:00 GHC.Prim docs: note and test - - - - - b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00 Switch order on `GhcMake.IsBoot` In !1798 we were requested to replace many `Bool`s with this data type. But those bools had `False` meaning `NotBoot`, so the `Ord` instance would be flipped if we use this data-type as-is. Since the planned formally-`Bool` occurrences vastly outnumber the current occurrences, we figured it would be better to conform the `Ord` instance to how the `Bool` is used now, fixing any issues, rather than fix them currently with the bigger refactor later in !1798. That way, !1798 can be a "pure" refactor with no behavioral changes. - - - - - af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00 Modules: Utils and Data (#13009) Update Haddock submodule Metric Increase: haddock.compiler - - - - - cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00 Fix misleading Ptr phantom type in SerializedCompact (#15653) - - - - - 22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00 Tweak includes in non-moving GC headers We don't use hash tables in non-moving GC so remove the includes. This breaks Compact.c as existing includes no longer include Hash.h, so include Hash.h explicitly in Compact.c. - - - - - 99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00 TH: fix Show/Eq/Ord instances for Bytes (#16457) We shouldn't compare pointer values but the actual bytes. - - - - - c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00 hadrian: always capture both stdout and stderr when running a builder fails The idea being that when a builder('s command) fails, we quite likely want to have all the information available to figure out why. Depending on the builder _and_ the particular problem, the useful bits of information can be printed on stdout or stderr. We accomplish this by defining a simple wrapper for Shake's `cmd` function, that just _always_ captures both streams in case the command returns a non-zero exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`. Fixes #18089. - - - - - 4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00 Define a Quote IO instance Fixes #18103. - - - - - 518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00 Make boxed 1-tuples have known keys Unlike other tuples, which use special syntax and are "known" by way of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not use special syntax. Therefore, in order to make sure that the internals of GHC are aware of the `data Unit a = Unit a` definition in `GHC.Tuple`, we give `Unit` known keys. For the full details, see `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)` in `GHC.Builtin.Types`. Fixes #18097. - - - - - 2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Document backpack fields in DynFlags - - - - - 10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo * Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule - - - - - 69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Remove unused `emptyGenericUnitInfo` - - - - - 9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactor UnitInfo load/store from databases Converting between UnitInfo stored in package databases and UnitInfo as they are used in ghc-pkg and ghc was done in a very convoluted way (via BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.). It was difficult to understand and even more to modify (I wanted to try to use a GADT for UnitId but fun deps got in the way). The new code uses much more straightforward functions to convert between the different representations. Much simpler. - - - - - ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Factorize mungePackagePaths code This patch factorizes the duplicated code used in ghc-pkg and in GHC to munge package paths/urls. It also fixes haddock-html munging in GHC (allowed to be either a file or a url) to mimic ghc-pkg behavior. - - - - - 10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00 Refactoring unit management code Over the years the unit management code has been modified a lot to keep up with changes in Cabal (e.g. support for several library components in the same package), to integrate BackPack, etc. I found it very hard to understand as the terminology wasn't consistent, was referring to past concepts, etc. The terminology is now explained as clearly as I could in the Note "About Units" and the code is refactored to reflect it. ------------------- Many names were misleading: UnitId is not an Id but could be a virtual unit (an indefinite one instantiated on the fly), IndefUnitId constructor may contain a definite instantiated unit, etc. * Rename IndefUnitId into InstantiatedUnit * Rename IndefModule into InstantiatedModule * Rename UnitId type into Unit * Rename IndefiniteUnitId constructor into VirtUnit * Rename DefiniteUnitId constructor into RealUnit * Rename packageConfigId into mkUnit * Rename getPackageDetails into unsafeGetUnitInfo * Rename InstalledUnitId into UnitId Remove references to misleading ComponentId: a ComponentId is just an indefinite unit-id to be instantiated. * Rename ComponentId into IndefUnitId * Rename ComponentDetails into UnitPprInfo * Fix display of UnitPprInfo with empty version: this is now used for units dynamically generated by BackPack Generalize several types (Module, Unit, etc.) so that they can be used with different unit identifier types: UnitKey, UnitId, Unit, etc. * GenModule: Module, InstantiatedModule and InstalledModule are now instances of this type * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit, PackageDatabase Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor. Add basic support for UnitKey. They should be used more in the future to avoid mixing them up with UnitId as we do now. Add many comments. Update Haddock submodule - - - - - 8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00 Unit: split and rename modules Introduce GHC.Unit.* hierarchy for everything concerning units, packages and modules. Update Haddock submodule - - - - - 71484b09 by Alexis King at 2020-04-30T01:57:35-04:00 Allow block arguments in arrow control operators Arrow control operators have their own entries in the grammar, so they did not cooperate with BlockArguments. This was just a minor oversight, so this patch adjusts the grammar to add the desired behavior. fixes #18050 - - - - - a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00 Allow LambdaCase to be used as a command in proc notation - - - - - f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00 Document BlockArguments/LambdaCase support in arrow notation - - - - - 5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00 Add tests for #17873 - - - - - 19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00 Mark rule args as non-tail-called This was just an omission...b I'd failed to call markAllNonTailCall on rule args. I think this bug has been here a long time, but it's quite hard to trigger. Fixes #18098 - - - - - 014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00 Hadrian: Improve tool-args command to support more components There is a new command to hadrian, tool:path/to/file.hs, which returns the options needed to compile that file in GHCi. This is now used in the ghci script with argument `ghc/Main.hs` but its main purpose is to support the new multi-component branch of ghcide. - - - - - 2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Clear bitmap after initializing block size Previously nonmovingInitSegment would clear the bitmap before initializing the segment's block size. This is broken since nonmovingClearBitmap looks at the segment's block size to determine how much bitmap to clear. - - - - - 54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Explicitly memoize block count A profile cast doubt on whether the compiler hoisted the bound out the loop as I would have expected here. It turns out it did but nevertheless it seems clearer to just do this manually. - - - - - 99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00 nonmoving: Eagerly flush all capabilities' update remembered sets (cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957) - - - - - 05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 Remove OneShotInfo field of LFReEntrant, document OneShotInfo The field is only used in withNewTickyCounterFun and it's easier to directly pass a parameter for one-shot info to withNewTickyCounterFun instead of passing it via LFReEntrant. This also makes !2842 simpler. Other changes: - New Note (by SPJ) [OneShotInfo overview] added. - Arity argument of thunkCode removed as it's always 0. - - - - - a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00 GHC.StgToCmm.Ticky: remove a few unused stuff - - - - - 780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Use platform in Iface Binary - - - - - f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00 Refactor PprDebug handling If `-dppr-debug` is set, then PprUser and PprDump styles are silently replaced with PprDebug style. This was done in `mkUserStyle` and `mkDumpStyle` smart constructors. As a consequence they needed a DynFlags parameter. Now we keep the original PprUser and PprDump styles until they are used to create an `SDocContext`. I.e. the substitution is only performed in `initSDocContext`. - - - - - b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Remove PprStyle param of logging actions Use `withPprStyle` instead to apply a specific style to a SDoc. - - - - - de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00 Fully remove PprDebug PprDebug was a pain to deal with consistently as it is implied by `-dppr-debug` but it isn't really a PprStyle. We remove it completely and query the appropriate SDoc flag instead (`sdocPprDebug`) via helpers (`getPprDebug` and its friends). - - - - - 8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Only call checkSingle if we would report warnings - - - - - fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00 PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info `HsWrapper`s introduce evidence bindings through `WpEvLam` which the pattern-match coverage checker should be made aware of. Failing to do so caused #18049, where the resulting impreciseness of imcompleteness warnings seemingly contradicted with `-Winaccessible-code`. The solution is simple: Collect all the evidence binders of an `HsWrapper` and add it to the ambient `Deltas` before desugaring the wrapped expression. But that means we pick up many more evidence bindings, even when they wrap around code without a single pattern match to check! That regressed `T3064` by over 300%, so now we are adding long-distance info lazily through judicious use of `unsafeInterleaveIO`. Fixes #18049. - - - - - 7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00 rts: Enable tracing of nonmoving heap census with -ln Previously this was not easily available to the user. Fix this. Non-moving collection lifecycle events are now reported with -lg. - - - - - c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Move eventlog documentation users guide - - - - - 02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00 users guide: Add documentation for non-moving GC events - - - - - b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00 Flatten nested casts in the simple optimizer Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112 - - - - - 8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00 Don't return a panic in tcNestedSplice In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a typechecked expression of "panic". That is usually OK, because the result is discarded. But it happens that tcApp now looks at the typechecked expression, trivially, to ask if it is tagToEnum. So being bottom is bad. Moreover a debug-trace might print it out. So better to return a civilised expression, even though it is usually discarded. - - - - - 0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00 Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130". - - - - - 30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00 Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly) - - - - - b9f7c08f by jneira at 2020-05-04T13:20:37-04:00 Remove unused hs-boot file - - - - - 1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00 Remove references to -package-key * remove references to `-package-key` which has been removed in 2016 (240ddd7c39536776e955e881d709bbb039b48513) * remove support for `-this-package-key` which has been deprecated at the same time - - - - - 7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00 Remove SpecConstrAnnotation (#13681) This has been deprecated since 2013. Use GHC.Types.SPEC instead. Make GHC.Exts "not-home" for haddock Metric Decrease: haddock.base - - - - - 3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00 Fix Haskell98 short description in documentation - - - - - 2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00 Add regression tests for #16244, #16245, #16758 Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up fixing quite a few bugs: * This commit fixes #16244 completely. A regression test has been added. * This commit fixes one program from #16245. (The program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still panics, and the program in https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still loops infinitely.) A regression test has been added for this program. * This commit fixes #16758. Accordingly, this patch removes the `expect_broken` label from the `T16758` test case, moves it from `should_compile` to `should_fail` (as it should produce an error message), and checks in the expected stderr. - - - - - 40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00 Fix colorized error messages (#18128) In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages by using "dump" style instead of "user" style. This commits fixes it. - - - - - 7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00 Refactor hole constraints. Previously, holes (both expression holes / out of scope variables and partial-type-signature wildcards) were emitted as *constraints* via the CHoleCan constructor. While this worked fine for error reporting, there was a fair amount of faff in keeping these constraints in line. In particular, and unlike other constraints, we could never change a CHoleCan to become CNonCanonical. In addition: * the "predicate" of a CHoleCan constraint was really the type of the hole, which is not a predicate at all * type-level holes (partial type signature wildcards) carried evidence, which was never used * tcNormalise (used in the pattern-match checker) had to create a hole constraint just to extract it again; it was quite messy The new approach is to record holes directly in WantedConstraints. It flows much more nicely now. Along the way, I did some cleaning up of commentary in GHC.Tc.Errors.Hole, which I had a hard time understanding. This was instigated by a future patch that will refactor the way predicates are handled. The fact that CHoleCan's "predicate" wasn't really a predicate is incompatible with that future patch. No test case, because this is meant to be purely internal. It turns out that this change improves the performance of the pattern-match checker, likely because fewer constraints are sloshing about in tcNormalise. I have not investigated deeply, but an improvement is not a surprise here: ------------------------- Metric Decrease: PmSeriesG ------------------------- - - - - - 420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00 rts: Zero block flags with -DZ Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging. - - - - - 740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix incorrect failed_to_evac value during deadlock gc Previously we would incorrectly set the failed_to_evac flag if we evacuated a value due to a deadlock GC. This would cause us to mark more things as dirty than strictly necessary. It also turned up a nasty but which I will fix next. - - - - - b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00 nonmoving: Fix handling of dirty objects Previously we (incorrectly) relied on failed_to_evac to be "precise". That is, we expected it to only be true if *all* of an object's fields lived outside of the non-moving heap. However, does not match the behavior of failed_to_evac, which is true if *any* of the object's fields weren't promoted (meaning that some others *may* live in the non-moving heap). This is problematic as we skip the non-moving write barrier for dirty objects (which we can only safely do if *all* fields point outside of the non-moving heap). Clearly this arises due to a fundamental difference in the behavior expected of failed_to_evac in the moving and non-moving collector. e.g., in the moving collector it is always safe to conservatively say failed_to_evac=true whereas in the non-moving collector the safe value is false. This issue went unnoticed as I never wrote down the dirtiness invariant enforced by the non-moving collector. We now define this invariant as An object being marked as dirty implies that all of its fields are on the mark queue (or, equivalently, update remembered set). To maintain this invariant we teach nonmovingScavengeOne to push the fields of objects which we fail to evacuate to the update remembered set. This is a simple and reasonably cheap solution and avoids the complexity and fragility that other, more strict alternative invariants would require. All of this is described in a new Note, Note [Dirty flags in the non-moving collector] in NonMoving.c. - - - - - 9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00 Allow atomic update of NameCache in readHieFile The situation arises in ghcide where multiple different threads may need to update the name cache, therefore with the older interface it could happen that you start reading a hie file with name cache A and produce name cache A + B, but another thread in the meantime updated the namecache to A + C. Therefore if you write the new namecache you will lose the A' updates from the second thread. Updates haddock submodule - - - - - edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00 Make isTauTy detect higher-rank contexts Previously, `isTauTy` would only detect higher-rank `forall`s, not higher-rank contexts, which led to some minor bugs observed in #18127. Easily fixed by adding a case for `(FunTy InvisArg _ _)`. Fixes #18127. - - - - - a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00 ELF linker: increment curSymbol after filling in fields of current entry The bug was introduced in a8b7cef4d45 which added a field to the `symbols` array elements and then updated this code incorrectly: - oc->symbols[curSymbol++] = nm; + oc->symbols[curSymbol++].name = nm; + oc->symbols[curSymbol].addr = symbol->addr; - - - - - cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00 Move LeadingUnderscore into Platform (#17957) Avoid direct use of DynFlags to know if symbols must be prefixed by an underscore. - - - - - 94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00 Don't use DynFlags in showLinkerState (#17957) - - - - - 9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00 Refactoring: Use bindSigTyVarsFV in rnMethodBinds `rnMethodBinds` was explicitly using `xoptM` to determine if `ScopedTypeVariables` is enabled before bringing type variables bound by the class/instance header into scope. However, this `xoptM` logic is already performed by the `bindSigTyVarsFV` function. This patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number of places where we need to consult if `ScopedTypeVariables` is on. This is purely refactoring, and there should be no user-visible change in behavior. - - - - - 6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00 Remove further dead code found by a simple Python script. Avoid removing some functions that are part of an API even though they're not used in-tree at the moment. - - - - - 78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00 Add doc examples for Bifoldable See #17929 - - - - - 66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00 doc (Bitraversable): Add examples to Bitraversable * Add examples to Data.Bitraversable * Fix formatting for (,) in Bitraversable and Bifoldable * Fix mistake on bimapAccumR documentation See #17929 - - - - - 9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00 Specify kind variables for inferred kinds in base. - - - - - 4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00 HsSigWcTypeScoping: Pull in documentation from stray location - - - - - f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00 Rename local `real_fvs` to `implicit_vs` It doesn't make sense to call the "free" variables we are about to implicitly bind the real ones. - - - - - 20570b4b by John Ericson at 2020-05-08T15:29:36-04:00 A few tiny style nits with renaming - Use case rather than guards that repeatedly scrutenize same thing. - No need for view pattern when `L` is fine. - Use type synnonym to convey the intent like elsewhere. - - - - - 09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00 Add `forAllOrNothing` function with note - - - - - bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Document lawlessness of Ap's Num instance - - - - - cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply suggestion to libraries/base/Data/Monoid.hs - - - - - 926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00 Apply more suggestions from Simon Jakobi - - - - - 7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00 Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965) This fixes a bug that resulted in some programs being accepted that used the same identifier as a field label and another declaration, depending on the order they appeared in the source code. - - - - - 88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00 Fix specialisation for DFuns When specialising a DFun we must take care to saturate the unfolding. See Note [Specialising DFuns] in Specialise. Fixes #18120 - - - - - 86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00 Remove unused SEGMENT_PROT_RWX It's been unused for a year and is problematic on any OS which requires W^X for security. - - - - - 9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00 Add test for #16167 - - - - - aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00 Bump exceptions submodule so that dist-boot is .gitignore'd `exceptions` is a stage-0 boot library as of commit 30272412fa437ab8e7a8035db94a278e10513413, which means that building `exceptions` in a GHC tree will generate a `dist-boot` directory. However, this directory was not specified in `exceptions`' `.gitignore` file, which causes it to dirty up the current `git` working directory. Accordingly, this bumps the `exceptions` submodule to commit ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f, which adds `dist-boot` to the `.gitignore` file. - - - - - ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00 Linker.c: initialize n_symbols of ObjectCode with other fields - - - - - 951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00 Fix unboxed-sums GC ptr-slot rubbish value (#17791) This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make - - - - - b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00 rts: Make non-existent linker search path merely a warning As noted in #18105, previously this resulted in a rather intrusive error message. This is in contrast to the general expectation that search paths are merely places to look, not places that must exist. Fixes #18105. - - - - - cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00 rts/CNF: Fix fixup comparison function Previously we would implicitly convert the difference between two words to an int, resulting in an integer overflow on 64-bit machines. Fixes #16992 - - - - - a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00 Pack some of IdInfo fields into a bit field This reduces residency of compiler quite a bit on some programs. Example stats when building T10370: Before: 2,871,242,832 bytes allocated in the heap 4,693,328,008 bytes copied during GC 33,941,448 bytes maximum residency (276 sample(s)) 375,976 bytes maximum slop 83 MiB total memory in use (0 MB lost due to fragmentation) After: 2,858,897,344 bytes allocated in the heap 4,629,255,440 bytes copied during GC 32,616,624 bytes maximum residency (278 sample(s)) 314,400 bytes maximum slop 80 MiB total memory in use (0 MB lost due to fragmentation) So -3.9% residency, -1.3% bytes copied and -0.4% allocations. Fixes #17497 Metric Decrease: T9233 T9675 - - - - - 670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Fix base URL Revert a change previously made for testing purposes. - - - - - 8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00 get-win32-tarballs: Improve diagnostics output - - - - - 8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00 docs: Add examples for Data.Semigroup.Arg{Min,Max} Context: #17153 - - - - - cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00 Add few cleanups of the CAF logic Give the NameSet of non-CAFfy names a proper newtype to distinguish it from all of the other NameSets floating about. - - - - - 90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00 fix printf warning when using with ghc with clang on mingw - - - - - 86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00 CprAnal: Don't attach CPR sigs to expandable bindings (#18154) Instead, look through expandable unfoldings in `cprTransform`. See the new Note [CPR for expandable unfoldings]: ``` Long static data structures (whether top-level or not) like xs = x1 : xs1 xs1 = x2 : xs2 xs2 = x3 : xs3 should not get CPR signatures, because they * Never get WW'd, so their CPR signature should be irrelevant after analysis (in fact the signature might even be harmful for that reason) * Would need to be inlined/expanded to see their constructed product * Recording CPR on them blows up interface file sizes and is redundant with their unfolding. In case of Nested CPR, this blow-up can be quadratic! But we can't just stop giving DataCon application bindings the CPR property, for example fac 0 = 1 fac n = n * fac (n-1) fac certainly has the CPR property and should be WW'd! But FloatOut will transform the first clause to lvl = 1 fac 0 = lvl If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a CPR signature to extrapolate into a CPR transformer ('cprTransform'). So instead we keep on cprAnal'ing through *expandable* unfoldings for these arity 0 bindings via 'cprExpandUnfolding_maybe'. In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one for each data declaration. It's wasteful to attach CPR signatures to each of them (and intractable in case of Nested CPR). ``` Fixes #18154. - - - - - e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00 users-guide: Add discussion of shared object naming Fixes #18074. - - - - - 5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00 testsuite: Print sign of performance changes Executes the minor formatting change in the tabulated performance changes suggested in #18135. - - - - - 9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00 testsuite: Add testcase for #18129 - - - - - 266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00 doc: Reformulate the opening paragraph of Ch. 4 in User's guide Removes mentioning of Hugs (it is not helpful for new users anymore). Changes the wording for the rest of the paragraph. Fixes #18132. - - - - - 55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00 Predicate, Equivalence derive via `.. -> a -> All' - - - - - d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00 hadrian: add a --freeze2 option to freeze stage 1 and 2 - - - - - d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00 Don't reload environment files on every setSessionDynFlags Makes `interpretPackageEnv` (which loads envirinment files) a part of `parseDynamicFlags` (parsing command-line arguments, which is typically done once) instead of `setSessionDynFlags` (which is typically called several times). Making several (transitive) calls to `interpretPackageEnv`, as before, caused #18125 #16318, which should be fixed now. - - - - - 102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00 Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) This implements chunks (2) and (3) of https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely, it introduces a dedicated `HsPatSigType` AST type, which represents the types that can appear in pattern signatures and term-level `RULE` binders. Previously, these were represented with `LHsSigWcType`. Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended semantics of the two types are slightly different, as evidenced by the fact that they have different code paths in the renamer and typechecker. See also the new `Note [Pattern signature binders and scoping]` in `GHC.Hs.Types`. - - - - - b17574f7 by Hécate at 2020-05-13T20:05:28-04:00 fix(documentation): Fix the RST links to GHC.Prim - - - - - df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00 Document (->) using inferred quantification for its runtime representations. Fixes #18142. - - - - - 1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00 Tweak man page for ghc command This commit updates the ghc command's man page as followings: * Enable `man_show_urls` to show URL addresses in the `DESCRIPTION` section of ghc.rst, because sphinx currently removes hyperlinks for man pages. * Add a `SEE ALSO` section to point to the GHC homepage - - - - - a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00 GHCi: Add link to the user's guide in help message This commit adds a link to the user's guide in ghci's `:help` message. Newcomers could easily reach to details of ghci. - - - - - 404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00 Handle single unused import - - - - - 1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00 Ensure that printMinimalImports closes handle Fixes #18166. - - - - - c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00 hadrian: Tell testsuite driver about LLVM availability This reflects the logic present in the Make build system into Hadrian. Fixes #18167. - - - - - c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00 Improve some folds over Uniq[D]FM * Replace some non-deterministic lazy folds with strict folds. * Replace some O(n log n) folds in deterministic order with O(n) non-deterministic folds. * Replace some folds with set-operations on the underlying IntMaps. This reduces max residency when compiling `nofib/spectral/simple/Main.hs` with -O0 by about 1%. Maximum residency when compiling Cabal also seems reduced on the order of 3-9%. - - - - - 477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00 Use Data.IntMap.disjoint Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1. This patch applies this function where appropriate in hopes of modest compiler performance improvements. Closes #16806. - - - - - e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00 IdInfo: Add reference to bitfield-packing ticket - - - - - 9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00 DmdAnal: Improve handling of precise exceptions This patch does two things: Fix possible unsoundness in what was called the "IO hack" and implement part 2.1 of the "fixing precise exceptions" plan in https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions, which, in combination with !2956, supersedes !3014 and !2525. **IO hack** The "IO hack" (which is a fallback to preserve precise exceptions semantics and thus soundness, rather than some smart thing that increases precision) is called `exprMayThrowPreciseException` now. I came up with two testcases exemplifying possible unsoundness (if twisted enough) in the old approach: - `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting to manual state token threading and direct use of primops. More details below. - `T13380e`: Demonstrating unsoundness of the "IO hack" when we have Nested CPR. Not currently relevant, as we don't have Nested CPR yet. - `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI calls. Basically, the IO hack assumed that precise exceptions can only be thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I couldn't come up with a program using the `IO` abstraction that violates this assumption. But it's easy to do so via manual state token threading and direct use of primops, see `T13380d`. Also similar code might be generated by Nested CPR in the (hopefully not too) distant future, see `T13380e`. Hence, we now have a more careful test in `forcesRealWorld` that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR). **Precise exceptions** In #13380 and #17676 we saw that we didn't preserve precise exception semantics in demand analysis. We fixed that with minimal changes in !2956, but that was terribly unprincipled. That unprincipledness resulted in a loss of precision, which is tracked by these new test cases: - `T13380b`: Regression in dead code elimination, because !2956 was too syntactic about `raiseIO#` - `T13380c`: No need to apply the "IO hack" when the IO action may not throw a precise exception (and the existing IO hack doesn't detect that) Fixing both issues in !3014 turned out to be too complicated and had the potential to regress in the future. Hence we decided to only fix `T13380b` and augment the `Divergence` lattice with a new middle-layer element, `ExnOrDiv`, which means either `Diverges` (, throws an imprecise exception) or throws a *precise* exception. See the wiki page on Step 2.1 for more implementational details: https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21 - - - - - 568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00 GHC.Cmm.Opt: Handle MO_XX_Conv This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3 but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't handled. Ideally we would eliminate the match but this appears to be a larger task. Fixes #18141. - - - - - 5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00 Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr There are two different Notes named `[When to print foralls]`. The most up-to-date one is in `GHC.Iface.Type`, but there is a second one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was written before GHC switched over to using ifaces to pretty-print types. I decided to just remove the latter and replace it with a reference to the former. [ci skip] - - - - - 55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00 base: Add Generic instances to various datatypes under GHC.* * GHC.Fingerprint.Types: Fingerprint * GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags * GHC.Stats: RTSStats and GCStats * GHC.ByteOrder: ByteOrder * GHC.Unicode: GeneralCategory * GHC.Stack.Types: SrcLoc Metric Increase: haddock.base - - - - - a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00 Explicit Specificity Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8 - - - - - 24e61aad by Ben Price at 2020-05-21T12:12:17-04:00 Lint should say when it is checking a rule It is rather confusing that when lint finds an error in a rule attached to a binder, it reports the error as in the RHS, not the rule: ... In the RHS of foo We add a clarifying line: ... In the RHS of foo In a rule attached to foo The implication that the rule lives inside the RHS is a bit odd, but this niggle is already present for unfoldings, whose pattern we are following. - - - - - 78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00 nonmoving: Optimise the write barrier - - - - - 13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00 Refactor linear reg alloc to remember past assignments. When assigning registers we now first try registers we assigned to in the past, instead of picking the "first" one. This is in extremely helpful when dealing with loops for which variables are dead for part of the loop. This is important for patterns like this: foo = arg1 loop: use(foo) ... foo = getVal() goto loop; There we: * assign foo to the register of arg1. * use foo, it's dead after this use as it's overwritten after. * do other things. * look for a register to put foo in. If we pick an arbitrary one it might differ from the register the start of the loop expect's foo to be in. To fix this we simply look for past register assignments for the given variable. If we find one and the register is free we use that register. This reduces the need for fixup blocks which match the register assignment between blocks. In the example above between the end and the head of the loop. This patch also moves branch weight estimation ahead of register allocation and adds a flag to control it (cmm-static-pred). * It means the linear allocator is more likely to assign the hotter code paths first. * If it assign these first we are: + Less likely to spill on the hot path. + Less likely to introduce fixup blocks on the hot path. These two measure combined are surprisingly effective. Based on nofib we get in the mean: * -0.9% instructions executed * -0.1% reads/writes * -0.2% code size. * -0.1% compiler allocations. * -0.9% compile time. * -0.8% runtime. Most of the benefits are simply a result of removing redundant moves and spills. Reduced compiler allocations likely are the result of less code being generated. (The added lookup is mostly non-allocating). - - - - - edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00 NCG: Codelayout: Distinguish conditional and other branches. In #18053 we ended up with a suboptimal code layout because the code layout algorithm didn't distinguish between conditional and unconditional control flow. We can completely eliminate unconditional control flow instructions by placing blocks next to each other, not so much for conditionals. In terms of implementation we simply give conditional branches less weight before computing the layout. Fixes #18053 - - - - - b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00 gitlab-ci: Set locale to C.UTF-8. - - - - - a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow spaces in GHCi :script file names This patch updates the user interface of GHCi so that file names passed to the ':script' command may contain spaces escaped with a backslash. For example: :script foo\ bar.script The implementation uses a modified version of 'words' that does not break on escaped spaces. Fixes #18027. - - - - - 82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Add extra tests for GHCi :script syntax checks The syntax for GHCi's ":script" command allows for only a single file name to be passed as an argument. This patch adds a test for the cases in which a file name is missing or multiple file names are passed. Related to #T18027. - - - - - a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Allow GHCi :script file names in double quotes This patch updates the user interface of GHCi so that file names passed to the ':script' command can be wrapped in double quotes. For example: :script "foo bar.script" The implementation uses a modified version of 'words' that treats character sequences enclosed in double quotes as single words. Fixes #18027. - - - - - cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00 Update documentation for GHCi :script This patch adds the fixes that allow for file names containing spaces to be passed to GHCi's ':script' command to the release notes for 8.12 and expands the user-guide documentation for ':script' by mentioning how such file names can be passed. Related to #18027. - - - - - 0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00 llvmGen: Consider Relocatable read-only data as not constantReferences: #18137 - - - - - 964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_pat` - - - - - b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00 Use `Checker` for `tc_lpat` and `tc_lpats` - - - - - 5108e84a by John Ericson at 2020-05-21T12:17:30-04:00 More judiciously panic in `ts_pat` - - - - - 510e0451 by John Ericson at 2020-05-21T12:17:30-04:00 Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker` - - - - - cb4231db by John Ericson at 2020-05-21T12:17:30-04:00 Tiny cleaup eta-reduce away a function argument In GHC, not in the code being compiled! - - - - - 6890c38d by John Ericson at 2020-05-21T12:17:30-04:00 Use braces with do in `SplicePat` case for consistency - - - - - 3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00 Fix spelling mistakes and typos - - - - - b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Add INLINABLE pragmas to Enum list producers The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in the interface file so we can do list fusion at usage sites. Related tickets: #15185, #8763, #18178. - - - - - e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Piggyback on Enum Word methods for Word64 If we are on a 64 bit platform, we can use the efficient Enum Word methods for the Enum Word64 instance. - - - - - 892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00 Document INLINE(ABLE) pragmas that enable fusion - - - - - 2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00 MR template should ask for key part - - - - - a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00 Make `Int`'s `mod` and `rem` strict in their first arguments They used to be strict until 4d2ac2d (9 years ago). It's obviously better to be strict for performance reasons. It also blocks #18067. NoFib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- integer -1.1% +0.4% wheel-sieve2 +21.2% +20.7% -------------------------------------------------------------------------------- Min -1.1% -0.0% Max +21.2% +20.7% Geometric Mean +0.2% +0.2% ``` The regression in `wheel-sieve2` is due to reboxing that likely will go away with the resolution of #18067. See !3282 for details. Fixes #18187. - - - - - d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00 Clarify pitfalls of NegativeLiterals; see #18022. - - - - - 1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00 Fix wording in primops documentation to reflect the correct reasoning: * Besides resizing functions, shrinking ones also mutate the size of a mutable array and because of those two `sizeofMutabeByteArray` and `sizeofSmallMutableArray` are now deprecated * Change reference in documentation to the newer functions `getSizeof*` instead of `sizeof*` for shrinking functions * Fix incorrect mention of "byte" instead of "small" - - - - - 4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00 Don't variable-length encode magic iface constant. We changed to use variable length encodings for many types by default, including Word32. This makes sense for numbers but not when Word32 is meant to represent four bytes. I added a FixedLengthEncoding newtype to Binary who's instances interpret their argument as a collection of bytes instead of a number. We then use this when writing/reading magic numbers to the iface file. I also took the libery to remove the dummy iface field. This fixes #18180. - - - - - a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00 Add a regression test for #11506 The testcase works now. See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202 - - - - - 8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00 Sort deterministically metric output Previously, we sorted according to the test name and way, but the metrics (max_bytes_used/peak_megabytes_allocated etc.) were appearing in nondeterministic order. - - - - - 566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00 Move isDynLinkName into GHC.Types.Name It doesn't belong into GHC.Unit.State - - - - - d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00 docs: fix formatting and add some links [skip ci] - - - - - 49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00 Implement cstringLength# and FinalPtr This function and its accompanying rule resolve issue #5218. A future PR to the bytestring library will make the internal Data.ByteString.Internal.unsafePackAddress compute string length with cstringLength#. This will improve the status quo because it is eligible for constant folding. Additionally, introduce a new data constructor to ForeignPtrContents named FinalPtr. This additional data constructor, when used in the IsString instance for ByteString, leads to more Core-to-Core optimization opportunities, fewer runtime allocations, and smaller binaries. Also, this commit re-exports all the functions from GHC.CString (including cstringLength#) in GHC.Exts. It also adds a new test driver. This test driver is used to perform substring matches on Core that is dumped after all the simplifier passes. In this commit, it is used to check that constant folding of cstringLength# works. - - - - - dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00 simplCore: Ignore ticks in rule templates This fixes #17619, where a tick snuck in to the template of a rule, resulting in a panic during rule matching. The tick in question was introduced via post-inlining, as discussed in `Note [Simplifying rules]`. The solution we decided upon was to simply ignore ticks in the rule template, as discussed in `Note [Tick annotations in RULE matching]`. Fixes #18162. Fixes #17619. - - - - - 82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00 Fix #18145 and also avoid needless work with implicit vars - `forAllOrNothing` now is monadic, so we can trace whether we bind an explicit `forall` or not. - #18145 arose because the free vars calculation was needlessly complex. It is now greatly simplified. - Replaced some other implicit var code with `filterFreeVarsToBind`. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00 Bump process submodule Fixes #17926. - - - - - 856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00 users-guide: Clarify meaning of -haddock flag Fixes #18206. - - - - - 7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00 git: Add ignored commits file This can be used to tell git to ignore bulk renaming commits like the recently-finished module hierarchy refactoring. Configured with, git config blame.ignoreRevsFile .git-ignore-revs - - - - - 63d30e60 by jneira at 2020-05-24T01:54:42-04:00 Add hie-bios script for windows systems It is a direct translation of the sh script - - - - - 59182b88 by jneira at 2020-05-24T01:54:42-04:00 Honour previous values for CABAL and CABFLAGS The immediate goal is let the hie-bios.bat script set CABFLAGS with `-v0` and remove all cabal output except the compiler arguments - - - - - 932dc54e by jneira at 2020-05-24T01:54:42-04:00 Add specific configuration for windows in hie.yaml - - - - - e0eda070 by jneira at 2020-05-24T01:54:42-04:00 Remove not needed hie-bios output - - - - - a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Move Config module into GHC.Settings - - - - - 37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Core.Arity into GHC.Core.Opt.Arity - - - - - a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Rename GHC.Hs.Types into GHC.Hs.Type See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610 - - - - - 1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00 Bump haddock submodule - - - - - 66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00 Add orderingTyCon to wiredInTyCons (#18185) `Ordering` needs to be wired in for use in the built-in `CmpNat` and `CmpSymbol` type families, but somehow it was never added to the list of `wiredInTyCons`, leading to the various oddities observed in #18185. Easily fixed by moving `orderingTyCon` from `basicKnownKeyNames` to `wiredInTyCons`. Fixes #18185. - - - - - 01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00 Remove unused hs-boot file - - - - - 7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix cross-compiler build (#16051) - - - - - 15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix distDir per stage - - - - - b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00 Hadrian: fix hp2ps error during cross-compilation Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265) - - - - - cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00 Make Unicode brackets opening/closing tokens (#18225) The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as described in GHC Proposal #229. This commit makes the unicode variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII counterparts. - - - - - 013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00 Revert "Specify kind variables for inferred kinds in base." As noted in !3132, this has rather severe knock-on consequences in user-code. We'll need to revisit this before merging something along these lines. This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396. - - - - - 4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Drop redundant ad-hoc boot module check To determine whether the module is a boot module Coverage.addTicksToBinds was checking for a `boot` suffix in the module source filename. This is quite ad-hoc and shouldn't be necessary; the callsite in `deSugar` already checks that the module isn't a boot module. - - - - - 1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make tickBoxCount strict This could otherwise easily cause a leak of (+) thunks. - - - - - b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Make ccIndices strict This just seems like a good idea. - - - - - 02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. - - - - - b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00 Coverage: Factor out addMixEntry - - - - - 53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00 Add info about typeclass evidence to .hie files See `testsuite/tests/hiefile/should_run/HieQueries.hs` and `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the `ContextInfo` associated with an Identifier. These are associated with the appropriate identifiers for the evidence variables collected when we come across `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST. Instance dictionary and superclass selector dictionaries from `tcg_insts` and classes defined in `tcg_tcs` are also recorded in the AST as originating from their definition span This allows us to save a complete picture of the evidence constructed by the constraint solver, and will let us report this to the user, enabling features like going to the instance definition from the invocation of a class method(or any other method taking a constraint) and finding all usages of a particular instance. Additionally, - Mark NodeInfo with an origin so we can differentiate between bindings origininating in the source vs those in ghc - Along with typeclass evidence info, also include information on Implicit Parameters - Add a few utility functions to HieUtils in order to query the new info Updates haddock submodule - - - - - 6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00 Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity We should allow a wrapper with up to 82 parameters when the original function had 82 parameters to begin with. I verified that this made no difference on NoFib, but then again it doesn't use huge records... Fixes #18122. - - - - - cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00 Enhance Note [About units] for Backpack - - - - - ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00 core-spec: Modify file paths according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * GHC/Core.hs <= coreSyn/CoreSyn.hs * GHC/Core/Coercion.hs <= types/Coercion.hs * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs * GHC/Core/Coercion/Opt.hs <= types/OptCoercion.hs * GHC/Core/DataCon.hs <= basicTypes/DataCon.hs * GHC/Core/FamInstEnv.hs <= types/FamInstEnv.hs * GHC/Core/Lint.hs <= coreSyn/CoreLint.hs * GHC/Core/Subst.hs <= coreSyn/CoreSubst.hs * GHC/Core/TyCo/Rep.hs <= types/TyCoRep.hs * GHC/Core/TyCon.hs <= types/TyCon.hs * GHC/Core/Type.hs <= types/Type.hs * GHC/Core/Unify.hs <= types/Unify.hs * GHC/Types/Literal.hs <= basicTypes/Literal.hs * GHC/Types/Var.hs <= basicTypes/Var.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [skip ci] - - - - - 04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00 eventlog: Fix racy flushing Previously no attempt was made to avoid multiple threads writing their capability-local eventlog buffers to the eventlog writer simultaneously. This could result in multiple eventlog streams being interleaved. Fix this by documenting that the EventLogWriter's write() and flush() functions may be called reentrantly and fix the default writer to protect its FILE* by a mutex. Fixes #18210. - - - - - d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00 Make `identifier` parse unparenthesized `->` (#18060) - - - - - 28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00 GHC.Core.Unfold: Refactor traceInline This reduces duplication as well as fixes a bug wherein -dinlining-check would override -ddump-inlinings. Moreover, the new variant - - - - - 1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00 Avoid unnecessary allocations due to tracing utilities While ticky-profiling the typechecker I noticed that hundreds of millions of SDocs are being allocated just in case -ddump-*-trace is enabled. This is awful. We avoid this by ensuring that the dump flag check is inlined into the call site, ensuring that the tracing document needn't be allocated unless it's actually needed. See Note [INLINE conditional tracing utilities] for details. Fixes #18168. Metric Decrease: T9961 haddock.Cabal haddock.base haddock.compiler - - - - - 5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00 Add Semigroup/Monoid for Q (#18123) - - - - - dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00 Fix #18071 Run the core linter on candidate instances to ensure they are well-kinded. Better handle quantified constraints by using a CtWanted to avoid having unsolved constraints thrown away at the end by the solver. - - - - - 10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00 FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231) Otherwise we risk turning trivial RHS into non-trivial RHS, introducing unnecessary bindings in the next Simplifier run, resulting in more churn. Fixes #18231. - - - - - 08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00 DmdAnal: Recognise precise exceptions from case alternatives (#18086) Consider ```hs m :: IO () m = do putStrLn "foo" error "bar" ``` `m` (from #18086) always throws a (precise or imprecise) exception or diverges. Yet demand analysis infers `<L,A>` as demand signature instead of `<L,A>x` for it. That's because the demand analyser sees `putStrLn` occuring in a case scrutinee and decides that it has to `deferAfterPreciseException`, because `putStrLn` throws a precise exception on some control flow paths. This will mask the `botDiv` `Divergence`of the single case alt containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself, the final `Divergence` is `topDiv`. This is easily fixed: `deferAfterPreciseException` works by `lub`ing with the demand type of a virtual case branch denoting the precise exceptional control flow. We used `nopDmdType` before, but we can be more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`. Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv` instead of `topDiv`, which combines with the result from the scrutinee to `exnDiv`, and all is well. Fixes #18086. - - - - - aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00 Ticky-ticky: Record DataCon name in ticker name This makes it significantly easier to spot the nature of allocations regressions and comes at a reasonably low cost. - - - - - 8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00 hadrian: Don't track GHC's verbosity argument Teach hadrian to ignore GHC's -v argument in its recompilation check, thus fixing #18131. - - - - - 13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00 Rip out CmmStackInfo(updfr_space) As noted in #18232, this field is currently completely unused and moreover doesn't have a clear meaning. - - - - - f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00 Fix "build/elem" RULE. An redundant constraint prevented the rule from matching. Fixing this allows a call to elem on a known list to be translated into a series of equality checks, and eventually a simple case expression. Surprisingly this seems to regress elem for strings. To avoid this we now also allow foldrCString to inline and add an UTF8 variant. This results in elem being compiled to a tight non-allocating loop over the primitive string literal which performs a linear search. In the process this commit adds UTF8 variants for some of the functions in GHC.CString. This is required to make this work for both ASCII and UTF8 strings. There are also small tweaks to the CString related rules. We now allow ourselfes the luxury to compare the folding function via eqExpr, which helps to ensure the rule fires before we inline foldrCString*. Together with a few changes to allow matching on both the UTF8 and ASCII variants of the CString functions. - - - - - bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00 CoreToStg: Add Outputable ArgInfo instance - - - - - 0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Make Lint check return type of a join point Consider join x = rhs in body It's important that the type of 'rhs' is the same as the type of 'body', but Lint wasn't checking that invariant. Now it does! This was exposed by investigation into !3113. - - - - - c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00 Do not float join points in exprIsConApp_maybe We hvae been making exprIsConApp_maybe cleverer in recent times: commit b78cc64e923716ac0512c299f42d4d0012306c05 Date: Thu Nov 15 17:14:31 2018 +0100 Make constructor wrappers inline only during the final phase commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6 Date: Thu Jan 24 17:58:50 2019 +0100 Look through newtype wrappers (Trac #16254) commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1 Date: Thu Feb 21 12:03:22 2019 +0000 Fix exprIsConApp_maybe But alas there was still a bug, now immortalised in Note [Don't float join points] in SimpleOpt. It's quite hard to trigger because it requires a dead join point, but it came up when compiling Cabal Cabal.Distribution.Fields.Lexer.hs, when working on !3113. Happily, the fix is extremly easy. Finding the bug was not so easy. - - - - - 46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00 Allow simplification through runRW# Because runRW# inlines so late, we were previously able to do very little simplification across it. For instance, given even a simple program like case runRW# (\s -> let n = I# 42# in n) of I# n# -> f n# we previously had no way to avoid the allocation of the I#. This patch allows the simplifier to push strict contexts into the continuation of a runRW# application, as explained in in Note [Simplification of runRW#] in GHC.CoreToStg.Prep. Fixes #15127. Metric Increase: T9961 Metric Decrease: ManyConstructors Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com> - - - - - 277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00 Eta expand un-saturated primops Now since we no longer try to predict CAFfyness we have no need for the solution to #16846. Eta expanding unsaturated primop applications is conceptually simpler, especially in the presence of levity polymorphism. This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb, as suggested in #18079. Closes #18079. - - - - - f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00 base: Scrap deprecation plan for Data.Monoid.{First,Last} See the discussion on the libraries mailing list for context: https://mail.haskell.org/pipermail/libraries/2020-April/030357.html - - - - - 8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00 Fix typo in documentation - - - - - 998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00 Always define USE_PTHREAD_FOR_ITIMER for FreeBSD. - - - - - f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00 hadrian: introduce 'install' target Its logic is very simple. It `need`s the `binary-dist-dir` target and runs suitable `configure` and `make install` commands for the user. A new `--prefix` command line argument is introduced to specify where GHC should be installed. - - - - - 67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00 Build a threaded stage 1 if the bootstrapping GHC supports it. - - - - - aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00 PPC NCG: No per-symbol .section ".toc" directives All position independent symbols are collected during code generation and emitted in one go. Prepending each symbol with a .section ".toc" directive is redundant. This patch drops the per-symbol directives leading to smaller assembler files. Fixes #18250 - - - - - 4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Teach getNumProcessors to return available processors Previously we would report the number of physical processors, which can be quite wrong in a containerized setting. Now we rather return how many processors are in our affinity mask when possible. I also refactored the code to prefer platform-specific since this will report logical CPUs instead of physical (using `machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD). Fixes #14781. - - - - - 1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00 users-guide: Note change in getNumProcessors in users guide - - - - - 3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00 rts: Drop compatibility shims for Windows Vista We can now assume that the thread and processor group interfaces are available. - - - - - 7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00 PPC NCG: Fix .size directive on powerpc64 ELF v1 Thanks to Sergei Trofimovich for pointing out the issue. Fixes #18237 - - - - - 7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00 Optimize GHC.Utils.Monad. Many functions in this module are recursive and as such are marked loop breakers. Which means they are unlikely to get an unfolding. This is *bad*. We always want to specialize them to specific Monads. Which requires a visible unfolding at the use site. I rewrote the recursive ones from: foo f x = ... foo x' ... to foo f x = go x where go x = ... As well as giving some pragmas to make all of them available for specialization. The end result is a reduction of allocations of about -1.4% for nofib/spectral/simple/Main.hs when compiled with `-O`. ------------------------- Metric Decrease: T12425 T14683 T5631 T9233 T9675 T9961 WWRec ------------------------- - - - - - 8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00 Windows: Bump Windows toolchain to 0.2 - - - - - 6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00 Simplify contexts in GHC.Iface.Ext.Ast - - - - - 2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00 Cleanup OVERWRITING_CLOSURE logic The code is just more confusing than it needs to be. We don't need to mix the threaded check with the ldv profiling check since ldv's init already checks for this. Hence they can be two separate checks. Taking the sanity checking into account is also cleaner via DebugFlags.sanity. No need for checking the DEBUG define. The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the old code had also make things a lot more opaque IMO so I removed those. - - - - - 6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00 Fix OVERWRITING_CLOSURE assuming closures are not inherently used The new ASSERT in LDV_recordDead() was being tripped up by MVars when removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via OVERWRITE_INFO(). - - - - - 38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00 Always zero shrunk mutable array slop when profiling When shrinking arrays in the profiling way we currently don't always zero the leftover slop. This means we can't traverse such closures in the heap profiler. The old Note [zeroing slop] and #8402 have some rationale for why this is so but I belive the reasoning doesn't apply to mutable closures. There users already have to ensure multiple threads don't step on each other's toes so zeroing should be safe. - - - - - b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for #18151 - - - - - 9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00 testsuite: Add test for desugaring of PostfixOperators - - - - - 2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00 HsToCore: Eta expand left sections Strangely, the comment next to this code already alluded to the fact that even simply eta-expanding will sacrifice laziness. It's quite unclear how we regressed so far. See #18151. - - - - - d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00 Winferred-safe-imports: Do not exit with error Currently, when -Winferred-safe-imports is enabled, even when it is not turned into an error, the compiler will still exit with exit code 1 if this warning was emitted. Make sure it is really treated as a warning. - - - - - f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00 nonmoving: Optimise log2_ceil - - - - - aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00 Clarify description of fromListN - - - - - 7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00 Apply suggestion to libraries/base/GHC/Exts.hs - - - - - f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00 Add `isInScope` check to `lintCoercion` Mirrors the behaviour of `lintType`. - - - - - 5ac4d946 by fendor at 2020-06-01T06:36:18-04:00 Lint rhs of IfaceRule - - - - - 1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00 Fix wording in documentation The duplicate "orphan instance" phrase here doesn't make sense, and was probably an accident. - - - - - 5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00 configure: Modify aclocal.m4 according to new module hierarchy This patch updates file paths according to new module hierarchy [1]: * Rename: * compiler/GHC/Parser.hs <= compiler/parser/Parser.hs * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs * Add: * compiler/GHC/Cmm/Lexer.hs [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular - - - - - 15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Don't fail if we can't unlink __symlink_test Afterall, it's possible we were unable to create it due to lack of symlink permission. - - - - - 4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Refactor ghostscript detection Tamar reported that he saw crashes due to unhandled exceptions. - - - - - 2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/perf_notes: Fix ill-typed assignments - - - - - e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite/testutil: Fix bytes/str mismatch - - - - - 7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00 testsuite: Work around spurious mypy failure - - - - - 11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00 Clean up file paths for new module hierarchy This updates comments only. This patch replaces file references according to new module hierarchy. See also: * https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular * https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00 Modify file paths to module paths for new module hierarchy This updates comments only. This patch replaces module references according to new module hierarchy [1][2]. For files under the `compiler/` directory, I replace them as module paths instead of file paths. For instance, `GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3]. For current and future haddock's markup, this patch encloses the module name with "" [4]. [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 [3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613 [4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules - - - - - 68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00 Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo - - - - - 95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00 Hadrian: fix binary-dist target for cross-compilation - - - - - 730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for the @-operator Since GHC diverges from the Haskell Report by allowing the user to define (@) as an infix operator, we better give a good error message when the user does so unintentionally. In general, this is rather hard to do, as some failures will be discovered only in the renamer or the type checker: x :: (Integer, Integer) x @ (a, b) = (1, 2) This patch does *not* address this general case. However, it gives much better error messages when the binding is not syntactically valid: pairs xs @ (_:xs') = zip xs xs' Before this patch, the error message was rather puzzling: <interactive>:1:1: error: Parse error in pattern: pairs After this patch, the error message includes a hint: <interactive>:1:1: error: Parse error in pattern: pairs In a function binding for the ‘@’ operator. Perhaps you meant an as-pattern, which must not be surrounded by whitespace - - - - - 0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TypeApplications With this patch, we always parse f @t as a type application, thereby producing better error messages. This steals two syntactic forms: * Prefix form of the @-operator in expressions. Since the @-operator is a divergence from the Haskell Report anyway, this is not a major loss. * Prefix form of @-patterns. Since we are stealing loose infix form anyway, might as well sacrifice the prefix form for the sake of much better error messages. - - - - - c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00 Improve parser error messages for TemplateHaskellQuotes While [e| |], [t| |], [d| |], and so on, steal syntax from list comprehensions, [| |] and [|| ||] do not steal any syntax. Thus we can improve error messages by always accepting them in the lexer. Turns out the renamer already performs necessary validation. - - - - - 120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00 gitlab-ci: Disable use of ld.lld on ARMv7 It turns out that lld non-deterministically fails on ARMv7. I suspect this may be due to the a kernel regression as this only started happening when we upgraded to 5.4. Nevertheless, easily avoided by simply sticking with gold. Works around #18280. - - - - - d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00 gitlab-ci: Ensure that workaround for #18280 applies to bindisttest We need to ensure that the `configure` flags working around #18280 are propagated to the bindisttest `configure` as well. - - - - - cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00 gitlab-ci: Allow ARMv7 job to fail Due to #18298. - - - - - 32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00 Clean up boot vs non-boot disambiguating types We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule. - - - - - c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00 docs: Add more details on InterruptibleFFI. Details from https://gitlab.haskell.org/ghc/ghc/issues/8684 and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430 - - - - - 1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00 Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr. MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd. This regression did not make it into a release of GHC. Here, the original behavior is restored, and FinalPtr is given the same treatment as PlainPtr. - - - - - 2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00 Fix documentation on type families not being extracted It looks like the location of the Names used for CoAxioms on type families are now located at their type constructors. Previously, Docs.hs thought the Names were located in the RHS, so the RealSrcSpan in the instanceMap and getInstLoc didn't match up. Fixes #18241 - - - - - 6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00 GHC.Hs.Instances: Compile with -O0 This module contains exclusively Data instances, which are going to be slow no matter what we do. Furthermore, they are incredibly slow to compile with optimisation (see #9557). Consequently we compile this with -O0. See #18254. - - - - - c330331a by nineonine at 2020-06-04T04:37:59-04:00 Add test for #17669 - - - - - cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00 rts: Add Windows-specific implementation of rtsSleep Previously we would use the POSIX path, which uses `nanosleep`. However, it turns out that `nanosleep` is provided by `libpthread` on Windows. In general we don't want to incur such a dependency. Avoid this by simply using `Sleep` on Windows. Fixes #18272. - - - - - ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00 compiler: Disable use of process jobs with process < 1.6.9 Due to #17926. - - - - - 6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00 [linker] Adds void printLoadedObjects(void); This allows us to dump in-memory object code locations for debugging. Fixup printLoadedObjects prototype - - - - - af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00 base: fix sign confusion in log1mexp implementation (fix #17125) author: claude (https://gitlab.haskell.org/trac-claude) The correct threshold for log1mexp is -(log 2) with the current specification of log1mexp. This change improves accuracy for large negative inputs. To avoid code duplication, a small helper function is added; it isn't the default implementation in Floating because it needs Ord. This patch does nothing to address that the Haskell specification is different from that in common use in other languages. - - - - - 2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00 Simple subsumption This patch simplifies GHC to use simple subsumption. Ticket #17775 Implements GHC proposal #287 https://github.com/ghc-proposals/ghc-proposals/blob/master/ proposals/0287-simplify-subsumption.rst All the motivation is described there; I will not repeat it here. The implementation payload: * tcSubType and friends become noticably simpler, because it no longer uses eta-expansion when checking subsumption. * No deeplyInstantiate or deeplySkolemise That in turn means that some tests fail, by design; they can all be fixed by eta expansion. There is a list of such changes below. Implementing the patch led me into a variety of sticky corners, so the patch includes several othe changes, some quite significant: * I made String wired-in, so that "foo" :: String rather than "foo" :: [Char] This improves error messages, and fixes #15679 * The pattern match checker relies on knowing about in-scope equality constraints, andd adds them to the desugarer's environment using addTyCsDs. But the co_fn in a FunBind was missed, and for some reason simple-subsumption ends up with dictionaries there. So I added a call to addTyCsDs. This is really part of #18049. * I moved the ic_telescope field out of Implication and into ForAllSkol instead. This is a nice win; just expresses the code much better. * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader. We called checkDataKindSig inside tc_kind_sig, /before/ solveEqualities and zonking. Obviously wrong, easily fixed. * solveLocalEqualitiesX: there was a whole mess in here, around failing fast enough. I discovered a bad latent bug where we could successfully kind-check a type signature, and use it, but have unsolved constraints that could fill in coercion holes in that signature -- aargh. It's all explained in Note [Failure in local type signatures] in GHC.Tc.Solver. Much better now. * I fixed a serious bug in anonymous type holes. IN f :: Int -> (forall a. a -> _) -> Int that "_" should be a unification variable at the /outer/ level; it cannot be instantiated to 'a'. This was plain wrong. New fields mode_lvl and mode_holes in TcTyMode, and auxiliary data type GHC.Tc.Gen.HsType.HoleMode. This fixes #16292, but makes no progress towards the more ambitious #16082 * I got sucked into an enormous refactoring of the reporting of equality errors in GHC.Tc.Errors, especially in mkEqErr1 mkTyVarEqErr misMatchMsg misMatchMsgOrCND In particular, the very tricky mkExpectedActualMsg function is gone. It took me a full day. But the result is far easier to understand. (Still not easy!) This led to various minor improvements in error output, and an enormous number of test-case error wibbles. One particular point: for occurs-check errors I now just say Can't match 'a' against '[a]' rather than using the intimidating language of "occurs check". * Pretty-printing AbsBinds Tests review * Eta expansions T11305: one eta expansion T12082: one eta expansion (undefined) T13585a: one eta expansion T3102: one eta expansion T3692: two eta expansions (tricky) T2239: two eta expansions T16473: one eta determ004: two eta expansions (undefined) annfail06: two eta (undefined) T17923: four eta expansions (a strange program indeed!) tcrun035: one eta expansion * Ambiguity check at higher rank. Now that we have simple subsumption, a type like f :: (forall a. Eq a => Int) -> Int is no longer ambiguous, because we could write g :: (forall a. Eq a => Int) -> Int g = f and it'd typecheck just fine. But f's type is a bit suspicious, and we might want to consider making the ambiguity check do a check on each sub-term. Meanwhile, these tests are accepted, whereas they were previously rejected as ambiguous: T7220a T15438 T10503 T9222 * Some more interesting error message wibbles T13381: Fine: one error (Int ~ Exp Int) rather than two (Int ~ Exp Int, Exp Int ~ Int) T9834: Small change in error (improvement) T10619: Improved T2414: Small change, due to order of unification, fine T2534: A very simple case in which a change of unification order means we get tow unsolved constraints instead of one tc211: bizarre impredicative tests; just accept this for now Updates Cabal and haddock submodules. Metric Increase: T12150 T12234 T5837 haddock.base Metric Decrease: haddock.compiler haddock.Cabal haddock.base Merge note: This appears to break the `UnliftedNewtypesDifficultUnification` test. It has been marked as broken in the interest of merging. (cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5) - - - - - 2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00 Simplify bindLHsTyVarBndrs and bindHsQTyVars Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate `Maybe` arguments, which I find terribly confusing. Thankfully, it's possible to remove one `Maybe` argument from each of these functions, which this patch accomplishes: * `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if GHC should warn about any of the quantified type variables going unused. However, every call site uses `Nothing` in practice. This makes sense, since it doesn't really make sense to warn about unused type variables bound by an `LHsQTyVars`. For instance, you wouldn't warn about the `a` in `data Proxy a = Proxy` going unused. As a result, I simply remove this `Maybe SDoc` argument altogether. * `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same reasons that `bindHsQTyVars` took one. To make things more confusing, however, `bindLHsTyVarBndrs` also takes a separate `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in warnings and error messages. In practice, the `Maybe SDoc` and the `HsDocContext` often contain the same text. See the call sites for `bindLHsTyVarBndrs` in `rnFamInstEqn` and `rnConDecl`, for instance. There are only a handful of call sites where the text differs between the `Maybe SDoc` and `HsDocContext` arguments: * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`" and the `HsDocContext` says "`In the transformation rule`". * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says "`In the type`" but the `HsDocContext` is inhereted from the surrounding context (e.g., if `rnHsTyKi` were called on a top-level type signature, the `HsDocContext` would be "`In the type signature`" instead) In both cases, warnings/error messages arguably _improve_ by unifying making the `Maybe SDoc`'s text match that of the `HsDocContext`. As a result, I decided to remove the `Maybe SDoc` argument to `bindLHsTyVarBndrs` entirely and simply reuse the text from the `HsDocContext`. (I decided to change the phrase "transformation rule" to "rewrite rule" while I was in the area.) The `Maybe SDoc` argument has one other purpose: signaling when to emit "`Unused quantified type variable`" warnings. To recover this functionality, I replaced the `Maybe SDoc` argument with a boolean-like `WarnUnusedForalls` argument. The only `bindLHsTyVarBndrs` call site that chooses _not_ to emit these warnings in `bindHsQTyVars`. - - - - - e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00 hadrian: Add missing deriveConstants dependency on ghcplatform.h deriveConstants wants to compile C sources which #include PosixSource.h, which itself #includes ghcplatform.h. Make sure that Hadrian knows about this dependency. Fixes #18290. - - - - - b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00 ghc-prim needs to depend on libc and libm libm is just an empty shell on musl, and all the math functions are contained in libc. - - - - - 6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00 Disable DLL loading if without system linker Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though. - - - - - 4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00 Range is actually +/-2^32, not +/-2^31 See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf - - - - - f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00 OccurAnal: Avoid exponential behavior due to where clauses Previously the `Var` case of `occAnalApp` could in some cases (namely in the case of `runRW#` applications) call `occAnalRhs` two. In the case of nested `runRW#`s this results in exponential complexity. In some cases the compilation time that resulted would be very long indeed (see #18296). Fixes #18296. Metric Decrease: T9961 T12150 T12234 - - - - - 9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00 Add link to GHC's wiki in the GHC API header This adds a URL to point to GHC's wiki in the GHC API header. Newcomers could easily find more information from the GHC API's web like [1]. [1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html [skip ci] - - - - - 72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00 Make GADT constructors adhere to the forall-or-nothing rule properly Issue #18191 revealed that the types of GADT constructors don't quite adhere to the `forall`-or-nothing rule. This patch serves to clean up this sad state of affairs somewhat. The main change is not in the code itself, but in the documentation, as this patch introduces two sections to the GHC User's Guide: * A "Formal syntax for GADTs" section that presents a BNF-style grammar for what is and isn't allowed in GADT constructor types. This mostly exists to codify GHC's existing behavior, but it also imposes a new restriction that addresses #18191: the outermost `forall` and/or context in a GADT constructor is not allowed to be surrounded by parentheses. Doing so would make these `forall`s/contexts nested, and GADTs do not support nested `forall`s/contexts at present. * A "`forall`-or-nothing rule" section that describes exactly what the `forall`-or-nothing rule is all about. Surprisingly, there was no mention of this anywhere in the User's Guide up until now! To adhere the new specification in the "Formal syntax for GADTs" section of the User's Guide, the following code changes were made: * A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced. This is very much like `splitLHsSigmaTy`, except that it avoids splitting apart any parentheses, which can be syntactically significant for GADT types. See `Note [No nested foralls or contexts in GADT constructors]` in `GHC.Hs.Type`. * `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return it when given a prefix GADT constructor. Unlike `ConDeclGADT`, `ConDeclGADTPrefixPs` does not split the GADT type into its argument and result types, as this cannot be done until after the type is renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why this is the case). * `GHC.Renamer.Module.rnConDecl` now has an additional case for `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into its `forall`s, context, argument types, and result type, and (2) checks for nested `forall`s/contexts. Step (2) used to be performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather than the renamer, but now the relevant code from the typechecker can simply be deleted. One nice side effect of this change is that we are able to give a more accurate error message for GADT constructors that use visible dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`), which improves the stderr in the `T16326_Fail6` test case. Fixes #18191. Bumps the Haddock submodule. - - - - - a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00 Always use rnImplicitBndrs to bring implicit tyvars into scope This implements a first step towards #16762 by changing the renamer to always use `rnImplicitBndrs` to bring implicitly bound type variables into scope. The main change is in `rnFamInstEqn` and `bindHsQTyVars`, which previously used _ad hoc_ methods of binding their implicit tyvars. There are a number of knock-on consequences: * One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding mechanism was to give more precise source locations in `-Wunused-type-patterns` warnings. (See https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an example of this.) However, these warnings are actually a little _too_ precise, since implicitly bound type variables don't have exact binding sites like explicitly bound type variables do. A similar problem existed for "`Different names for the same type variable`" errors involving implicit tyvars bound by `bindHsQTyVars`. Therefore, we simply accept the less precise (but more accurate) source locations from `rnImplicitBndrs` in `rnFamInstEqn` and `bindHsQTyVars`. See `Note [Source locations for implicitly bound type variables]` in `GHC.Rename.HsType` for the full story. * In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs to be able to look up names from the parent class (in the event that we are renaming an associated type family instance). As a result, `rnImplicitBndrs` now takes an argument of type `Maybe assoc`, which is `Just` in the event that a type family instance is associated with a class. * Previously, GHC kept track of three type synonyms for free type variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups` (which are allowed to contain duplicates), and `FreeKiTyVarsNoDups` (which contain no duplicates). However, making is a distinction between `-Dups` and `-NoDups` is now pointless, as all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually end up being passed to `rnImplicitBndrs`, which removes duplicates. As a result, I decided to just get rid of `FreeKiTyVarsDups` and `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`. * The `bindLRdrNames` and `deleteBys` functions are now dead code, so I took the liberty of removing them. - - - - - 24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00 Clarify leaf module names for new module hierarchy This updates comments only. This patch replaces leaf module names according to new module hierarchy [1][2] as followings: * Expand leaf names to easily find the module path: for instance, `Id.hs` to `GHC.Types.Id`. * Modify leaf names according to new module hierarchy: for instance, `Convert.hs` to `GHC.ThToHs`. * Fix typo: for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep` See also !3375 [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular [2]: https://gitlab.haskell.org/ghc/ghc/issues/13009 - - - - - 92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00 rts: Remove unused GET_ENTRY closure macro This macro is not used and got broken in the meantime, as ENTRY_CODE was deleted. - - - - - 87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00 Fix -fkeep-cafs flag name in users guide - - - - - ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00 Expose impliedGFlags, impledOffGFlags, impliedXFlags - - - - - 7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00 Cross-module LambdaFormInfo passing - Store LambdaFormInfos of exported Ids in interface files - Use them in importing modules This is for optimization purposes: if we know LambdaFormInfo of imported Ids we can generate more efficient calling code, see `getCallMethod`. Exporting (putting them in interface files or in ModDetails) and importing (reading them from interface files) are both optional. We don't assume known LambdaFormInfos anywhere and do not change how we call Ids with unknown LambdaFormInfos. Runtime, allocation, and residency numbers when building Cabal-the-library (commit 0d4ee7ba3): (Log and .hp files are in the MR: !2842) | | GHC HEAD | This patch | Diff | |-----|----------|------------|----------------| | -O0 | 0:35.89 | 0:34.10 | -1.78s, -4.98% | | -O1 | 2:24.01 | 2:23.62 | -0.39s, -0.27% | | -O2 | 2:52.23 | 2:51.35 | -0.88s, -0.51% | | | GHC HEAD | This patch | Diff | |-----|-----------------|-----------------|----------------------------| | -O0 | 54,843,608,416 | 54,878,769,544 | +35,161,128 bytes, +0.06% | | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% | | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% | NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively turn all GCs into major GCs, and do GC more often. | | GHC HEAD | This patch | Diff | |-----|----------------------------|------------------------------|----------------------------| | -O0 | 410,284,000 (910 samples) | 411,745,008 (906 samples) | +1,461,008 bytes, +0.35% | | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples) | +14,925,696 bytes, +1.60% | | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% | NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS 0.0% 0.0% +0.0% +0.0% +0.0% CSD 0.0% 0.0% 0.0% +0.0% +0.0% FS 0.0% 0.0% +0.0% +0.0% +0.0% S 0.0% 0.0% +0.0% +0.0% +0.0% VS 0.0% 0.0% +0.0% +0.0% +0.0% VSD 0.0% 0.0% +0.0% +0.0% +0.1% VSM 0.0% 0.0% +0.0% +0.0% +0.0% anna 0.0% 0.0% -0.3% -0.8% -0.0% ansi 0.0% 0.0% -0.0% -0.0% 0.0% atom 0.0% 0.0% -0.0% -0.0% 0.0% awards 0.0% 0.0% -0.1% -0.3% 0.0% banner 0.0% 0.0% -0.0% -0.0% -0.0% bernouilli 0.0% 0.0% -0.0% -0.0% -0.0% binary-trees 0.0% 0.0% -0.0% -0.0% +0.0% boyer 0.0% 0.0% -0.0% -0.0% 0.0% boyer2 0.0% 0.0% -0.0% -0.0% 0.0% bspt 0.0% 0.0% -0.0% -0.2% 0.0% cacheprof 0.0% 0.0% -0.1% -0.4% +0.0% calendar 0.0% 0.0% -0.0% -0.0% 0.0% cichelli 0.0% 0.0% -0.9% -2.4% 0.0% circsim 0.0% 0.0% -0.0% -0.0% 0.0% clausify 0.0% 0.0% -0.1% -0.3% 0.0% comp_lab_zift 0.0% 0.0% -0.0% -0.0% +0.0% compress 0.0% 0.0% -0.0% -0.0% -0.0% compress2 0.0% 0.0% -0.0% -0.0% 0.0% constraints 0.0% 0.0% -0.1% -0.2% -0.0% cryptarithm1 0.0% 0.0% -0.0% -0.0% 0.0% cryptarithm2 0.0% 0.0% -1.4% -4.1% -0.0% cse 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e1 0.0% 0.0% -0.0% -0.0% -0.0% digits-of-e2 0.0% 0.0% -0.0% -0.0% -0.0% dom-lt 0.0% 0.0% -0.1% -0.2% 0.0% eliza 0.0% 0.0% -0.5% -1.5% 0.0% event 0.0% 0.0% -0.0% -0.0% -0.0% exact-reals 0.0% 0.0% -0.1% -0.3% +0.0% exp3_8 0.0% 0.0% -0.0% -0.0% -0.0% expert 0.0% 0.0% -0.3% -1.0% -0.0% fannkuch-redux 0.0% 0.0% +0.0% +0.0% +0.0% fasta 0.0% 0.0% -0.0% -0.0% +0.0% fem 0.0% 0.0% -0.0% -0.0% 0.0% fft 0.0% 0.0% -0.0% -0.0% 0.0% fft2 0.0% 0.0% -0.0% -0.0% 0.0% fibheaps 0.0% 0.0% -0.0% -0.0% +0.0% fish 0.0% 0.0% 0.0% -0.0% +0.0% fluid 0.0% 0.0% -0.4% -1.2% +0.0% fulsom 0.0% 0.0% -0.0% -0.0% 0.0% gamteb 0.0% 0.0% -0.1% -0.3% 0.0% gcd 0.0% 0.0% -0.0% -0.0% 0.0% gen_regexps 0.0% 0.0% -0.0% -0.0% -0.0% genfft 0.0% 0.0% -0.0% -0.0% 0.0% gg 0.0% 0.0% -0.0% -0.0% +0.0% grep 0.0% 0.0% -0.0% -0.0% -0.0% hidden 0.0% 0.0% -0.1% -0.4% -0.0% hpg 0.0% 0.0% -0.2% -0.5% +0.0% ida 0.0% 0.0% -0.0% -0.0% +0.0% infer 0.0% 0.0% -0.3% -0.8% -0.0% integer 0.0% 0.0% -0.0% -0.0% +0.0% integrate 0.0% 0.0% -0.0% -0.0% 0.0% k-nucleotide 0.0% 0.0% -0.0% -0.0% +0.0% kahan 0.0% 0.0% -0.0% -0.0% +0.0% knights 0.0% 0.0% -2.2% -5.4% 0.0% lambda 0.0% 0.0% -0.6% -1.8% 0.0% last-piece 0.0% 0.0% -0.0% -0.0% 0.0% lcss 0.0% 0.0% -0.0% -0.1% 0.0% life 0.0% 0.0% -0.0% -0.1% 0.0% lift 0.0% 0.0% -0.2% -0.6% +0.0% linear 0.0% 0.0% -0.0% -0.0% -0.0% listcompr 0.0% 0.0% -0.0% -0.0% 0.0% listcopy 0.0% 0.0% -0.0% -0.0% 0.0% maillist 0.0% 0.0% -0.1% -0.3% +0.0% mandel 0.0% 0.0% -0.0% -0.0% 0.0% mandel2 0.0% 0.0% -0.0% -0.0% -0.0% mate +0.0% 0.0% -0.0% -0.0% -0.0% minimax 0.0% 0.0% -0.2% -1.0% 0.0% mkhprog 0.0% 0.0% -0.1% -0.2% -0.0% multiplier 0.0% 0.0% -0.0% -0.0% -0.0% n-body 0.0% 0.0% -0.0% -0.0% +0.0% nucleic2 0.0% 0.0% -0.1% -0.2% 0.0% para 0.0% 0.0% -0.0% -0.0% -0.0% paraffins 0.0% 0.0% -0.0% -0.0% 0.0% parser 0.0% 0.0% -0.2% -0.7% 0.0% parstof 0.0% 0.0% -0.0% -0.0% +0.0% pic 0.0% 0.0% -0.0% -0.0% 0.0% pidigits 0.0% 0.0% +0.0% +0.0% +0.0% power 0.0% 0.0% -0.2% -0.6% +0.0% pretty 0.0% 0.0% -0.0% -0.0% -0.0% primes 0.0% 0.0% -0.0% -0.0% 0.0% primetest 0.0% 0.0% -0.0% -0.0% -0.0% prolog 0.0% 0.0% -0.3% -1.1% 0.0% puzzle 0.0% 0.0% -0.0% -0.0% 0.0% queens 0.0% 0.0% -0.0% -0.0% +0.0% reptile 0.0% 0.0% -0.0% -0.0% 0.0% reverse-complem 0.0% 0.0% -0.0% -0.0% +0.0% rewrite 0.0% 0.0% -0.7% -2.5% -0.0% rfib 0.0% 0.0% -0.0% -0.0% 0.0% rsa 0.0% 0.0% -0.0% -0.0% 0.0% scc 0.0% 0.0% -0.1% -0.2% -0.0% sched 0.0% 0.0% -0.0% -0.0% -0.0% scs 0.0% 0.0% -1.0% -2.6% +0.0% simple 0.0% 0.0% +0.0% -0.0% +0.0% solid 0.0% 0.0% -0.0% -0.0% 0.0% sorting 0.0% 0.0% -0.6% -1.6% 0.0% spectral-norm 0.0% 0.0% +0.0% 0.0% +0.0% sphere 0.0% 0.0% -0.0% -0.0% -0.0% symalg 0.0% 0.0% -0.0% -0.0% +0.0% tak 0.0% 0.0% -0.0% -0.0% 0.0% transform 0.0% 0.0% -0.0% -0.0% 0.0% treejoin 0.0% 0.0% -0.0% -0.0% 0.0% typecheck 0.0% 0.0% -0.0% -0.0% +0.0% veritas +0.0% 0.0% -0.2% -0.4% +0.0% wang 0.0% 0.0% -0.0% -0.0% 0.0% wave4main 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve1 0.0% 0.0% -0.0% -0.0% -0.0% wheel-sieve2 0.0% 0.0% -0.0% -0.0% +0.0% x2n1 0.0% 0.0% -0.0% -0.0% -0.0% -------------------------------------------------------------------------------- Min 0.0% 0.0% -2.2% -5.4% -0.0% Max +0.0% 0.0% +0.0% +0.0% +0.1% Geometric Mean -0.0% -0.0% -0.1% -0.3% +0.0% Metric increases micro benchmarks tracked in #17686: Metric Increase: T12150 T12234 T12425 T13035 T5837 T6048 T9233 Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00 Give Language a Bounded instance - - - - - 9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Optimisation in Unique.Supply This patch switches on -fno-state-hack in GHC.Types.Unique.Supply. It turned out that my fixes for #18078 (coercion floating) changed the optimisation pathway for mkSplitUniqSupply in such a way that we had an extra allocation inside the inner loop. Adding -fno-state-hack fixed that -- and indeed the loop in mkSplitUniqSupply is a classic example of the way in which -fno-state-hack can be bad; see #18238. Moreover, the new code is better than the old. They allocate the same, but the old code ends up with a partial application. The net effect is that the test perf/should_run/UniqLoop runs 20% faster! From 2.5s down to 2.0s. The allocation numbers are the same -- but elapsed time falls. Good! The bad thing about this is that it's terribly delicate. But at least it's a good example of such delicacy in action. There is a long Note [Optimising the unique supply] which now explains all this. - - - - - 6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00 Implement cast worker/wrapper properly The cast worker/wrapper transformation transforms x = e |> co into y = e x = y |> co This is done by the simplifier, but we were being careless about transferring IdInfo from x to y, and about what to do if x is a NOINLNE function. This resulted in a series of bugs: #17673, #18093, #18078. This patch fixes all that: * Main change is in GHC.Core.Opt.Simplify, and the new prepareBinding function, which does this cast worker/wrapper transform. See Note [Cast worker/wrappers]. * There is quite a bit of refactoring around prepareRhs, makeTrivial etc. It's nicer now. * Some wrappers from strictness and cast w/w, notably those for a function with a NOINLINE, should inline very late. There wasn't really a mechanism for that, which was an existing bug really; so I invented a new finalPhase = Phase (-1). It's used for all simplifier runs after the user-visible phase 2,1,0 have run. (No new runs of the simplifier are introduced thereby.) See new Note [Compiler phases] in GHC.Types.Basic; the main changes are in GHC.Core.Opt.Driver * Doing this made me trip over two places where the AnonArgFlag on a FunTy was being lost so we could end up with (Num a -> ty) rather than (Num a => ty) - In coercionLKind/coercionRKind - In contHoleType in the Simplifier I fixed the former by defining mkFunctionType and using it in coercionLKind/RKind. I could have done the same for the latter, but the information is almost to hand. So I fixed the latter by - adding sc_hole_ty to ApplyToVal (like ApplyToTy), - adding as_hole_ty to ValArg (like TyArg) - adding sc_fun_ty to StrictArg Turned out I could then remove ai_type from ArgInfo. This is just moving the deck chairs around, but it worked out nicely. See the new Note [AnonArgFlag] in GHC.Types.Var * When looking at the 'arity decrease' thing (#18093) I discovered that stable unfoldings had a much lower arity than the actual optimised function. That's what led to the arity-decrease message. Simple solution: eta-expand. It's described in Note [Eta-expand stable unfoldings] in GHC.Core.Opt.Simplify * I also discovered that unsafeCoerce wasn't being inlined if the context was boring. So (\x. f (unsafeCoerce x)) would create a thunk -- yikes! I fixed that by making inlineBoringOK a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold. I also found that unsafeCoerceName was unused, so I removed it. I made a test case for #18078, and a very similar one for #17673. The net effect of all this on nofib is very modest, but positive: -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- anna -0.4% -0.1% -3.1% -3.1% 0.0% fannkuch-redux -0.4% -0.3% -0.1% -0.1% 0.0% maillist -0.4% -0.1% -7.8% -1.0% -14.3% primetest -0.4% -15.6% -7.1% -6.6% 0.0% -------------------------------------------------------------------------------- Min -0.9% -15.6% -13.3% -14.2% -14.3% Max -0.3% 0.0% +12.1% +12.4% 0.0% Geometric Mean -0.4% -0.2% -2.3% -2.2% -0.1% All following metric decreases are compile-time allocation decreases between -1% and -3%: Metric Decrease: T5631 T13701 T14697 T15164 - - - - - 32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00 Fix lookupGlobalOccRn_maybe sometimes reporting an error In some cases it was possible for lookupGlobalOccRn_maybe to return an error, when it should be returning a Nothing. If it called lookupExactOcc_either when there were no matching GlobalRdrElts in the otherwise case, it would return an error message. This could be caused when lookupThName_maybe in Template Haskell was looking in different namespaces (thRdrNameGuesses), guessing different namespaces that the name wasn't guaranteed to be found in. However, by addressing this some more accurate errors were being lost in the conversion to Maybes. So some of the lookup* functions have been shuffled about so that errors should always be ignored in lookup*_maybes, and propagated otherwise. This fixes #18263 - - - - - 9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00 Initialize the allocation counter in GHCi to 0 (Fixes #16012) According to the documentation for the function `getAllocationCounter` in [System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html) initialize the allocationCounter also in GHCi to 0. - - - - - 8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00 test: fix conc038 We had spurious failures of conc038 test on CI with stdout: ``` newThread started -mainThread -Haskell: 2 newThread back again +mainThread 1 sec later shutting down +Haskell: 2 ``` - - - - - 4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00 Release Notes: Add news from the pattern-match checker [skip ci] - - - - - 3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00 Only test T16190 with the NCG T16190 is meant to test a NCG feature. It has already caused spurious failures in other MRs (e.g. !2165) when LLVM is used. - - - - - 2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00 DynFlags refactoring VIII (#17957) * Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.* * Add LlvmOpts datatype to store Llvm backend options * Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and Llvm.MetaExpr) which require LlvmOpts. * Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`) - - - - - 7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove unused code - - - - - 72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor homeUnit * rename thisPackage into homeUnit * document and refactor several Backpack things - - - - - 8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Rename unsafeGetUnitInfo into unsafeLookupUnit - - - - - f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Add allowVirtualUnits field in PackageState Instead of always querying DynFlags to know whether we are allowed to use virtual units (i.e. instantiated on-the-fly, cf Note [About units] in GHC.Unit), we store it once for all in `PackageState.allowVirtualUnits`. This avoids using DynFlags too much (cf #17957) and is preliminary work for #14335. - - - - - e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00 Enhance UnitId use * use UnitId instead of String to identify wired-in units * use UnitId instead of Unit in the backend (Unit are only use by Backpack to produce type-checked interfaces, not real code) * rename lookup functions for consistency * documentation - - - - - 9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00 Remove LinkerUnitId type alias - - - - - d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00 Refactor WiredMap * Remove WiredInUnitId and WiredUnitId type aliases - - - - - 3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document and refactor `mkUnit` and `mkUnitInfoMap` - - - - - d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove PreloadUnitId type alias - - - - - f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename listUnitInfoMap into listUnitInfo There is no Map involved - - - - - ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit The terminology changed over time and now package databases contain "units" (there can be several units compiled from a single Cabal package: one per-component, one for each option set, one per instantiation, etc.). We should try to be consistent internally and use "units": that's what this renaming does. Maybe one day we'll fix the UI too (e.g. replace -package-id with -unit-id, we already have -this-unit-id and ghc-pkg has -unit-id...) but it's not done in this patch. * rename getPkgFrameworkOpts into getUnitFrameworkOpts * rename UnitInfoMap into ClosureUnitInfoMap * rename InstalledPackageIndex into UnitInfoMap * rename UnusablePackages into UnusableUnits * rename PackagePrecedenceIndex into UnitPrecedenceMap * rename PackageDatabase into UnitDatabase * rename pkgDatabase into unitDatabases * rename pkgState into unitState * rename initPackages into initUnits * rename renamePackage into renameUnitInfo * rename UnusablePackageReason into UnusableUnitReason * rename getPackage* into getUnit* * etc. - - - - - 202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Make ClosureUnitInfoMap uses UnitInfoMap - - - - - 55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove ClosureUnitInfoMap - - - - - 653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Rename Package into Unit (2) * rename PackageState into UnitState * rename findWiredInPackages into findWiredInUnits * rename lookupModuleInAll[Packages,Units] * etc. - - - - - ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move dump_mod_map into initUnits - - - - - 598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move wiring of homeUnitInstantiations outside of mkUnitState - - - - - 437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00 Avoid timing module map dump in initUnits - - - - - 9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Remove preload parameter of mkUnitState * Remove preload parameter (unused) * Don't explicitly return preloaded units: redundant because already returned as "preloadUnits" field of UnitState - - - - - 266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: refactor unwireUnit - - - - - 9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00 Document getPreloadUnitsAnd - - - - - bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: remove useless add_package parameter - - - - - 36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: make listVisibleModuleNames take a UnitState - - - - - 5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document add_package - - - - - 4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Refactor and document closeUnitDeps - - - - - 42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: findWiredInUnits - - - - - a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: reportCycles, reportUnusable - - - - - 8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: merge_databases - - - - - fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00 DynFlags: add UnitConfig datatype Avoid directly querying flags from DynFlags to build the UnitState. Instead go via UnitConfig so that we could reuse this to make another UnitState for plugins. - - - - - 4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00 Move distrustAll into mkUnitState - - - - - 28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Create helper upd_wired_in_home_instantiations - - - - - ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Put database cache in UnitConfig - - - - - bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00 Don't return preload units when we set DyNFlags Preload units can be retrieved in UnitState when needed (i.e. in GHCi) - - - - - 1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00 NCGConfig: remove useless ncgUnitId field - - - - - c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Doc: fix some comments - - - - - 456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00 Bump haddock submodule and allow metric decrease Metric Decrease: T12150 T12234 T5837 Metric Increase: T16190 - - - - - 42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00 Trim the demand for recursive product types Ticket #18304 showed that we need to be very careful when exploring the demand (esp usage demand) on recursive product types. This patch solves the problem by trimming the demand on such types -- in effect, a form of "widening". See the Note [Trimming a demand to a type] in DmdAnal, which explains how I did this by piggy-backing on an existing mechansim for trimming demands becuase of GADTs. The significant payload of this patch is very small indeed: * Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to avoid looking through recursive types. But on the way * I found that ae_rec_tc was entirely inoperative and did nothing. So I removed it altogether from DmdAnal. * I moved some code around in DmdAnal and Demand. (There are no actual changes in dmdFix.) * I changed the API of DmsAnal.dmdAnalRhsLetDown to return a StrictSig rather than a decorated Id * I removed the dead function peelTsFuns from Demand Performance effects: Nofib: 0.0% changes. Not surprising, because they don't use recursive products Perf tests T12227: 1% increase in compiler allocation, becuase $cto gets w/w'd. It did not w/w before because it takes a deeply nested argument, so the worker gets too many args, so we abandon w/w altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough) With this patch we trim the demands. That is not strictly necessary (since these Generic type constructors are like tuples -- they can't cause a loop) but the net result is that we now w/w $cto which is fine. UniqLoop: 16% decrease in /runtime/ allocation. The UniqSupply is a recursive product, so currently we abandon all strictness on 'churn'. With this patch 'churn' gets useful strictness, and we w/w it. Hooray Metric Decrease: UniqLoop Metric Increase: T12227 - - - - - 87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00 Add introductory prose for Data.Traversable - - - - - 9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00 Fix #12073: Add MonadFix Q instance - - - - - 220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00 testsuite: Increase size of T12150 As noted in #18319, this test was previously very fragile. Increase its size to make it more likely that its fails with its newly-increased acceptance threshold. Metric Increase: T12150 - - - - - 8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00 gitlab-ci: Always push perf notes Previously we ci.sh would run with `set -e` implying that we wouldn't push perf notes if the testsuite were to fail, even if it *only* failed due to perf notes. This rendered the whole performance testing story quite fragile as a single regressing commit would cause every successive commit to fail since a new baseline would not be uploaded. Fix this by ensuring that we always push performance notes. - - - - - 7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00 gitlab-ci: Eliminate redundant push of CI metrics - - - - - a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00 Use HsForAllTelescope to avoid inferred, visible foralls Currently, `HsForAllTy` permits the combination of `ForallVis` and `Inferred`, but you can't actually typecheck code that uses it (e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a new `HsForAllTelescope` data type that makes a type-level distinction between visible and invisible `forall`s such that visible `forall`s do not track `Specificity`. That part of the patch is actually quite small; the rest is simply changing consumers of `HsType` to accommodate this new type. Fixes #18235. Bumps the `haddock` submodule. - - - - - c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00 winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges. The initial version was rewritten by Tamar Christina. It was rewritten in large parts by Andreas Klebinger. Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at> - - - - - 9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00 codeGen: Don't discard live case binders in unsafeEqualityProof logic Previously CoreToStg would unconditionally discard cases of the form: case unsafeEqualityProof of wild { _ -> rhs } and rather replace the whole thing with `rhs`. However, in some cases (see #18227) the case binder is still live, resulting in unbound occurrences in `rhs`. Fix this by only discarding the case if the case binder is dead. Fixes #18227. - - - - - e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00 testsuite: Add tests for #18227 T18227A is the original issue which gave rise to the ticket and depends upon bytestring. T18227B is a minimized reproducer. - - - - - 8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Fix rts include and library paths Fixes two bugs: * (?) and (<>) associated in a surprising way * We neglected to include libdw paths in the rts configure flags - - - - - bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00 hadrian: Drop redundant GHC arguments Cabal should already be passing this arguments to GHC. - - - - - 01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00 FFI: Fix pass small ints in foreign call wrappers The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933 - - - - - 502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00 Fix "ndecreasingIndentation" in manual (#18116) - - - - - 9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00 Use foldl' in unionManyUniqDSets - - - - - 761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00 Load .lo as well. Some archives contain so called linker objects, with the affectionate .lo suffic. For example the musl libc.a will come in that form. We still want to load those objects, hence we should not discard them and look for .lo as well. Ultimately we might want to fix this proerly by looking at the file magic. - - - - - cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00 User's Guide: KnownNat evidence is Natural This bit of documentation got outdated after commit 1fcede43d2b30f33b7505e25eb6b1f321be0407f - - - - - d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00 Fix typos and formatting in user guide - - - - - 56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00 Resolve TODO - - - - - 3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00 Rename TcHoleErrors to GHC.Tc.Errors.Hole - - - - - d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00 hadrian: Build with threaded runtime if available See #16873. - - - - - 0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00 T16190: only measure bytes_allocated Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics fluctuate by 13%. - - - - - 4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00 docs: fix formatting in users guide - - - - - eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00 Move CLabel assertions into smart constructors (#17957) It avoids using DynFlags in the Outputable instance of Clabel to check assertions at pretty-printing time. - - - - - 7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00 base: Bump to 4.15.0.0 - - - - - 20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00 configure: Use grep -q instead of --quiet The latter is apparently not supported by busybox. - - - - - 40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00 Linear types (#15981) This is the first step towards implementation of the linear types proposal (https://github.com/ghc-proposals/ghc-proposals/pull/111). It features * A language extension -XLinearTypes * Syntax for linear functions in the surface language * Linearity checking in Core Lint, enabled with -dlinear-core-lint * Core-to-core passes are mostly compatible with linearity * Fields in a data type can be linear or unrestricted; linear fields have multiplicity-polymorphic constructors. If -XLinearTypes is disabled, the GADT syntax defaults to linear fields The following items are not yet supported: * a # m -> b syntax (only prefix FUN is supported for now) * Full multiplicity inference (multiplicities are really only checked) * Decent linearity error messages * Linear let, where, and case expressions in the surface language (each of these currently introduce the unrestricted variant) * Multiplicity-parametric fields * Syntax for annotating lambda-bound or let-bound with a multiplicity * Syntax for non-linear/multiple-field-multiplicity records * Linear projections for records with a single linear field * Linear pattern synonyms * Multiplicity coercions (test LinearPolyType) A high-level description can be found at https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation Following the link above you will find a description of the changes made to Core. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Matthew Pickering * Arnaud Spiwack With contributions from: * Mark Barbone * Alexander Vershilov Updates haddock submodule. - - - - - 6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00 Various performance improvements This implements several general performance improvements to GHC, to offset the effect of the linear types change. General optimisations: - Add a `coreFullView` function which iterates `coreView` on the head. This avoids making function recursive solely because the iterate `coreView` themselves. As a consequence, this functions can be inlined, and trigger case-of-known constructor (_e.g._ `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`, `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`, `tyConAppTyCon_maybe`). The common pattern about all these functions is that they are almost always used as views, and immediately consumed by a case expression. This commit also mark them asx `INLINE`. - In `subst_ty` add a special case for nullary `TyConApp`, which avoid allocations altogether. - Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This required quite a bit of module shuffling. case. `myTyConApp` enforces crucial sharing, which was lost during substitution. See also !2952 . - Make `subst_ty` stricter. - In `eqType` (specifically, in `nonDetCmpType`), add a special case, tested first, for the very common case of nullary `TyConApp`. `nonDetCmpType` has been made `INLINE` otherwise it is actually a regression. This is similar to the optimisations in !2952. Linear-type specific optimisations: - Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in the definition of the pattern synonyms `One` and `Many`. - Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`: `Multiplicity` now import `Type` normally, rather than from the `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the `One` and `Many` pattern synonyms. - Make `updateIdTypeAndMult` strict in its type and multiplicity - The `scaleIdBy` gets a specialised definition rather than being an alias to `scaleVarBy` - `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type, Type)` instead of `Type -> Maybe (Scaled Type, Type)` - Remove the `MultMul` pattern synonym in favour of a view `isMultMul` because pattern synonyms appear not to inline well. - in `eqType`, in a `FunTy`, compare multiplicities last: they are almost always both `Many`, so it helps failing faster. - Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the instances of `TyConApp ManyDataConTy []` are physically the same. This commit has been authored by * Richard Eisenberg * Krzysztof Gogolewski * Arnaud Spiwack Metric Decrease: haddock.base T12227 T12545 T12990 T1969 T3064 T5030 T9872b Metric Increase: haddock.base haddock.Cabal haddock.compiler T12150 T12234 T12425 T12707 T13035 T13056 T15164 T16190 T18304 T1969 T3064 T3294 T5631 T5642 T5837 T6048 T9020 T9233 T9675 T9872a T9961 WWRec - - - - - 57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Remove integer-simple integer-simple uses lists of words (`[Word]`) to represent big numbers instead of ByteArray#: * it is less efficient than the newer ghc-bignum native backend * it isn't compatible with the big number representation that is now shared by all the ghc-bignum backends (based on the one that was used only in integer-gmp before). As a consequence, we simply drop integer-simple - - - - - 9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00 ghc-bignum library ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701 - - - - - 96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update compiler Thanks to ghc-bignum, the compiler can be simplified: * Types and constructors of Integer and Natural can be wired-in. It means that we don't have to query them from interfaces. It also means that numeric literals don't have to carry their type with them. * The same code is used whatever ghc-bignum backend is enabled. In particular, conversion of bignum literals into final Core expressions is now much more straightforward. Bignum closure inspection too. * GHC itself doesn't depend on any integer-* package anymore * The `integerLibrary` setting is gone. - - - - - 0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `base` package * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming - - - - - aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00 Update `make` based build system * replace integer-* package selection with ghc-bignum backend selection - - - - - f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update testsuite * support detection of slow ghc-bignum backend (to replace the detection of integer-simple use). There are still some test cases that the native backend doesn't handle efficiently enough. * remove tests for GMP only functions that have been removed from ghc-bignum * fix test results showing dependent packages (e.g. integer-gmp) or showing suggested instances * fix test using Integer/Natural API or showing internal names - - - - - dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Update Hadrian * support ghc-bignum backend selection in flavours and command-line * support ghc-bignum "--check" flag (compare results of selected backend against results of the native one) in flavours and command-line (e.g. pass --bignum=check-gmp" to check the "gmp" backend) * remove the hack to workaround #15286 * build GMP only when the gmp backend is used * remove hacks to workaround `text` package flags about integer-*. We fix `text` to use ghc-bignum unconditionally in another patch - - - - - fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00 Bump bytestring and text submodules - - - - - 1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00 docs: mention -hiedir in docs for -outputdir [skip ci] - - - - - 729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00 Hadrian: fix build on Mac OS Catalina (#17798) - - - - - 95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00 Relax allocation threshold for T12150. This test performs little work, so the most minor allocation changes often cause the test to fail. Increasing the threshold to 2% should help with this. - - - - - 8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00 hadrian: Bump pinned cabal.project to an existent index-state - - - - - 08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00 Fix uninitialized field read in Linker.c Valgrind report of the bug when running the test `linker_unload`: ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x36C027A: loadArchive_ (LoadArchive.c:522) ==29666== by 0x36C0600: loadArchive (LoadArchive.c:626) ==29666== by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload) ==29666== ==29666== Conditional jump or move depends on uninitialised value(s) ==29666== at 0x369C5B4: setOcInitialStatus (Linker.c:1305) ==29666== by 0x369C6C5: mkOc (Linker.c:1347) ==29666== by 0x369C9F6: preloadObjectFile (Linker.c:1507) ==29666== by 0x369CA8D: loadObj_ (Linker.c:1536) ==29666== by 0x369CB17: loadObj (Linker.c:1557) ==29666== by 0x3866BC: main (linker_unload.c:33) The problem is `mkOc` allocates a new `ObjectCode` and calls `setOcInitialStatus` without initializing the `status` field. `setOcInitialStatus` reads the field as first thing: static void setOcInitialStatus(ObjectCode* oc) { if (oc->status == OBJECT_DONT_RESOLVE) return; if (oc->archiveMemberName == NULL) { oc->status = OBJECT_NEEDED; } else { oc->status = OBJECT_LOADED; } } `setOcInitialStatus` is unsed in two places for two different purposes: in `mkOc` where we don't have the `status` field initialized yet (`mkOc` is supposed to initialize it), and `loadOc` where we do have `status` field initialized and we want to update it. Instead of splitting the function into two functions which are both called just once I inline the functions in the use sites and remove it. Fixes #18342 - - - - - da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00 fix windows bootstrap due to linker changes - - - - - 2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00 DynFlags: store default depth in SDocContext (#17957) It avoids having to use DynFlags to reach for pprUserLength. - - - - - d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00 Move tablesNextToCode field into Platform tablesNextToCode is a platform setting and doesn't belong into DynFlags (#17957). Doing this is also a prerequisite to fix #14335 where we deal with two platforms (target and host) that may have different platform settings. - - - - - 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - ae2545cc by Ben Gamari at 2020-10-26T11:12:46-04:00 codeGen: Produce local symbols for module-internal functions It turns out that some important native debugging/profiling tools (e.g. perf) rely only on symbol tables for function name resolution (as opposed to using DWARF DIEs). However, previously GHC would emit temporary symbols (e.g. `.La42b`) to identify module-internal entities. Such symbols are dropped during linking and therefore not visible to runtime tools (in addition to having rather un-helpful unique names). For instance, `perf report` would often end up attributing all cost to the libc `frame_dummy` symbol since Haskell code was no covered by any proper symbol (see #17605). We now rather follow the model of C compilers and emit descriptively-named local symbols for module internal things. Since this will increase object file size this behavior can be disabled with the `-fno-expose-all-symbols` flag. With this `perf record` can finally be used against Haskell executables. Even more, with `-g3` `perf annotate` provides inline source code. - - - - - d108b65e by Ben Gamari at 2020-10-26T11:12:46-04:00 Enable -fexpose-all-symbols when debug level is set - - - - - 17 changed files: - + .git-ignore-revs - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/merge_request_templates/merge-request.md - .gitlab/test-metrics.sh - .gitmodules - CODEOWNERS - Makefile - README.md - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - + compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/Names/TH.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd94eb01d1d1b9b0cb04126e9a29c6e7454bea90...d108b65efe79930586b86b4d027d81e5797338b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd94eb01d1d1b9b0cb04126e9a29c6e7454bea90...d108b65efe79930586b86b4d027d81e5797338b8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 16:18:18 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 26 Oct 2020 12:18:18 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix error message location in tcCheckPatSynDecl Message-ID: <5f96f6cae1ec8_8973fa3b8bf2e44367683@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 3708933f by Vladislav Zavialov at 2020-10-23T13:54:02+03:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 58e4aba8 by Ben Gamari at 2020-10-26T12:18:07-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 8e1db39e by Simon Peyton Jones at 2020-10-26T12:18:07-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 808aaef6 by Sergei Trofimovich at 2020-10-26T12:18:09-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 29cf0054 by David Eichmann at 2020-10-26T12:18:11-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - 30 changed files: - compiler/GHC/Cmm/Type.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/ghc.cabal.in - ghc.mk - hadrian/src/Rules/Clean.hs - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/hpc - libraries/parsec - libraries/process - libraries/stm - libraries/template-haskell/template-haskell.cabal.in - libraries/terminfo - libraries/unix - testsuite/driver/testlib.py The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18f6252303656ca58a1b755f33bbe8ea9d6eb523...29cf005404d976672233e2704dfcf3820171340d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18f6252303656ca58a1b755f33bbe8ea9d6eb523...29cf005404d976672233e2704dfcf3820171340d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 16:44:34 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Mon, 26 Oct 2020 12:44:34 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f96fcf2eaba5_8973fa3b920a5983739df@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: a070ab7d by David Eichmann at 2020-10-26T16:44:12+00:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr Changes: ===================================== includes/RtsAPI.h ===================================== @@ -38,6 +38,17 @@ typedef struct StgClosure_ *HaskellObj; */ typedef struct Capability_ Capability; +/* + * An abstract type representing the token returned by rts_pause(). + */ +typedef struct PauseToken_ PauseToken; + +/* + * From a PauseToken, get a Capability token used when allocating objects and + * threads in the RTS. + */ +Capability *pauseTokenCapability(PauseToken *pauseToken); + /* * The public view of a Capability: we can be sure it starts with * these two components (but it may have more private fields). @@ -330,17 +341,77 @@ extern void freeFullProgArgv ( void ) ; /* exit() override */ extern void (*exitFn)(int); -/* ---------------------------------------------------------------------------- - Locking. - - You have to surround all access to the RtsAPI with these calls. - ------------------------------------------------------------------------- */ - -// acquires a token which may be used to create new objects and -// evaluate them. +/* Note [Locking and Pausing the RTS] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You have to surround all access to the RtsAPI with rts_lock/rts_unlock or +with rts_pause/rts_resume. + + +# rts_lock / rts_unlock + +Use `rts_lock` to acquire a token which may be used to call other RtsAPI +functions and call `rts_unlock` to return the token. When locked, garbage +collection will not occur. As long as 1 or more capabilities are not locked, +haskell threads will continue to execute. If you want to pause execution of +all haskell threads then use rts_pause/rts_resume instead. + +The implementation of `rts_lock` acquires a capability for this thread. Hence, +at most n locks can be held simultaneously, where n is the number of +capabilities. It is an error to call `rts_lock` when the rts is already +paused by the current OS thread (see rts_pause/rts_resume below). + + +# rts_pause / rts_resume + +Use `rts_pause` to pause execution of all Haskell threads and `rts_resume` to +resume them. The implementation acquires all capabilities. `rts_resume` +must be called on the same thread as `rts_pause`. `rts_pause`, much like +rts_lock, returns a token. A `Capability` can be extracted from that token using +`pauseTokenCapability()`. The `Capability` can then be used to call other RtsAPI +functions. + +* With the RTS paused, garbage collections will not occur and haskell threads + will not execute, allocate, nor mutate their stacks. +* Non-Haskell (i.e. non-worker) threads such as those running safe FFI calls + will NOT be paused and can still mutate pinned mutable data such as pinned + `MutableByteArray#`s. +* You may call `rts_pause` from within a non-worker OS thread. +* You may call `rts_pause` from within a *safe* FFI call. In this case, make + sure to call `rts_resume` within the same FFI call or the RTS will deadlock. +* Calling `rts_pause` from an *unsafe* FFI call will cause an error. +* On return, the rts will be fully paused: all haskell threads are stopped + and all capabilities are acquired by the current OS thread. +* Calling `rts_pause` in between rts_lock/rts_unlock on the same thread will + cause an error. +* Calling `rts_pause` results in an error if the RTS is already paused by the + current OS thread. +* Only one OS thread at a time can keep the rts paused. +* `rts_pause` will block while another thread is pausing the RTS, and + continue when the current thread is given exclusive permission to pause the + RTS. + +## Note on implementation. + +Thread safety is achieved almost entirely by the mechanism of acquiring and +releasing Capabilities, resulting in a sort of mutex / critical section pattern. +This has the following consequences: + +* There are at most `n_capabilities` threads currently in a + rts_lock/rts_unlock section. +* There is at most 1 threads in a rts_pause/rts_resume section. In that case + there will be no threads in a rts_lock/rts_unlock section. +* rts_pause and rts_lock may block in order to enforce the above 2 + invariants. + +*/ + +// Acquires a token which may be used to create new objects and evaluate them. +// See Note [Locking and Pausing the RTS] for correct usage. Capability *rts_lock (void); // releases the token acquired with rts_lock(). +// See Note [Locking and Pausing the RTS] for correct usage. void rts_unlock (Capability *token); // If you are in a context where you know you have a current capability but @@ -483,6 +554,18 @@ void rts_checkSchedStatus (char* site, Capability *); SchedulerStatus rts_getSchedStatus (Capability *cap); +// Halt execution of all Haskell threads. +// See Note [Locking and Pausing the RTS] for correct usage. +PauseToken *rts_pause (void); + +// Counterpart of rts_pause: Continue from a pause. +// See Note [Locking and Pausing the RTS] for correct usage. +// [in] pauseToken: the token returned by rts_pause. +void rts_resume (PauseToken *pauseToken); + +// Returns true if the rts is paused. See rts_pause() and rts_resume(). +bool rts_isPaused(void); + /* * The RTS allocates some thread-local data when you make a call into * Haskell using one of the rts_eval() functions. This data is not ===================================== rts/Capability.c ===================================== @@ -858,7 +858,15 @@ void waitForCapability (Capability **pCap, Task *task) /* See Note [GC livelock] in Schedule.c for why we have gcAllowed and return the bool */ bool /* Did we GC? */ -yieldCapability (Capability** pCap, Task *task, bool gcAllowed) +yieldCapability + ( Capability** pCap // [in/out] Task's owned capability. Set to the + // newly owned capability on return. + // Precondition: + // pCap != NULL + // && *pCap != NULL + , Task *task // [in] This thread's task. + , bool gcAllowed + ) { Capability *cap = *pCap; ===================================== rts/RtsAPI.c ===================================== @@ -577,6 +577,16 @@ rts_getSchedStatus (Capability *cap) return cap->running_task->incall->rstat; } +#if defined(THREADED_RTS) +// The task that paused the RTS. The rts_pausing_task variable is owned by the +// task that owns all capabilities (there is at most one such task). +// +// It's possible to remove this and instead define the pausing task as whichever +// task owns all capabilities, but using `rts_pausing_task` leads to marginally +// cleaner code/API and better error messages. +Task * rts_pausing_task = NULL; +#endif + Capability * rts_lock (void) { @@ -593,6 +603,14 @@ rts_lock (void) stg_exit(EXIT_FAILURE); } +#if defined(THREADED_RTS) + if (rts_pausing_task == task) { + errorBelch("error: rts_lock: The RTS is already paused by this thread.\n" + " There is no need to call rts_lock if you have already called rts_pause."); + stg_exit(EXIT_FAILURE); + } +#endif + cap = NULL; waitForCapability(&cap, task); @@ -620,21 +638,21 @@ rts_unlock (Capability *cap) task = cap->running_task; ASSERT_FULL_CAPABILITY_INVARIANTS(cap,task); - // Now release the Capability. With the capability released, GC - // may happen. NB. does not try to put the current Task on the + // Now release the Capability. With the capability released, GC + // may happen. NB. does not try to put the current Task on the // worker queue. - // NB. keep cap->lock held while we call boundTaskExiting(). This + // NB. keep cap->lock held while we call exitMyTask(). This // is necessary during shutdown, where we want the invariant that // after shutdownCapability(), all the Tasks associated with the - // Capability have completed their shutdown too. Otherwise we - // could have boundTaskExiting()/workerTaskStop() running at some + // Capability have completed their shutdown too. Otherwise we + // could have exitMyTask()/workerTaskStop() running at some // random point in the future, which causes problems for // freeTaskManager(). ACQUIRE_LOCK(&cap->lock); releaseCapability_(cap,false); // Finally, we can release the Task to the free list. - boundTaskExiting(task); + exitMyTask(); RELEASE_LOCK(&cap->lock); if (task->incall == NULL) { @@ -645,6 +663,152 @@ rts_unlock (Capability *cap) } } +struct PauseToken_ { + Capability *capability; +}; + +Capability *pauseTokenCapability(PauseToken *pauseToken) { + return pauseToken->capability; +} + +#if defined(THREADED_RTS) + +// See Note [Locking and Pausing the RTS] +PauseToken *rts_pause (void) +{ + // It is an error if this thread already paused the RTS. If another + // thread has paused the RTS, then rts_pause will block until rts_resume is + // called (and compete with other threads calling rts_pause). The blocking + // behavior is implied by the use of `stopAllCapabilities`. + Task * task = getMyTask(); + if (rts_pausing_task == task) + { + // This task already pased the RTS. + errorBelch("error: rts_pause: This thread has already paused the RTS."); + stg_exit(EXIT_FAILURE); + } + + // The current task must not own a capability. This is true for non-worker + // threads e.g. when making a safe FFI call. We allow pausing when + // `task->cap->running_task != task` because the capability can be taken by + // other capabilities. Doing this check is justified because rts_pause is a + // user facing function and we want good error reporting. We also don't + // expect rts_pause to be performance critical. + if (task->cap && task->cap->running_task == task) + { + // This task owns a capability (and it can't be taken by other capabilities). + errorBelch(task->cap->in_haskell + ? ("error: rts_pause: attempting to pause via an unsafe FFI call.\n" + " Perhaps a 'foreign import unsafe' should be 'safe'?") + : ("error: rts_pause: attempting to pause from a Task that owns a capability.\n" + " Have you already acquired a capability e.g. with rts_lock?")); + stg_exit(EXIT_FAILURE); + } + + task = newBoundTask(); + stopAllCapabilities(NULL, task); + + // Now we own all capabilities so we own rts_pausing_task and may set it. + rts_pausing_task = task; + + PauseToken *token = malloc(sizeof(PauseToken)); + token->capability = task->cap; + return token; +} + +static void assert_isPausedOnMyTask(const char *functionName); + +// See Note [Locking and Pausing the RTS]. The pauseToken argument is here just +// for symmetry with rts_pause and to match the pattern of rts_lock/rts_unlock. +void rts_resume (PauseToken *pauseToken) +{ + assert_isPausedOnMyTask("rts_resume"); + Task * task = getMyTask(); + + // Now we own all capabilities so we own rts_pausing_task and may write to + // it. + rts_pausing_task = NULL; + + // releaseAllCapabilities will not block because the current task owns all + // capabilities. + releaseAllCapabilities(n_capabilities, NULL, task); + exitMyTask(); + free(pauseToken); +} + +// See RtsAPI.h +bool rts_isPaused(void) +{ + return rts_pausing_task != NULL; +} + +// Check that the rts_pause was called on this thread/task and this thread owns +// all capabilities. If not, outputs an error and exits with EXIT_FAILURE. +static void assert_isPausedOnMyTask(const char *functionName) +{ + Task * task = getMyTask(); + if (rts_pausing_task == NULL) + { + errorBelch ( + "error: %s: the rts is not paused. Did you forget to call rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + + if (task != rts_pausing_task) + { + // We don't have ownership of rts_pausing_task, so it may have changed + // just after the above read. Still, we are garanteed that + // rts_pausing_task won't be set to the current task (because the + // current task is here now!), so the error messages are still correct. + errorBelch ( + "error: %s: called from a different OS thread than rts_pause.", + functionName); + + stg_exit(EXIT_FAILURE); + } + + // Check that we own all capabilities. + for (unsigned int i = 0; i < n_capabilities; i++) + { + Capability *cap = capabilities[i]; + if (cap->running_task != task) + { + errorBelch ( + "error: %s: the pausing thread does not own all capabilities.\n" + " Have you manually released a capability after calling rts_pause?", + functionName); + stg_exit(EXIT_FAILURE); + } + } +} + + +#else +PauseToken GNU_ATTRIBUTE(__noreturn__) +*rts_pause (void) +{ + errorBelch("Warning: Pausing the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +void GNU_ATTRIBUTE(__noreturn__) +rts_resume (PauseToken *pauseToken STG_UNUSED) +{ + errorBelch("Warning: Resuming the RTS is only possible for " + "multithreaded RTS."); + stg_exit(EXIT_FAILURE); +} + +bool rts_isPaused() +{ + errorBelch("Warning: Pausing/Resuming the RTS is only possible for " + "multithreaded RTS."); + return false; +} +#endif + void rts_done (void) { freeMyTask(); @@ -680,7 +844,7 @@ void rts_done (void) void hs_try_putmvar (/* in */ int capability, /* in */ HsStablePtr mvar) { - Task *task = getTask(); + Task *task = getMyTask(); Capability *cap; Capability *task_old_cap USED_IF_THREADS; ===================================== rts/Schedule.c ===================================== @@ -1411,7 +1411,15 @@ scheduleNeedHeapProfile( bool ready_to_gc ) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -void stopAllCapabilities (Capability **pCap, Task *task) +void stopAllCapabilities + ( Capability **pCap // [in/out] This thread's task's owned capability. + // pCap may be NULL if no capability is owned. + // Else *pCap != NULL + // On return, set to the task's newly owned + // capability (task->cap). Though, the Task will + // technically own all capabilities. + , Task *task // [in] This thread's task. + ) { stopAllCapabilitiesWith(pCap, task, SYNC_OTHER); } @@ -1463,9 +1471,16 @@ void stopAllCapabilitiesWith (Capability **pCap, Task *task, SyncType sync_type) * -------------------------------------------------------------------------- */ #if defined(THREADED_RTS) -static bool requestSync ( - Capability **pcap, Task *task, PendingSync *new_sync, - SyncType *prev_sync_type) +static bool requestSync + ( Capability **pcap // [in/out] This thread's task's owned capability. + // May change if there is an existing sync (true is returned). + // Precondition: + // pcap may be NULL + // *pcap != NULL + , Task *task // [in] This thread's task. + , PendingSync *new_sync // [in] The new requested sync. + , SyncType *prev_sync_type // [out] Only set if there is an existing sync (true is returned). + ) { PendingSync *sync; @@ -1559,7 +1574,7 @@ static void acquireAllCapabilities(Capability *cap, Task *task) void releaseAllCapabilities(uint32_t n, Capability *keep_cap, Task *task) { uint32_t i; - + ASSERT( task != NULL); for (i = 0; i < n; i++) { Capability *tmpcap = capabilities[i]; if (keep_cap != tmpcap) { @@ -2082,7 +2097,7 @@ forkProcess(HsStablePtr *entry RELEASE_LOCK(&capabilities[i]->lock); } - boundTaskExiting(task); + exitMyTask(); // just return the pid return pid; @@ -2762,7 +2777,7 @@ exitScheduler (bool wait_foreign USED_IF_THREADS) // debugBelch("n_failed_trygrab_idles = %d, n_idle_caps = %d\n", // n_failed_trygrab_idles, n_idle_caps); - boundTaskExiting(task); + exitMyTask(); } void @@ -2821,7 +2836,7 @@ performGC_(bool force_major) waitForCapability(&cap,task); scheduleDoGC(&cap,task,force_major,false); releaseCapability(cap); - boundTaskExiting(task); + exitMyTask(); } void ===================================== rts/Task.c ===================================== @@ -118,7 +118,7 @@ freeTaskManager (void) return tasksRunning; } -Task* getTask (void) +Task* getMyTask (void) { Task *task; @@ -306,7 +306,7 @@ newBoundTask (void) stg_exit(EXIT_FAILURE); } - task = getTask(); + task = getMyTask(); task->stopped = false; @@ -317,13 +317,12 @@ newBoundTask (void) } void -boundTaskExiting (Task *task) +exitMyTask (void) { + Task* task = myTask(); #if defined(THREADED_RTS) ASSERT(osThreadId() == task->id); #endif - ASSERT(myTask() == task); - endInCall(task); // Set task->stopped, but only if this is the last call (#4850). @@ -524,7 +523,7 @@ void rts_setInCallCapability ( int preferred_capability, int affinity USED_IF_THREADS) { - Task *task = getTask(); + Task *task = getMyTask(); task->preferred_capability = preferred_capability; #if defined(THREADED_RTS) @@ -541,7 +540,7 @@ void rts_pinThreadToNumaNode ( { #if defined(THREADED_RTS) if (RtsFlags.GcFlags.numa) { - Task *task = getTask(); + Task *task = getMyTask(); task->node = capNoToNumaNode(node); if (!DEBUG_IS_ON || !RtsFlags.DebugFlags.numa) { // faking NUMA setThreadNode(numa_map[task->node]); ===================================== rts/Task.h ===================================== @@ -149,8 +149,8 @@ typedef struct Task_ { struct InCall_ *spare_incalls; bool worker; // == true if this is a worker Task - bool stopped; // == true between newBoundTask and - // boundTaskExiting, or in a worker Task. + bool stopped; // == false between newBoundTask and + // exitMyTask, or in a worker Task. // So that we can detect when a finalizer illegally calls back into Haskell bool running_finalizers; @@ -200,9 +200,9 @@ extern Mutex all_tasks_mutex; void initTaskManager (void); uint32_t freeTaskManager (void); -// Create a new Task for a bound thread. This Task must be released -// by calling boundTaskExiting. The Task is cached in -// thread-local storage and will remain even after boundTaskExiting() +// Create a new Task for a bound thread. This Task must be released +// by calling exitMyTask(). The Task is cached in +// thread-local storage and will remain even after exitMyTask() // has been called; to free the memory, see freeMyTask(). // Task* newBoundTask (void); @@ -210,11 +210,10 @@ Task* newBoundTask (void); // Return the current OS thread's Task, which is created if it doesn't already // exist. After you have finished using RTS APIs, you should call freeMyTask() // to release this thread's Task. -Task* getTask (void); +Task* getMyTask (void); -// The current task is a bound task that is exiting. -// -void boundTaskExiting (Task *task); +// Exit myTask - This is the counterpart of newBoundTask(). +void exitMyTask (void); // Free a Task if one was previously allocated by newBoundTask(). // This is not necessary unless the thread that called newBoundTask() ===================================== rts/sm/NonMoving.c ===================================== @@ -1215,7 +1215,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO * #if defined(THREADED_RTS) finish: - boundTaskExiting(task); + exitMyTask(); // We are done... mark_thread = 0; ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -0,0 +1,20 @@ +test('pause_resume_via_safe_ffi', + [ only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) +test('pause_resume_via_pthread', + [ only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) +test('pause_resume_via_safe_ffi_concurrent', + [ only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) +test('pause_and_use_rts_api', + [ only_ways(['threaded1', 'threaded2']) + , extra_files(['pause_resume.c','pause_resume.h']) + ], + multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs ===================================== @@ -0,0 +1,28 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndUseRtsAPIAndResume" + pauseAndUseRtsAPIAndResume + :: (StablePtr (Int -> Int)) + -> Int + -> Int + -> Int + -> (StablePtr (IO Int)) + -> IO () + +main :: IO () +main = do + addOne <- newStablePtr ((+1) :: Int -> Int) + ioOne <- newStablePtr (return 1 :: IO Int) + successMay <- timeout 5000000 $ pauseAndUseRtsAPIAndResume + addOne + 1 + 2 + 3 + ioOne + case successMay of + Nothing -> exitFailure + Just () -> exitSuccess ===================================== testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout ===================================== @@ -0,0 +1,34 @@ +Pause the RTS...Paused +getRTSStats... +getRTSStatsEnabled... +getAllocations... +rts_getSchedStatus... +rts_getChar, rts_mkChar... +rts_getInt, rts_mkInt... +rts_getInt8, rts_mkInt8... +rts_getInt16, rts_mkInt16... +rts_getInt32, rts_mkInt32... +rts_getInt64, rts_mkInt64... +rts_getWord, rts_mkWord... +rts_getWord8, rts_mkWord8... +rts_getWord16, rts_mkWord16... +rts_getWord32, rts_mkWord32... +rts_getWord64, rts_mkWord64... +rts_getPtr, rts_mkPtr... +rts_getFunPtr, rts_mkFunPtr... +rts_getFloat, rts_mkFloat... +rts_getDouble, rts_mkDouble... +rts_getStablePtr, rts_mkStablePtr... +rts_getBool, rts_mkBool... +rts_mkString... +rts_apply... +rts_eval... +rts_eval_... +rts_evalIO... +rts_evalStableIOMain... +rts_evalStableIO... +rts_evalLazyIO... +rts_evalLazyIO_... +rts_setInCallCapability... +rts_pinThreadToNumaNode... +Resume the RTS...Resumed ===================================== testsuite/tests/rts/pause-resume/pause_resume.c ===================================== @@ -0,0 +1,244 @@ +#include +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "pause_resume.h" + +void expectNoChange(const char * msg, volatile unsigned int * count); +void expectChange(const char * msg, volatile unsigned int * count); + +// Test rts_pause/rts_resume by observing a count that we expect to be +// incremented by concurrent Haskell thread(s). We expect rts_pause to stop +// those threads and hence stop incrementing the count. +void pauseAndResume + ( bool assertNotPaused // [in] True to enable assertions before rts_pause and after rts_resume. + // Often disabled when calling this concurrently. + , volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be running", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } + + // Pause and assert. + PauseToken * token = rts_pause(); + Capability * cap = pauseTokenCapability(token); + if(cap == NULL) { + errorBelch("rts_pause() returned NULL."); + exit(1); + } + + if(!rts_isPaused()) { + errorBelch("Expected the RTS to be paused."); + exit(1); + } + + expectNoChange("RTS should be paused", count); + + // Resume. + rts_resume(token); + + // Assert the RTS is resumed. + if (assertNotPaused) + { + expectChange("RTS should be resumed", count); + if(rts_isPaused()) { + errorBelch("Expected the RTS to be resumed."); + exit(1); + } + } +} + +int addOne(int a) +{ + return a + 1; +} + +// Pause tht RTS and call all RtsAPI.h functions. +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn // [in] A Haskell function (StablePtr (a -> a)) + , HaskellObj haskellFnArgument // [in] An argument to apply to haskellFn (a) + , HaskellObj obj1 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HaskellObj obj2 // [in] arbitrary haskell value to evaluate of arbitrary type. + , HsStablePtr stablePtrIO // [in] arbitrary haskell IO action to execute (StablePtr (IO t)) + ) +{ + // Pause the RTS. + printf("Pause the RTS..."); + PauseToken * token = rts_pause(); + Capability * cap = pauseTokenCapability(token); + printf("Paused\n"); + + // Note the original capability. We assert that cap is not changed by + // functions that take &cap. + Capability *const cap0 = cap; + + // Call RtsAPI.h functions + printf("getRTSStats...\n"); + RTSStats s; + getRTSStats (&s); + printf("getRTSStatsEnabled...\n"); + getRTSStatsEnabled(); + printf("getAllocations...\n"); + getAllocations(); + printf("rts_getSchedStatus...\n"); + rts_getSchedStatus(cap); + printf("rts_getChar, rts_mkChar...\n"); + rts_getChar (rts_mkChar ( cap, 0 )); + printf("rts_getInt, rts_mkInt...\n"); + rts_getInt (rts_mkInt ( cap, 0 )); + printf("rts_getInt8, rts_mkInt8...\n"); + rts_getInt8 (rts_mkInt8 ( cap, 0 )); + printf("rts_getInt16, rts_mkInt16...\n"); + rts_getInt16 (rts_mkInt16 ( cap, 0 )); + printf("rts_getInt32, rts_mkInt32...\n"); + rts_getInt32 (rts_mkInt32 ( cap, 0 )); + printf("rts_getInt64, rts_mkInt64...\n"); + rts_getInt64 (rts_mkInt64 ( cap, 0 )); + printf("rts_getWord, rts_mkWord...\n"); + rts_getWord (rts_mkWord ( cap, 0 )); + printf("rts_getWord8, rts_mkWord8...\n"); + rts_getWord8 (rts_mkWord8 ( cap, 0 )); + printf("rts_getWord16, rts_mkWord16...\n"); + rts_getWord16 (rts_mkWord16 ( cap, 0 )); + printf("rts_getWord32, rts_mkWord32...\n"); + rts_getWord32 (rts_mkWord32 ( cap, 0 )); + printf("rts_getWord64, rts_mkWord64...\n"); + rts_getWord64 (rts_mkWord64 ( cap, 0 )); + printf("rts_getPtr, rts_mkPtr...\n"); + int x = 0; + rts_getPtr (rts_mkPtr ( cap, &x)); + printf("rts_getFunPtr, rts_mkFunPtr...\n"); + rts_getFunPtr (rts_mkFunPtr ( cap, &addOne )); + printf("rts_getFloat, rts_mkFloat...\n"); + rts_getFloat (rts_mkFloat ( cap, 0.0 )); + printf("rts_getDouble, rts_mkDouble...\n"); + rts_getDouble (rts_mkDouble ( cap, 0.0 )); + printf("rts_getStablePtr, rts_mkStablePtr...\n"); + rts_getStablePtr (rts_mkStablePtr ( cap, &x )); + printf("rts_getBool, rts_mkBool...\n"); + rts_getBool (rts_mkBool ( cap, 0 )); + printf("rts_mkString...\n"); + rts_mkString ( cap, "Hello ghc-debug!" ); + printf("rts_apply...\n"); + rts_apply ( cap, deRefStablePtr(haskellFn), haskellFnArgument ); + + printf("rts_eval...\n"); + HaskellObj ret; + rts_eval(&cap, obj1, &ret); + assert(cap == cap0); + + printf("rts_eval_...\n"); + rts_eval_ (&cap, obj2, 50, &ret); + assert(cap == cap0); + + printf("rts_evalIO...\n"); + HaskellObj io = deRefStablePtr(stablePtrIO); + rts_evalIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalStableIOMain...\n"); + HsStablePtr retStablePtr; + rts_evalStableIOMain (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalStableIO...\n"); + rts_evalStableIO (&cap, stablePtrIO, &retStablePtr); + assert(cap == cap0); + + printf("rts_evalLazyIO...\n"); + rts_evalLazyIO (&cap, io, &ret); + assert(cap == cap0); + + printf("rts_evalLazyIO_...\n"); + rts_evalLazyIO_ (&cap, io, 50, &ret); + assert(cap == cap0); + + printf("rts_setInCallCapability...\n"); + rts_setInCallCapability (0, 1); + printf("rts_pinThreadToNumaNode...\n"); + rts_pinThreadToNumaNode (0); + + // Resume the RTS. + printf("Resume the RTS..."); + rts_resume(token); + assert(cap == cap0); + printf("Resumed\n"); +} + +void* pauseAndResumeViaThread_helper(volatile unsigned int * count) +{ + pauseAndResume(false, count); + return NULL; +} + +// Call pauseAndResume via a new thread and return the thread ID. +unsigned long pauseAndResumeViaThread + ( volatile unsigned int * count // [in] Haskell threads should be forever incrementing this. + ) +{ + pthread_t threadId; + pthread_create(&threadId, NULL, &pauseAndResumeViaThread_helper, count); + return threadId; +} + +const int TIMEOUT = 1000000; // 1 second + +// Wait for &count to change (else exit(1) after TIMEOUT). +void expectChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + return; + } + + if (microSecondsLeft < 0) + { + printf("Expected: %s\n", msg); + exit(1); + } + } +} + +// Ensure &count does NOT change (for TIMEOUT else exit(1)). +void expectNoChange(const char * msg, volatile unsigned int * count) +{ + unsigned int count_0 = *count; + int microSecondsLeft = TIMEOUT; + unsigned int sleepTime = 10000; + while (true) + { + usleep(sleepTime); + microSecondsLeft -= sleepTime; + + if (count_0 != *count) + { + // Change detected. + printf("Expected: %s\n", msg); + exit(1); + } + + if (microSecondsLeft < 0) + { + return; + } + } +} ===================================== testsuite/tests/rts/pause-resume/pause_resume.h ===================================== @@ -0,0 +1,10 @@ + +void pauseAndResume(bool assertNotPaused, volatile unsigned int * count); +unsigned long pauseAndResumeViaThread(volatile unsigned int * count); +void pauseAndUseRtsAPIAndResume + ( HaskellObj haskellFn + , HaskellObj haskellFnArgument + , HaskellObj obj1 + , HaskellObj obj2 + , HsStablePtr stablePtrIO + ); ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs ===================================== @@ -0,0 +1,44 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Exts + +foreign import ccall safe "pause_resume.h pauseAndResumeViaThread" + safe_pauseAndResumeViaThread_c :: Ptr CUInt -> IO CULong + +foreign import ccall safe "pthread.h pthread_join" + -- We use CULong for the opaque type `pthread_t`, but this seems to work in + -- practice. + safe_pthread_join_c :: CULong -> Ptr Any -> IO () + +pthread_join :: CULong -> IO () +pthread_join threadId = safe_pthread_join_c threadId nullPtr + +-- Simple test of rts_pause() followed by rts_resume() via a new thread created +-- in c code. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + pthread_join =<< safe_pauseAndResumeViaThread_c countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + pthread_join =<< safe_pauseAndResumeViaThread_c countPtr + putMVar mvar () + takeMVar mvar ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs ===================================== @@ -0,0 +1,38 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import GHC.Stack + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Simple test of rts_pause() followed by rts_resume() +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Test rts_pause/rts_resume. + safe_pauseAndResume_c cTrue countPtr + + -- Test rts_pause/rts_resume from a unbound (worker) thread. + mvar <- newEmptyMVar + forkIO $ do + safe_pauseAndResume_c cTrue countPtr + putMVar mvar () + takeMVar mvar + +cTrue :: CBool +cTrue = 1 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs ===================================== @@ -0,0 +1,52 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Control.Concurrent.MVar +import Control.Monad +import Foreign.C.Types +import Foreign.Marshal.Alloc +import Foreign.Ptr +import Foreign.Storable +import System.Exit +import System.Timeout + +foreign import ccall safe "pause_resume.h pauseAndResume" + safe_pauseAndResume_c :: CBool -> Ptr CUInt -> IO () + +-- Test that concurrent calls to rts_pause()/rts_resume() doesn't cause deadlock. +main :: IO () +main = do + alloca $ \countPtr -> do + poke countPtr 0 + + -- forever increment count. Changes will be observed from the c code. + sequence_ $ replicate 4 $ forkIO $ forever $ do + count <- peek countPtr + poke countPtr (count + 1) + threadDelay 10000 -- 10 milliseconds + + -- Note that each call blocks for about a second, so this will take 5 + -- seconds to complete. + let n = 5 + mvars <- sequence $ replicate n newEmptyMVar + forM_ mvars $ \mvar -> forkIO $ do + safe_pauseAndResume_c + -- Don't check rts_isPaused() before rts_pause nore after rts_resume + -- because we're doing this concurrently so that would introduce a race + -- condition. + cFalse + countPtr + putMVar mvar () + + -- Wait (at least 2n seconds to be safe) for all threads to finish. + result <- timeout (2 * n * 1000000) (mapM_ takeMVar mvars) + case result of + Nothing -> do + putStrLn "Not all rts_pause/rts_resume threads have finished. Assuming deadlocked and failing test." + exitFailure + Just () -> do + putStrLn "All threads finished" + exitSuccess + +cFalse :: CBool +cFalse = 0 ===================================== testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout ===================================== @@ -0,0 +1 @@ +All threads finished ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -0,0 +1,23 @@ + +test('unsafe_rts_pause', + [ only_ways(['threaded1', 'threaded2']) + , exit_code(1) + ], compile_and_run, ['']) +test('rts_lock_when_paused', + [ only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) +test('rts_pause_when_locked', + [ only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) +test('rts_double_pause', + [ only_ways(['threaded1', 'threaded2']) + , exit_code(1) + , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) + ], + multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h doublePause" + safe_doublePause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_doublePause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr ===================================== @@ -0,0 +1 @@ +rts_double_pause: error: rts_pause: This thread has already paused the RTS. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Pausing... \ No newline at end of file ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h lockThenPause" + safe_lockThenPause_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_lockThenPause_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr ===================================== @@ -0,0 +1,2 @@ +rts_lock_when_paused: error: rts_pause: attempting to pause from a Task that owns a capability. + Have you already acquired a capability e.g. with rts_lock? ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout ===================================== @@ -0,0 +1,2 @@ +Locking...Locked +Pausing... ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c ===================================== @@ -0,0 +1,83 @@ +#include +#include + +#include "Rts.h" +#include "RtsAPI.h" + +#include "rts_pause_lock.h" + +// Although we expect errors rather than deadlock, we don't want a failed test +// to be a deadlocked test. Hence we use this as a 1 second timeout mechanism. +void assertDoneAfterOneSecond(int * done) +{ + sleep(1); + if (!*done) + { + printf("Deadlock detected."); + exit(1); + } +} + +void lockThenPause (int * done) { + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Pausing..."); + PauseToken * token = rts_pause(); + Capability * pauseCap = pauseTokenCapability(token); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(token); + printf("Resumed\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + *done = 1; +} + +void pauseThenLock (int * done) { + printf("Pausing..."); + PauseToken * token = rts_pause(); + Capability * pauseCap = pauseTokenCapability(token); + printf("Paused\n"); + + printf("Locking..."); + Capability * lockCap = rts_lock(); + printf("Locked\n"); + + printf("Unlocking..."); + rts_unlock(lockCap); + printf("Unlocked\n"); + + printf("Resuming..."); + rts_resume(token); + printf("Resumed\n"); + + *done = 1; +} + +void doublePause (int * done) { + printf("Pausing..."); + PauseToken * tokenA = rts_pause(); + Capability * pauseCapA = pauseTokenCapability(tokenA); + printf("Paused\n"); + + printf("Pausing..."); + PauseToken * tokenB = rts_pause(); + Capability * pauseCapB = pauseTokenCapability(tokenB); + printf("Paused\n"); + + printf("Resuming..."); + rts_resume(tokenA); + printf("Resuming\n"); + + printf("Resuming..."); + rts_resume(tokenB); + printf("Resumed\n"); + + *done = 1; +} ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h ===================================== @@ -0,0 +1,5 @@ + +void assertDoneAfterOneSecond(int * done); +void lockThenPause (int * done); +void pauseThenLock (int * done); +void doublePause (int * done); ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs ===================================== @@ -0,0 +1,23 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Control.Concurrent +import Foreign +import Foreign.C +import System.Exit +import System.Timeout + +foreign import ccall safe "rts_pause_lock.h assertDoneAfterOneSecond" + safe_assertDoneAfterOneSecond_c :: Ptr CInt -> IO () + +foreign import ccall safe "rts_pause_lock.h pauseThenLock" + safe_pauseThenLock_c :: Ptr CInt -> IO () + +main :: IO () +main = alloca $ \donePtr -> do + -- We don't expect a deadlock, but we want to avoid one in the case of a + -- failed test. + poke donePtr 0 + forkIO $ safe_assertDoneAfterOneSecond_c donePtr + + -- The actual test. + safe_pauseThenLock_c donePtr ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr ===================================== @@ -0,0 +1,2 @@ +rts_pause_when_locked: error: rts_lock: The RTS is already paused by this thread. + There is no need to call rts_lock if you have already called rts_pause. ===================================== testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout ===================================== @@ -0,0 +1,2 @@ +Pausing...Paused +Locking... ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Data.Word +import Data.IORef +import GHC.Clock +import Control.Concurrent +import Foreign.Ptr +import System.Mem +import Control.Monad + +data Capability + +foreign import ccall unsafe "RtsAPI.h rts_pause" + unsafe_rts_pause_c :: IO (Ptr Capability) + +main :: IO () +main = do + -- Making a unsafe call to rts_pause() should fail. We cannot allow this + -- haskell thread to continue if the RTS is paused. + _ <- unsafe_rts_pause_c + putStrLn "Oops! Haskell thread has continued even though RTS was paused." ===================================== testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.stderr ===================================== @@ -0,0 +1,2 @@ +unsafe_rts_pause: error: rts_pause: attempting to pause via an unsafe FFI call. + Perhaps a 'foreign import unsafe' should be 'safe'? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a070ab7d721de5222f0c3654b2c7dc38d73b28d9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a070ab7d721de5222f0c3654b2c7dc38d73b28d9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 17:27:36 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 13:27:36 -0400 Subject: [Git][ghc/ghc][wip/uf-conf-codegen] CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal Message-ID: <5f970708abe85_8973fa3b83faa703884e6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC Commits: d5cc796b by Ben Gamari at 2020-10-26T13:27:29-04:00 CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal Previously we would call hs_word2float which is incredibly expensive compared to just a MOV. - - - - - 1 changed file: - compiler/GHC/CmmToAsm/X86/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2511,6 +2511,14 @@ genCCall' config is32Bit (PrimTarget (MO_Clz width)) dest_regs@[dst] args@[src] bw = widthInBits width lbl = mkCmmCodeLabel primUnitId (fsLit (clzLabel width)) +genCCall' config _ (PrimTarget (MO_UF_Conv width)) [dst] [CmmLit arg_lit] _ + | CmmFloat n _ <- arg_lit = do + let fmt = floatFormat width + Amode amode amode_code <- memConstant (mkAlignment $ widthInBytes width) (CmmFloat (realToFrac arg_lit) width) + let platform = ncgPlatform config + let dst_r = getRegisterReg platform (CmmLocal dst) + return $ amode_code `appOL` unitOL (MOV fmt (OpAddr amode) (OpReg dst_r)) + genCCall' config is32Bit (PrimTarget (MO_UF_Conv width)) dest_regs args bid = do targetExpr <- cmmMakeDynamicReference config CallReference lbl View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5cc796b8fb6501445641dcb79a7237c8ccfd3fa -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5cc796b8fb6501445641dcb79a7237c8ccfd3fa You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 17:33:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 13:33:20 -0400 Subject: [Git][ghc/ghc][wip/uf-conf-codegen] primops: Document semantics of Float/Int conversions Message-ID: <5f9708606d4c0_8973fa3ba673ebc390366@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC Commits: fa34519a by Ben Gamari at 2020-10-26T13:32:23-04:00 primops: Document semantics of Float/Int conversions Fixes #18840. - - - - - 1 changed file: - compiler/GHC/Builtin/primops.txt.pp Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -607,10 +607,22 @@ primop IntToWordOp "int2Word#" GenPrimOp Int# -> Word# with code_size = 0 primop IntToFloatOp "int2Float#" GenPrimOp Int# -> Float# + {Convert an {\tt Int#} to the corrsponding {\tt Float#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Float# 1# == 1.0#}} primop IntToDoubleOp "int2Double#" GenPrimOp Int# -> Double# + {Convert an {\tt Int#} to the corrsponding {\tt Double#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Double# 1# == 1.0#}} primop WordToFloatOp "word2Float#" GenPrimOp Word# -> Float# + {Convert an {\tt Word#} to the corrsponding {\tt Float#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Float# 1# == 1.0#}} primop WordToDoubleOp "word2Double#" GenPrimOp Word# -> Double# + {Convert an {\tt Word#} to the corrsponding {\tt Double#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Double# 1# == 1.0#}} primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int# {Shift left. Result undefined if shift amount is not View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fa34519a875ed13c66f6c5e990a873239d53a234 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fa34519a875ed13c66f6c5e990a873239d53a234 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 17:58:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 13:58:18 -0400 Subject: [Git][ghc/ghc][wip/uf-conf-codegen] 2 commits: CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal Message-ID: <5f970e3a93921_8973fa38007de7039545d@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC Commits: 5c756080 by Ben Gamari at 2020-10-26T13:58:13-04:00 CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal Previously we would call hs_word2float which is incredibly expensive compared to just a MOV. - - - - - 1b92bde8 by Ben Gamari at 2020-10-26T13:58:13-04:00 primops: Document semantics of Float/Int conversions Fixes #18840. - - - - - 2 changed files: - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToAsm/X86/CodeGen.hs Changes: ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -607,10 +607,22 @@ primop IntToWordOp "int2Word#" GenPrimOp Int# -> Word# with code_size = 0 primop IntToFloatOp "int2Float#" GenPrimOp Int# -> Float# + {Convert an {\tt Int#} to the corrsponding {\tt Float#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Float# 1# == 1.0#}} primop IntToDoubleOp "int2Double#" GenPrimOp Int# -> Double# + {Convert an {\tt Int#} to the corrsponding {\tt Double#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Double# 1# == 1.0#}} primop WordToFloatOp "word2Float#" GenPrimOp Word# -> Float# + {Convert an {\tt Word#} to the corrsponding {\tt Float#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Float# 1# == 1.0#}} primop WordToDoubleOp "word2Double#" GenPrimOp Word# -> Double# + {Convert an {\tt Word#} to the corrsponding {\tt Double#} with the same + integral value (up to truncation due to floating-point precision). e.g. + {\tt int2Double# 1# == 1.0#}} primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int# {Shift left. Result undefined if shift amount is not ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2511,6 +2511,14 @@ genCCall' config is32Bit (PrimTarget (MO_Clz width)) dest_regs@[dst] args@[src] bw = widthInBits width lbl = mkCmmCodeLabel primUnitId (fsLit (clzLabel width)) +genCCall' config _ (PrimTarget (MO_UF_Conv width)) [dst] [CmmLit arg_lit] _ + | CmmFloat n _ <- arg_lit = do + let fmt = floatFormat width + Amode amode amode_code <- memConstant (mkAlignment $ widthInBytes width) (CmmFloat (realToFrac n) width) + let platform = ncgPlatform config + let dst_r = getRegisterReg platform (CmmLocal dst) + return $ amode_code `appOL` unitOL (MOV fmt (OpAddr amode) (OpReg dst_r)) + genCCall' config is32Bit (PrimTarget (MO_UF_Conv width)) dest_regs args bid = do targetExpr <- cmmMakeDynamicReference config CallReference lbl View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa34519a875ed13c66f6c5e990a873239d53a234...1b92bde80e492895ff2be26d673a5f179543a539 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa34519a875ed13c66f6c5e990a873239d53a234...1b92bde80e492895ff2be26d673a5f179543a539 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 18:53:10 2020 From: gitlab at gitlab.haskell.org (chessai) Date: Mon, 26 Oct 2020 14:53:10 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/data-dot-foldable-optimisations Message-ID: <5f971b168f07f_8973fa3bc17d050414418@gitlab.haskell.org.mail> chessai pushed new branch wip/data-dot-foldable-optimisations at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/data-dot-foldable-optimisations You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 19:27:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 15:27:04 -0400 Subject: [Git][ghc/ghc][wip/local-symbols-2] 4 commits: nativeGen: Make makeImportsDoc take an NCGConfig rather than DynFlags Message-ID: <5f972308a709_8973fa3b05d044c425080@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/local-symbols-2 at Glasgow Haskell Compiler / GHC Commits: 09be7a6a by Ben Gamari at 2020-10-26T14:56:37-04:00 nativeGen: Make makeImportsDoc take an NCGConfig rather than DynFlags It appears this was an oversight as there is no reason the full DynFlags is necessary. - - - - - f0856701 by Ben Gamari at 2020-10-26T15:22:37-04:00 Move this_module into NCGConfig In various places in the NCG we need the Module currently being compiled. Let's move this into the environment instead of chewing threw another register. - - - - - 94c8f75a by Ben Gamari at 2020-10-26T15:25:46-04:00 codeGen: Produce local symbols for module-internal functions It turns out that some important native debugging/profiling tools (e.g. perf) rely only on symbol tables for function name resolution (as opposed to using DWARF DIEs). However, previously GHC would emit temporary symbols (e.g. `.La42b`) to identify module-internal entities. Such symbols are dropped during linking and therefore not visible to runtime tools (in addition to having rather un-helpful unique names). For instance, `perf report` would often end up attributing all cost to the libc `frame_dummy` symbol since Haskell code was no covered by any proper symbol (see #17605). We now rather follow the model of C compilers and emit descriptively-named local symbols for module internal things. Since this will increase object file size this behavior can be disabled with the `-fno-expose-all-symbols` flag. With this `perf record` can finally be used against Haskell executables. Even more, with `-g3` `perf annotate` provides inline source code. - - - - - 566ebbd9 by Ben Gamari at 2020-10-26T15:25:51-04:00 Enable -fexpose-all-symbols when debug level is set - - - - - 11 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/debug-info.rst - docs/users_guide/phases.rst Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -118,6 +118,7 @@ module GHC.Cmm.CLabel ( LabelStyle (..), pprDebugCLabel, pprCLabel, + ppInternalProcLabel, -- * Others dynamicLinkerLabelInfo, @@ -1082,8 +1083,8 @@ isLocalCLabel this_mod lbl = -- that data resides in a DLL or not. [Win32 only.] -- @labelDynamic@ returns @True@ if the label is located -- in a DLL, be it a data reference or not. -labelDynamic :: NCGConfig -> Module -> CLabel -> Bool -labelDynamic config this_mod lbl = +labelDynamic :: NCGConfig -> CLabel -> Bool +labelDynamic config lbl = case lbl of -- is the RTS in a DLL or not? RtsLabel _ -> @@ -1136,6 +1137,7 @@ labelDynamic config this_mod lbl = externalDynamicRefs = ncgExternalDynamicRefs config platform = ncgPlatform config os = platformOS platform + this_mod = ncgThisModule config this_unit = toUnitId (moduleUnit this_mod) @@ -1359,6 +1361,39 @@ pprCLabel platform sty lbl = CmmLabel _ _ fs CmmRet -> maybe_underscore $ ftext fs <> text "_ret" CmmLabel _ _ fs CmmClosure -> maybe_underscore $ ftext fs <> text "_closure" +-- Note [Internal proc labels] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Some tools (e.g. the `perf` utility on Linux) rely on the symbol table +-- for resolution of function names. To help these tools we provide the +-- (enabled by default) -fexpose-all-symbols flag which causes GHC to produce +-- symbols even for symbols with are internal to a module (although such +-- symbols will have only local linkage). +-- +-- Note that these labels are *not* referred to by code. They are strictly for +-- diagnostics purposes. +-- +-- To avoid confusion, it is desireable to add a module-qualifier to the +-- symbol name. However, the Name type's Internal constructor doesn't carry +-- knowledge of the current Module. Consequently, we have to pass this around +-- explicitly. + +-- | Generate a label for a procedure internal to a module (if +-- 'Opt_ExposeAllSymbols' is enabled). +-- See Note [Internal proc labels]. +ppInternalProcLabel :: Module -- ^ the current module + -> CLabel + -> Maybe SDoc -- ^ the internal proc label +ppInternalProcLabel this_mod (IdLabel nm _ flavour) + | isInternalName nm + = Just + $ text "_" <> ppr this_mod + <> char '_' + <> ztext (zEncodeFS (occNameFS (occName nm))) + <> char '_' + <> pprUniqueAlways (getUnique nm) + <> ppIdFlavor flavour +ppInternalProcLabel _ _ = Nothing ppIdFlavor :: IdLabelInfo -> SDoc ppIdFlavor x = pp_cSEP <> case x of ===================================== compiler/GHC/Cmm/Info/Build.hs ===================================== @@ -946,7 +946,8 @@ oneSRT dflags staticFuns lbls caf_lbls isCAF cafs static_data = do topSRT <- get let - config = initNCGConfig dflags + this_mod = thisModule topSRT + config = initNCGConfig dflags this_mod profile = targetProfile dflags platform = profilePlatform profile srtMap = moduleSRTMap topSRT @@ -1019,8 +1020,6 @@ oneSRT dflags staticFuns lbls caf_lbls isCAF cafs static_data = do in state{ moduleSRTMap = srt_map } - this_mod = thisModule topSRT - allStaticData = all (\(CAFLabel clbl) -> Set.member clbl static_data) caf_lbls @@ -1048,7 +1047,7 @@ oneSRT dflags staticFuns lbls caf_lbls isCAF cafs static_data = do -- when dynamic linking is used we cannot guarantee that the offset -- between the SRT and the info table will fit in the offset field. -- Consequently we build a singleton SRT in this case. - not (labelDynamic config this_mod lbl) + not (labelDynamic config lbl) -- MachO relocations can't express offsets between compilation units at -- all, so we are always forced to build a singleton SRT in this case. ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -152,7 +152,7 @@ nativeCodeGen :: forall a . DynFlags -> Module -> ModLocation -> Handle -> UniqS -> Stream IO RawCmmGroup a -> IO a nativeCodeGen dflags this_mod modLoc h us cmms - = let config = initNCGConfig dflags + = let config = initNCGConfig dflags this_mod platform = ncgPlatform config nCG' :: ( OutputableP Platform statics, Outputable jumpDest, Instruction instr) => NcgImpl statics instr jumpDest -> IO a @@ -290,7 +290,7 @@ finishNativeGen dflags config modLoc bufh@(BufHandle _ _ h) us ngs -- write out the imports let ctx = ncgAsmContext config printSDocLn ctx Pretty.LeftMode h - $ makeImportsDoc dflags (concat (ngs_imports ngs)) + $ makeImportsDoc config (concat (ngs_imports ngs)) return us' where dump_stats = dumpAction dflags (mkDumpStyle alwaysQualify) @@ -479,7 +479,7 @@ cmmNativeGen dflags this_mod modLoc ncgImpl us fileIds dbgMap cmm count -- generate native code from cmm let ((native, lastMinuteImports, fileIds', nativeCfgWeights), usGen) = {-# SCC "genMachCode" #-} - initUs us $ genMachCode config this_mod modLoc + initUs us $ genMachCode config modLoc (cmmTopCodeGen ncgImpl) fileIds dbgMap opt_cmm cmmCfg @@ -750,8 +750,8 @@ computeUnwinding _ ncgImpl (CmmProc _ _ _ (ListGraph blks)) = -- | Build a doc for all the imports. -- -makeImportsDoc :: DynFlags -> [CLabel] -> SDoc -makeImportsDoc dflags imports +makeImportsDoc :: NCGConfig -> [CLabel] -> SDoc +makeImportsDoc config imports = dyld_stubs imports $$ -- On recent versions of Darwin, the linker supports @@ -779,7 +779,6 @@ makeImportsDoc dflags imports else Outputable.empty) where - config = initNCGConfig dflags platform = ncgPlatform config -- Generate "symbol stubs" for all external symbols that might @@ -915,7 +914,7 @@ apply_mapping ncgImpl ufm (CmmProc info lbl live (ListGraph blocks)) genMachCode :: NCGConfig - -> Module -> ModLocation + -> ModLocation -> (RawCmmDecl -> NatM [NatCmmDecl statics instr]) -> DwarfFiles -> LabelMap DebugBlock @@ -928,9 +927,9 @@ genMachCode , CFG ) -genMachCode config this_mod modLoc cmmTopCodeGen fileIds dbgMap cmm_top cmm_cfg +genMachCode config modLoc cmmTopCodeGen fileIds dbgMap cmm_top cmm_cfg = do { initial_us <- getUniqueSupplyM - ; let initial_st = mkNatM_State initial_us 0 config this_mod + ; let initial_st = mkNatM_State initial_us 0 config modLoc fileIds dbgMap cmm_cfg (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top) final_delta = natm_delta final_st @@ -1004,7 +1003,6 @@ instance Monad CmmOptM where instance CmmMakeDynamicReferenceM CmmOptM where addImport = addImportCmmOpt - getThisModule = CmmOptM $ \_ this_mod imports -> OptMResult this_mod imports addImportCmmOpt :: CLabel -> CmmOptM () addImportCmmOpt lbl = CmmOptM $ \_ _ imports -> OptMResult () (lbl:imports) @@ -1146,9 +1144,10 @@ cmmExprNative referenceKind expr = do -> return other -- | Initialize the native code generator configuration from the DynFlags -initNCGConfig :: DynFlags -> NCGConfig -initNCGConfig dflags = NCGConfig +initNCGConfig :: DynFlags -> Module -> NCGConfig +initNCGConfig dflags this_mod = NCGConfig { ncgPlatform = targetPlatform dflags + , ncgThisModule = this_mod , ncgAsmContext = initSDocContext dflags (PprCode AsmStyle) , ncgProcAlignment = cmmProcAlignment dflags , ncgExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags @@ -1193,5 +1192,6 @@ initNCGConfig dflags = NCGConfig , ncgDwarfEnabled = debugLevel dflags > 0 , ncgDwarfUnwindings = debugLevel dflags >= 1 , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. + , ncgExposeInternalSymbols = gopt Opt_ExposeInternalSymbols dflags } ===================================== compiler/GHC/CmmToAsm/Config.hs ===================================== @@ -11,12 +11,14 @@ import GHC.Prelude import GHC.Platform import GHC.Cmm.Type (Width(..)) import GHC.CmmToAsm.CFG.Weight +import GHC.Unit.Module (Module) import GHC.Utils.Outputable -- | Native code generator configuration data NCGConfig = NCGConfig { ncgPlatform :: !Platform -- ^ Target platform , ncgAsmContext :: !SDocContext -- ^ Context for ASM code generation + , ncgThisModule :: !Module -- ^ The name of the module we are currently compiling , ncgProcAlignment :: !(Maybe Int) -- ^ Mandatory proc alignment , ncgExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , ncgPIC :: !Bool -- ^ Enable Position-Independent Code @@ -37,6 +39,7 @@ data NCGConfig = NCGConfig , ncgDwarfEnabled :: !Bool -- ^ Enable Dwarf generation , ncgDwarfUnwindings :: !Bool -- ^ Enable unwindings , ncgDwarfStripBlockInfo :: !Bool -- ^ Strip out block information from generated Dwarf + , ncgExposeInternalSymbols :: !Bool -- ^ Expose symbol table entries for internal symbols } -- | Return Word size ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -80,6 +80,8 @@ data NcgImpl statics instr jumpDest = NcgImpl { canShortcut :: instr -> Maybe jumpDest, shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics, shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr, + -- | 'Module' is only for printing internal labels. See Note [Internal proc + -- labels] in CLabel. pprNatCmmDecl :: NatCmmDecl statics instr -> SDoc, maxSpillSlots :: Int, allocatableRegs :: [RealReg], @@ -107,7 +109,6 @@ data NatM_State natm_imports :: [(CLabel)], natm_pic :: Maybe Reg, natm_config :: NCGConfig, - natm_this_module :: Module, natm_modloc :: ModLocation, natm_fileid :: DwarfFiles, natm_debug_map :: LabelMap DebugBlock, @@ -125,9 +126,9 @@ newtype NatM result = NatM (NatM_State -> (result, NatM_State)) unNat :: NatM a -> NatM_State -> (a, NatM_State) unNat (NatM a) = a -mkNatM_State :: UniqSupply -> Int -> NCGConfig -> Module -> ModLocation -> +mkNatM_State :: UniqSupply -> Int -> NCGConfig -> ModLocation -> DwarfFiles -> LabelMap DebugBlock -> CFG -> NatM_State -mkNatM_State us delta config this_mod +mkNatM_State us delta config = \loc dwf dbg cfg -> NatM_State { natm_us = us @@ -135,7 +136,6 @@ mkNatM_State us delta config this_mod , natm_imports = [] , natm_pic = Nothing , natm_config = config - , natm_this_module = this_mod , natm_modloc = loc , natm_fileid = dwf , natm_debug_map = dbg @@ -198,10 +198,11 @@ getCfgWeights = NatM $ \ st -> (ncgCfgWeights (natm_config st), st) setDeltaNat :: Int -> NatM () setDeltaNat delta = NatM $ \ st -> ((), st {natm_delta = delta}) - getThisModuleNat :: NatM Module -getThisModuleNat = NatM $ \ st -> (natm_this_module st, st) +getThisModuleNat = NatM $ \ st -> (ncgThisModule $ natm_config st, st) +instance HasModule NatM where + getModule = getThisModuleNat addImportNat :: CLabel -> NatM () addImportNat imp ===================================== compiler/GHC/CmmToAsm/PIC.hs ===================================== @@ -65,7 +65,6 @@ import GHC.Cmm import GHC.Cmm.CLabel import GHC.Types.Basic -import GHC.Unit.Module import GHC.Utils.Outputable import GHC.Utils.Panic @@ -95,11 +94,9 @@ data ReferenceKind class Monad m => CmmMakeDynamicReferenceM m where addImport :: CLabel -> m () - getThisModule :: m Module instance CmmMakeDynamicReferenceM NatM where addImport = addImportNat - getThisModule = getThisModuleNat cmmMakeDynamicReference :: CmmMakeDynamicReferenceM m @@ -113,13 +110,11 @@ cmmMakeDynamicReference config referenceKind lbl = return $ CmmLit $ CmmLabel lbl -- already processed it, pass through | otherwise - = do this_mod <- getThisModule - let platform = ncgPlatform config + = do let platform = ncgPlatform config case howToAccessLabel config (platformArch platform) (platformOS platform) - this_mod referenceKind lbl of AccessViaStub -> do @@ -208,7 +203,7 @@ data LabelAccessStyle | AccessViaSymbolPtr | AccessDirectly -howToAccessLabel :: NCGConfig -> Arch -> OS -> Module -> ReferenceKind -> CLabel -> LabelAccessStyle +howToAccessLabel :: NCGConfig -> Arch -> OS -> ReferenceKind -> CLabel -> LabelAccessStyle -- Windows -- In Windows speak, a "module" is a set of objects linked into the @@ -231,7 +226,7 @@ howToAccessLabel :: NCGConfig -> Arch -> OS -> Module -> ReferenceKind -> CLabel -- into the same .exe file. In this case we always access symbols directly, -- and never use __imp_SYMBOL. -- -howToAccessLabel config _ OSMinGW32 this_mod _ lbl +howToAccessLabel config _arch OSMinGW32 _kind lbl -- Assume all symbols will be in the same PE, so just access them directly. | not (ncgExternalDynamicRefs config) @@ -239,7 +234,7 @@ howToAccessLabel config _ OSMinGW32 this_mod _ lbl -- If the target symbol is in another PE we need to access it via the -- appropriate __imp_SYMBOL pointer. - | labelDynamic config this_mod lbl + | labelDynamic config lbl = AccessViaSymbolPtr -- Target symbol is in the same PE as the caller, so just access it directly. @@ -255,9 +250,9 @@ howToAccessLabel config _ OSMinGW32 this_mod _ lbl -- It is always possible to access something indirectly, -- even when it's not necessary. -- -howToAccessLabel config arch OSDarwin this_mod DataReference lbl +howToAccessLabel config arch OSDarwin DataReference lbl -- data access to a dynamic library goes via a symbol pointer - | labelDynamic config this_mod lbl + | labelDynamic config lbl = AccessViaSymbolPtr -- when generating PIC code, all cross-module data references must @@ -276,21 +271,21 @@ howToAccessLabel config arch OSDarwin this_mod DataReference lbl | otherwise = AccessDirectly -howToAccessLabel config arch OSDarwin this_mod JumpReference lbl +howToAccessLabel config arch OSDarwin JumpReference lbl -- dyld code stubs don't work for tailcalls because the -- stack alignment is only right for regular calls. -- Therefore, we have to go via a symbol pointer: | arch == ArchX86 || arch == ArchX86_64 - , labelDynamic config this_mod lbl + , labelDynamic config lbl = AccessViaSymbolPtr -howToAccessLabel config arch OSDarwin this_mod _ lbl +howToAccessLabel config arch OSDarwin _kind lbl -- Code stubs are the usual method of choice for imported code; -- not needed on x86_64 because Apple's new linker, ld64, generates -- them automatically. | arch /= ArchX86_64 - , labelDynamic config this_mod lbl + , labelDynamic config lbl = AccessViaStub | otherwise @@ -301,7 +296,7 @@ howToAccessLabel config arch OSDarwin this_mod _ lbl -- AIX -- quite simple (for now) -howToAccessLabel _config _arch OSAIX _this_mod kind _lbl +howToAccessLabel _config _arch OSAIX kind _lbl = case kind of DataReference -> AccessViaSymbolPtr CallReference -> AccessDirectly @@ -318,7 +313,7 @@ howToAccessLabel _config _arch OSAIX _this_mod kind _lbl -- from position independent code. It is also required from the main program -- when dynamic libraries containing Haskell code are used. -howToAccessLabel _ (ArchPPC_64 _) os _ kind _ +howToAccessLabel _config (ArchPPC_64 _) os kind _lbl | osElfTarget os = case kind of -- ELF PPC64 (powerpc64-linux), AIX, MacOS 9, BeOS/PPC @@ -330,7 +325,7 @@ howToAccessLabel _ (ArchPPC_64 _) os _ kind _ -- regular calls are handled by the runtime linker _ -> AccessDirectly -howToAccessLabel config _ os _ _ _ +howToAccessLabel config _arch os _kind _lbl -- no PIC -> the dynamic linker does everything for us; -- if we don't dynamically link to Haskell code, -- it actually manages to do so without messing things up. @@ -339,11 +334,11 @@ howToAccessLabel config _ os _ _ _ not (ncgExternalDynamicRefs config) = AccessDirectly -howToAccessLabel config arch os this_mod DataReference lbl +howToAccessLabel config arch os DataReference lbl | osElfTarget os = case () of -- A dynamic label needs to be accessed via a symbol pointer. - _ | labelDynamic config this_mod lbl + _ | labelDynamic config lbl -> AccessViaSymbolPtr -- For PowerPC32 -fPIC, we have to access even static data @@ -369,25 +364,25 @@ howToAccessLabel config arch os this_mod DataReference lbl -- (AccessDirectly, because we get an implicit symbol stub) -- and calling functions from PIC code on non-i386 platforms (via a symbol stub) -howToAccessLabel config arch os this_mod CallReference lbl +howToAccessLabel config arch os CallReference lbl | osElfTarget os - , labelDynamic config this_mod lbl && not (ncgPIC config) + , labelDynamic config lbl && not (ncgPIC config) = AccessDirectly | osElfTarget os , arch /= ArchX86 - , labelDynamic config this_mod lbl + , labelDynamic config lbl , ncgPIC config = AccessViaStub -howToAccessLabel config _ os this_mod _ lbl +howToAccessLabel config _arch os _kind lbl | osElfTarget os - = if labelDynamic config this_mod lbl + = if labelDynamic config lbl then AccessViaSymbolPtr else AccessDirectly -- all other platforms -howToAccessLabel config _ _ _ _ _ +howToAccessLabel config _arch _os _kind _lbl | not (ncgPIC config) = AccessDirectly ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -90,6 +90,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = -- special case for code without info table: pprSectionAlign config (Section Text lbl) $$ pprProcAlignment config $$ + pprProcLabel config lbl $$ pprLabel platform lbl $$ -- blocks guaranteed not null, so label needed vcat (map (pprBasicBlock config top_info) blocks) $$ (if ncgDwarfEnabled config @@ -99,6 +100,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = Just (CmmStaticsRaw info_lbl _) -> pprSectionAlign config (Section Text info_lbl) $$ pprProcAlignment config $$ + pprProcLabel config lbl $$ (if platformHasSubsectionsViaSymbols platform then pdoc platform (mkDeadStripPreventer info_lbl) <> char ':' else empty) $$ @@ -114,6 +116,15 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = else empty) $$ pprSizeDecl platform info_lbl +-- | Output an internal proc label. See Note [Internal proc labels] in CLabel. +pprProcLabel :: NCGConfig -> CLabel -> SDoc +pprProcLabel config lbl + | ncgExposeInternalSymbols config + , Just lbl' <- ppInternalProcLabel (ncgThisModule config) lbl + = lbl' <> char ':' + | otherwise + = empty + -- | Output the ELF .size directive. pprSizeDecl :: Platform -> CLabel -> SDoc pprSizeDecl platform lbl ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -274,6 +274,7 @@ data GeneralFlag -- forwards all -L flags to the collect2 command without using a -- response file and as such breaking apart. | Opt_SingleLibFolder + | Opt_ExposeInternalSymbols | Opt_KeepCAFs | Opt_KeepGoing | Opt_ByteCode ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -376,7 +376,6 @@ import qualified GHC.LanguageExtensions as LangExt -- ----------------------------------------------------------------------------- -- DynFlags - -- | Used to differentiate the scope an include needs to apply to. -- We have to split the include paths to avoid accidentally forcing recursive -- includes since -I overrides the system search paths. See #14312. @@ -3404,6 +3403,7 @@ fFlagsDeps = [ flagSpec "error-spans" Opt_ErrorSpans, flagSpec "excess-precision" Opt_ExcessPrecision, flagSpec "expose-all-unfoldings" Opt_ExposeAllUnfoldings, + flagSpec "expose-internal-symbols" Opt_ExposeInternalSymbols, flagSpec "external-dynamic-refs" Opt_ExternalDynamicRefs, flagSpec "external-interpreter" Opt_ExternalInterpreter, flagSpec "flat-cache" Opt_FlatCache, @@ -4392,7 +4392,13 @@ setVerbosity :: Maybe Int -> DynP () setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 }) setDebugLevel :: Maybe Int -> DynP () -setDebugLevel mb_n = upd (\dfs -> dfs{ debugLevel = mb_n `orElse` 2 }) +setDebugLevel mb_n = + upd (\dfs -> exposeSyms $ dfs{ debugLevel = n }) + where + n = mb_n `orElse` 2 + exposeSyms + | n > 0 = setGeneralFlag' Opt_ExposeInternalSymbols + | otherwise = id data PkgDbRef = GlobalPkgDb ===================================== docs/users_guide/debug-info.rst ===================================== @@ -14,6 +14,7 @@ useable by most UNIX debugging tools. :category: debugging :since: 7.10, numeric levels since 8.0 + :implies: :ghc-flag:`-fexpose-all-symbols` Emit debug information in object code. Currently only DWARF debug information is supported on x86-64 and i386. Currently debug levels 0 ===================================== docs/users_guide/phases.rst ===================================== @@ -720,6 +720,20 @@ Options affecting code generation all target platforms. See the :ghc-flag:`--print-object-splitting-supported` flag to check whether your GHC supports object splitting. +.. ghc-flag:: -fexpose-all-symbols + :shortdesc: Produce symbols for all functions, including internal functions. + :type: dynamic + :category: codegen + :default: on + + By default, GHC emits verbose symbol tables which include local symbols for + module-internal functions. These can be useful for tools like :ref:`perf + ` but increase object file sizes. + + :ghc-flag:`-fno-expose-all-symbols` suppresses all non-global symbol table + entries, resulting in smaller object file sizes at the expense of + debuggability. + .. _options-linker: Options affecting linking View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d108b65efe79930586b86b4d027d81e5797338b8...566ebbd9ddd7695ce4cb1939d917747a769bc32b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d108b65efe79930586b86b4d027d81e5797338b8...566ebbd9ddd7695ce4cb1939d917747a769bc32b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 21:05:20 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 17:05:20 -0400 Subject: [Git][ghc/ghc][wip/keepAlive-the-return-of-the-primop] Fix Message-ID: <5f973a10ceb12_8973fa3a65ef6bc4358f3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/keepAlive-the-return-of-the-primop at Glasgow Haskell Compiler / GHC Commits: 435a4b08 by Ben Gamari at 2020-10-26T17:05:10-04:00 Fix - - - - - 1 changed file: - libraries/base/GHC/ForeignPtr/Ops.hs Changes: ===================================== libraries/base/GHC/ForeignPtr/Ops.hs ===================================== @@ -51,9 +51,7 @@ module GHC.ForeignPtr.Ops import GHC.Word import GHC.Int import GHC.Base -import GHC.Prim import GHC.ForeignPtr -import GHC.Magic peekWord8ForeignPtr :: ForeignPtr ty -> Int -> IO Word8 peekWord8ForeignPtr (ForeignPtr addr c) (I# d) = IO $ \s0 -> View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435a4b0898db0df3359d2b962c8da735eae48dc9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/435a4b0898db0df3359d2b962c8da735eae48dc9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 21:08:05 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 17:08:05 -0400 Subject: [Git][ghc/ghc][wip/T17605] 4 commits: nativeGen/dwarf: Fix procedure end addresses Message-ID: <5f973ab5b7c8_8973fa3d96188cc436575@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17605 at Glasgow Haskell Compiler / GHC Commits: 98d6d845 by Ben Gamari at 2020-10-26T17:07:55-04:00 nativeGen/dwarf: Fix procedure end addresses Previously the `.debug_aranges` and `.debug_info` (DIE) DWARF information would claim that procedures (represented with a `DW_TAG_subprogram` DIE) would only span the range covered by their entry block. This omitted all of the continuation blocks (represented by `DW_TAG_lexical_block` DIEs), confusing `perf`. Fix this by introducing a end-of-procedure label and using this as the `DW_AT_high_pc` of procedure `DW_TAG_subprogram` DIEs Fixes #17605. - - - - - 9d60b61f by Ben Gamari at 2020-10-26T17:07:55-04:00 nativeGen/dwarf: Only produce DW_AT_source_note DIEs in -g3 Standard debugging tools don't know how to understand these so let's not produce them unless asked. - - - - - ebf04add by Ben Gamari at 2020-10-26T17:07:55-04:00 nativeGen/dwarf: Use DW_AT_linkage instead of DW_AT_MIPS_linkage - - - - - 1fac3b52 by Ben Gamari at 2020-10-26T17:07:55-04:00 gitlab-ci: Add DWARF release jobs for Debian 10, Fedora27 - - - - - 9 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - docs/users_guide/debug-info.rst Changes: ===================================== .gitlab-ci.yml ===================================== @@ -719,6 +719,15 @@ release-x86_64-linux-deb10: <<: *release extends: .build-x86_64-linux-deb10 +release-x86_64-linux-deb10-dwarf: + <<: *release + extends: .build-x86_64-linux-deb10 + variables: + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + TEST_ENV: "x86_64-linux-deb10-dwarf" + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-deb10-linux-dwarf.tar.xz" + ################################# # x86_64-linux-ubuntu 20.04 ################################# @@ -834,7 +843,7 @@ release-x86_64-linux-centos7: # x86_64-linux-fedora27 ################################# -validate-x86_64-linux-fedora27: +.build-x86_64-linux-fedora27: extends: .validate-linux stage: full-build image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV" @@ -843,7 +852,6 @@ validate-x86_64-linux-fedora27: LLC: /bin/false OPT: /bin/false TEST_ENV: "x86_64-linux-fedora27" - BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" cache: key: linux-x86_64-fedora27 artifacts: @@ -852,6 +860,20 @@ validate-x86_64-linux-fedora27: # longer. expire_in: 8 week +validate-x86_64-linux-fedora27: + extends: .build-x86_64-linux-fedora27 + variables: + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux.tar.xz" + +release-x86_64-linux-fedora27-dwarf: + <<: *release + extends: .build-x86_64-linux-fedora27 + variables: + CONFIGURE_ARGS: "--enable-dwarf-unwind" + BUILD_FLAVOUR: dwarf + BIN_DIST_PREP_TAR_COMP: "ghc-x86_64-fedora27-linux-dwarf.tar.xz" + TEST_ENV: "x86_64-linux-fedora27-dwarf" + ############################################################ # Validation via Pipelines (Windows) ############################################################ ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -44,6 +44,7 @@ module GHC.Cmm.CLabel ( mkAsmTempLabel, mkAsmTempDerivedLabel, mkAsmTempEndLabel, + mkAsmTempProcEndLabel, mkAsmTempDieLabel, mkDirty_MUT_VAR_Label, @@ -754,6 +755,10 @@ mkAsmTempDerivedLabel = AsmTempDerivedLabel mkAsmTempEndLabel :: CLabel -> CLabel mkAsmTempEndLabel l = mkAsmTempDerivedLabel l (fsLit "_end") +-- | A label indicating the end of a procedure. +mkAsmTempProcEndLabel :: CLabel -> CLabel +mkAsmTempProcEndLabel l = mkAsmTempDerivedLabel l (fsLit "_proc_end") + -- | Construct a label for a DWARF Debug Information Entity (DIE) -- describing another symbol. mkAsmTempDieLabel :: CLabel -> CLabel ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -1190,8 +1190,9 @@ initNCGConfig dflags = NCGConfig ArchX86 -> v _ -> Nothing - , ncgDwarfEnabled = debugLevel dflags > 0 + , ncgDwarfEnabled = debugLevel dflags > 0 , ncgDwarfUnwindings = debugLevel dflags >= 1 - , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. + , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. + , ncgDwarfSourceNotes = debugLevel dflags >= 3 -- We produce GHC-specific source-note DIEs only with -g3 } ===================================== compiler/GHC/CmmToAsm/Config.hs ===================================== @@ -37,6 +37,7 @@ data NCGConfig = NCGConfig , ncgDwarfEnabled :: !Bool -- ^ Enable Dwarf generation , ncgDwarfUnwindings :: !Bool -- ^ Enable unwindings , ncgDwarfStripBlockInfo :: !Bool -- ^ Strip out block information from generated Dwarf + , ncgDwarfSourceNotes :: !Bool -- ^ Enable GHC-specific source note DIEs } -- | Return Word size ===================================== compiler/GHC/CmmToAsm/Dwarf.hs ===================================== @@ -99,10 +99,10 @@ dwarfGen config modLoc us blocks = do -- scattered in the final binary. Without split sections, we could make a -- single arange based on the first/last proc. mkDwarfARange :: DebugBlock -> DwarfARange -mkDwarfARange proc = DwarfARange start end +mkDwarfARange proc = DwarfARange lbl end where - start = dblCLabel proc - end = mkAsmTempEndLabel start + lbl = dblCLabel proc + end = mkAsmTempProcEndLabel lbl -- | Header for a compilation unit, establishing global format -- parameters @@ -195,14 +195,17 @@ procToDwarf config prc goodParent _ = True -- | Generate DWARF info for a block -blockToDwarf :: DebugBlock -> DwarfInfo -blockToDwarf blk - = DwarfBlock { dwChildren = concatMap tickToDwarf (dblTicks blk) - ++ map blockToDwarf (dblBlocks blk) +blockToDwarf :: NCGConfig -> DebugBlock -> DwarfInfo +blockToDwarf config blk + = DwarfBlock { dwChildren = map blockToDwarf (dblBlocks blk) ++ srcNotes , dwLabel = dblCLabel blk , dwMarker = marker } where + srcNotes + | ncgDwarfSourceNotes config = concatMap tickToDwarf (dblTicks blk) + | otherwise = [] + marker | Just _ <- dblPosition blk = Just $ mkAsmTempLabel $ dblLabel blk | otherwise = Nothing -- block was optimized out ===================================== compiler/GHC/CmmToAsm/Dwarf/Constants.hs ===================================== @@ -48,7 +48,7 @@ dW_TAG_ghc_src_note = 0x5b00 -- * Dwarf attributes dW_AT_name, dW_AT_stmt_list, dW_AT_low_pc, dW_AT_high_pc, dW_AT_language, dW_AT_comp_dir, dW_AT_producer, dW_AT_external, dW_AT_frame_base, - dW_AT_use_UTF8, dW_AT_MIPS_linkage_name :: Word + dW_AT_use_UTF8, dW_AT_linkage_name :: Word dW_AT_name = 0x03 dW_AT_stmt_list = 0x10 dW_AT_low_pc = 0x11 @@ -59,7 +59,7 @@ dW_AT_producer = 0x25 dW_AT_external = 0x3f dW_AT_frame_base = 0x40 dW_AT_use_UTF8 = 0x53 -dW_AT_MIPS_linkage_name = 0x2007 +dW_AT_linkage_name = 0x6e -- * Custom DWARF attributes -- Chosen a more or less random section of the vendor-extensible region ===================================== compiler/GHC/CmmToAsm/Dwarf/Types.hs ===================================== @@ -105,7 +105,7 @@ pprAbbrevDecls platform haveDebugLine = -- DwAbbrSubprogramWithParent subprogramAttrs = [ (dW_AT_name, dW_FORM_string) - , (dW_AT_MIPS_linkage_name, dW_FORM_string) + , (dW_AT_linkage_name, dW_FORM_string) , (dW_AT_external, dW_FORM_flag) , (dW_AT_low_pc, dW_FORM_addr) , (dW_AT_high_pc, dW_FORM_addr) @@ -190,7 +190,7 @@ pprDwarfInfoOpen platform _ (DwarfSubprogram _ name label parent) = $$ pprLabelString platform label $$ pprFlag (externallyVisibleCLabel label) $$ pprWord platform (pdoc platform label) - $$ pprWord platform (pdoc platform $ mkAsmTempEndLabel label) + $$ pprWord platform (pdoc platform $ mkAsmTempProcEndLabel label) $$ pprByte 1 $$ pprByte dW_OP_call_frame_cfa $$ parentValue ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -92,8 +92,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = pprProcAlignment config $$ pprLabel platform lbl $$ -- blocks guaranteed not null, so label needed vcat (map (pprBasicBlock config top_info) blocks) $$ - (if ncgDwarfEnabled config - then pdoc platform (mkAsmTempEndLabel lbl) <> char ':' else empty) $$ + ppWhen (ncgDwarfEnabled config) (pprBlockEndLabel lbl $$ pprProcEndLabel lbl) $$ pprSizeDecl platform lbl Just (CmmStaticsRaw info_lbl _) -> @@ -103,6 +102,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = then pdoc platform (mkDeadStripPreventer info_lbl) <> char ':' else empty) $$ vcat (map (pprBasicBlock config top_info) blocks) $$ + ppWhen (ncgDwarfEnabled config) (pprProcEndLabel info_lbl) $$ -- above: Even the first block gets a label, because with branch-chain -- elimination, it might be the target of a goto. (if platformHasSubsectionsViaSymbols platform @@ -114,6 +114,17 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = else empty) $$ pprSizeDecl platform info_lbl +pprProcEndLabel :: CLabel -- ^ Procedure name + -> SDoc +pprProcEndLabel lbl = + ppr (mkAsmTempProcEndLabel lbl) <> char ':' + +pprBlockEndLabel :: CLabel -- ^ Block name + -> SDoc +pprBlockEndLabel lbl = + ppr (mkAsmTempEndLabel lbl) <> char ':' + + -- | Output the ELF .size directive. pprSizeDecl :: Platform -> CLabel -> SDoc pprSizeDecl platform lbl @@ -126,10 +137,7 @@ pprBasicBlock config info_env (BasicBlock blockid instrs) = maybe_infotable $ pprLabel platform asmLbl $$ vcat (map (pprInstr platform) instrs) $$ - (if ncgDwarfEnabled config - then pdoc (ncgPlatform config) (mkAsmTempEndLabel asmLbl) <> char ':' - else empty - ) + ppWhen (ncgDwarfEnabled config) (pprBlockEndLabel asmLbl) where asmLbl = blockLbl blockid platform = ncgPlatform config @@ -141,10 +149,8 @@ pprBasicBlock config info_env (BasicBlock blockid instrs) vcat (map (pprData config) info) $$ pprLabel platform infoLbl $$ c $$ - (if ncgDwarfEnabled config - then pdoc platform (mkAsmTempEndLabel infoLbl) <> char ':' - else empty - ) + ppWhen (ncgDwarfEnabled config) (pdoc platform (mkAsmTempEndLabel infoLbl) <> char ':') + -- Make sure the info table has the right .loc for the block -- coming right after it. See [Note: Info Offset] infoTableLoc = case instrs of ===================================== docs/users_guide/debug-info.rst ===================================== @@ -23,7 +23,9 @@ useable by most UNIX debugging tools. * ``-g1``: produces stack unwinding records for top-level functions (sufficient for basic backtraces) * ``-g2``: produces stack unwinding records for top-level functions as well as inner blocks (allowing more precise backtraces than with ``-g1``). - * ``-g3``: same as ``-g2``. + * ``-g3``: produces GHC-specific DWARF information for use by more + sophisticated Haskell-aware debugging tools (see :ref:`dwarf-dies` for + details) If ⟨n⟩ is omitted, level 2 is assumed. @@ -265,6 +267,7 @@ In particular GHC produces the following DWARF sections, ``.debug_arange`` Address range information necessary for efficient lookup in debug information. +.. _dwarf_dies: Debugging information entities ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd153e5796e4fbe57c2ee9a989f4541d6f63b898...1fac3b522979a24f67a639d749ccbfbd799cdff2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd153e5796e4fbe57c2ee9a989f4541d6f63b898...1fac3b522979a24f67a639d749ccbfbd799cdff2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 21:22:05 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Mon, 26 Oct 2020 17:22:05 -0400 Subject: [Git][ghc/ghc][wip/local-symbols-2] 2 commits: codeGen: Produce local symbols for module-internal functions Message-ID: <5f973dfd4a0e7_8973fa3b908ec284373f6@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/local-symbols-2 at Glasgow Haskell Compiler / GHC Commits: 49c69308 by Ben Gamari at 2020-10-26T17:21:57-04:00 codeGen: Produce local symbols for module-internal functions It turns out that some important native debugging/profiling tools (e.g. perf) rely only on symbol tables for function name resolution (as opposed to using DWARF DIEs). However, previously GHC would emit temporary symbols (e.g. `.La42b`) to identify module-internal entities. Such symbols are dropped during linking and therefore not visible to runtime tools (in addition to having rather un-helpful unique names). For instance, `perf report` would often end up attributing all cost to the libc `frame_dummy` symbol since Haskell code was no covered by any proper symbol (see #17605). We now rather follow the model of C compilers and emit descriptively-named local symbols for module internal things. Since this will increase object file size this behavior can be disabled with the `-fno-expose-all-symbols` flag. With this `perf record` can finally be used against Haskell executables. Even more, with `-g3` `perf annotate` provides inline source code. - - - - - 6a977ea5 by Ben Gamari at 2020-10-26T17:21:57-04:00 Enable -fexpose-all-symbols when debug level is set - - - - - 9 changed files: - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/debug-info.rst - docs/users_guide/phases.rst Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -118,6 +118,7 @@ module GHC.Cmm.CLabel ( LabelStyle (..), pprDebugCLabel, pprCLabel, + ppInternalProcLabel, -- * Others dynamicLinkerLabelInfo, @@ -1360,6 +1361,39 @@ pprCLabel platform sty lbl = CmmLabel _ _ fs CmmRet -> maybe_underscore $ ftext fs <> text "_ret" CmmLabel _ _ fs CmmClosure -> maybe_underscore $ ftext fs <> text "_closure" +-- Note [Internal proc labels] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Some tools (e.g. the `perf` utility on Linux) rely on the symbol table +-- for resolution of function names. To help these tools we provide the +-- (enabled by default) -fexpose-all-symbols flag which causes GHC to produce +-- symbols even for symbols with are internal to a module (although such +-- symbols will have only local linkage). +-- +-- Note that these labels are *not* referred to by code. They are strictly for +-- diagnostics purposes. +-- +-- To avoid confusion, it is desireable to add a module-qualifier to the +-- symbol name. However, the Name type's Internal constructor doesn't carry +-- knowledge of the current Module. Consequently, we have to pass this around +-- explicitly. + +-- | Generate a label for a procedure internal to a module (if +-- 'Opt_ExposeAllSymbols' is enabled). +-- See Note [Internal proc labels]. +ppInternalProcLabel :: Module -- ^ the current module + -> CLabel + -> Maybe SDoc -- ^ the internal proc label +ppInternalProcLabel this_mod (IdLabel nm _ flavour) + | isInternalName nm + = Just + $ text "_" <> ppr this_mod + <> char '_' + <> ztext (zEncodeFS (occNameFS (occName nm))) + <> char '_' + <> pprUniqueAlways (getUnique nm) + <> ppIdFlavor flavour +ppInternalProcLabel _ _ = Nothing ppIdFlavor :: IdLabelInfo -> SDoc ppIdFlavor x = pp_cSEP <> case x of ===================================== compiler/GHC/CmmToAsm.hs ===================================== @@ -1192,5 +1192,6 @@ initNCGConfig dflags this_mod = NCGConfig , ncgDwarfEnabled = debugLevel dflags > 0 , ncgDwarfUnwindings = debugLevel dflags >= 1 , ncgDwarfStripBlockInfo = debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. + , ncgExposeInternalSymbols = gopt Opt_ExposeInternalSymbols dflags } ===================================== compiler/GHC/CmmToAsm/Config.hs ===================================== @@ -18,8 +18,7 @@ import GHC.Utils.Outputable data NCGConfig = NCGConfig { ncgPlatform :: !Platform -- ^ Target platform , ncgAsmContext :: !SDocContext -- ^ Context for ASM code generation - , ncgThisModule :: !Module -- ^ The name of the module we are currently compiling (for generating debug information) - -- See Note [Internal proc labels] in CLabel. + , ncgThisModule :: !Module -- ^ The name of the module we are currently compiling , ncgProcAlignment :: !(Maybe Int) -- ^ Mandatory proc alignment , ncgExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , ncgPIC :: !Bool -- ^ Enable Position-Independent Code @@ -40,6 +39,7 @@ data NCGConfig = NCGConfig , ncgDwarfEnabled :: !Bool -- ^ Enable Dwarf generation , ncgDwarfUnwindings :: !Bool -- ^ Enable unwindings , ncgDwarfStripBlockInfo :: !Bool -- ^ Strip out block information from generated Dwarf + , ncgExposeInternalSymbols :: !Bool -- ^ Expose symbol table entries for internal symbols } -- | Return Word size ===================================== compiler/GHC/CmmToAsm/Monad.hs ===================================== @@ -80,6 +80,8 @@ data NcgImpl statics instr jumpDest = NcgImpl { canShortcut :: instr -> Maybe jumpDest, shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics, shortcutJump :: (BlockId -> Maybe jumpDest) -> instr -> instr, + -- | 'Module' is only for printing internal labels. See Note [Internal proc + -- labels] in CLabel. pprNatCmmDecl :: NatCmmDecl statics instr -> SDoc, maxSpillSlots :: Int, allocatableRegs :: [RealReg], ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -90,6 +90,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = -- special case for code without info table: pprSectionAlign config (Section Text lbl) $$ pprProcAlignment config $$ + pprProcLabel config lbl $$ pprLabel platform lbl $$ -- blocks guaranteed not null, so label needed vcat (map (pprBasicBlock config top_info) blocks) $$ (if ncgDwarfEnabled config @@ -99,6 +100,7 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = Just (CmmStaticsRaw info_lbl _) -> pprSectionAlign config (Section Text info_lbl) $$ pprProcAlignment config $$ + pprProcLabel config lbl $$ (if platformHasSubsectionsViaSymbols platform then pdoc platform (mkDeadStripPreventer info_lbl) <> char ':' else empty) $$ @@ -114,6 +116,15 @@ pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) = else empty) $$ pprSizeDecl platform info_lbl +-- | Output an internal proc label. See Note [Internal proc labels] in CLabel. +pprProcLabel :: NCGConfig -> CLabel -> SDoc +pprProcLabel config lbl + | ncgExposeInternalSymbols config + , Just lbl' <- ppInternalProcLabel (ncgThisModule config) lbl + = lbl' <> char ':' + | otherwise + = empty + -- | Output the ELF .size directive. pprSizeDecl :: Platform -> CLabel -> SDoc pprSizeDecl platform lbl ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -274,6 +274,7 @@ data GeneralFlag -- forwards all -L flags to the collect2 command without using a -- response file and as such breaking apart. | Opt_SingleLibFolder + | Opt_ExposeInternalSymbols | Opt_KeepCAFs | Opt_KeepGoing | Opt_ByteCode ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -376,7 +376,6 @@ import qualified GHC.LanguageExtensions as LangExt -- ----------------------------------------------------------------------------- -- DynFlags - -- | Used to differentiate the scope an include needs to apply to. -- We have to split the include paths to avoid accidentally forcing recursive -- includes since -I overrides the system search paths. See #14312. @@ -3404,6 +3403,7 @@ fFlagsDeps = [ flagSpec "error-spans" Opt_ErrorSpans, flagSpec "excess-precision" Opt_ExcessPrecision, flagSpec "expose-all-unfoldings" Opt_ExposeAllUnfoldings, + flagSpec "expose-internal-symbols" Opt_ExposeInternalSymbols, flagSpec "external-dynamic-refs" Opt_ExternalDynamicRefs, flagSpec "external-interpreter" Opt_ExternalInterpreter, flagSpec "flat-cache" Opt_FlatCache, @@ -4392,7 +4392,13 @@ setVerbosity :: Maybe Int -> DynP () setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 }) setDebugLevel :: Maybe Int -> DynP () -setDebugLevel mb_n = upd (\dfs -> dfs{ debugLevel = mb_n `orElse` 2 }) +setDebugLevel mb_n = + upd (\dfs -> exposeSyms $ dfs{ debugLevel = n }) + where + n = mb_n `orElse` 2 + exposeSyms + | n > 0 = setGeneralFlag' Opt_ExposeInternalSymbols + | otherwise = id data PkgDbRef = GlobalPkgDb ===================================== docs/users_guide/debug-info.rst ===================================== @@ -14,6 +14,7 @@ useable by most UNIX debugging tools. :category: debugging :since: 7.10, numeric levels since 8.0 + :implies: :ghc-flag:`-fexpose-all-symbols` Emit debug information in object code. Currently only DWARF debug information is supported on x86-64 and i386. Currently debug levels 0 ===================================== docs/users_guide/phases.rst ===================================== @@ -720,6 +720,20 @@ Options affecting code generation all target platforms. See the :ghc-flag:`--print-object-splitting-supported` flag to check whether your GHC supports object splitting. +.. ghc-flag:: -fexpose-internal-symbols + :shortdesc: Produce symbols for all functions, including internal functions. + :type: dynamic + :category: codegen + + Request that GHC emits verbose symbol tables which include local symbols + for module-internal functions. These can be useful for tools like + :ref:`perf ` but increase object file sizes. + This is implied by :ghc-flag:`-g2` and above. + + :ghc-flag:`-fno-expose-internal-symbols` suppresses all non-global symbol + table entries, resulting in smaller object file sizes at the expense of + debuggability. + .. _options-linker: Options affecting linking View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/566ebbd9ddd7695ce4cb1939d917747a769bc32b...6a977ea5f9ac560568a9a3e5bfa90c0936b25cb9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/566ebbd9ddd7695ce4cb1939d917747a769bc32b...6a977ea5f9ac560568a9a3e5bfa90c0936b25cb9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Mon Oct 26 23:29:39 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Mon, 26 Oct 2020 19:29:39 -0400 Subject: [Git][ghc/ghc][wip/az/exactprint] 52 commits: Fall back to types when looking up data constructors (#18740) Message-ID: <5f975be37d92f_8973fa3a78324dc45821f@gitlab.haskell.org.mail> Alan Zimmerman pushed to branch wip/az/exactprint at Glasgow Haskell Compiler / GHC Commits: 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 3eafc771 by Alan Zimmerman at 2020-10-26T22:11:15+00:00 Proof of Concept implementation of in-tree API Annotations This MR introduces a possible machinery to introduce API Annotations into the TTG extension points. It is intended to be a concrete example for discussion. It still needs to process comments. ---- Work in progress, adding more TTG extensions for annotations. And fixing ppr round-trip tests by being able to blank out in-tree annotations, as done with SrcSpans. This is needed for the case of class Foo a where for which current ppr does not print the "where". Rename AA to AddApiAnn and AA to AddAnn Add XConPatIn and XConPatOut Rebase ---- First pass at bringing in LocatedA for API anns in locations Treatment of ECP in parsing is provisional at this stage, leads to some horribly stuff in Parser.y and RdrHsSyn. It is an extensive but not invasive change. I think (AZ). Locally it reports some parsing tests using less memory. Add ApiAnns to the HsExpr data structure. rebase. Change HsMatchContext and HsStmtContext to use an id, not a GhcPass parameter. Add ApiAnns to Hs/Types Rebase Rebased 2020-03-25 WIP on in-tree annotations Includes updating HsModule Imports LocateA ImportDecl so we can hang AnnSemi off it A whole bunch of stuff more InjectivityAnn and FamEqn now have annotations in them Add annotations to context srcspan ---- In-tree annotations: LHsDecl and LHsBind LocatedA ---- WIP on in-tree annotations ---- in-tree annotations: LHsType is now LocatedA ---- FunDeps is now also a HS data type ---- WIP. Added LocatedA to Pat, Expr, Decl And worked some more through Parser.y ---- LStmt now Located ---- Finished working through Parser.y, tests seem ok failures relate to annotations. Adding test infrastructure for check-exact Like check-ppr, but checking for an exact reproduction of the parsed source file. Starting to work on actual exact printer Bring in ApiAnnName As an alternative for LocatedA, to be used for names only. Carrying extra name adornments, such as locations of backticks, parens, etc. Working on changing ApiAnnName to accurately reflect actual usage Get rid of AnnApiName in favour of LocatedN Working on check-exact. Making progress Working on the ghc-exact bit Progress, can reproduce the first Test.hs file. Move API Annotations out of the extensions to annotations Remove LHsLocalBinds Fix up after rebasing to bring in XRec Main thing is to make type instance XRec (GhcPass p) a = GenLocated (Anno a) a type family Anno a = b But this has massive implications. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Data/OrdList.hs - compiler/GHC/Driver/Backpack.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/020b027bc2c6995bd523ec9d8998513bad21f60b...3eafc77103486f4b39ca2db6083532f03f7f5e7e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/020b027bc2c6995bd523ec9d8998513bad21f60b...3eafc77103486f4b39ca2db6083532f03f7f5e7e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 00:38:44 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Mon, 26 Oct 2020 20:38:44 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: build system: Clean mingw tarballs Message-ID: <5f976c1478120_8973fa3d9bcfe64471359@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: c9437bbc by Ben Gamari at 2020-10-26T20:38:29-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 209ece69 by Simon Peyton Jones at 2020-10-26T20:38:29-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 2c6bac6d by Sergei Trofimovich at 2020-10-26T20:38:30-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 3c239748 by David Eichmann at 2020-10-26T20:38:31-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e313b385 by Alan Zimmerman at 2020-10-26T20:38:32-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - 83606bea by Sylvain Henry at 2020-10-26T20:38:36-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 81436b69 by Ben Gamari at 2020-10-26T20:38:36-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/29cf005404d976672233e2704dfcf3820171340d...81436b69240c3403dabe00f4aece7c968b5d76c1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/29cf005404d976672233e2704dfcf3820171340d...81436b69240c3403dabe00f4aece7c968b5d76c1 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 02:52:52 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Mon, 26 Oct 2020 22:52:52 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 4 commits: Revert "[AArch64] Aarch64 Always PIC" Message-ID: <5f978b84b21c0_8973fa31b424f48486336@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: a3b232d7 by Moritz Angermann at 2020-10-26T21:05:55+08:00 Revert "[AArch64] Aarch64 Always PIC" This reverts commit 921276592218211f441fcf011fc52441e3a2f0a6. - - - - - e85f6825 by Moritz Angermann at 2020-10-26T21:07:26+08:00 Revert "[Storage/Adjustor] Drop size check in allocExec" This reverts commit 37a62ae956a25e5832fbe125a4d8ee556fd11042. - - - - - a71ece1b by Moritz Angermann at 2020-10-26T21:10:43+08:00 [Storage] Reinstate check; add comment. - - - - - 0f7df369 by Moritz Angermann at 2020-10-27T10:52:25+08:00 [AArch64] Aarch64 Always PIC - - - - - 2 changed files: - compiler/GHC/Driver/Session.hs - rts/sm/Storage.c Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3817,8 +3817,10 @@ validHoleFitsImpliedGFlags default_PIC :: Platform -> [GeneralFlag] default_PIC platform = case (platformOS platform, platformArch platform) of - (OSDarwin, ArchX86_64) -> [Opt_PIC] - (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in + (OSDarwin, ArchX86_64) -> [Opt_PIC] + (OSDarwin, ArchAarch64) -> [Opt_PIC] + (OSLinux, ArchAarch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] + (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in -- OpenBSD since 5.3 release -- (1 May 2013) we need to -- always generate PIC. See @@ -5111,4 +5113,3 @@ initSDocContext dflags style = SDC -- | Initialize the pretty-printing options using the default user style initDefaultSDocContext :: DynFlags -> SDocContext initDefaultSDocContext dflags = initSDocContext dflags defaultUserStyle - ===================================== rts/sm/Storage.c ===================================== @@ -1751,6 +1751,14 @@ AdjustorWritable allocateExec(W_ bytes, AdjustorExecutable *exec_ret) { AdjustorWritable writ; ffi_closure* cl; + // This check is necessary as we can't use allocateExec for anything *but* + // ffi_closures on ios/darwin on arm. libffi does some heavy lifting to + // get around the X^W restrictions, and we can't just use this codepath + // to allocate generic executable space. For those cases we have to refer + // back to allocateWrite/markExec/freeWrite (see above.) + if (bytes != sizeof(ffi_closure)) { + barf("allocateExec: for ffi_closure only"); + } ACQUIRE_SM_LOCK; cl = writ = ffi_closure_alloc((size_t)bytes, exec_ret); if (cl != NULL) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5764bca329c18619598fbe99433f581a119a5898...0f7df369abfd5b17fcde67a4aea11d425baafb65 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5764bca329c18619598fbe99433f581a119a5898...0f7df369abfd5b17fcde67a4aea11d425baafb65 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 03:23:11 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Mon, 26 Oct 2020 23:23:11 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] 2 commits: Some small changes, mostly comments. Message-ID: <5f97929f21c04_897e1760ac488093@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 4e538977 by Richard Eisenberg at 2020-10-26T21:48:36-04:00 Some small changes, mostly comments. - - - - - 3cf175e0 by Richard Eisenberg at 2020-10-26T23:22:46-04:00 Fix #18875 by breaking type variable cycles. - - - - - 11 changed files: - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Utils/TcMType.hs - testsuite/tests/indexed-types/should_fail/Simple13.hs → testsuite/tests/indexed-types/should_compile/Simple13.hs - testsuite/tests/indexed-types/should_compile/all.T - testsuite/tests/indexed-types/should_fail/all.T - testsuite/tests/typecheck/should_fail/all.T Changes: ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -29,7 +29,7 @@ module GHC.Core.Type ( mkAppTy, mkAppTys, splitAppTy, splitAppTys, repSplitAppTys, splitAppTy_maybe, repSplitAppTy_maybe, tcRepSplitAppTy_maybe, - mkVisFunTy, mkInvisFunTy, + mkFunTy, mkVisFunTy, mkInvisFunTy, mkVisFunTys, mkVisFunTyMany, mkInvisFunTyMany, mkVisFunTysMany, mkInvisFunTysMany, ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1003,9 +1003,11 @@ unify_ty env ty1 (TyVarTy tv2) kco = uVar (umSwapRn env) tv2 ty1 (mkSymCo kco) unify_ty env ty1 ty2 _kco + -- NB: This keeps Constraint and Type distinct, as it should for use in the + -- type-checker. | Just (tc1, tys1) <- mb_tc_app1 , Just (tc2, tys2) <- mb_tc_app2 - , tc1 == tc2 || (tcIsLiftedTypeKind ty1 && tcIsLiftedTypeKind ty2) + , tc1 == tc2 = if isInjectiveTyCon tc1 Nominal then unify_tys env tys1 tys2 else do { let inj | isTypeFamilyTyCon tc1 ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -2305,12 +2305,18 @@ canEqCanLHSFinish ev eq_rel swapped lhs rhs , TyVarLHS lhs_tv <- lhs , NomEq <- eq_rel -> do { traceTcS "canEqCanLHSFinish breaking a cycle" (ppr lhs $$ ppr rhs) - ; new_rhs <- breakTyVarCycle lhs_tv rhs + ; new_rhs <- breakTyVarCycle (ctEvLoc ev) rhs ; traceTcS "new RHS:" (ppr new_rhs) ; let new_pred = mkPrimEqPred (mkTyVarTy lhs_tv) new_rhs new_new_ev = new_ev { ctev_pred = new_pred } - ; continueWith (CEqCan { cc_ev = new_new_ev, cc_lhs = lhs - , cc_rhs = new_rhs, cc_eq_rel = eq_rel }) } + -- See Detail (6) of Note [Type variable cycles in Givens] + + ; if anyRewritableTyVar True NomEq (\ _ tv -> tv == lhs_tv) new_rhs + then do { traceTcS "Note [Type variable cycles in Givens] Detail (1)" + (ppr new_new_ev) + ; continueWith (mkIrredCt status new_ev) } + else continueWith (CEqCan { cc_ev = new_new_ev, cc_lhs = lhs + , cc_rhs = new_rhs, cc_eq_rel = eq_rel }) } -- We must not use it for further rewriting! | otherwise @@ -2610,43 +2616,39 @@ Instead, we detect this scenario by the following characteristics: - a Given CEqCan constraint - with a tyvar on its LHS - with a soluble occurs-check failure + - and a nominal equality -Having identified the scenario, we create a fresh untouchable metavariable a' -(with MetaInfo CycleBreakerTv), and replace all occurrences of `a` in the RHS -with a'. This is done by breakTyVarCycle. We have now disrupted the -occurs-check problem and can make the CEqCan. +Having identified the scenario, we wish to replace all type family +applications on the RHS with fresh metavariables (with MetaInfo +CycleBreakerTv). This is done in breakTyVarCycle. These metavariables are +untouchable, but we also emit Givens relating the fresh variables to the type +family applications they replace. -Of course, we don't want a' leaking into e.g. error messages. So we -restore the cycles by setting a' := a after we're done running the -solver (in nestImplicTcS and runTcSWithEvBinds). This is done by -restoreTyVarCycles, which uses the inert_tv_cycles field in InertSet, -which contains the pairings invented in breakTyVarCycle. +Of course, we don't want our fresh variables leaking into e.g. error messages. +So we fill in the metavariables with their original type family applications +after we're done running the solver (in nestImplicTcS and runTcSWithEvBinds). +This is done by restoreTyVarCycles, which uses the inert_cycle_breakers field in +InertSet, which contains the pairings invented in breakTyVarCycle. -Note that we don't have to think about evidence here, because the -loop-breaker variable just gets zonked right back to the original -one. By the time we examine the evidence, all traces of this trick -are very long gone. +In our example, we start with -There are drawbacks of this approach: + [G] a ~ Maybe (F a) - 1. This trick allows us to use a loopy Given once, but not twice. - And it's possible for twice to be necessary. #18875: +We then change this to become - type family G a b where - G (Maybe c) d = d + [G] a ~ Maybe cbv + [G] F a ~ cbv - h :: (e ~ Maybe (G e f)) => e -> f - h (Just x) = x +and set cbv := F a after we're done solving. - In order to accept this, we have to use the Given twice, in order - for G e f to reduce to show that e ~ Maybe f. +There are drawbacks of this approach: - 2. We apply this trick only for Givens, never for Wanted or Derived. + 1. We apply this trick only for Givens, never for Wanted or Derived. It wouldn't make sense for Wanted, because Wanted never rewrite. But it's conceivable that a Derived would benefit from this all. I doubt it would ever happen, though, so I'm holding off. - 3. We don't use this trick for representational equalities, as there + 2. We don't use this trick for representational equalities, as there is no concrete use case where it is helpful (unlike for nominal equalities). Furthermore, because function applications can be CanEqLHSs, but newtype applications cannot, the disparities between @@ -2658,8 +2660,56 @@ There are drawbacks of this approach: f :: (Coercible a (N a b), Coercible (N a b) b) => a -> b f = coerce - failed with "Could not match 'b' with 'b'." Further work is saved - for when we have a concrete incentive to explore this dark corner. + failed with "Could not match 'b' with 'b'." Further work is held off + until when we have a concrete incentive to explore this dark corner. + +Details: + + (1) We don't look under foralls, at all, when substituting away type family + applications, because doing so can never be fruitful. Recall that we + are in a case like [G] a ~ forall b. ... a .... Until we have a type + family that can pull the body out from a forall, this will always be + insoluble. Note also that the forall cannot be in an argument to a + type family, or that outer type family application would already have + been substituted away. + + However, we still must check to make sure that breakTyVarCycle actually + succeeds in getting rid of all occurrences of the offending variable. + If one is hidden under a forall, this won't be true. So we perform + an additional check after performing the substitution. + + Skipping this check causes typecheck/should_fail/GivenForallLoop to loop. + + (2) Our goal here is to avoid loops in rewriting. We can thus skip looking + in coercions, as we don't rewrite in coercions. + + (3) As we're substituting, we can build ill-kinded + types. For example, if we have Proxy (F a) b, where (b :: F a), then + replacing this with Proxy cbv b is ill-kinded. However, we will later + set cbv := F a, and so the zonked type will be well-kinded again. + The temporary ill-kinded type hurts no one, and avoiding this would + be quite painfully difficult. + + (4) The evidence for the produced Givens is all just reflexive, because + we will eventually set the cycle-breaker variable to be the type family, + and then, after the zonk, all will be well. + + (5) The approach here is inefficient. For instance, we could choose to + affect only type family applications that mention the offending variable. + We could try to detect cases like a ~ (F a, F a) and use the same + tyvar to replace F a. (Cf. Note [Flattening] in GHC.Core.Unify, which + goes to this extra effort.) There may be other opportunities for + improvement. However, this is really a very small corner case, always + tickled by a user-written Given. The investment to craft a clever, + performant solution seems unworthwhile. + + (6) We often get the predicate associated with a constraint from its + evidence. We thus must not only make sure the generated CEqCan's + fields have the updated RHS type, but we must also update the + evidence itself. As in Detail (4), we don't need to change the + evidence term (as in e.g. rewriteEqEvidence) because the cycle + breaker variables are all zonked away by the time we examine the + evidence. -} ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -559,6 +559,10 @@ flatten_one :: TcType -> FlatM (Xi, Coercion) -- Postcondition: Coercion :: Xi ~ TcType -- The role on the result coercion matches the EqRel in the FlattenEnv +flatten_one ty + | Just ty' <- flattenView ty -- See Note [Flattening synonyms] + = flatten_one ty' + flatten_one xi@(LitTy {}) = do { role <- getRole ; return (xi, mkReflCo role xi) } @@ -569,16 +573,8 @@ flatten_one (TyVarTy tv) flatten_one (AppTy ty1 ty2) = flatten_app_tys ty1 [ty2] -flatten_one ty@(TyConApp tc tys) - -- Expand type synonyms that mention type families - -- on the RHS; see Note [Flattening synonyms] - | isForgetfulSynTyCon tc || not (isFamFreeTyCon tc) - , Just expanded_ty <- tcView ty - = flatten_one expanded_ty - - -- Otherwise, it's a type function application, and we have to - -- flatten it away as well, and generate a new given equality constraint - -- between the application and a newly generated flattening skolem variable. +flatten_one (TyConApp tc tys) + -- If it's a type family application, try to reduce it | isTypeFamilyTyCon tc = flatten_fam_app tc tys ===================================== compiler/GHC/Tc/Solver/Monad.hs ===================================== @@ -123,7 +123,7 @@ module GHC.Tc.Solver.Monad ( -- if the whole instance matcher simply belongs -- here - breakTyVarCycle + breakTyVarCycle, flattenView ) where #include "HsVersions.h" @@ -146,6 +146,7 @@ import GHC.Tc.Instance.Class( InstanceWhat(..), safeOverlap, instanceReturnsDict import GHC.Tc.Utils.TcType import GHC.Driver.Session import GHC.Core.Type +import qualified GHC.Core.TyCo.Rep as Rep -- this needs to be used only very locally import GHC.Core.Coercion import GHC.Core.Unify @@ -392,8 +393,8 @@ data InertSet -- Canonical Given, Wanted, Derived -- Sometimes called "the inert set" - , inert_tv_cycles :: [(TcTyVar, TcTyVar)] - -- a list of CycleBreakerTv / original tv pairs (in that order) + , inert_cycle_breakers :: [(TcTyVar, TcType)] + -- a list of CycleBreakerTv / original family applications -- used to undo the cycle-breaking needed to handle -- Note [Type variable cycles in Givens] in GHC.Tc.Solver.Canonical @@ -434,10 +435,10 @@ emptyInertCans emptyInert :: InertSet emptyInert - = IS { inert_cans = emptyInertCans - , inert_tv_cycles = [] - , inert_flat_cache = emptyFunEqs - , inert_solved_dicts = emptyDictMap } + = IS { inert_cans = emptyInertCans + , inert_cycle_breakers = [] + , inert_flat_cache = emptyFunEqs + , inert_solved_dicts = emptyDictMap } {- Note [Solved dictionaries] @@ -1397,7 +1398,7 @@ addTyEq old_eqs tv ct addCanFunEq :: FunEqMap EqualCtList -> TyCon -> [TcType] -> Ct -> FunEqMap EqualCtList addCanFunEq old_eqs fun_tc fun_args ct - = alterTcApp old_eqs (getUnique fun_tc) fun_args upd + = alterTcApp old_eqs fun_tc fun_args upd where upd (Just old_equal_ct_list) = Just $ addToEqualCtList ct old_equal_ct_list upd Nothing = Just $ [ct] @@ -1419,14 +1420,10 @@ findTyEqs icans tv = lookupDVarEnv (inert_eqs icans) tv `orElse` [] delEq :: InertCans -> CanEqLHS -> TcType -> InertCans delEq ic lhs rhs = case lhs of - TyVarLHS tv -> ic { inert_eqs = modifyDVarEnv - (filter (not . isThisOne)) - (inert_eqs ic) tv } - TyFamLHS tf args -> ic { inert_funeqs = alterTcApp - (inert_funeqs ic) - (getUnique tf) - args - upd } + TyVarLHS tv + -> ic { inert_eqs = modifyDVarEnv (filter (not . isThisOne)) (inert_eqs ic) tv } + TyFamLHS tf args + -> ic { inert_funeqs = alterTcApp (inert_funeqs ic) tf args upd } where upd (Just eq_ct_list) | null filtered = Nothing @@ -1508,11 +1505,11 @@ When adding an equality to the inerts: kickOutRewritable with Nominal, Given. See kickOutAfterUnification. -} -addInertCan :: Ct -> TcS () -- Constraints *other than* equalities +addInertCan :: Ct -> TcS () -- Precondition: item /is/ canonical -- See Note [Adding an equality to the InertCans] addInertCan ct - = do { traceTcS "insertInertCan {" $ + = do { traceTcS "addInertCan {" $ text "Trying to insert new inert item:" <+> ppr ct ; ics <- getInertCans @@ -1702,7 +1699,7 @@ kick_out_rewritable new_fr new_lhs extend_fun_eqs :: FunEqMap EqualCtList -> CanEqLHS -> EqualCtList -> FunEqMap EqualCtList extend_fun_eqs eqs (TyFamLHS fam_tc fam_args) cts - = insertTcApp eqs (getUnique fam_tc) fam_args cts + = insertTcApp eqs fam_tc fam_args cts extend_fun_eqs eqs other _cts = pprPanic "extend_fun_eqs" (ppr eqs $$ ppr other) kick_out_eqs :: (container -> CanEqLHS -> EqualCtList -> container) @@ -2338,7 +2335,7 @@ not match the requested info exactly! -} -type TcAppMap a = UniqDFM Unique (ListMap LooseTypeMap a) +type TcAppMap a = UniqDFM TyCon (ListMap LooseTypeMap a) -- Indexed by tycon then the arg types, using "loose" matching, where -- we don't require kind equality. This allows, for example, (a |> co) -- to match (a). @@ -2352,27 +2349,24 @@ isEmptyTcAppMap m = isNullUDFM m emptyTcAppMap :: TcAppMap a emptyTcAppMap = emptyUDFM -findTcApp :: TcAppMap a -> Unique -> [Type] -> Maybe a -findTcApp m u tys = do { tys_map <- lookupUDFM m u - ; lookupTM tys tys_map } +findTcApp :: TcAppMap a -> TyCon -> [Type] -> Maybe a +findTcApp m tc tys = do { tys_map <- lookupUDFM m tc + ; lookupTM tys tys_map } -delTcApp :: TcAppMap a -> Unique -> [Type] -> TcAppMap a -delTcApp m cls tys = adjustUDFM (deleteTM tys) m cls +delTcApp :: TcAppMap a -> TyCon -> [Type] -> TcAppMap a +delTcApp m tc tys = adjustUDFM (deleteTM tys) m tc -insertTcApp :: TcAppMap a -> Unique -> [Type] -> a -> TcAppMap a -insertTcApp m cls tys ct = alterUDFM alter_tm m cls +insertTcApp :: TcAppMap a -> TyCon -> [Type] -> a -> TcAppMap a +insertTcApp m tc tys ct = alterUDFM alter_tm m tc where alter_tm mb_tm = Just (insertTM tys ct (mb_tm `orElse` emptyTM)) -alterTcApp :: forall a. TcAppMap a -> Unique -> [Type] -> (Maybe a -> Maybe a) -> TcAppMap a -alterTcApp m cls tys upd = alterUDFM alter_tm m cls +alterTcApp :: forall a. TcAppMap a -> TyCon -> [Type] -> (Maybe a -> Maybe a) -> TcAppMap a +alterTcApp m tc tys upd = alterUDFM alter_tm m tc where alter_tm :: Maybe (ListMap LooseTypeMap a) -> Maybe (ListMap LooseTypeMap a) alter_tm m_elt = Just (alterTM tys upd (m_elt `orElse` emptyTM)) --- mapTcApp :: (a->b) -> TcAppMap a -> TcAppMap b --- mapTcApp f = mapUDFM (mapTM f) - filterTcAppMap :: (Ct -> Bool) -> TcAppMap Ct -> TcAppMap Ct filterTcAppMap f m = mapUDFM do_tm m @@ -2457,7 +2451,7 @@ findDict m loc cls tys = Nothing -- See Note [Solving CallStack constraints] | otherwise - = findTcApp m (getUnique cls) tys + = findTcApp m (classTyCon cls) tys findDictsByClass :: DictMap a -> Class -> Bag a findDictsByClass m cls @@ -2465,10 +2459,10 @@ findDictsByClass m cls | otherwise = emptyBag delDict :: DictMap a -> Class -> [Type] -> DictMap a -delDict m cls tys = delTcApp m (getUnique cls) tys +delDict m cls tys = delTcApp m (classTyCon cls) tys addDict :: DictMap a -> Class -> [Type] -> a -> DictMap a -addDict m cls tys item = insertTcApp m (getUnique cls) tys item +addDict m cls tys item = insertTcApp m (classTyCon cls) tys item addDictsByClass :: DictMap Ct -> Class -> Bag Ct -> DictMap Ct addDictsByClass m cls items @@ -2511,7 +2505,7 @@ emptyFunEqs :: TcAppMap a emptyFunEqs = emptyTcAppMap findFunEq :: FunEqMap a -> TyCon -> [Type] -> Maybe a -findFunEq m tc tys = findTcApp m (getUnique tc) tys +findFunEq m tc tys = findTcApp m tc tys findFunEqsByTyCon :: FunEqMap a -> TyCon -> [a] -- Get inert function equation constraints that have the given tycon @@ -2519,8 +2513,8 @@ findFunEqsByTyCon :: FunEqMap a -> TyCon -> [a] -- We use this to check for derived interactions with built-in type-function -- constructors. findFunEqsByTyCon m tc - | Just tm <- lookupUDFM m (getUnique tc) = foldTM (:) tm [] - | otherwise = [] + | Just tm <- lookupUDFM m tc = foldTM (:) tm [] + | otherwise = [] foldFunEqs :: (a -> b -> b) -> FunEqMap a -> b -> b foldFunEqs = foldTcAppMap @@ -2535,7 +2529,7 @@ anyFunEqMap m test = foldFunEqs (\ a b -> b || test a) m False -- filterFunEqs = filterTcAppMap insertFunEq :: FunEqMap a -> TyCon -> [Type] -> a -> FunEqMap a -insertFunEq m tc tys val = insertTcApp m (getUnique tc) tys val +insertFunEq m tc tys val = insertTcApp m tc tys val {- ************************************************************************ @@ -3435,24 +3429,61 @@ See GHC.Tc.Solver.Monad.deferTcSForAllEq ************************************************************************ -} --- | Replace all occurrences of the LHS tyvar in an RHS with a fresh --- variable, recording the pairing in the TcS monad. +-- | Replace all type family applications in the RHS with fresh variables, +-- emitting givens that relate the type family application to the variable. -- See Note [Type variable cycles in Givens] in GHC.Tc.Solver.Canonical. -breakTyVarCycle :: TyVar -- the LHS tyvar +breakTyVarCycle :: CtLoc -> TcType -- the RHS - -> TcS TcType -- new RHS that doesn't mention TyVar -breakTyVarCycle lhs_tv rhs - = do { new_tv <- wrapTcS (TcM.newCycleBreakerTyVar lhs_tv) - ; updInertTcS $ \is -> - is { inert_tv_cycles = (new_tv, lhs_tv) : inert_tv_cycles is } - ; let in_scope = mkInScopeSet (tyCoVarsOfType rhs) - subst0 = mkEmptyTCvSubst in_scope - subst = extendTvSubstWithClone subst0 lhs_tv new_tv - ; return (substTy subst rhs) } + -> TcS TcType -- new RHS that doesn't have any type families +-- This could be considerably more efficient. See Detail (5) of Note. +breakTyVarCycle loc = go + where + go ty | Just ty' <- flattenView ty = go ty' + go (Rep.TyConApp tc tys) + | isTypeFamilyTyCon tc + = do { let (fun_args, extra_args) = splitAt (tyConArity tc) tys + fun_app = mkTyConApp tc fun_args + fun_app_kind = tcTypeKind fun_app + ; new_tv <- wrapTcS (TcM.newCycleBreakerTyVar fun_app_kind) + ; let new_ty = mkTyVarTy new_tv + given_pred = mkHeteroPrimEqPred fun_app_kind fun_app_kind + fun_app new_ty + given_term = evCoercion $ mkNomReflCo new_ty -- See Detail (4) of Note + ; new_given <- newGivenEvVar loc (given_pred, given_term) + ; traceTcS "breakTyVarCycle replacing type family" (ppr new_given) + ; emitWorkNC [new_given] + ; updInertTcS $ \is -> + is { inert_cycle_breakers = (new_tv, fun_app) : + inert_cycle_breakers is } + ; extra_args' <- mapM go extra_args + ; return (mkAppTys new_ty extra_args') } + -- Worried that this substitution will change kinds? + -- See Detail (3) of Note + + | otherwise + = mkTyConApp tc <$> mapM go tys + + go (Rep.AppTy ty1 ty2) = mkAppTy <$> go ty1 <*> go ty2 + go (Rep.FunTy vis w arg res) = mkFunTy vis <$> go w <*> go arg <*> go res + go (Rep.CastTy ty co) = mkCastTy <$> go ty <*> pure co + + go ty@(Rep.TyVarTy {}) = return ty + go ty@(Rep.LitTy {}) = return ty + go ty@(Rep.ForAllTy {}) = return ty -- See Detail (1) of Note + go ty@(Rep.CoercionTy {}) = return ty -- See Detail (2) of Note -- | Filli in CycleBreakerTvs with the variables they stand for. -- See Note [Type variable cycles in Givens] in GHC.Tc.Solver.Canonical. restoreTyVarCycles :: InertSet -> TcM () restoreTyVarCycles is - = forM_ (inert_tv_cycles is) $ \ (cycle_breaker_tv, orig_tv) -> - TcM.writeMetaTyVar cycle_breaker_tv (mkTyVarTy orig_tv) + = forM_ (inert_cycle_breakers is) $ \ (cycle_breaker_tv, orig_ty) -> + TcM.writeMetaTyVar cycle_breaker_tv orig_ty + +-- Unwrap a type synonym only when either: +-- The type synonym is forgetful, or +-- the type synonym mentions a type family in its expansion +flattenView :: TcType -> Maybe TcType +flattenView ty@(Rep.TyConApp tc _) + | isForgetfulSynTyCon tc || (isTypeSynonymTyCon tc && not (isFamFreeTyCon tc)) + = tcView ty +flattenView _other = Nothing ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -150,7 +150,7 @@ data Ct -- a ~ [a] occurs check } - | CEqCan { -- tv ~ rhs + | CEqCan { -- CanEqLHS ~ rhs -- Invariants: -- * See Note [inert_eqs: the inert equalities] in GHC.Tc.Solver.Monad -- * Many are checked in checkTypeEq in GHC.Tc.Utils.Unify ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -871,11 +871,11 @@ cloneAnonMetaTyVar info tv kind -- Make a new CycleBreakerTv. See Note [Type variable cycles in Givens] -- in GHC.Tc.Solver.Canonical. -newCycleBreakerTyVar :: TyVar -> TcM TcTyVar -newCycleBreakerTyVar old_tv +newCycleBreakerTyVar :: TcKind -> TcM TcTyVar +newCycleBreakerTyVar kind = do { details <- newMetaDetails CycleBreakerTv - ; name <- cloneMetaTyVarName (tyVarName old_tv) - ; return (mkTcTyVar name (tyVarKind old_tv) details) } + ; name <- newMetaTyVarName (fsLit "cbv") + ; return (mkTcTyVar name kind details) } newMetaDetails :: MetaInfo -> TcM TcTyVarDetails newMetaDetails info ===================================== testsuite/tests/indexed-types/should_fail/Simple13.hs → testsuite/tests/indexed-types/should_compile/Simple13.hs ===================================== ===================================== testsuite/tests/indexed-types/should_compile/all.T ===================================== @@ -10,6 +10,7 @@ test('Simple9', normal, compile, ['']) test('Simple10', normal, compile, ['']) test('Simple11', normal, compile, ['']) test('Simple12', normal, compile, ['']) +test('Simple13', normal, compile, ['']) test('Simple14', normal, compile_fail, ['']) test('Simple15', normal, compile, ['']) test('Simple16', normal, compile, ['']) @@ -297,3 +298,4 @@ test('T17923', normal, compile, ['']) test('T18065', normal, compile, ['-O']) test('CEqCanOccursCheck', normal, compile, ['']) test('GivenLoop', normal, compile, ['']) +test('T18875', normal, compile, ['']) ===================================== testsuite/tests/indexed-types/should_fail/all.T ===================================== @@ -163,4 +163,3 @@ test('T17008a', normal, compile_fail, ['-fprint-explicit-kinds']) test('T13571', normal, compile_fail, ['']) test('T13571a', normal, compile_fail, ['']) test('T18648', normal, compile_fail, ['']) -test('Simple13', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -584,3 +584,4 @@ test('too-many', normal, compile_fail, ['']) test('T18640a', normal, compile_fail, ['']) test('T18640b', normal, compile_fail, ['']) test('T18640c', normal, compile_fail, ['']) +test('GivenForallLoop', normal, compile_fail, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cdc73a4c3e789c7725e594b7582896301d77f8c7...3cf175e03363960bc603572eaaffbf13c559f0c5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cdc73a4c3e789c7725e594b7582896301d77f8c7...3cf175e03363960bc603572eaaffbf13c559f0c5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 06:09:11 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 02:09:11 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 10 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f97b987f0a4b_897faeaa1050427d@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ae9d35dc by David Beacham at 2020-10-27T02:08:53-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - 2db03934 by Vladislav Zavialov at 2020-10-27T02:08:54-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - d45fc8d3 by Tamar Christina at 2020-10-27T02:08:56-04:00 winio: simplify logic remove optimization step. - - - - - 20f70d75 by Ben Gamari at 2020-10-27T02:08:56-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 7e95397e by Simon Peyton Jones at 2020-10-27T02:08:57-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 2acfb14f by Sergei Trofimovich at 2020-10-27T02:08:58-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 6dd9df6b by David Eichmann at 2020-10-27T02:08:59-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - d5f51caa by Alan Zimmerman at 2020-10-27T02:08:59-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - 018f988a by Sylvain Henry at 2020-10-27T02:09:01-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - ba4fd210 by Ben Gamari at 2020-10-27T02:09:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/Type.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81436b69240c3403dabe00f4aece7c968b5d76c1...ba4fd2104e95ee6632e421255b98606c03de23d0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81436b69240c3403dabe00f4aece7c968b5d76c1...ba4fd2104e95ee6632e421255b98606c03de23d0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 08:45:41 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 27 Oct 2020 04:45:41 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] 3 commits: Fix spelling Message-ID: <5f97de3559e2f_8973fa3d98bd9c452591d@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 1180fca2 by Moritz Angermann at 2020-10-27T15:30:33+08:00 Fix spelling - - - - - 022ac19c by Moritz Angermann at 2020-10-27T16:35:08+08:00 Drop mmap_next (not needed with forced PIC anymore) - - - - - cf91bf47 by Moritz Angermann at 2020-10-27T16:35:32+08:00 [testsuite] static001 is not broken anymore. - - - - - 4 changed files: - compiler/GHC/Driver/Session.hs - rts/Linker.c - rts/LinkerInternals.h - testsuite/tests/driver/all.T Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3818,8 +3818,8 @@ default_PIC :: Platform -> [GeneralFlag] default_PIC platform = case (platformOS platform, platformArch platform) of (OSDarwin, ArchX86_64) -> [Opt_PIC] - (OSDarwin, ArchAarch64) -> [Opt_PIC] - (OSLinux, ArchAarch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] + (OSDarwin, ArchAArch64) -> [Opt_PIC] + (OSLinux, ArchAArch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in -- OpenBSD since 5.3 release -- (1 May 2013) we need to ===================================== rts/Linker.c ===================================== @@ -1052,42 +1052,6 @@ resolveSymbolAddr (pathchar* buffer, int size, } #if RTS_LINKER_USE_MMAP - -/* ----------------------------------------------------------------------------- - Occationally we depend on mmap'd region being close to already mmap'd regions. - - Our static in-memory linker may be restricted by the architectures relocation - range. E.g. aarch64 has a +-4GB range for PIC code, thus we'd preferrably - get memory for the linker close to existing mappings. mmap on it's own is - free to return any memory location, independent of what the preferred - location argument indicates. - - For example mmap (via qemu) might give you addresses all over the available - memory range if the requested location is already occupied. - - mmap_next will do a linear search from the start page upwards to find a - suitable location that is as close as possible to the locations (proivded - via the first argument). - -------------------------------------------------------------------------- */ - -void* -mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { - if(addr == NULL) return mmap(addr, length, prot, flags, fd, offset); - // we are going to look for up to pageSize * 1024 * 1024 (4GB) from the - // address. - size_t pageSize = getPageSize(); - for(int i = (uintptr_t)addr & (pageSize-1) ? 1 : 0; i < 1024*1024; i++) { - void *target = (void*)(((uintptr_t)addr & ~(pageSize-1))+(i*pageSize)); - void *mem = mmap(target, length, prot, flags, fd, offset); - if(mem == NULL) return mem; - if(mem == target) return mem; - munmap(mem, length); - IF_DEBUG(linker && (i % 1024 == 0), - debugBelch("mmap_next failed to find suitable space in %p - %p\n", addr, target)); - } - return NULL; -} - // // Returns NULL on failure. // @@ -1119,8 +1083,8 @@ mmap_again: debugBelch("mmapForLinker: \tflags %#0x\n", MAP_PRIVATE | tryMap32Bit | fixed | flags)); - result = mmap_next(map_addr, size, prot, - MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); + result = mmap(map_addr, size, prot, + MAP_PRIVATE|tryMap32Bit|fixed|flags, fd, offset); if (result == MAP_FAILED) { sysErrorBelch("mmap %" FMT_Word " bytes at %p",(W_)size,map_addr); ===================================== rts/LinkerInternals.h ===================================== @@ -14,7 +14,6 @@ #if RTS_LINKER_USE_MMAP #include -void* mmap_next(void *addr, size_t length, int prot, int flags, int fd, off_t offset); #endif void printLoadedObjects(void); ===================================== testsuite/tests/driver/all.T ===================================== @@ -121,7 +121,7 @@ else: only_darwin = skip test('static001', [extra_files(['Static001.hs']), - only_darwin, expect_broken(8127)], + only_darwin], makefile_test, ['static001']) test('dynHelloWorld', @@ -261,7 +261,7 @@ test('T12955', normal, makefile_test, []) test('T12971', [when(opsys('mingw32'), expect_broken(17945)), ignore_stdout], makefile_test, []) test('json', normal, compile_fail, ['-ddump-json']) test('json2', normalise_version('base','ghc-prim'), compile, ['-ddump-types -ddump-json']) -test('T16167', exit_code(1), run_command, +test('T16167', exit_code(1), run_command, ['{compiler} -x hs -e ":set prog T16167.hs" -ddump-json T16167.hs']) test('T13604', [], makefile_test, []) test('T13604a', [], makefile_test, []) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f7df369abfd5b17fcde67a4aea11d425baafb65...cf91bf47c106074136b165a4c3e5db6f55f0554e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0f7df369abfd5b17fcde67a4aea11d425baafb65...cf91bf47c106074136b165a4c3e5db6f55f0554e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 10:29:16 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Tue, 27 Oct 2020 06:29:16 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f97f67c50adb_8973fa38003cf9c540614@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 6664f8e5 by Daniel Rogozin at 2020-10-27T13:28:51+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/binary - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6664f8e5143ead51117f03fa767013b5cf4436ad -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6664f8e5143ead51117f03fa767013b5cf4436ad You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 10:55:15 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Tue, 27 Oct 2020 06:55:15 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] the char kind: type families, functionality, and submodule updates Message-ID: <5f97fc93e3bf3_897a2da7945462fc@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: da2e7af5 by Daniel Rogozin at 2020-10-27T13:54:37+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Utils/Binary.hs - libraries/base/Data/Typeable/Internal.hs - libraries/base/GHC/TypeLits.hs - libraries/binary - libraries/ghc-prim/GHC/Types.hs - libraries/template-haskell/Language/Haskell/TH/Lib.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da2e7af56e7aa1e7f6ddd9e5c1f546c4230c5927 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da2e7af56e7aa1e7f6ddd9e5c1f546c4230c5927 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 11:39:35 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 07:39:35 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f9806f71ee75_8973fa3a71e3a54573392@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 76978387 by David Beacham at 2020-10-27T07:39:21-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - 24f25a68 by Vladislav Zavialov at 2020-10-27T07:39:21-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 780fc2c7 by Tamar Christina at 2020-10-27T07:39:23-04:00 winio: simplify logic remove optimization step. - - - - - 3ed10dbc by Ben Gamari at 2020-10-27T07:39:23-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 96a2aaa4 by Ben Gamari at 2020-10-27T07:39:24-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - fbfe5c57 by Simon Peyton Jones at 2020-10-27T07:39:24-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - ab8d477f by Sergei Trofimovich at 2020-10-27T07:39:25-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - cd25e4d8 by David Eichmann at 2020-10-27T07:39:27-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - ccc2a455 by Alan Zimmerman at 2020-10-27T07:39:27-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d100e97f by Ben Gamari at 2020-10-27T07:39:27-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - d1d0a099 by Sebastian Graf at 2020-10-27T07:39:27-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Types/Demand.hs - compiler/ghc.cabal.in - ghc.mk - hadrian/hadrian.cabal - hadrian/src/Builder.hs - hadrian/src/Rules/Clean.hs - libraries/array - libraries/base/Data/Ord.hs - libraries/base/GHC/Event/Windows.hsc - libraries/base/base.cabal - libraries/base/changelog.md - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba4fd2104e95ee6632e421255b98606c03de23d0...d1d0a09920c69ff9c4a197defc9d0e03b051f809 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba4fd2104e95ee6632e421255b98606c03de23d0...d1d0a09920c69ff9c4a197defc9d0e03b051f809 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 12:14:34 2020 From: gitlab at gitlab.haskell.org (Moritz Angermann) Date: Tue, 27 Oct 2020 08:14:34 -0400 Subject: [Git][ghc/ghc][wip/angerman/aarch64-ncg] is PIC enough? Message-ID: <5f980f2a91a82_8973fa3bbd4d52059356b@gitlab.haskell.org.mail> Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC Commits: 17090309 by Moritz Angermann at 2020-10-27T20:14:15+08:00 is PIC enough? - - - - - 1 changed file: - compiler/GHC/Driver/Session.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3819,7 +3819,7 @@ default_PIC platform = case (platformOS platform, platformArch platform) of (OSDarwin, ArchX86_64) -> [Opt_PIC] (OSDarwin, ArchAArch64) -> [Opt_PIC] - (OSLinux, ArchAArch64) -> [Opt_PIC, Opt_ExternalDynamicRefs] + (OSLinux, ArchAArch64) -> [Opt_PIC] --, Opt_ExternalDynamicRefs] (OSOpenBSD, ArchX86_64) -> [Opt_PIC] -- Due to PIE support in -- OpenBSD since 5.3 release -- (1 May 2013) we need to View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/170903093be2a26ee527a68354a0d6bca4264e50 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/170903093be2a26ee527a68354a0d6bca4264e50 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 13:52:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 27 Oct 2020 09:52:37 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-metric-baseline Message-ID: <5f9826256b73d_8973fa3a658a96061697c@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/hadrian-metric-baseline at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-metric-baseline You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 14:35:22 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 27 Oct 2020 10:35:22 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bump-time Message-ID: <5f98302a872d6_897c8eb938633382@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/bump-time at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bump-time You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 14:45:29 2020 From: gitlab at gitlab.haskell.org (Andreas Klebinger) Date: Tue, 27 Oct 2020 10:45:29 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/32bit_cmp_fix Message-ID: <5f983289296f6_8973fa3a71142406349bb@gitlab.haskell.org.mail> Andreas Klebinger pushed new branch wip/andreask/32bit_cmp_fix at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/32bit_cmp_fix You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 17:59:42 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 13:59:42 -0400 Subject: [Git][ghc/ghc][master] Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f98600e5318e_8973fa3ba888194664429@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - 2 changed files: - libraries/base/Data/Ord.hs - libraries/base/changelog.md Changes: ===================================== libraries/base/Data/Ord.hs ===================================== @@ -28,11 +28,11 @@ import Data.Bits (Bits, FiniteBits) import Foreign.Storable (Storable) import GHC.Ix (Ix) import GHC.Base -import GHC.Enum (Bounded, Enum) +import GHC.Enum (Bounded(..)) import GHC.Float (Floating, RealFloat) import GHC.Num import GHC.Read -import GHC.Real (Fractional, Integral, Real, RealFrac) +import GHC.Real (Fractional, Real, RealFrac) import GHC.Show -- | @@ -66,10 +66,29 @@ clamp (low, high) a = min high (max a low) -- | The 'Down' type allows you to reverse sort order conveniently. A value of type -- @'Down' a@ contains a value of type @a@ (represented as @'Down' a@). +-- -- If @a@ has an @'Ord'@ instance associated with it then comparing two -- values thus wrapped will give you the opposite of their normal sort order. -- This is particularly useful when sorting in generalised list comprehensions, --- as in: @then sortWith by 'Down' x@ +-- as in: @then sortWith by 'Down' x at . +-- +-- >>> compare True False +-- GT +-- +-- >>> compare (Down True) (Down False) +-- LT +-- +-- If @a@ has a @'Bounded'@ instance then the wrapped instance also respects +-- the reversed ordering by exchanging the values of @'minBound'@ and +-- @'maxBound'@. +-- +-- >>> minBound :: Int +-- -9223372036854775808 +-- +-- >>> minBound :: Down Int +-- Down 9223372036854775807 +-- +-- All other instances of @'Down' a@ behave as they do for @a at . -- -- @since 4.6.0.0 newtype Down a = Down @@ -81,12 +100,9 @@ newtype Down a = Down , Semigroup -- ^ @since 4.11.0.0 , Monoid -- ^ @since 4.11.0.0 , Bits -- ^ @since 4.14.0.0 - , Bounded -- ^ @since 4.14.0.0 - , Enum -- ^ @since 4.14.0.0 , FiniteBits -- ^ @since 4.14.0.0 , Floating -- ^ @since 4.14.0.0 , Fractional -- ^ @since 4.14.0.0 - , Integral -- ^ @since 4.14.0.0 , Ix -- ^ @since 4.14.0.0 , Real -- ^ @since 4.14.0.0 , RealFrac -- ^ @since 4.14.0.0 @@ -114,6 +130,13 @@ instance (Show a) => Show (Down a) where instance Ord a => Ord (Down a) where compare (Down x) (Down y) = y `compare` x +-- | Swaps @'minBound'@ and @'maxBound'@ of the underlying type. +-- +-- @since 4.14.0.0 +instance Bounded a => Bounded (Down a) where + minBound = Down maxBound + maxBound = Down minBound + -- | @since 4.11.0.0 instance Functor Down where fmap = coerce ===================================== libraries/base/changelog.md ===================================== @@ -44,6 +44,9 @@ * `catMaybes` is now implemented using `mapMaybe`, so that it is both a "good consumer" and "good producer" for list-fusion (#18574) + * Correct `Bounded` instance and remove `Enum` and `Integral` instances for + `Data.Ord.Down`. + ## 4.14.0.0 *TBA* * Bundled with GHC 8.10.1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ad51bc9d2ad9168abad271f715ce73d3562218a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ad51bc9d2ad9168abad271f715ce73d3562218a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:00:20 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:00:20 -0400 Subject: [Git][ghc/ghc][master] Version bump: base-4.16 (#18712) Message-ID: <5f9860345718d_8973fa3ea77acf467017b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 30 changed files: - compiler/ghc.cabal.in - libraries/array - libraries/base/base.cabal - libraries/base/changelog.md - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in - libraries/haskeline - libraries/hpc - libraries/parsec - libraries/process - libraries/stm - libraries/template-haskell/template-haskell.cabal.in - libraries/terminfo - libraries/unix - testsuite/tests/dependent/should_compile/T14729.stderr - testsuite/tests/dependent/should_compile/T15743.stderr - testsuite/tests/dependent/should_compile/T15743e.stderr - testsuite/tests/indexed-types/should_compile/T15711.stderr - testsuite/tests/indexed-types/should_compile/T15852.stderr - testsuite/tests/polykinds/T15592.stderr - testsuite/tests/polykinds/T15592b.stderr - testsuite/tests/printer/T18052a.stderr - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr - utils/hsc2hs Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -57,7 +57,7 @@ Library Default-Language: Haskell2010 Exposed: False - Build-Depends: base >= 4.11 && < 4.16, + Build-Depends: base >= 4.11 && < 4.17, deepseq >= 1.4 && < 1.5, directory >= 1 && < 1.4, process >= 1 && < 1.7, ===================================== libraries/array ===================================== @@ -1 +1 @@ -Subproject commit ab535173d7885ebfc2005d8da2765f0f52c923ce +Subproject commit 10e6c7e0522367677e4c33cc1c56eb852ef13420 ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.15.0.0 +version: 4.16.0.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -29,7 +29,7 @@ `ConcFlags`, `DebugFlags`, `CCFlags`, `DoHeapProfile`, `ProfFlags`, `DoTrace`, `TraceFlags`, `TickyFlags`, `ParFlags`, `RTSFlags`, `RTSStats`, `GCStats`, `ByteOrder`, `GeneralCategory`, `SrcLoc` - + * Add rules `unpackUtf8`, `unpack-listUtf8` and `unpack-appendUtf8` to `GHC.Base`. They correspond to their ascii versions and hopefully make it easier for libraries to handle utf8 encoded strings efficiently. ===================================== libraries/deepseq ===================================== @@ -1 +1 @@ -Subproject commit b8c4fb4debaed6ef7eb6940ca4cfea6bd63cc212 +Subproject commit 0fd7fc88aded7d7a7a1c1250fd3dcd9152edba34 ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b697b3ea77dd4803f2f8f676dd64c8ea5277fcf0 +Subproject commit cecf363bc07004ad314e0297ce34ddba05031c0e ===================================== libraries/filepath ===================================== @@ -1 +1 @@ -Subproject commit 9088df9f97914664c9360857347d65c32dd6c892 +Subproject commit e60969e693ffea59725cc3ebcae415343ddd0692 ===================================== libraries/ghc-boot-th/ghc-boot-th.cabal.in ===================================== @@ -36,4 +36,4 @@ Library GHC.ForeignSrcLang.Type GHC.Lexeme - build-depends: base >= 4.7 && < 4.16 + build-depends: base >= 4.7 && < 4.17 ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -64,7 +64,7 @@ Library -- GHC.Version -- GHC.Platform.Host - build-depends: base >= 4.7 && < 4.16, + build-depends: base >= 4.7 && < 4.17, binary == 0.8.*, bytestring == 0.10.*, containers >= 0.5 && < 0.7, ===================================== libraries/ghc-compact/ghc-compact.cabal ===================================== @@ -37,7 +37,7 @@ library CPP build-depends: ghc-prim >= 0.5.3 && < 0.8, - base >= 4.9.0 && < 4.16, + base >= 4.9.0 && < 4.17, bytestring >= 0.10.6.0 ghc-options: -Wall ===================================== libraries/ghci/ghci.cabal.in ===================================== @@ -72,7 +72,7 @@ library Build-Depends: array == 0.5.*, - base >= 4.8 && < 4.16, + base >= 4.8 && < 4.17, binary == 0.8.*, bytestring == 0.10.*, containers >= 0.5 && < 0.7, ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit 2790f1c6ed94990ed51466079e8fb1097129c9b8 +Subproject commit 28ee26ad5b4ae1c0584f2ec11ac53be9671bf878 ===================================== libraries/hpc ===================================== @@ -1 +1 @@ -Subproject commit 772de3f7b43e31178f042ba77c071594845363e3 +Subproject commit fecf0496a65c4be275d613eb0632fecd5a123b69 ===================================== libraries/parsec ===================================== @@ -1 +1 @@ -Subproject commit 190492494fe92e8dd42165190b7ac112be1f7389 +Subproject commit 905bc2e3e1c374934d49e16dc5b7c49bf2c3c815 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit 72c6be917064c923e365622032d1f2fa07acb5eb +Subproject commit 102f5ca98661d3a6118e6610e59579c715a8ffd1 ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit 444f672416a354c3cfde9d94ec237a36be46ef59 +Subproject commit a439b76a645a903757d2410dd70fe44538f45759 ===================================== libraries/template-haskell/template-haskell.cabal.in ===================================== @@ -55,7 +55,7 @@ Library Language.Haskell.TH.Lib.Map build-depends: - base >= 4.11 && < 4.16, + base >= 4.11 && < 4.17, ghc-boot-th == @ProjectVersionMunged@, ghc-prim, pretty == 1.1.* ===================================== libraries/terminfo ===================================== @@ -1 +1 @@ -Subproject commit 3ebb36f4a2c42b74ec4e35efccc2be34c198a830 +Subproject commit 9add7edcc04a9a86aa84a7faea203b654da447d1 ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit ea13d990580273a883368793dfbb826cab5a22d4 +Subproject commit 8abd63ea234de02d2b3cb08b5098cd06c1a728f6 ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -1,6 +1,7 @@ TYPE CONSTRUCTORS data type T{14} :: - forall {k1} {k2} {k3} (k4 :: k2) k5. forall k6 -> + forall {k1} {k2} {k3} (k4 :: k2) k5. + forall k6 -> k6 -> Proxy k4 -> (k3 -> *) @@ -21,7 +22,8 @@ TYPE CONSTRUCTORS nominal phantom data type T2{14} :: - forall {k1} {k2} (k3 :: k2) k7. forall k4 -> + forall {k1} {k2} (k3 :: k2) k7. + forall k4 -> k4 -> Proxy k3 -> (k7 -> *) @@ -52,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {k2} {j :: k1} {c :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ DATA CONSTRUCTORS MkT :: forall {k} k1 (f :: k1 -> k -> *) (a :: k1) (b :: k). f a b -> T f a b -> T f a b Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.16.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,10 @@ subsumption_sort_hole_fits.hs:2:5: warning: [-Wtyped-holes (in -Wdefault)] Valid hole fits include lines :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.15.0.0:Data.OldList’)) + (and originally defined in ‘base-4.16.0.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.15.0.0:Data.OldList’)) + (and originally defined in ‘base-4.16.0.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 ===================================== utils/hsc2hs ===================================== @@ -1 +1 @@ -Subproject commit 9cacd5d465d5797e4935d1aa6ae6a71488a03938 +Subproject commit fe518b0e86a45826b5b1f4642037981bac7413d7 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eedec53df8bf030b36cdd1fcfd1ff06041bc46fd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eedec53df8bf030b36cdd1fcfd1ff06041bc46fd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:00:56 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:00:56 -0400 Subject: [Git][ghc/ghc][master] winio: simplify logic remove optimization step. Message-ID: <5f986058a2e43_8973fa3ba8881946730d7@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 1 changed file: - libraries/base/GHC/Event/Windows.hsc Changes: ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -555,9 +555,24 @@ withOverlappedEx mgr fname h offset startCB completionCB = do withRequest offset callbackData $ \hs_lpol cdData -> do let ptr_lpol = hs_lpol `plusPtr` cdOffset let lpol = castPtr hs_lpol + -- We need to add the payload before calling startCBResult, the reason being + -- that the I/O routine begins immediately then. If we don't then the request + -- may end up lost as processCompletion will get called with a null payload. + poke ptr_lpol cdData + + -- Since FILE_SKIP_COMPLETION_PORT_ON_SUCCESS can't be + -- relied on for non-file handles we need a way to prevent + -- us from handling a request inline and handle a completion + -- event handled without a queued I/O operation. Which means we + -- can't solely rely on the number of oustanding requests but most + -- also check intermediate status. + reqs <- addRequest + debugIO $ "+1.. " ++ show reqs ++ " requests queued. | " ++ show lpol + cdDataCheck <- peek ptr_lpol :: IO (Ptr CompletionData) debugIO $ "hs_lpol:" ++ show hs_lpol ++ " cdData:" ++ show cdData ++ " ptr_lpol:" ++ show ptr_lpol + ++ " *ptr_lpol:" ++ show cdDataCheck startCBResult <- startCB lpol `onException` (CbError `fmap` Win32.getLastError) >>= \result -> do @@ -630,29 +645,14 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "== >*< " ++ show (finished, done_early, will_finish_sync, h, lpol, lasterr) case (finished, done_early, will_finish_sync) of + (Just _, _, _) -> do + debugIO "request handled immediately (o/b), not queued." + return $ CbDone finished -- Still pending - (Nothing, False, False) -> do - -- Since FILE_SKIP_COMPLETION_PORT_ON_SUCCESS can't be - -- relied on for non-file handles we need a way to prevent - -- us from handling a request inline and handle a completion - -- event handled without a queued I/O operation. We can do - -- this by deferring the setting data pointer until we know - -- the request will be handled async. - poke ptr_lpol cdData - reqs <- addRequest - debugIO $ "+1.. " ++ show reqs ++ " requests queued. | " ++ show lpol + (Nothing, _, _) -> do -- If we should add back support to suspend the IO Manager thread -- then we will need to make sure it's running at this point. return result' - -- In progress, we will wait for completion. - (Nothing, False, True) -> do - debugIO $ "handling incomplete request synchronously " ++ show (h, lpol) - res <- waitForCompletion h lpol - debugIO $ "done blocking request 1: " ++ show (h, lpol) ++ " - " ++ show res - return res - _ -> do - debugIO "request handled immediately (o/b), not queued." - return $ CbDone finished CbError err' -> signalThrow (Just err') >> return result' CbDone _ -> do debugIO "request handled immediately (o), not queued." >> return result' @@ -660,8 +660,9 @@ withOverlappedEx mgr fname h offset startCB completionCB = do -- If an exception was received while waiting for IO to complete -- we try to cancel the request here. let cancel e = do + nerr <- getLastError debugIO $ "## Exception occurred. Cancelling request... " - debugIO $ show (e :: SomeException) + debugIO $ show (e :: SomeException) ++ " : " ++ show nerr _ <- uninterruptibleMask_ $ FFI.cancelIoEx' h lpol -- we need to wait for the cancellation before removing -- the pointer. @@ -669,10 +670,9 @@ withOverlappedEx mgr fname h offset startCB completionCB = do _ <- FFI.getOverlappedResult h lpol True oldDataPtr <- I.exchangePtr ptr_lpol nullReq when (oldDataPtr == cdData) $ - do reqs <- removeRequest - debugIO $ "-1.. " ++ show reqs ++ " requests queued after error." - status <- fmap fromIntegral getLastError - completionCB' status 0 + do reqs1 <- removeRequest + debugIO $ "-1.. " ++ show reqs1 ++ " requests queued after error." + completionCB' (fromIntegral nerr) 0 when (not threadedIOMgr) $ do num_remaining <- outstandingRequests -- Run timeouts. This way if we canceled the last @@ -693,22 +693,32 @@ withOverlappedEx mgr fname h offset startCB completionCB = do case startCBResult of CbPending -> runner CbDone rdata -> do - debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata - bytes <- if isJust rdata - then return rdata - -- Make sure it's safe to free the OVERLAPPED buffer - else FFI.getOverlappedResult h lpol False - debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes - case bytes of - Just res -> completionCB 0 res - Nothing -> do err <- FFI.overlappedIOStatus lpol - numBytes <- FFI.overlappedIONumBytes lpol - -- TODO: Remap between STATUS_ and ERROR_ instead - -- of re-interpret here. But for now, don't care. - let err' = fromIntegral err - debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes - completionCB err' (fromIntegral numBytes) + oldDataPtr <- I.exchangePtr ptr_lpol nullReq + if (oldDataPtr == cdData) + then + do reqs2 <- removeRequest + debugIO $ "-1.. " ++ show reqs2 ++ " requests queued." + debugIO $ dbgMsg $ ":: done " ++ show lpol ++ " - " ++ show rdata + bytes <- if isJust rdata + then return rdata + -- Make sure it's safe to free the OVERLAPPED buffer + else FFI.getOverlappedResult h lpol False + cdDataCheck2 <- peek ptr_lpol :: IO (Ptr CompletionData) + debugIO $ dbgMsg $ ":: exit *ptr_lpol: " ++ show cdDataCheck2 + debugIO $ dbgMsg $ ":: done bytes: " ++ show bytes + case bytes of + Just res -> completionCB 0 res + Nothing -> do err <- FFI.overlappedIOStatus lpol + numBytes <- FFI.overlappedIONumBytes lpol + -- TODO: Remap between STATUS_ and ERROR_ instead + -- of re-interpret here. But for now, don't care. + let err' = fromIntegral err + debugIO $ dbgMsg $ ":: done callback: " ++ show err' ++ " - " ++ show numBytes + completionCB err' (fromIntegral numBytes) + else readIOPort signal CbError err -> do + reqs3 <- removeRequest + debugIO $ "-1.. " ++ show reqs3 ++ " requests queued." let err' = fromIntegral err completionCB err' 0 _ -> do @@ -1034,14 +1044,25 @@ processCompletion Manager{..} n delay = do let hs_lpol = castPtr lpol :: Ptr FFI.HASKELL_OVERLAPPED let ptr_lpol = castPtr (hs_lpol `plusPtr` cdOffset) :: Ptr (Ptr CompletionData) cdDataCheck <- peek ptr_lpol + oldDataPtr <- I.exchangePtr ptr_lpol nullReq :: IO (Ptr CompletionData) debugIO $ " $ checking " ++ show lpol ++ " -en ptr_lpol: " ++ show ptr_lpol ++ " offset: " ++ show cdOffset ++ " cdData: " ++ show cdDataCheck ++ " at idx " ++ show idx - oldDataPtr <- I.exchangePtr ptr_lpol nullReq :: IO (Ptr CompletionData) + ptrd <- peek ptr_lpol + debugIO $ ":: nullReq " ++ show nullReq debugIO $ ":: oldDataPtr " ++ show oldDataPtr - when (oldDataPtr /= nullPtr) $ + debugIO $ ":: oldDataPtr (ptr)" ++ show ptrd + -- A nullPtr indicates that we received a request which we shouldn't + -- have. Essentially the field is 0 initialized and a nullPtr means + -- it wasn't given a payload. + -- A nullReq means that something else already handled the request, + -- this can happen if for instance the request was cancelled. + -- The former is an error while the latter is OK. For now we treat + -- them both as the same, but external tools such as API monitor are + -- used to distinguish between the two when doing API tracing. + when (oldDataPtr /= nullPtr && oldDataPtr /= castPtr nullReq) $ do debugIO $ "exchanged: " ++ show oldDataPtr payload <- peek oldDataPtr :: IO CompletionData let !cb = cdCallback payload @@ -1055,7 +1076,9 @@ processCompletion Manager{..} n delay = do -- now require the callback to free the memory since the -- callback allocated it. This allows us to simplify memory -- management and reduce bugs. See Note [Memory Management]. - cb status' (dwNumberOfBytesTransferred oe) + let bytes = dwNumberOfBytesTransferred oe + debugIO $ "?: status " ++ show status' ++ " - " ++ show bytes ++ " bytes return." + cb status' bytes -- clear the array so we don't erroneously interpret the output, in -- certain circumstances like lockFileEx the code could return 1 entry View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/412018c1214a19649e0ccfff73e80a0622635dd5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/412018c1214a19649e0ccfff73e80a0622635dd5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:01:33 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:01:33 -0400 Subject: [Git][ghc/ghc][master] hadrian: Suppress xelatex output unless it fails Message-ID: <5f98607d3b9aa_8973fa3bb21aaa4677883@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - 2 changed files: - hadrian/hadrian.cabal - hadrian/src/Builder.hs Changes: ===================================== hadrian/hadrian.cabal ===================================== @@ -138,6 +138,7 @@ executable hadrian build-depends: Cabal >= 3.0 && < 3.3 , QuickCheck >= 2.6 && < 2.14 , base >= 4.8 && < 5 + , bytestring >= 0.10 && < 0.12 , containers >= 0.5 && < 0.7 , directory >= 1.3.1.0 && < 1.4 , extra >= 1.4.7 ===================================== hadrian/src/Builder.hs ===================================== @@ -15,6 +15,7 @@ module Builder ( ) where import Control.Exception.Extra (Partial) +import qualified Data.ByteString.Lazy.Char8 as BSL import Development.Shake.Classes import Development.Shake.Command import GHC.Generics @@ -26,6 +27,8 @@ import Hadrian.Builder.Tar import Hadrian.Oracles.Path import Hadrian.Oracles.TextFile import Hadrian.Utilities +import System.Exit +import System.IO (stderr) import Base import Context @@ -286,7 +289,18 @@ instance H.Builder Builder where Makeinfo -> do cmd' echo [path] "--no-split" [ "-o", output] [input] - Xelatex -> unit $ cmd' [Cwd output] [path] buildArgs + Xelatex -> + -- xelatex produces an incredible amount of output, almost + -- all of which is useless. Suppress it unless user + -- requests a loud build. + if verbosity >= Loud + then cmd' [Cwd output] [path] buildArgs + else do (Stdouterr out, Exit code) <- cmd' [Cwd output] [path] buildArgs + when (code /= ExitSuccess) $ do + liftIO $ BSL.hPutStrLn stderr out + putFailure "xelatex failed!" + fail "xelatex failed" + Makeindex -> unit $ cmd' [Cwd output] [path] (buildArgs ++ [input]) Tar _ -> cmd' buildOptions echo [path] buildArgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4950dd075ce79e13d24362d669e134ed5a4ddec7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4950dd075ce79e13d24362d669e134ed5a4ddec7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:02:07 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:02:07 -0400 Subject: [Git][ghc/ghc][master] build system: Clean mingw tarballs Message-ID: <5f98609fdb068_8973fa3b3002bac68077b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 2 changed files: - ghc.mk - hadrian/src/Rules/Clean.hs Changes: ===================================== ghc.mk ===================================== @@ -1424,6 +1424,13 @@ distclean : clean # Don't delete 'inplace' itself, it contains source files. $(call removeTrees,inplace/mingw) +# Remove the download tarballs. This is because updating +# the tarballs doesn't remove old ones. After a tarbal is updated +# you end up with both in your tree and get a franken build. +# The downside here is that a maintainer clean will trigger more +# bandwidth usage from haskell.org + $(call removeTrees,ghc-tarballs) + # Remove the fs utilities. $(call removeFiles,utils/lndir/fs.h) $(call removeFiles,utils/lndir/fs.c) ===================================== hadrian/src/Rules/Clean.hs ===================================== @@ -18,6 +18,11 @@ cleanSourceTree = do forM_ [Stage0 ..] $ removeDirectory . (path -/-) . stageString removeDirectory "sdistprep" cleanFsUtils + cleanMingwTarballs + +cleanMingwTarballs :: Action () +cleanMingwTarballs = do + liftIO $ IO.removeDirectoryRecursive "ghc-tarballs" -- Clean all temporary fs files copied by configure into the source folder cleanFsUtils :: Action () View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d8ab2ef6ffe30ec91c795e0223392dd96ea61a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d8ab2ef6ffe30ec91c795e0223392dd96ea61a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:02:43 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:02:43 -0400 Subject: [Git][ghc/ghc][master] Fix two constraint solving problems Message-ID: <5f9860c3889e0_8973fa3ba888194683680@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - 10 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - + testsuite/tests/polykinds/T18855.hs - testsuite/tests/polykinds/all.T - testsuite/tests/typecheck/should_fail/T10709b.stderr - testsuite/tests/typecheck/should_fail/T12589.stderr Changes: ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -42,7 +42,8 @@ module GHC.Core.Coercion ( mkAxiomInstCo, mkProofIrrelCo, downgradeRole, mkAxiomRuleCo, mkGReflRightCo, mkGReflLeftCo, mkCoherenceLeftCo, mkCoherenceRightCo, - mkKindCo, castCoercionKind, castCoercionKindI, + mkKindCo, + castCoercionKind, castCoercionKind1, castCoercionKind2, mkFamilyTyConAppCo, mkHeteroCoercionType, @@ -1513,24 +1514,44 @@ instCoercions g ws ; return (piResultTy <$> g_tys <*> w_tys, g') } -- | Creates a new coercion with both of its types casted by different casts --- @castCoercionKind g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, +-- @castCoercionKind2 g r t1 t2 h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -castCoercionKind :: Coercion -> Role -> Type -> Type +castCoercionKind2 :: Coercion -> Role -> Type -> Type -> CoercionN -> CoercionN -> Coercion -castCoercionKind g r t1 t2 h1 h2 +castCoercionKind2 g r t1 t2 h1 h2 = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) +-- | @castCoercionKind1 g r t1 t2 h@ = @coercionKind g r t1 t2 h h@ +-- That is, it's a specialised form of castCoercionKind, where the two +-- kind coercions are identical +-- @castCoercionKind1 g r t1 t2 h@, where @g :: t1 ~r t2@, +-- has type @(t1 |> h) ~r (t2 |> h)@. +-- @h@ must be nominal. +-- See Note [castCoercionKind1] +castCoercionKind1 :: Coercion -> Role -> Type -> Type + -> CoercionN -> Coercion +castCoercionKind1 g r t1 t2 h + = case g of + Refl {} -> ASSERT( r == Nominal ) -- Refl is always Nominal + mkNomReflCo (mkCastTy t2 h) + GRefl _ _ mco -> case mco of + MRefl -> mkReflCo r (mkCastTy t2 h) + MCo kind_co -> GRefl r (mkCastTy t1 h) $ + MCo (mkSymCo h `mkTransCo` kind_co `mkTransCo` h) + _ -> castCoercionKind2 g r t1 t2 h h + -- | Creates a new coercion with both of its types casted by different casts -- @castCoercionKind g h1 h2@, where @g :: t1 ~r t2@, -- has type @(t1 |> h1) ~r (t2 |> h2)@. -- @h1@ and @h2@ must be nominal. -- It calls @coercionKindRole@, so it's quite inefficient (which 'I' stands for) --- Use @castCoercionKind@ instead if @t1@, @t2@, and @r@ are known beforehand. -castCoercionKindI :: Coercion -> CoercionN -> CoercionN -> Coercion -castCoercionKindI g h1 h2 - = mkCoherenceRightCo r t2 h2 (mkCoherenceLeftCo r t1 h1 g) - where (Pair t1 t2, r) = coercionKindRole g +-- Use @castCoercionKind2@ instead if @t1@, @t2@, and @r@ are known beforehand. +castCoercionKind :: Coercion -> CoercionN -> CoercionN -> Coercion +castCoercionKind g h1 h2 + = castCoercionKind2 g r t1 t2 h1 h2 + where + (Pair t1 t2, r) = coercionKindRole g mkFamilyTyConAppCo :: TyCon -> [CoercionN] -> CoercionN -- ^ Given a family instance 'TyCon' and its arg 'Coercion's, return the @@ -1592,6 +1613,23 @@ mkCoCast c g (tc, _) = splitTyConApp (coercionLKind g) co_list = decomposeCo (tyConArity tc) g (tyConRolesRepresentational tc) +{- Note [castCoercionKind1] +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +castCoercionKind1 deals with the very important special case of castCoercionKind2 +where the two kind coercions are identical. In that case we can exploit the +situation where the main coercion is reflexive, via the special cases for Refl +and GRefl. + +This is important when flattening (ty |> co). We flatten ty, yielding + fco :: ty ~ ty' +and now we want a coercion xco between + xco :: (ty |> co) ~ (ty' |> co) +That's exactly what castCoercionKind1 does. And it's very very common for +fco to be Refl. In that case we do NOT want to get some terrible composition +of mkLeftCoherenceCo and mkRightCoherenceCo, which is what castCoercionKind2 +has to do in its full generality. See #18413. +-} + {- %************************************************************************ %* * @@ -1967,8 +2005,8 @@ ty_co_subst !lc role ty else pprPanic "ty_co_subst: covar is not almost devoid" (ppr t) go r ty@(LitTy {}) = ASSERT( r == Nominal ) mkNomReflCo ty - go r (CastTy ty co) = castCoercionKindI (go r ty) (substLeftCo lc co) - (substRightCo lc co) + go r (CastTy ty co) = castCoercionKind (go r ty) (substLeftCo lc co) + (substRightCo lc co) go r (CoercionTy co) = mkProofIrrelCo r kco (substLeftCo lc co) (substRightCo lc co) where kco = go Nominal (coercionType co) ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -1447,7 +1447,7 @@ normalise_type ty = do { (nco, nty) <- go ty ; lc <- getLC ; let co' = substRightCo lc co - ; return (castCoercionKind nco Nominal ty nty co co' + ; return (castCoercionKind2 nco Nominal ty nty co co' , mkCastTy nty co') } go (CoercionTy co) = do { lc <- getLC ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -1134,18 +1134,10 @@ data Coercion -- These ones mirror the shape of types = -- Refl :: _ -> N + -- A special case reflexivity for a very common case: Nominal reflexivity + -- If you need Representational, use (GRefl Representational ty MRefl) + -- not (SubCo (Refl ty)) Refl Type -- See Note [Refl invariant] - -- Invariant: applications of (Refl T) to a bunch of identity coercions - -- always show up as Refl. - -- For example (Refl T) (Refl a) (Refl b) shows up as (Refl (T a b)). - - -- Applications of (Refl T) to some coercions, at least one of - -- which is NOT the identity, show up as TyConAppCo. - -- (They may not be fully saturated however.) - -- ConAppCo coercions (like all coercions other than Refl) - -- are NEVER the identity. - - -- Use (GRefl Representational ty MRefl), not (SubCo (Refl ty)) -- GRefl :: "e" -> _ -> Maybe N -> e -- See Note [Generalized reflexive coercion] @@ -1254,26 +1246,30 @@ instance Outputable MCoercion where ppr MRefl = text "MRefl" ppr (MCo co) = text "MCo" <+> ppr co -{- -Note [Refl invariant] -~~~~~~~~~~~~~~~~~~~~~ -Invariant 1: - -Coercions have the following invariant - Refl (similar for GRefl r ty MRefl) is always lifted as far as possible. - -You might think that a consequences is: - Every identity coercions has Refl at the root - -But that's not quite true because of coercion variables. Consider - g where g :: Int~Int - Left h where h :: Maybe Int ~ Maybe Int -etc. So the consequence is only true of coercions that -have no coercion variables. +{- Note [Refl invariant] +~~~~~~~~~~~~~~~~~~~~~~~~ +Invariant 1: Refl lifting + Refl (similar for GRefl r ty MRefl) is always lifted as far as possible. + For example + (Refl T) (Refl a) (Refl b) is normalised (by mkAPpCo) to (Refl (T a b)). + + You might think that a consequences is: + Every identity coercion has Refl at the root + + But that's not quite true because of coercion variables. Consider + g where g :: Int~Int + Left h where h :: Maybe Int ~ Maybe Int + etc. So the consequence is only true of coercions that + have no coercion variables. + +Invariant 2: TyConAppCo + An application of (Refl T) to some coercions, at least one of which is + NOT the identity, is normalised to TyConAppCo. (They may not be + fully saturated however.) TyConAppCo coercions (like all coercions + other than Refl) are NEVER the identity. Note [Generalized reflexive coercion] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - GRefl is a generalized reflexive coercion (see #15192). It wraps a kind coercion, which might be reflexive (MRefl) or any coercion (MCo co). The typing rules for GRefl: ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1454,7 +1454,7 @@ ty_co_match menv subst (TyVarTy tv1) co lkco rkco = if any (inRnEnvR rn_env) (tyCoVarsOfCoList co) then Nothing -- occurs check failed else Just $ extendVarEnv subst tv1' $ - castCoercionKindI co (mkSymCo lkco) (mkSymCo rkco) + castCoercionKind co (mkSymCo lkco) (mkSymCo rkco) | otherwise = Nothing ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -2542,6 +2542,9 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs is_float_eq_candidate ct | pred <- ctPred ct , EqPred NomEq ty1 ty2 <- classifyPredType pred + , case ct of + CIrredCan {} -> False -- See Note [Do not float blocked constraints] + _ -> True -- See #18855 = float_eq ty1 ty2 || float_eq ty2 ty1 | otherwise = False @@ -2552,7 +2555,26 @@ floatEqualities skols given_ids ev_binds_var no_given_eqs && (not (isTyVarTyVar tv1) || isTyVarTy ty2) Nothing -> False -{- Note [Float equalities from under a skolem binding] +{- Note [Do not float blocked constraints] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As #18855 showed, we must not float an equality that is blocked. +Consider + forall a[4]. [W] co1: alpha[4] ~ Maybe (a[4] |> bco) + [W] co2: alpha[4] ~ Maybe (beta[4] |> bco]) + [W] bco: kappa[2] ~ Type + +Now co1, co2 are blocked by bco. We will eventually float out bco +and solve it at level 2. But the danger is that we will *also* +float out co2, and that is bad bad bad. Because we'll promote alpha +and beta to level 2, and then fail to unify the promoted beta +with the skolem a[4]. + +Solution: don't float out blocked equalities. Remember: we only want +to float out if we can solve; see Note [Which equalities to float]. + +(Future plan: kill floating altogether.) + +Note [Float equalities from under a skolem binding] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Which of the simple equalities can we float out? Obviously, only ones that don't mention the skolem-bound variables. But that is ===================================== compiler/GHC/Tc/Solver/Flatten.hs ===================================== @@ -1206,9 +1206,11 @@ flatten_one ty@(ForAllTy {}) flatten_one (CastTy ty g) = do { (xi, co) <- flatten_one ty ; (g', _) <- flatten_co g - ; role <- getRole - ; return (mkCastTy xi g', castCoercionKind co role xi ty g' g) } + ; return (mkCastTy xi g', castCoercionKind1 co role xi ty g') } + -- It makes a /big/ difference to call castCoercionKind1 not + -- the more general castCoercionKind2. + -- See Note [castCoercionKind1] in GHC.Core.Coercion flatten_one (CoercionTy co) = first mkCoercionTy <$> flatten_co co ===================================== testsuite/tests/polykinds/T18855.hs ===================================== @@ -0,0 +1,18 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind + +type family Apply (f :: a -> b) (x :: a) :: b + +type F :: forall a. + forall (p :: forall bOne. Either a bOne -> Type) + -> forall bTwo. + forall (e :: Either a bTwo) + -> Apply p e + +type family F ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -225,3 +225,4 @@ test('T18451', normal, compile_fail, ['']) test('T18451a', normal, compile_fail, ['']) test('T18451b', normal, compile_fail, ['']) test('T18522-ppr', normal, ghci_script, ['T18522-ppr.script']) +test('T18855', normal, compile, ['']) ===================================== testsuite/tests/typecheck/should_fail/T10709b.stderr ===================================== @@ -11,44 +11,44 @@ T10709b.hs:6:22: error: x4 = (replicateM 2 . mask) (\ _ -> return ()) T10709b.hs:7:22: error: - • Couldn't match type ‘t0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘t0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (t0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘t0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (\ x -> undefined x) In an equation for ‘x5’: x5 = (replicateM 2 . mask) (\ x -> undefined x) T10709b.hs:8:22: error: - • Couldn't match type ‘p0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘p0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (p0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘p0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (id (\ _ -> undefined)) In an equation for ‘x6’: x6 = (replicateM 2 . mask) (id (\ _ -> undefined)) T10709b.hs:9:22: error: - • Couldn't match type ‘b0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘b0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (b0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘b0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) (const undefined) In an equation for ‘x7’: x7 = (replicateM 2 . mask) (const undefined) T10709b.hs:10:22: error: - • Couldn't match type ‘a0’ with ‘forall a. IO a -> IO a’ + • Couldn't match type ‘a0’ with ‘forall a1. IO a1 -> IO a1’ Expected: (a0 -> IO a) -> IO a Actual: ((forall a1. IO a1 -> IO a1) -> IO a) -> IO a Cannot instantiate unification variable ‘a0’ - with a type involving polytypes: forall a. IO a -> IO a + with a type involving polytypes: forall a1. IO a1 -> IO a1 • In the second argument of ‘(.)’, namely ‘mask’ In the expression: (replicateM 2 . mask) ((\ x -> undefined x) :: a -> b) ===================================== testsuite/tests/typecheck/should_fail/T12589.stderr ===================================== @@ -1,12 +1,2 @@ T12589.hs:13:3: error: Variable not in scope: (&) :: t0 -> t1 -> t - -T12589.hs:13:5: error: - • Couldn't match expected type ‘t1’ - with actual type ‘(forall a. Bounded a => f0 a) -> h0 f0 xs0’ - Cannot instantiate unification variable ‘t1’ - with a type involving polytypes: - (forall a. Bounded a => f0 a) -> h0 f0 xs0 - • In the second argument of ‘(&)’, namely ‘hcpure (Proxy @Bounded)’ - In the expression: minBound & hcpure (Proxy @Bounded) - In an equation for ‘a’: a = minBound & hcpure (Proxy @Bounded) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b3d23afcad8bc14f2ba69b8dbe05c314e6e7b29 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b3d23afcad8bc14f2ba69b8dbe05c314e6e7b29 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:03:22 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:03:22 -0400 Subject: [Git][ghc/ghc][master] ghc.mk: amend 'make sdist' Message-ID: <5f9860eaab7bf_8973fa3c4474e406865cd@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 1 changed file: - ghc.mk Changes: ===================================== ghc.mk ===================================== @@ -1215,7 +1215,8 @@ sdist-ghc-prep-tree : cd $(SRC_DIST_GHC_DIR) && $(MAKE) distclean $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/tarballs/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/libraries/stamp/) - $(call removeTrees,$(SRC_DIST_GHC_DIR)/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/) + $(call removeTrees,$(SRC_DIST_GHC_DIR)/hadrian/_build/) + $(call removeTrees,$(SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/) $(call removeTrees,$(SRC_DIST_GHC_DIR)/compiler/stage[123]) $(call removeFiles,$(SRC_DIST_GHC_DIR)/mk/build.mk) $(call removeFiles,$(SRC_DIST_GHC_DIR)/rts/rts.cabal) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f76c5a083edc62bb40efbb0e76e8a3bf50ead765 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f76c5a083edc62bb40efbb0e76e8a3bf50ead765 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:04:01 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:04:01 -0400 Subject: [Git][ghc/ghc][master] Use config.run_ways for multi_compile_and_run tests Message-ID: <5f98611158696_8973fa3bb21aaa4689264@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -946,7 +946,7 @@ def test_common_work(watcher: testutil.Watcher, # All the ways we might run this test if func == compile or func == multimod_compile: all_ways = config.compile_ways - elif func == compile_and_run or func == multimod_compile_and_run: + elif func in [compile_and_run, multi_compile_and_run, multimod_compile_and_run]: all_ways = config.run_ways elif func == ghci_script: if WayName('ghci') in config.run_ways: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78b52c888a1cc68750261382e3a62fff65242016 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78b52c888a1cc68750261382e3a62fff65242016 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:04:33 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:04:33 -0400 Subject: [Git][ghc/ghc][master] Api Annotations: Introduce AnnPercent for HsExplicitMult Message-ID: <5f9861313aacb_8973fa3bb21aaa4690088@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - 3 changed files: - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs Changes: ===================================== compiler/GHC/Parser.y ===================================== @@ -2056,17 +2056,18 @@ type :: { LHsType GhcPs } [mu AnnRarrow $2] } | btype mult '->' ctype {% hintLinear (getLoc $2) - >> ams $1 [mj AnnMult $2,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] - >> ams (sLL $1 $> $ HsFunTy noExtField ((unLoc $2) (toUnicode $3)) $1 $4) - [mj AnnMult $2,mu AnnRarrow $3] } + >> let (arr, ann) = (unLoc $2) (toUnicode $3) + in (ams $1 [ann,mu AnnRarrow $3] -- See Note [GADT decl discards annotations] + >> ams (sLL $1 $> $ HsFunTy noExtField arr $1 $4) + [ann,mu AnnRarrow $3]) } | btype '->.' ctype {% hintLinear (getLoc $2) >> ams $1 [mu AnnLollyU $2] -- See Note [GADT decl discards annotations] >> ams (sLL $1 $> $ HsFunTy noExtField (HsLinearArrow UnicodeSyntax) $1 $3) [mu AnnLollyU $2] } -mult :: { Located (IsUnicodeSyntax -> HsArrow GhcPs) } - : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $2) } +mult :: { Located (IsUnicodeSyntax -> (HsArrow GhcPs, AddAnn)) } + : PREFIX_PERCENT atype { sLL $1 $> (\u -> mkMultTy u $1 $2) } btype :: { LHsType GhcPs } : infixtype {% runPV $1 } ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,7 +301,7 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule - | AnnMult -- ^ '%1' + | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf @@ -318,6 +318,7 @@ data AnnKeywordId | AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell | AnnPackageName | AnnPattern + | AnnPercent -- ^ '%' -- for HsExplicitMult | AnnProc | AnnQualified | AnnRarrow -- ^ '->' ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -2617,9 +2617,10 @@ mkLHsOpTy x op y = let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y in L loc (mkHsOpTy x op y) -mkMultTy :: IsUnicodeSyntax -> LHsType GhcPs -> HsArrow GhcPs -mkMultTy u (L _ (HsTyLit _ (HsNumTy _ 1))) = HsLinearArrow u -mkMultTy u t = HsExplicitMult u t +mkMultTy :: IsUnicodeSyntax -> Located Token -> LHsType GhcPs -> (HsArrow GhcPs, AddAnn) +mkMultTy u tok t@(L _ (HsTyLit _ (HsNumTy _ 1))) + = (HsLinearArrow u, AddAnn AnnPercentOne (combineLocs tok t)) +mkMultTy u tok t = (HsExplicitMult u t, AddAnn AnnPercent (getLoc tok)) ----------------------------------------------------------------------------- -- Token symbols View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3fdd4197cd9def4af40acb3753843e3e9a74d7e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3fdd4197cd9def4af40acb3753843e3e9a74d7e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:05:09 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:05:09 -0400 Subject: [Git][ghc/ghc][master] gitlab-ci: Bump ci-images Message-ID: <5f986155917f4_8973fa3b936483069548b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,7 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 6ceb0cecaeefd4927b26c054e4897724986078c8 + DOCKER_REV: 0da9c4be73f2d73868f610d20352af856e8f2727 # Sequential version number capturing the versions of all tools fetched by # .gitlab/ci.sh. Used for invalidation of GitLab CI cache. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2a25f42f884ad4ac841a36474498131596da506 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d2a25f42f884ad4ac841a36474498131596da506 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:05:44 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Tue, 27 Oct 2020 14:05:44 -0400 Subject: [Git][ghc/ghc][master] DmdAnal: Kill `is_thunk` case in `splitFV` Message-ID: <5f986178edb00_8977981fb469819@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -574,8 +574,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs rhs_fv2 = rhs_fv1 `keepAliveDmdEnv` extra_fvs -- See Note [Lazy and unleashable free variables] - (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv2 - is_thunk = not (exprIsHNF rhs) && not (isJoinId id) + (lazy_fv, sig_fv) = partitionVarEnv isWeakDmd rhs_fv2 -- Find the RHS free vars of the unfoldings and RULES -- See Note [Absence analysis for stable unfoldings and RULES] @@ -595,8 +594,9 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs mkRhsDmd :: AnalEnv -> Arity -> CoreExpr -> CleanDemand mkRhsDmd _env rhs_arity _rhs = mkCallDmds rhs_arity cleanEvalDmd --- | If given the let-bound 'Id', 'useLetUp' determines whether we should --- process the binding up (body before rhs) or down (rhs before body). +-- | If given the (local, non-recursive) let-bound 'Id', 'useLetUp' determines +-- whether we should process the binding up (body before rhs) or down (rhs +-- before body). -- -- We use LetDown if there is a chance to get a useful strictness signature to -- unleash at call sites. LetDown is generally more precise than LetUp if we can ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -42,7 +42,7 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, - splitDmdTy, splitFVs, deferAfterPreciseException, + splitDmdTy, isWeakDmd, deferAfterPreciseException, postProcessUnsat, postProcessDmdType, splitProdDmd_maybe, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, @@ -796,22 +796,6 @@ cleanUseDmd_maybe :: Demand -> Maybe UseDmd cleanUseDmd_maybe (JD { ud = Use _ u }) = Just u cleanUseDmd_maybe _ = Nothing -splitFVs :: Bool -- Thunk - -> DmdEnv -> (DmdEnv, DmdEnv) -splitFVs is_thunk rhs_fvs - | is_thunk = strictPairToTuple $ - nonDetStrictFoldUFM_Directly add (emptyVarEnv :*: emptyVarEnv) rhs_fvs - -- It's OK to use a non-deterministic fold because we - -- immediately forget the ordering by putting the elements - -- in the envs again - | otherwise = partitionVarEnv isWeakDmd rhs_fvs - where - add uniq dmd@(JD { sd = s, ud = u }) (lazy_fv :*: sig_fv) - | Lazy <- s = addToUFM_Directly lazy_fv uniq dmd :*: sig_fv - | otherwise = addToUFM_Directly lazy_fv uniq (JD { sd = Lazy, ud = u }) - :*: - addToUFM_Directly sig_fv uniq (JD { sd = s, ud = Abs }) - keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have -- /some/ usage in the returned demand types -- they are not Absent @@ -842,11 +826,6 @@ splitProdDmd_maybe (JD { sd = s, ud = u }) (Lazy, Use _ (UProd ux)) -> Just (mkJointDmds (replicate (length ux) Lazy) ux) _ -> Nothing -data StrictPair a b = !a :*: !b - -strictPairToTuple :: StrictPair a b -> (a, b) -strictPairToTuple (x :*: y) = (x, y) - {- ********************************************************************* * * TypeShape and demand trimming View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28f98b01d055c8027f9495b1669bf875b3e42168 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/28f98b01d055c8027f9495b1669bf875b3e42168 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 18:55:33 2020 From: gitlab at gitlab.haskell.org (Danya Rogozin) Date: Tue, 27 Oct 2020 14:55:33 -0400 Subject: [Git][ghc/ghc][wip/ghc-11342-char-kind] 12 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f986d25aa587_8973fa3d9c4cdb07068d0@gitlab.haskell.org.mail> Danya Rogozin pushed to branch wip/ghc-11342-char-kind at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - d1688d5a by Daniel Rogozin at 2020-10-27T21:55:04+03:00 the char kind: type families, functionality, and submodule updates Co-authored-by: Rinat Stryungis <rinat.stryungis at serokell.io> Metric Decrease: T5205 Metric Increase: Naperian T13035 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Map.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Binds.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/StgToCmm/Closure.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Solver.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da2e7af56e7aa1e7f6ddd9e5c1f546c4230c5927...d1688d5a8639338653e59e8591f3a3b90817d35f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/da2e7af56e7aa1e7f6ddd9e5c1f546c4230c5927...d1688d5a8639338653e59e8591f3a3b90817d35f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 19:09:23 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Tue, 27 Oct 2020 15:09:23 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] 14 commits: Note [Type variable cycles in Givens] Message-ID: <5f987063235df_8973fa31ac0c158713068@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 1b043c88 by Richard Eisenberg at 2020-10-27T15:06:37-04:00 Note [Type variable cycles in Givens] - - - - - 49c1ad28 by Richard Eisenberg at 2020-10-27T15:06:48-04:00 Handle obscure corner case in canonicalize - - - - - ef664084 by Richard Eisenberg at 2020-10-27T15:06:48-04:00 Handle (=>) specially in pure unifier - - - - - 15cb78fe by Richard Eisenberg at 2020-10-27T15:06:48-04:00 Start deleting stuff. Hooray! - - - - - 8bb11f44 by Richard Eisenberg at 2020-10-27T15:07:30-04:00 Fix test output - - - - - f3ac0a75 by Richard Eisenberg at 2020-10-27T15:07:35-04:00 Delete delete delete !! - - - - - 79dbf2c8 by Richard Eisenberg at 2020-10-27T15:07:36-04:00 More deleting. Checkpoint before removing FlattenMode - - - - - 008eede8 by Richard Eisenberg at 2020-10-27T15:07:36-04:00 Remove FlattenMode - - - - - 56950a02 by Richard Eisenberg at 2020-10-27T15:07:36-04:00 Stopped bumping ctLocDepth in runFlatten - - - - - d9a026e4 by Richard Eisenberg at 2020-10-27T15:07:36-04:00 Finished deleting. - - - - - 7555fffc by Richard Eisenberg at 2020-10-27T15:07:36-04:00 A few error message wibbles - - - - - c4836b65 by Richard Eisenberg at 2020-10-27T15:08:12-04:00 Some small changes, mostly comments. - - - - - de2b37ef by Richard Eisenberg at 2020-10-27T15:08:12-04:00 Fix #18875 by breaking type variable cycles. - - - - - e9d981ec by Richard Eisenberg at 2020-10-27T15:09:07-04:00 Actually add test files - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Plugin.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/Solver/Monad.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - testsuite/tests/gadt/T3169.stderr - testsuite/tests/gadt/T7293.stderr - testsuite/tests/gadt/T7294.stderr - + testsuite/tests/indexed-types/should_compile/GivenLoop.hs - testsuite/tests/indexed-types/should_compile/Simple13.hs - + testsuite/tests/indexed-types/should_compile/T18875.hs - testsuite/tests/indexed-types/should_compile/all.T - + testsuite/tests/indexed-types/should_fail/Simple13.stderr - testsuite/tests/indexed-types/should_fail/T13784.stderr - testsuite/tests/indexed-types/should_fail/T2627b.stderr - testsuite/tests/indexed-types/should_fail/T4179.stderr - testsuite/tests/indexed-types/should_fail/T5439.stderr - testsuite/tests/indexed-types/should_fail/T8227.stderr - testsuite/tests/partial-sigs/should_compile/T12844.stderr - testsuite/tests/partial-sigs/should_compile/T14715.stderr - testsuite/tests/polykinds/T14172.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3cf175e03363960bc603572eaaffbf13c559f0c5...e9d981ec57cb894bba78e2d761e35e6730b89e30 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3cf175e03363960bc603572eaaffbf13c559f0c5...e9d981ec57cb894bba78e2d761e35e6730b89e30 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 20:23:23 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Tue, 27 Oct 2020 16:23:23 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/az/tweak-annpercent-order Message-ID: <5f9881bb1ef9c_8973fa3b83571407266eb@gitlab.haskell.org.mail> Alan Zimmerman pushed new branch wip/az/tweak-annpercent-order at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/az/tweak-annpercent-order You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 20:31:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 27 Oct 2020 16:31:27 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/ghc-8.10-backports Message-ID: <5f98839fa15_8973fa3a79edca4733029@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/ghc-8.10-backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/ghc-8.10-backports You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 21:13:18 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Tue, 27 Oct 2020 17:13:18 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Add Detail (7) to the Note Message-ID: <5f988d6e5d9d6_8973fa3a7b5d60c7448af@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: c1caf60c by Richard Eisenberg at 2020-10-27T17:13:03-04:00 Add Detail (7) to the Note - - - - - 4 changed files: - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Utils/TcType.hs - testsuite/tests/typecheck/should_fail/ContextStack2.hs - + testsuite/tests/typecheck/should_fail/GivenForallLoop.stderr Changes: ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -2303,6 +2303,7 @@ canEqCanLHSFinish ev eq_rel swapped lhs rhs | OtherCIS <- status , Given <- ctEvFlavour ev , TyVarLHS lhs_tv <- lhs + , not (isCycleBreakerTyVar lhs_tv) -- See Detail (7) of Note , NomEq <- eq_rel -> do { traceTcS "canEqCanLHSFinish breaking a cycle" (ppr lhs $$ ppr rhs) ; new_rhs <- breakTyVarCycle (ctEvLoc ev) rhs @@ -2711,6 +2712,41 @@ Details: breaker variables are all zonked away by the time we examine the evidence. + (7) We don't wish to apply this magic to CycleBreakerTvs themselves. + Consider this, from typecheck/should_compile/ContextStack2: + + type instance TF (a, b) = (TF a, TF b) + t :: (a ~ TF (a, Int)) => ... + + [G] a ~ TF (a, Int) + + The RHS reduces, so we get + + [G] a ~ (TF a, TF Int) + + We then break cycles, to get + + [G] g1 :: a ~ (cbv1, cbv2) + [G] g2 :: TF a ~ cbv1 + [G] g3 :: TF Int ~ cbv2 + + g1 gets added to the inert set, as written. But then g2 becomes + the work item. g1 rewrites g2 to become + + [G] TF (cbv1, cbv2) ~ cbv1 + + which then uses the type instance to become + + [G] (TF cbv1, TF cbv2) ~ cbv1 + + which looks remarkably like the Given we started with. If left + unchecked, this will end up breaking cycles again, looping ad + infinitum (and resulting in a context-stack reduction error, + not an outright loop). The solution is easy: don't break cycles + if the var is already a CycleBreakerTv. This makes sense, because + we only want to break cycles for user-written loopy Givens, and + a CycleBreakerTv certainly isn't user-written. + -} {- ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -39,7 +39,7 @@ module GHC.Tc.Utils.TcType ( MetaDetails(Flexi, Indirect), MetaInfo(..), isImmutableTyVar, isSkolemTyVar, isMetaTyVar, isMetaTyVarTy, isTyVarTy, tcIsTcTyVar, isTyVarTyVar, isOverlappableTyVar, isTyConableTyVar, - isAmbiguousTyVar, metaTyVarRef, metaTyVarInfo, + isAmbiguousTyVar, isCycleBreakerTyVar, metaTyVarRef, metaTyVarInfo, isFlexi, isIndirect, isRuntimeUnkSkol, metaTyVarTcLevel, setMetaTyVarTcLevel, metaTyVarTcLevel_maybe, isTouchableMetaTyVar, @@ -1019,7 +1019,7 @@ isImmutableTyVar :: TyVar -> Bool isImmutableTyVar tv = isSkolemTyVar tv isTyConableTyVar, isSkolemTyVar, isOverlappableTyVar, - isMetaTyVar, isAmbiguousTyVar :: TcTyVar -> Bool + isMetaTyVar, isAmbiguousTyVar, isCycleBreakerTyVar :: TcTyVar -> Bool isTyConableTyVar tv -- True of a meta-type variable that can be filled in @@ -1064,6 +1064,14 @@ isAmbiguousTyVar tv _ -> False | otherwise = False +isCycleBreakerTyVar tv + | isTyVar tv -- See Note [Coercion variables in free variable lists] + , MetaTv { mtv_info = CycleBreakerTv } <- tcTyVarDetails tv + = True + + | otherwise + = False + isMetaTyVarTy :: TcType -> Bool isMetaTyVarTy (TyVarTy tv) = isMetaTyVar tv isMetaTyVarTy _ = False ===================================== testsuite/tests/typecheck/should_fail/ContextStack2.hs ===================================== @@ -12,11 +12,11 @@ type instance TF (a,b) = (TF a, TF b) t :: (a ~ TF (a,Int)) => Int t = undefined -{- a ~ TF (a,Int) +{- a ~ TF (a,Int) ~ (TF a, TF Int) ~ (TF (TF (a,Int)), TF Int) ~ (TF (TF a, TF Int), TF Int) - ~ ((TF (TF a), TF (TF Int)), TF Int) + ~ ((TF (TF a), TF (TF Int)), TF Int) fsk ~ a @@ -28,7 +28,7 @@ t = undefined a ~ (TF a, TF Int) (flatten rhs) a ~ (fsk1, TF Int) -(wk) TF a ~ fsk1 +(wk) TF a ~ fsk1 --> (rewrite inert) @@ -43,7 +43,7 @@ t = undefined * TF (fsk1, fsk2) ~ fsk1 (wk) TF Tnt ~ fsk2 ---> +--> fsk ~ (fsk1, TF Int) a ~ (fsk1, TF Int) @@ -51,7 +51,7 @@ t = undefined (flatten rhs) fsk1 ~ (fsk3, TF fsk2) - + (wk) TF Int ~ fsk2 TF fsk1 ~ fsk3 -} ===================================== testsuite/tests/typecheck/should_fail/GivenForallLoop.stderr ===================================== @@ -0,0 +1,20 @@ + +GivenForallLoop.hs:8:11: error: + • Could not deduce: a ~ b + from the context: a ~ (forall b1. F a b1) + bound by the type signature for: + loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b + at GivenForallLoop.hs:7:1-42 + ‘a’ is a rigid type variable bound by + the type signature for: + loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b + at GivenForallLoop.hs:7:1-42 + ‘b’ is a rigid type variable bound by + the type signature for: + loopy :: forall a b. (a ~ (forall b1. F a b1)) => a -> b + at GivenForallLoop.hs:7:1-42 + • In the expression: x + In an equation for ‘loopy’: loopy x = x + • Relevant bindings include + x :: a (bound at GivenForallLoop.hs:8:7) + loopy :: a -> b (bound at GivenForallLoop.hs:8:1) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1caf60c9e2eff957f0ebf3136194da1c36361e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c1caf60c9e2eff957f0ebf3136194da1c36361e8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 21:14:49 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Tue, 27 Oct 2020 17:14:49 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] A few error wibbles Message-ID: <5f988dc9a42cc_8973fa3b86ac0d47455e9@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: 225b422f by Richard Eisenberg at 2020-10-27T17:14:36-04:00 A few error wibbles - - - - - 2 changed files: - testsuite/tests/indexed-types/should_fail/T7788.stderr - testsuite/tests/indexed-types/should_fail/T9554.stderr Changes: ===================================== testsuite/tests/indexed-types/should_fail/T7788.stderr ===================================== @@ -1,7 +1,7 @@ T7788.hs:9:7: error: • Reduction stack overflow; size = 201 - When simplifying the following type: F (Fix Id) + When simplifying the following type: F (Id (Fix Id)) Use -freduction-depth=0 to disable this check (any upper bound you could choose might fail unpredictably with minor updates to GHC, so disabling the check is recommended if ===================================== testsuite/tests/indexed-types/should_fail/T9554.stderr ===================================== @@ -2,7 +2,7 @@ T9554.hs:11:9: error: • Reduction stack overflow; size = 201 When simplifying the following type: - F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F Bool)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F Bool))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) Use -freduction-depth=0 to disable this check (any upper bound you could choose might fail unpredictably with minor updates to GHC, so disabling the check is recommended if @@ -13,7 +13,7 @@ T9554.hs:11:9: error: T9554.hs:13:17: error: • Reduction stack overflow; size = 201 When simplifying the following type: - F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F Bool)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F (F Bool))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) Use -freduction-depth=0 to disable this check (any upper bound you could choose might fail unpredictably with minor updates to GHC, so disabling the check is recommended if View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/225b422f03e5df0c58aa161ca60c38291ffa3ca3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/225b422f03e5df0c58aa161ca60c38291ffa3ca3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 21:54:20 2020 From: gitlab at gitlab.haskell.org (chessai) Date: Tue, 27 Oct 2020 17:54:20 -0400 Subject: [Git][ghc/ghc][wip/data-dot-foldable-optimisations] Optimisations in Data.Foldable (T17867) Message-ID: <5f98970cb2ad5_897c80fa287494f2@gitlab.haskell.org.mail> chessai pushed to branch wip/data-dot-foldable-optimisations at Glasgow Haskell Compiler / GHC Commits: 62edf22a by chessai at 2020-10-27T14:53:55-07:00 Optimisations in Data.Foldable (T17867) This PR concerns the following functions from `Data.Foldable`: * minimum * maximum * sum * product * minimumBy * maximumBy - Default implementations of these functions now use `foldl'` or `foldMap'`. - All have been marked with INLINEABLE to make room for further optimisations. - - - - - 1 changed file: - libraries/base/Data/Foldable.hs Changes: ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -507,7 +507,8 @@ class Foldable t where -- @since 4.8.0.0 maximum :: forall a . Ord a => t a -> a maximum = fromMaybe (errorWithoutStackTrace "maximum: empty structure") . - getMax . foldMap (Max #. (Just :: a -> Maybe a)) + getMax . foldMap' (Max #. (Just :: a -> Maybe a)) + {-# INLINEABLE maximum #-} -- | The least element of a non-empty structure. -- @@ -529,7 +530,8 @@ class Foldable t where -- @since 4.8.0.0 minimum :: forall a . Ord a => t a -> a minimum = fromMaybe (errorWithoutStackTrace "minimum: empty structure") . - getMin . foldMap (Min #. (Just :: a -> Maybe a)) + getMin . foldMap' (Min #. (Just :: a -> Maybe a)) + {-# INLINEABLE minimum #-} -- | The 'sum' function computes the sum of the numbers of a structure. -- @@ -554,7 +556,8 @@ class Foldable t where -- -- @since 4.8.0.0 sum :: Num a => t a -> a - sum = getSum #. foldMap Sum + sum = getSum #. foldMap' Sum + {-# INLINEABLE sum #-} -- | The 'product' function computes the product of the numbers of a -- structure. @@ -580,7 +583,8 @@ class Foldable t where -- -- @since 4.8.0.0 product :: Num a => t a -> a - product = getProduct #. foldMap Product + product = getProduct #. foldMap' Product + {-# INLINEABLE product #-} -- instances for Prelude types @@ -1111,10 +1115,15 @@ all p = getAll #. foldMap (All #. p) -- See Note [maximumBy/minimumBy space usage] maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -maximumBy cmp = foldl1 max' - where max' x y = case cmp x y of - GT -> x - _ -> y +maximumBy cmp = fromMaybe (errorWithoutStackTrace "maximumBy: empty structure") + . foldl' max' Nothing + where + max' mx y = Just (case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> x + _ -> y) +{-# INLINEABLE maximumBy #-} -- | The least element of a non-empty structure with respect to the -- given comparison function. @@ -1128,10 +1137,15 @@ maximumBy cmp = foldl1 max' -- See Note [maximumBy/minimumBy space usage] minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -minimumBy cmp = foldl1 min' - where min' x y = case cmp x y of - GT -> y - _ -> x +minimumBy cmp = fromMaybe (errorWithoutStackTrace "minimumBy: empty structure") + . foldl' min' Nothing + where + min' mx y = Just (case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> y + _ -> x) +{-# INLINEABLE minimumBy #-} -- | 'notElem' is the negation of 'elem'. -- @@ -1268,12 +1282,6 @@ proportional to the size of the data structure. For the common case of lists, this could be particularly bad (see #10830). For the common case of lists, switching the implementations of maximumBy and -minimumBy to foldl1 solves the issue, as GHC's strictness analysis can then -make these functions only use O(1) stack space. It is perhaps not the optimal -way to fix this problem, as there are other conceivable data structures -(besides lists) which might benefit from specialized implementations for -maximumBy and minimumBy (see -https://gitlab.haskell.org/ghc/ghc/issues/10830#note_129843 for a further -discussion). But using foldl1 is at least always better than using foldr1, so -GHC has chosen to adopt that approach for now. +minimumBy to foldl1 solves the issue, assuming GHC's strictness analysis can then +make these functions only use O(1) stack space. As of base 4.16, we have switched to employing foldl' over foldl1, not relying on GHC's optimiser in general. See https://gitlab.haskell.org/ghc/ghc/-/issues/17867 for more context. -} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62edf22a727e03c854ff8b613bd5177e0b81e3c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62edf22a727e03c854ff8b613bd5177e0b81e3c2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 22:37:04 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 27 Oct 2020 18:37:04 -0400 Subject: [Git][ghc/ghc][wip/T16762] wibbles after RAE review Message-ID: <5f98a11062054_8973fa3a75630f87672a9@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 61eaca5f by Simon Peyton Jones at 2020-10-27T22:36:11+00:00 wibbles after RAE review - - - - - 4 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Utils/Monad.hs Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -366,9 +366,9 @@ tcHsSigWcType :: UserTypeCtxt -> LHsSigWcType GhcRn -> TcM Type -- already checked this, so we can simply ignore it. tcHsSigWcType ctxt sig_ty = tcHsSigType ctxt (dropWildCards sig_ty) -kcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM () +kcClassSigType :: [Located Name] -> LHsSigType GhcRn -> TcM () -- This is a special form of tcClassSigType that is used during the --- kind-checking phase to infer the kind of class variables. Cf. tc_hs_sig_type. +-- kind-checking phase to infer the kind of class variables. Cf. tc_lhs_sig_type. -- Importantly, this does *not* kind-generalize. Consider -- class SC f where -- meth :: forall a (x :: f a). Proxy x -> () @@ -379,7 +379,7 @@ kcClassSigType :: SkolemInfo -> [Located Name] -> LHsSigType GhcRn -> TcM () -- end up promoting kappa to the top level (because kind-generalization is -- normally done right before adding a binding to the context), and then we -- can't set kappa := f a, because a is local. -kcClassSigType _skol_info names +kcClassSigType names sig_ty@(L _ (HsSig { sig_bndrs = hs_outer_bndrs, sig_body = hs_ty })) = addSigCtxt (funsSigCtxt names) sig_ty $ do { _ <- bindOuterSigTKBndrs_Tv hs_outer_bndrs $ @@ -390,7 +390,7 @@ tcClassSigType :: [Located Name] -> LHsSigType GhcRn -> TcM Type -- Does not do validity checking tcClassSigType names sig_ty = addSigCtxt sig_ctxt sig_ty $ - do { (implic, ty) <- tc_hs_sig_type skol_info sig_ty (TheKind liftedTypeKind) + do { (implic, ty) <- tc_lhs_sig_type skol_info sig_ty (TheKind liftedTypeKind) ; emitImplication implic ; return ty } -- Do not zonk-to-Type, nor perform a validity check @@ -421,9 +421,9 @@ tcHsSigType ctxt sig_ty do { traceTc "tcHsSigType {" (ppr sig_ty) -- Generalise here: see Note [Kind generalisation] - ; (implic, ty) <- tc_hs_sig_type skol_info sig_ty (expectedKindInCtxt ctxt) + ; (implic, ty) <- tc_lhs_sig_type skol_info sig_ty (expectedKindInCtxt ctxt) - -- Spit out the implication (and perhaps fail fast) + -- Float out constraints, failing fast if not possible -- See Note [Failure in local type signatures] in GHC.Tc.Solver ; traceTc "tcHsSigType 2" (ppr implic) ; simplifyAndEmitFlatConstraints (mkImplicWC (unitBag implic)) @@ -435,7 +435,7 @@ tcHsSigType ctxt sig_ty where skol_info = SigTypeSkol ctxt -tc_hs_sig_type :: SkolemInfo -> LHsSigType GhcRn +tc_lhs_sig_type :: SkolemInfo -> LHsSigType GhcRn -> ContextKind -> TcM (Implication, TcType) -- Kind-checks/desugars an 'LHsSigType', -- solve equalities, @@ -443,11 +443,11 @@ tc_hs_sig_type :: SkolemInfo -> LHsSigType GhcRn -- This will never emit constraints, as it uses solveEqualities internally. -- No validity checking or zonking -- Returns also an implication for the unsolved constraints -tc_hs_sig_type skol_info (L loc (HsSig { sig_bndrs = hs_outer_bndrs +tc_lhs_sig_type skol_info (L loc (HsSig { sig_bndrs = hs_outer_bndrs , sig_body = hs_ty })) ctxt_kind = setSrcSpan loc $ do { (tc_lvl, wanted, (outer_bndrs, ty)) - <- pushLevelAndSolveEqualitiesX "tc_hs_sig_type" $ + <- pushLevelAndSolveEqualitiesX "tc_lhs_sig_type" $ -- See Note [Failure in local type signatures] tcOuterTKBndrs skol_info hs_outer_bndrs $ do { kind <- newExpectedKind ctxt_kind @@ -455,7 +455,7 @@ tc_hs_sig_type skol_info (L loc (HsSig { sig_bndrs = hs_outer_bndrs -- Any remaining variables (unsolved in the solveEqualities) -- should be in the global tyvars, and therefore won't be quantified - ; traceTc "tc_hs_sig_type" (ppr hs_outer_bndrs $$ ppr outer_bndrs) + ; traceTc "tc_lhs_sig_type" (ppr hs_outer_bndrs $$ ppr outer_bndrs) ; (outer_tv_bndrs :: [InvisTVBinder]) <- scopedSortOuter outer_bndrs ; let ty1 = mkInvisForAllTys outer_tv_bndrs ty @@ -475,7 +475,7 @@ tcHsSigType is tricky. Consider (T11142) This is ill-kinded becuase of a nested skolem-escape. That will show up as an un-solvable constraint in the implication -returned by buildTvImplication in tc_hs_sig_type. See Note [Skolem +returned by buildTvImplication in tc_lhs_sig_type. See Note [Skolem escape prevention] in GHC.Tc.Utils.TcType for why it is unsolvable (the unification variable for b's kind is untouchable). @@ -484,7 +484,7 @@ we'll try to float out the constraint, be unable to do so, and fail. See GHC.Tc.Solver Note [Failure in local type signatures] for more detail on this. -The separation between tcHsSigType and tc_hs_sig_type is because +The separation between tcHsSigType and tc_lhs_sig_type is because tcClassSigType wants to use the latter, but *not* fail fast, because there are skolems from the class decl which are in scope; but it's fine not to because tcClassDecl1 has a solveEqualities wrapped around all @@ -503,32 +503,31 @@ top level of a signature. tcStandaloneKindSig :: LStandaloneKindSig GhcRn -> TcM (Name, Kind) tcStandaloneKindSig (L _ (StandaloneKindSig _ (L _ name) ksig)) = addSigCtxt ctxt ksig $ - do { kind <- tc_top_lhs_type KindLevel ksig (expectedKindInCtxt ctxt) + do { kind <- tc_top_lhs_type KindLevel ctxt ksig ; checkValidType ctxt kind ; return (name, kind) } where ctxt = StandaloneKindSigCtxt name -tcTopLHsType :: LHsSigType GhcRn -> ContextKind -> TcM Type -tcTopLHsType lsig_ty ctxt_kind - = tc_top_lhs_type TypeLevel lsig_ty ctxt_kind +tcTopLHsType :: UserTypeCtxt -> LHsSigType GhcRn -> TcM Type +tcTopLHsType ctxt lsig_ty + = tc_top_lhs_type TypeLevel ctxt lsig_ty -tc_top_lhs_type :: TypeOrKind -> LHsSigType GhcRn -> ContextKind -> TcM Type +tc_top_lhs_type :: TypeOrKind -> UserTypeCtxt -> LHsSigType GhcRn -> TcM Type -- tc_top_lhs_type is used for kind-checking top-level LHsSigTypes where -- we want to fully solve /all/ equalities, and report errors -- Does zonking, but not validity checking because it's used -- for things (like deriving and instances) that aren't -- ordinary types -- Used for both types and kinds -tc_top_lhs_type tyki (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs - , sig_body = body })) ctxt_kind +tc_top_lhs_type tyki ctxt (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs + , sig_body = body })) = setSrcSpan loc $ do { traceTc "tc_top_lhs_type {" (ppr sig_ty) - ; let skol_info = InstSkol -- Why? ; (tclvl, wanted, (outer_bndrs, ty)) <- pushLevelAndSolveEqualitiesX "tc_top_lhs_type" $ tcOuterTKBndrs skol_info hs_outer_bndrs $ - do { kind <- newExpectedKind ctxt_kind + do { kind <- newExpectedKind (expectedKindInCtxt ctxt) ; tc_lhs_type (mkMode tyki) body kind } ; outer_tv_bndrs <- scopedSortOuter outer_bndrs @@ -540,6 +539,8 @@ tc_top_lhs_type tyki (L loc sig_ty@(HsSig { sig_bndrs = hs_outer_bndrs ; final_ty <- zonkTcTypeToType (mkInfForAllTys kvs ty1) ; traceTc "tc_top_lhs_type }" (vcat [ppr sig_ty, ppr final_ty]) ; return final_ty } + where + skol_info = SigTypeSkol ctxt ----------------- tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], Class, [Type], [Kind]) @@ -552,7 +553,7 @@ tcHsDeriv :: LHsSigType GhcRn -> TcM ([TyVar], Class, [Type], [Kind]) tcHsDeriv hs_ty = do { ty <- checkNoErrs $ -- Avoid redundant error report -- with "illegal deriving", below - tcTopLHsType hs_ty AnyKind + tcTopLHsType DerivClauseCtxt hs_ty ; let (tvs, pred) = splitForAllTys ty (kind_args, _) = splitFunTys (tcTypeKind pred) ; case getClassPredTys_maybe pred of @@ -581,7 +582,7 @@ tcDerivStrategy mb_lds tc_deriv_strategy AnyclassStrategy = boring_case AnyclassStrategy tc_deriv_strategy NewtypeStrategy = boring_case NewtypeStrategy tc_deriv_strategy (ViaStrategy ty) = do - ty' <- checkNoErrs $ tcTopLHsType ty AnyKind + ty' <- checkNoErrs $ tcTopLHsType DerivClauseCtxt ty let (via_tvs, via_pred) = splitForAllTys ty' pure (ViaStrategy via_pred, via_tvs) @@ -599,7 +600,7 @@ tcHsClsInstType user_ctxt hs_inst_ty -- eagerly avoids follow-on errors when checkValidInstance -- sees an unsolved coercion hole inst_ty <- checkNoErrs $ - tcTopLHsType hs_inst_ty (TheKind constraintKind) + tcTopLHsType user_ctxt hs_inst_ty ; checkValidInstance user_ctxt hs_inst_ty inst_ty ; return inst_ty } @@ -823,6 +824,7 @@ mkMode :: TypeOrKind -> TcTyMode mkMode tyki = TcTyMode { mode_tyki = tyki, mode_holes = Nothing } typeLevelMode, kindLevelMode :: TcTyMode +-- These modes expect no wildcards (holes) in the type kindLevelMode = mkMode KindLevel typeLevelMode = mkMode TypeLevel @@ -2904,6 +2906,7 @@ expectedKindInCtxt (GhciCtxt {}) = AnyKind -- The types in a 'default' decl can have varying kinds -- See Note [Extended defaults]" in GHC.Tc.Utils.Env expectedKindInCtxt DefaultDeclCtxt = AnyKind +expectedKindInCtxt DerivClauseCtxt = AnyKind expectedKindInCtxt TypeAppCtxt = AnyKind expectedKindInCtxt (ForSigCtxt _) = TheKind liftedTypeKind expectedKindInCtxt (InstDeclCtxt {}) = TheKind constraintKind @@ -2962,12 +2965,11 @@ bindOuterTKBndrsX skol_mode outer_bndrs thing_inside , thing) } getOuterTyVars :: HsOuterTyVarBndrs flag GhcTc -> [TcTyVar] +-- The returned [TcTyVar] is not necessarily in dependency order +-- at least for the HsOuterImplicit case getOuterTyVars (HsOuterImplicit { hso_ximplicit = tvs }) = tvs getOuterTyVars (HsOuterExplicit { hso_xexplicit = tvbs }) = binderVars tvbs -applyToFstM :: (a -> b) -> TcM (a, r) -> TcM (b, r) -applyToFstM f thing = do { (a,r) <- thing; return (f a, r) } - --------------- scopedSortOuter :: HsOuterTyVarBndrs Specificity GhcTc -> TcM [InvisTVBinder] -- Sort any /implicit/ binders into dependency order @@ -3085,6 +3087,7 @@ bindExplicitTKBndrs_Skol, bindExplicitTKBndrs_Tv bindExplicitTKBndrs_Skol = bindExplicitTKBndrsX (smVanilla { sm_clone = False }) bindExplicitTKBndrs_Tv = bindExplicitTKBndrsX (smVanilla { sm_clone = True, sm_tvtv = True }) + -- sm_clone: see Note [Cloning for type variable binders] bindExplicitTKBndrs_Q_Skol, bindExplicitTKBndrs_Q_Tv :: ContextKind @@ -3097,6 +3100,7 @@ bindExplicitTKBndrs_Q_Skol ctxt_kind hs_bndrs thing_inside bindExplicitTKBndrsX (smVanilla { sm_clone = False, sm_parent = True , sm_kind = ctxt_kind }) hs_bndrs thing_inside + -- sm_clone=False: see Note [Cloning for type variable binders] bindExplicitTKBndrs_Q_Tv ctxt_kind hs_bndrs thing_inside = applyToFstM binderVars $ @@ -3207,8 +3211,7 @@ bindImplicitTKBndrsX -> TcM a -> TcM ([TcTyVar], a) -- Returned [TcTyVar] are in 1-1 correspondence -- with the passed in [Name] -bindImplicitTKBndrsX (SM { sm_parent = check_parent, sm_clone = clone - , sm_tvtv = tvtv, sm_kind = ctxt_kind }) +bindImplicitTKBndrsX skol_mode@(SM { sm_parent = check_parent, sm_kind = ctxt_kind }) tv_names thing_inside = do { lcl_env <- getLclTypeEnv ; tkvs <- mapM (new_tv lcl_env) tv_names @@ -3222,39 +3225,36 @@ bindImplicitTKBndrsX (SM { sm_parent = check_parent, sm_clone = clone , Just (ATyVar _ tv) <- lookupNameEnv lcl_env name = return tv | otherwise - = do { name <- case clone of - True -> do { uniq <- newUnique - ; return (setNameUnique name uniq) } - False -> return name - ; kind <- newExpectedKind ctxt_kind - ; details <- case tvtv of - True -> newMetaDetails TyVarTv - False -> do { lvl <- getTcLevel - ; return (SkolemTv lvl False) } - ; return (mkTcTyVar name kind details) } + = do { kind <- newExpectedKind ctxt_kind + ; newTyVarBndr skol_mode name kind } -------------------------------------- -- SkolemMode -------------------------------------- -{- Note [SkolemMode] -~~~~~~~~~~~~~~~~~~~~ -SkolemMode decribes how to typecheck an explict (HsTyVarBndr) or -implicit (Name) binder in a type. It is just a record of flags -that describe what sort of TcTyVar to create. --} - +-- | 'SkolemMode' decribes how to typecheck an explict ('HsTyVarBndr') or +-- implicit ('Name') binder in a type. It is just a record of flags +-- that describe what sort of 'TcTyVar' to create. data SkolemMode = SM { sm_parent :: Bool -- True <=> check the in-scope parent type variable + -- Used only for asssociated types + , sm_clone :: Bool -- True <=> fresh unique + -- See Note [Cloning for type variable binders] + , sm_tvtv :: Bool -- True <=> use a TyVarTv, rather than SkolemTv + -- Why? See Note [Inferring kinds for type declarations] + -- in GHC.Tc.TyCl, and (in this module) + -- Note [Checking partial type signatures] + , sm_kind :: ContextKind -- Use this for the kind of any new binders + , sm_holes :: HoleInfo -- What to do for wildcards in the kind } smVanilla :: SkolemMode -smVanilla = SM { sm_parent = False - , sm_clone = True +smVanilla = SM { sm_clone = panic "sm_clone" -- We always override this + , sm_parent = False , sm_tvtv = False , sm_kind = AnyKind , sm_holes = Nothing } @@ -3263,7 +3263,10 @@ smVanilla = SM { sm_parent = False ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sometimes we must clone the Name of a type variable binder (written in the source program); and sometimes we must not. This is controlled by -the sm_clone field of SkolemMode +the sm_clone field of SkolemMode. + +In some cases it doesn't matter whether or not we clone. Perhaps +it'd be better to use MustClone/MayClone/MustNotClone. When we /must not/ clone * In the binders of a type signature (tcOuterTKBndrs) @@ -3288,9 +3291,8 @@ When we /must not/ clone * bindExplictTKBndrs_Q_Skol, bindExplictTKBndrs_Skol, do not clone. There is no need, I think. - The payoff here is that avoidng gratuitious cloning means that we can - lmost always take the fast path in swizzleTcTyConBndrs. "Almost - always" means not the case of mutual recursion with polymorphic kinds. + The payoff here is that avoiding gratuitious cloning means that we can + almost always take the fast path in swizzleTcTyConBndrs. When we /must/ clone. * bindOuterSigTKBndrs_Tv, bindExplicitTKBndrs_Tv do cloning ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -238,6 +238,7 @@ floatKindEqualities :: WantedConstraints -> Maybe (Bag Ct, Bag Hole) -- more floatable. -- Precondition 2: the 'wanteds' are zonked, since floatKindEqualities -- is not monadic +-- See Note [floatKindEqualities vs approximateWC] floatKindEqualities wc = float_wc emptyVarSet wc where float_wc :: TcTyCoVarSet -> WantedConstraints -> Maybe (Bag Ct, Bag Hole) @@ -374,6 +375,16 @@ All this is done: reporting errors, we avoid that happening. See also #18062, #11506 + +Note [floatKindEqualities vs approximateWC] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +floatKindEqualities and approximateWC are strikingly similar to each +other, but + +* floatKindEqualites tries to float /all/ equalities, and fails if + it can't, or if any implication is insoluble. +* approximateWC just floats out any constraints + (not just equalities) that can float; it never fails. -} @@ -2248,6 +2259,7 @@ defaultTyVarTcS the_tv approximateWC :: Bool -> WantedConstraints -> Cts -- Postcondition: Wanted or Derived Cts -- See Note [ApproximateWC] +-- See Note [floatKindEqualities vs approximateWC] approximateWC float_past_equalities wc = float_wc emptyVarSet wc where ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -746,7 +746,9 @@ swizzleTcTyConBndrs :: [(TcTyCon, ScopedPairs, TcKind)] swizzleTcTyConBndrs tc_infos | all no_swizzle swizzle_prs -- This fast path happens almost all the time - -- See Note [Non-cloning for tyvar binders] in GHC.Tc.Gen.HsType + -- See Note [Cloning for type variable binders] in GHC.Tc.Gen.HsType + -- "Almost all the time" means not the case of mutual recursion with + -- polymorphic kinds. = do { traceTc "Skipping swizzleTcTyConBndrs for" (ppr (map fstOf3 tc_infos)) ; return tc_infos } @@ -1551,11 +1553,9 @@ kcTyClDecl (ClassDecl { tcdLName = L _ name do { _ <- tcHsContext ctxt ; mapM_ (wrapLocM_ kc_sig) sigs } where - kc_sig (ClassOpSig _ _ nms op_ty) = kcClassSigType skol_info nms op_ty + kc_sig (ClassOpSig _ _ nms op_ty) = kcClassSigType nms op_ty kc_sig _ = return () - skol_info = TyConSkol ClassFlavour name - kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc -- closed type families look at their equations, but other families don't -- do anything here @@ -3306,6 +3306,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data mkPhiTy ctxt $ mkVisFunTys arg_tys $ res_ty) + ; traceTc "tcConDecl:GADT" (ppr names $$ ppr res_ty $$ ppr tkvs) ; reportUnsolvedEqualities skol_info tkvs tclvl wanted ; let tvbndrs = mkTyVarBinders InferredSpec tkvs ++ outer_tv_bndrs ===================================== compiler/GHC/Utils/Monad.hs ===================================== @@ -11,6 +11,7 @@ module GHC.Utils.Monad , zipWith3M, zipWith3M_, zipWith4M, zipWithAndUnzipM , mapAndUnzipM, mapAndUnzip3M, mapAndUnzip4M, mapAndUnzip5M , mapAccumLM + , applyToFstM, applyToSndM , mapSndM , concatMapM , mapMaybeM @@ -164,6 +165,12 @@ mapSndM f xs = go xs go [] = return [] go ((a,b):xs) = do { c <- f b; rs <- go xs; return ((a,c):rs) } +applyToFstM :: Monad m => (a -> b) -> m (a, r) -> m (b, r) +applyToFstM f thing = do { (a,r) <- thing; return (f a, r) } + +applyToSndM :: Monad m => (a -> b) -> m (r, a) -> m (r, b) +applyToSndM f thing = do { (r,a) <- thing; return (r, f a) } + -- | Monadic version of concatMap concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] concatMapM f xs = liftM concat (mapM f xs) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61eaca5f163912249d11796a2ab6d80044ca0b5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61eaca5f163912249d11796a2ab6d80044ca0b5c You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 22:47:45 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Tue, 27 Oct 2020 18:47:45 -0400 Subject: [Git][ghc/ghc][wip/T16762] 2 commits: Fix mistakes in the Haddock patch Message-ID: <5f98a391607c1_8973fa3bb2416a4776349@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 10f00950 by Ryan Scott at 2020-10-27T22:42:49+00:00 Fix mistakes in the Haddock patch - - - - - 104f60c8 by Simon Peyton Jones at 2020-10-27T22:46:40+00:00 Re-add Ryan's wibbles - - - - - 9 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/TyCl.hs - testsuite/tests/polykinds/T16762c.hs - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -457,7 +457,7 @@ data HsOuterTyVarBndrs flag pass -- | Used for signatures, e.g., -- -- @ --- f :: forall a {b}. blahg +-- f :: forall a {b}. blah -- @ -- -- We use 'Specificity' for the 'HsOuterTyVarBndrs' @flag@ to allow @@ -1664,8 +1664,8 @@ splitLHsSigmaTyInvis ty -- | Decompose a GADT type into its constituent parts. -- Returns @(outer_bndrs, mb_ctxt, body)@, where: -- --- * @outer_bndrs@ are 'OuterExplicit' if the type has explicit, outermost --- type variable binders. Otherwise, they are 'OuterImplicit'. +-- * @outer_bndrs@ are 'HsOuterExplicit' if the type has explicit, outermost +-- type variable binders. Otherwise, they are 'HsOuterImplicit'. -- -- * @mb_ctxt@ is @Just@ the context, if it is provided. -- Otherwise, it is @Nothing at . @@ -1684,7 +1684,7 @@ splitLHsGadtTy (L _ sig_ty) = (outer_bndrs, mb_ctxt, tau_ty) where split_bndrs :: HsSigType GhcPs -> (HsOuterSigTyVarBndrs GhcPs, LHsType GhcPs) - split_bndrs (HsSig { sig_bndrs = outer_bndrs, sig_body = body_ty}) = + split_bndrs (HsSig{sig_bndrs = outer_bndrs, sig_body = body_ty}) = (outer_bndrs, body_ty) -- | Decompose a type of the form @forall . body@ into its constituent ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -933,8 +933,6 @@ instance HasHaddock a => HasHaddock (HsWildCardBndrs GhcPs a) where instance HasHaddock (Located (HsSigType GhcPs)) where addHaddock (L l (HsSig{sig_bndrs = outer_bndrs, sig_body = body})) = - -- TODO RGS: I cargo-culted this code from the HsForAllTy case of the - -- HasHaddock instance for HsType. Is this right? Need Vlad to check. extendHdkA l $ do case outer_bndrs of HsOuterImplicit{} -> pure () ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -12,7 +12,7 @@ module GHC.Rename.HsType ( rnHsType, rnLHsType, rnLHsTypes, rnContext, rnHsKind, rnLHsKind, rnLHsTypeArgs, rnHsSigType, rnHsWcType, - HsSigWcTypeScoping(..), rnHsSigWcType, rnHsPatSigType, + HsPatSigTypeScoping(..), rnHsSigWcType, rnHsPatSigType, newTyVarNameRn, rnConDeclFields, rnLTyVar, @@ -81,7 +81,7 @@ to break several loops. ********************************************************* -} -data HsSigWcTypeScoping +data HsPatSigTypeScoping = AlwaysBind -- ^ Always bind any free tyvars of the given type, regardless of whether we -- have a forall at the top. @@ -131,7 +131,7 @@ rnHsSigWcType doc (HsWC { hswc_body = , sig_bndrs = outer_bndrs', sig_body = body_ty' }} , fvs) } } -rnHsPatSigType :: HsSigWcTypeScoping +rnHsPatSigType :: HsPatSigTypeScoping -> HsDocContext -> HsPatSigType GhcPs -> (HsPatSigType GhcRn -> RnM (a, FreeVars)) @@ -146,32 +146,20 @@ rnHsPatSigType :: HsSigWcTypeScoping rnHsPatSigType scoping ctx sig_ty thing_inside = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty) - ; rn_hs_sig_wc_type scoping ctx (hsPatSigType sig_ty) $ - \nwcs imp_tvs body -> - do { let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } - sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = body } - ; thing_inside sig_ty' - } } - --- The workhorse for rnHsSigWcType and rnHsPatSigType. -rn_hs_sig_wc_type :: HsSigWcTypeScoping -> HsDocContext - -> LHsType GhcPs - -> ([Name] -- Wildcard names - -> [Name] -- Implicitly bound type variable names - -> LHsType GhcRn - -> RnM (a, FreeVars)) - -> RnM (a, FreeVars) -rn_hs_sig_wc_type scoping ctxt hs_ty thing_inside - = do { free_vars <- filterInScopeM (extractHsTyRdrTyVars hs_ty) + ; free_vars <- filterInScopeM (extractHsTyRdrTyVars pat_sig_ty) ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars ; let nwc_rdrs = nubL nwc_rdrs' - ; implicit_bndrs <- case scoping of - AlwaysBind -> pure tv_rdrs - NeverBind -> pure [] - ; rnImplicitBndrs Nothing implicit_bndrs $ \ vars -> - do { (wcs, hs_ty', fvs1) <- rnWcBody ctxt nwc_rdrs hs_ty - ; (res, fvs2) <- thing_inside wcs vars hs_ty' + implicit_bndrs = case scoping of + AlwaysBind -> tv_rdrs + NeverBind -> [] + ; rnImplicitBndrs Nothing implicit_bndrs $ \ imp_tvs -> + do { (nwcs, pat_sig_ty', fvs1) <- rnWcBody ctx nwc_rdrs pat_sig_ty + ; let sig_names = HsPSRn { hsps_nwcs = nwcs, hsps_imp_tvs = imp_tvs } + sig_ty' = HsPS { hsps_ext = sig_names, hsps_body = pat_sig_ty' } + ; (res, fvs2) <- thing_inside sig_ty' ; return (res, fvs1 `plusFV` fvs2) } } + where + pat_sig_ty = hsPatSigType sig_ty rnHsWcType :: HsDocContext -> LHsWcType GhcPs -> RnM (LHsWcType GhcRn, FreeVars) rnHsWcType ctxt (HsWC { hswc_body = hs_ty }) ===================================== compiler/GHC/Tc/Gen/Bind.hs ===================================== @@ -1658,7 +1658,6 @@ decideGeneralisationPlan dflags lbinds closed sig_fn = [ null theta | TcIdSig (PartialSig { psig_hs_ty = hs_ty }) <- mapMaybe sig_fn (collectHsBindListBinders lbinds) - -- TODO RGS: What about outer parentheses here? , let (L _ theta, _) = splitLHsQualTy (hsSigWcType hs_ty) ] has_partial_sigs = not (null partial_sig_mrs) ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -4120,8 +4120,11 @@ promotionErr name err NoDataKindsTC -> text "perhaps you intended to use DataKinds" NoDataKindsDC -> text "perhaps you intended to use DataKinds" PatSynPE -> text "pattern synonyms cannot be promoted" - _ -> text "it is defined and used in the same recursive group" - -- RecDataConPE, ClassPE, TyConPE + RecDataConPE -> same_rec_group_msg + ClassPE -> same_rec_group_msg + TyConPE -> same_rec_group_msg + + same_rec_group_msg = text "it is defined and used in the same recursive group" {- ************************************************************************ ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -339,7 +339,7 @@ So here's the plan (see tcHsSigType): * buildTvImplication: build an implication for the residual, unsolved constraint -* simplifyAndEmitFlatConstraints: try to float out every unsolved equalities +* simplifyAndEmitFlatConstraints: try to float out every unsolved equality inside that implication, in the hope that it constrains only global type variables, not the locally-quantified ones. ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2934,7 +2934,7 @@ without treating the explicitly-quanfitifed ones specially. Wrinkles: variables, so that we get an error from Validity.checkFamPatBinders if a forall'd variable is not bound on the LHS - - We still want to complain about an bad telescope among the user-specified + - We still want to complain about a bad telescope among the user-specified variables. So in checkFamTelescope we emit an implication constraint quantifying only over them, purely so that we get a good telescope error. @@ -3300,7 +3300,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) } - ; (outer_tv_bndrs :: [TcInvisTVBinder]) <- scopedSortOuter outer_bndrs + ; outer_tv_bndrs <- scopedSortOuter outer_bndrs ; tkvs <- kindGeneralizeAll (mkInvisForAllTys outer_tv_bndrs $ mkPhiTy ctxt $ ===================================== testsuite/tests/polykinds/T16762c.hs ===================================== @@ -8,4 +8,3 @@ data SameKind :: k -> k -> Type -- Bad telescope data T = forall a k (b::k). MkT (SameKind a b) - ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 8d5d83effcb7218c27298a8a0411ec2d4633a582 +Subproject commit 638d96c98a29d566fdb36717868e2854ffebb01b View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61eaca5f163912249d11796a2ab6d80044ca0b5c...104f60c856d5d9d19203a0811e09a053394b0c11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/61eaca5f163912249d11796a2ab6d80044ca0b5c...104f60c856d5d9d19203a0811e09a053394b0c11 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Tue Oct 27 23:16:31 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Tue, 27 Oct 2020 19:16:31 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/backports Message-ID: <5f98aa4f4101e_8973fa3d9550e6c7889fc@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/backports at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/backports You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 00:10:31 2020 From: gitlab at gitlab.haskell.org (chessai) Date: Tue, 27 Oct 2020 20:10:31 -0400 Subject: [Git][ghc/ghc][wip/data-dot-foldable-optimisations] Optimisations in Data.Foldable (T17867) Message-ID: <5f98b6f76c82a_8973fa31cc0c458797685@gitlab.haskell.org.mail> chessai pushed to branch wip/data-dot-foldable-optimisations at Glasgow Haskell Compiler / GHC Commits: 37b5c2cd by chessai at 2020-10-27T17:10:17-07:00 Optimisations in Data.Foldable (T17867) This PR concerns the following functions from `Data.Foldable`: * minimum * maximum * sum * product * minimumBy * maximumBy - Default implementations of these functions now use `foldl'` or `foldMap'`. - All have been marked with INLINEABLE to make room for further optimisations. - - - - - 1 changed file: - libraries/base/Data/Foldable.hs Changes: ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -507,7 +507,8 @@ class Foldable t where -- @since 4.8.0.0 maximum :: forall a . Ord a => t a -> a maximum = fromMaybe (errorWithoutStackTrace "maximum: empty structure") . - getMax . foldMap (Max #. (Just :: a -> Maybe a)) + getMax . foldMap' (Max #. (Just :: a -> Maybe a)) + {-# INLINEABLE maximum #-} -- | The least element of a non-empty structure. -- @@ -529,7 +530,8 @@ class Foldable t where -- @since 4.8.0.0 minimum :: forall a . Ord a => t a -> a minimum = fromMaybe (errorWithoutStackTrace "minimum: empty structure") . - getMin . foldMap (Min #. (Just :: a -> Maybe a)) + getMin . foldMap' (Min #. (Just :: a -> Maybe a)) + {-# INLINEABLE minimum #-} -- | The 'sum' function computes the sum of the numbers of a structure. -- @@ -554,7 +556,8 @@ class Foldable t where -- -- @since 4.8.0.0 sum :: Num a => t a -> a - sum = getSum #. foldMap Sum + sum = getSum #. foldMap' Sum + {-# INLINEABLE sum #-} -- | The 'product' function computes the product of the numbers of a -- structure. @@ -580,7 +583,8 @@ class Foldable t where -- -- @since 4.8.0.0 product :: Num a => t a -> a - product = getProduct #. foldMap Product + product = getProduct #. foldMap' Product + {-# INLINEABLE product #-} -- instances for Prelude types @@ -1111,10 +1115,15 @@ all p = getAll #. foldMap (All #. p) -- See Note [maximumBy/minimumBy space usage] maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -maximumBy cmp = foldl1 max' - where max' x y = case cmp x y of - GT -> x - _ -> y +maximumBy cmp = fromMaybe (errorWithoutStackTrace "maximumBy: empty structure") + . foldl' max' Nothing + where + max' mx y = Just $ case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> x + _ -> y +{-# INLINEABLE maximumBy #-} -- | The least element of a non-empty structure with respect to the -- given comparison function. @@ -1128,10 +1137,15 @@ maximumBy cmp = foldl1 max' -- See Note [maximumBy/minimumBy space usage] minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -minimumBy cmp = foldl1 min' - where min' x y = case cmp x y of - GT -> y - _ -> x +minimumBy cmp = fromMaybe (errorWithoutStackTrace "minimumBy: empty structure") + . foldl' min' Nothing + where + min' mx y = Just $ case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> y + _ -> x +{-# INLINEABLE minimumBy #-} -- | 'notElem' is the negation of 'elem'. -- @@ -1268,12 +1282,6 @@ proportional to the size of the data structure. For the common case of lists, this could be particularly bad (see #10830). For the common case of lists, switching the implementations of maximumBy and -minimumBy to foldl1 solves the issue, as GHC's strictness analysis can then -make these functions only use O(1) stack space. It is perhaps not the optimal -way to fix this problem, as there are other conceivable data structures -(besides lists) which might benefit from specialized implementations for -maximumBy and minimumBy (see -https://gitlab.haskell.org/ghc/ghc/issues/10830#note_129843 for a further -discussion). But using foldl1 is at least always better than using foldr1, so -GHC has chosen to adopt that approach for now. +minimumBy to foldl1 solves the issue, assuming GHC's strictness analysis can then +make these functions only use O(1) stack space. As of base 4.16, we have switched to employing foldl' over foldl1, not relying on GHC's optimiser in general. See https://gitlab.haskell.org/ghc/ghc/-/issues/17867 for more context. -} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37b5c2cd472964e84242344a869b7d3752ef7684 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/37b5c2cd472964e84242344a869b7d3752ef7684 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 00:13:34 2020 From: gitlab at gitlab.haskell.org (chessai) Date: Tue, 27 Oct 2020 20:13:34 -0400 Subject: [Git][ghc/ghc][wip/data-dot-foldable-optimisations] Optimisations in Data.Foldable (T17867) Message-ID: <5f98b7ae1dbe8_8973fa31b103274804425@gitlab.haskell.org.mail> chessai pushed to branch wip/data-dot-foldable-optimisations at Glasgow Haskell Compiler / GHC Commits: dc94a241 by chessai at 2020-10-27T17:13:23-07:00 Optimisations in Data.Foldable (T17867) This PR concerns the following functions from `Data.Foldable`: * minimum * maximum * sum * product * minimumBy * maximumBy - Default implementations of these functions now use `foldl'` or `foldMap'`. - All have been marked with INLINEABLE to make room for further optimisations. - - - - - 1 changed file: - libraries/base/Data/Foldable.hs Changes: ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -507,7 +507,8 @@ class Foldable t where -- @since 4.8.0.0 maximum :: forall a . Ord a => t a -> a maximum = fromMaybe (errorWithoutStackTrace "maximum: empty structure") . - getMax . foldMap (Max #. (Just :: a -> Maybe a)) + getMax . foldMap' (Max #. (Just :: a -> Maybe a)) + {-# INLINEABLE maximum #-} -- | The least element of a non-empty structure. -- @@ -529,7 +530,8 @@ class Foldable t where -- @since 4.8.0.0 minimum :: forall a . Ord a => t a -> a minimum = fromMaybe (errorWithoutStackTrace "minimum: empty structure") . - getMin . foldMap (Min #. (Just :: a -> Maybe a)) + getMin . foldMap' (Min #. (Just :: a -> Maybe a)) + {-# INLINEABLE minimum #-} -- | The 'sum' function computes the sum of the numbers of a structure. -- @@ -554,7 +556,8 @@ class Foldable t where -- -- @since 4.8.0.0 sum :: Num a => t a -> a - sum = getSum #. foldMap Sum + sum = getSum #. foldMap' Sum + {-# INLINEABLE sum #-} -- | The 'product' function computes the product of the numbers of a -- structure. @@ -580,7 +583,8 @@ class Foldable t where -- -- @since 4.8.0.0 product :: Num a => t a -> a - product = getProduct #. foldMap Product + product = getProduct #. foldMap' Product + {-# INLINEABLE product #-} -- instances for Prelude types @@ -1111,10 +1115,15 @@ all p = getAll #. foldMap (All #. p) -- See Note [maximumBy/minimumBy space usage] maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -maximumBy cmp = foldl1 max' - where max' x y = case cmp x y of - GT -> x - _ -> y +maximumBy cmp = fromMaybe (errorWithoutStackTrace "maximumBy: empty structure") + . foldl' max' Nothing + where + max' mx y = Just $ case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> x + _ -> y +{-# INLINEABLE maximumBy #-} -- | The least element of a non-empty structure with respect to the -- given comparison function. @@ -1128,10 +1137,15 @@ maximumBy cmp = foldl1 max' -- See Note [maximumBy/minimumBy space usage] minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a -minimumBy cmp = foldl1 min' - where min' x y = case cmp x y of - GT -> y - _ -> x +minimumBy cmp = fromMaybe (errorWithoutStackTrace "minimumBy: empty structure") + . foldl' min' Nothing + where + min' mx y = Just $ case mx of + Nothing -> y + Just x -> case cmp x y of + GT -> y + _ -> x +{-# INLINEABLE minimumBy #-} -- | 'notElem' is the negation of 'elem'. -- @@ -1268,12 +1282,6 @@ proportional to the size of the data structure. For the common case of lists, this could be particularly bad (see #10830). For the common case of lists, switching the implementations of maximumBy and -minimumBy to foldl1 solves the issue, as GHC's strictness analysis can then -make these functions only use O(1) stack space. It is perhaps not the optimal -way to fix this problem, as there are other conceivable data structures -(besides lists) which might benefit from specialized implementations for -maximumBy and minimumBy (see -https://gitlab.haskell.org/ghc/ghc/issues/10830#note_129843 for a further -discussion). But using foldl1 is at least always better than using foldr1, so -GHC has chosen to adopt that approach for now. +minimumBy to foldl1 solves the issue, assuming GHC's strictness analysis can then +make these functions only use O(1) stack space. As of base 4.16, we have switched to employing foldl' over foldl1, not relying on GHC's optimiser. See https://gitlab.haskell.org/ghc/ghc/-/issues/17867 for more context. -} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc94a241770a7dc28a05eb3c8664d7ebb78dc375 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc94a241770a7dc28a05eb3c8664d7ebb78dc375 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 10:53:03 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 28 Oct 2020 06:53:03 -0400 Subject: [Git][ghc/ghc][wip/T16762] Testsuite wibbles Message-ID: <5f994d8f71339_8973fa31cbd87fc858093@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: a26f39ae by Simon Peyton Jones at 2020-10-28T10:52:22+00:00 Testsuite wibbles - - - - - 3 changed files: - testsuite/tests/polykinds/T11520.stderr - testsuite/tests/saks/should_fail/saks_fail020.stderr - testsuite/tests/typecheck/should_fail/T13909.stderr Changes: ===================================== testsuite/tests/polykinds/T11520.stderr ===================================== @@ -2,7 +2,7 @@ T11520.hs:15:77: error: • Expected kind ‘k2 -> k1’, but ‘g’ has kind ‘k4’ ‘k4’ is a rigid type variable bound by - the instance declaration + an instance declaration at T11520.hs:15:10-78 • In the second argument of ‘Compose’, namely ‘g’ In the first argument of ‘Typeable’, namely ‘(Compose f g)’ ===================================== testsuite/tests/saks/should_fail/saks_fail020.stderr ===================================== @@ -2,7 +2,7 @@ saks_fail020.hs:9:49: error: • Expected kind ‘k1’, but ‘a’ has kind ‘k’ ‘k’ is a rigid type variable bound by - the instance declaration + a standalone kind signature for ‘Foo2’ at saks_fail020.hs:9:14-55 ‘k1’ is a rigid type variable bound by an explicit forall (k :: Type) ===================================== testsuite/tests/typecheck/should_fail/T13909.stderr ===================================== @@ -3,7 +3,7 @@ T13909.hs:11:18: error: • Expecting two more arguments to ‘Hm’ Expected kind ‘k’, but ‘Hm’ has kind ‘forall k -> k -> *’ ‘k’ is a rigid type variable bound by - the instance declaration + an instance declaration at T13909.hs:11:10-19 • In the first argument of ‘HasName’, namely ‘Hm’ In the instance declaration for ‘HasName Hm’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a26f39aedca8bde393d868a92d8e0ba620fded1a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a26f39aedca8bde393d868a92d8e0ba620fded1a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 13:07:09 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Wed, 28 Oct 2020 09:07:09 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] 217 commits: Introduce OutputableP Message-ID: <5f996cfd63e24_8973fa3baf0b8cc88602b@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - d66f1a52 by David Eichmann at 2020-10-28T11:46:59+00:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lexer.x The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a070ab7d721de5222f0c3654b2c7dc38d73b28d9...d66f1a523da21c0e063c6280cc115adaf7ab5fa4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a070ab7d721de5222f0c3654b2c7dc38d73b28d9...d66f1a523da21c0e063c6280cc115adaf7ab5fa4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 13:41:30 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 28 Oct 2020 09:41:30 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 13 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f99750a43d2b_8973fa3b8583b1c9002f0@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - e85eebba by Ben Gamari at 2020-10-28T09:41:21-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - b159d5b9 by Alan Zimmerman at 2020-10-28T09:41:21-04:00 API Annotations: put constructors in alphabetical order - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Types/Demand.hs - compiler/ghc.cabal.in - ghc.mk - hadrian/hadrian.cabal - hadrian/src/Builder.hs - hadrian/src/Rules/Clean.hs - hadrian/src/Settings/Builders/RunTest.hs - libraries/array - libraries/base/Data/Ord.hs - libraries/base/GHC/Event/Windows.hsc - libraries/base/base.cabal - libraries/base/changelog.md - libraries/deepseq - libraries/directory - libraries/filepath - libraries/ghc-boot-th/ghc-boot-th.cabal.in - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-compact/ghc-compact.cabal - libraries/ghci/ghci.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1d0a09920c69ff9c4a197defc9d0e03b051f809...b159d5b97f5eedecfb0dfcb241a9da54ec8c175d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1d0a09920c69ff9c4a197defc9d0e03b051f809...b159d5b97f5eedecfb0dfcb241a9da54ec8c175d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 13:50:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 28 Oct 2020 09:50:57 -0400 Subject: [Git][ghc/ghc][wip/T17605] 15 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f9977415b14e_8973fa3d9c7c04c90164b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T17605 at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - d8b1e365 by Ben Gamari at 2020-10-28T09:50:49-04:00 nativeGen/dwarf: Fix procedure end addresses Previously the `.debug_aranges` and `.debug_info` (DIE) DWARF information would claim that procedures (represented with a `DW_TAG_subprogram` DIE) would only span the range covered by their entry block. This omitted all of the continuation blocks (represented by `DW_TAG_lexical_block` DIEs), confusing `perf`. Fix this by introducing a end-of-procedure label and using this as the `DW_AT_high_pc` of procedure `DW_TAG_subprogram` DIEs Fixes #17605. - - - - - dc47f7b6 by Ben Gamari at 2020-10-28T09:50:49-04:00 nativeGen/dwarf: Only produce DW_AT_source_note DIEs in -g3 Standard debugging tools don't know how to understand these so let's not produce them unless asked. - - - - - e8257006 by Ben Gamari at 2020-10-28T09:50:49-04:00 nativeGen/dwarf: Use DW_AT_linkage instead of DW_AT_MIPS_linkage - - - - - 3263780f by Ben Gamari at 2020-10-28T09:50:49-04:00 gitlab-ci: Add DWARF release jobs for Debian 10, Fedora27 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Flatten.hs - compiler/GHC/Types/Demand.hs - compiler/ghc.cabal.in - docs/users_guide/debug-info.rst - ghc.mk - hadrian/hadrian.cabal - hadrian/src/Builder.hs - hadrian/src/Rules/Clean.hs - libraries/array - libraries/base/Data/Ord.hs - libraries/base/GHC/Event/Windows.hsc - libraries/base/base.cabal - libraries/base/changelog.md The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fac3b522979a24f67a639d749ccbfbd799cdff2...3263780f03ca82310f8ff2ef4376cb743730f2dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fac3b522979a24f67a639d749ccbfbd799cdff2...3263780f03ca82310f8ff2ef4376cb743730f2dd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 16:44:41 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Wed, 28 Oct 2020 12:44:41 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] No more errors Message-ID: <5f999ff999587_8973fa31dad4828916986@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: e82493f1 by Sebastian Graf at 2020-10-28T17:44:31+01:00 No more errors - - - - - 7 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Stg/Lift/Analysis.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -144,13 +144,12 @@ dmdAnalStar :: AnalEnv -> Demand -- This one takes a *Demand* -> CoreExpr -- Should obey the let/app invariant -> (BothDmdArg, CoreExpr) -dmdAnalStar env dmd e - | (dmd_shell, cd) <- toCleanDmd dmd - , (dmd_ty, e') <- dmdAnal env cd e +dmdAnalStar env (n :* cd) e + | (dmd_ty, e') <- dmdAnal env cd e = ASSERT2( not (isUnliftedType (exprType e)) || exprOkForSpeculation e, ppr e ) -- The argument 'e' should satisfy the let/app invariant -- See Note [Analysing with absent demand] in GHC.Types.Demand - (postProcessDmdType dmd_shell dmd_ty, e') + (multDmdType n dmd_ty, e') -- Main Demand Analsysis machinery dmdAnal, dmdAnal' :: AnalEnv @@ -172,7 +171,7 @@ dmdAnal' env dmd (Var var) = (dmdTransform env var dmd, Var var) dmdAnal' env dmd (Cast e co) - = (dmd_ty `bothDmdType` mkBothDmdArg (coercionDmdEnv co), Cast e' co) + = (dmd_ty `plusDmdType` mkBothDmdArg (coercionDmdEnv co), Cast e' co) where (dmd_ty, e') = dmdAnal env dmd e @@ -206,7 +205,7 @@ dmdAnal' env dmd (App fun arg) -- , text "arg dmd_ty =" <+> ppr arg_ty -- , text "res dmd_ty =" <+> ppr res_ty -- , text "overall res dmd_ty =" <+> ppr (res_ty `bothDmdType` arg_ty) ]) - (res_ty `bothDmdType` arg_ty, App fun' arg') + (res_ty `plusDmdType` arg_ty, App fun' arg') dmdAnal' env dmd (Lam var body) | isTyVar var @@ -216,13 +215,13 @@ dmdAnal' env dmd (Lam var body) (body_ty, Lam var body') | otherwise - = let (body_dmd, defer_and_use) = peelCallDmd dmd + = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body (body_ty, body') = dmdAnal env body_dmd body (lam_ty, var') = annotateLamIdBndr env notArgOfDfun body_ty var in - (postProcessUnsat defer_and_use lam_ty, Lam var' body') + (multUnsat n lam_ty, Lam var' body') dmdAnal' env dmd (Case scrut case_bndr ty [(DataAlt dc, bndrs, rhs)]) -- Only one alternative with a product constructor @@ -243,9 +242,9 @@ dmdAnal' env dmd (Case scrut case_bndr ty [(DataAlt dc, bndrs, rhs)]) -- Compute demand on the scrutinee -- See Note [Demand on scrutinee of a product case] - scrut_dmd = mkProdDmd id_dmds + scrut_dmd = Prod id_dmds (scrut_ty, scrut') = dmdAnal env scrut_dmd scrut - res_ty = alt_ty3 `bothDmdType` toBothDmdArg scrut_ty + res_ty = alt_ty3 `plusDmdType` toBothDmdArg scrut_ty case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd bndrs' = setBndrsDemandInfo bndrs id_dmds in @@ -274,7 +273,7 @@ dmdAnal' env dmd (Case scrut case_bndr ty alts) = deferAfterPreciseException alt_ty | otherwise = alt_ty - res_ty = alt_ty2 `bothDmdType` toBothDmdArg scrut_ty + res_ty = alt_ty2 `plusDmdType` toBothDmdArg scrut_ty in -- pprTrace "dmdAnal:Case2" (vcat [ text "scrut" <+> ppr scrut @@ -304,7 +303,7 @@ dmdAnal' env dmd (Let (NonRec id rhs) body) id' = setIdDemandInfo id id_dmd (rhs_ty, rhs') = dmdAnalStar env (dmdTransformThunkDmd rhs id_dmd) rhs - final_ty = body_ty' `bothDmdType` rhs_ty + final_ty = body_ty' `plusDmdType` rhs_ty dmdAnal' env dmd (Let (NonRec id rhs) body) = (body_ty2, Let (NonRec id2 rhs') body') @@ -956,7 +955,7 @@ dmdFix top_lvl env let_dmd orig_pairs = ((env', lazy_fv'), (id', rhs')) where (lazy_fv1, sig, rhs') = dmdAnalRhsLetDown (Just bndrs) env let_dmd id rhs - lazy_fv' = plusVarEnv_C bothDmd lazy_fv lazy_fv1 + lazy_fv' = plusVarEnv_C plusDmd lazy_fv lazy_fv1 env' = extendAnalEnv top_lvl env id sig id' = setIdStrictness id sig @@ -1042,11 +1041,11 @@ coercionDmdEnv co = mapVarEnv (const topDmd) (getUniqSet $ coVarsOfCo co) addVarDmd :: DmdType -> Var -> Demand -> DmdType addVarDmd (DmdType fv ds res) var dmd - = DmdType (extendVarEnv_C bothDmd fv var dmd) ds res + = DmdType (extendVarEnv_C plusDmd fv var dmd) ds res addLazyFVs :: DmdType -> DmdEnv -> DmdType addLazyFVs dmd_ty lazy_fvs - = dmd_ty `bothDmdType` mkBothDmdArg lazy_fvs + = dmd_ty `plusDmdType` mkBothDmdArg lazy_fvs -- Using bothDmdType (rather than just both'ing the envs) -- is vital. Consider -- let f = \x -> (x,y) @@ -1114,7 +1113,7 @@ annotateLamIdBndr env arg_of_dfun dmd_ty id -- Watch out! See note [Lambda-bound unfoldings] final_ty = case maybeUnfoldingTemplate (idUnfolding id) of Nothing -> main_ty - Just unf -> main_ty `bothDmdType` unf_ty + Just unf -> main_ty `plusDmdType` unf_ty where (unf_ty, _) = dmdAnalStar env dmd unf ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1732,11 +1732,12 @@ calcSpecStrictness fn qvars pats go env _ _ = env go_one :: DmdEnv -> Demand -> CoreExpr -> DmdEnv - go_one env d (Var v) = extendVarEnv_C bothDmd env v d - go_one env d e - | Just ds <- splitProdDmd_maybe d -- NB: d does not have to be strict - , (Var _, args) <- collectArgs e = go env ds args - go_one env _ _ = env + go_one env d (Var v) = extendVarEnv_C plusDmd env v d + go_one env (_n :* cd) e -- NB: _n does not have to be strict + | (Var _, args) <- collectArgs e + , Just ds <- viewProd (length args) cd + = go env ds args + go_one env _ _ = env {- Note [spec_usg includes rhs_usg] ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -607,26 +607,18 @@ mkWWstr_one dflags fam_envs has_inlineable_prag arg dmd = idDemandInfo arg wantToUnbox :: FamInstEnvs -> Bool -> Type -> Demand -> Maybe ([Demand], DataConAppContext) -wantToUnbox fam_envs has_inlineable_prag ty dmd = +wantToUnbox fam_envs has_inlineable_prag ty dmd@(_ :* cd) = case deepSplitProductType_maybe fam_envs ty of Just dcac at DataConAppContext{ dcac_arg_tys = con_arg_tys } | isStrictDmd dmd -- See Note [Unpacking arguments with product and polymorphic demands] - , Just cs <- split_prod_dmd_arity dmd (length con_arg_tys) + , Just cs <- viewProd (length con_arg_tys) cd -- See Note [Do not unpack class dictionaries] , not (has_inlineable_prag && isClassPred ty) -- See Note [mkWWstr and unsafeCoerce] , cs `equalLength` con_arg_tys -> Just (cs, dcac) _ -> Nothing - where - split_prod_dmd_arity dmd arty - -- For seqDmd, splitProdDmd_maybe will return Nothing (because how would - -- it know the arity?), but it should behave like , for some - -- suitable arity - | isSeqDmd dmd = Just (replicate arty absDmd) - -- Otherwise splitProdDmd_maybe does the job - | otherwise = splitProdDmd_maybe dmd unbox_one :: DynFlags -> FamInstEnvs -> Var -> [Demand] ===================================== compiler/GHC/CoreToStg.hs ===================================== @@ -46,7 +46,7 @@ import GHC.Driver.Session import GHC.Platform.Ways import GHC.Driver.Ppr import GHC.Types.ForeignCall -import GHC.Types.Demand ( isUsedOnce ) +import GHC.Types.Demand ( isUsedOnceDmd ) import GHC.Builtin.PrimOps ( PrimCall(..) ) import GHC.Types.SrcLoc ( mkGeneralSrcSpan ) import GHC.Builtin.Names ( unsafeEqualityProofName ) @@ -719,8 +719,8 @@ mkTopStgRhs dflags this_mod ccs bndr rhs where unticked_rhs = stripStgTicksTopE (not . tickishIsCode) rhs - upd_flag | isUsedOnce (idDemandInfo bndr) = SingleEntry - | otherwise = Updatable + upd_flag | isUsedOnceDmd (idDemandInfo bndr) = SingleEntry + | otherwise = Updatable -- CAF cost centres generated for -fcaf-all caf_cc = mkAutoCC bndr modl @@ -761,8 +761,8 @@ mkStgRhs bndr rhs where unticked_rhs = stripStgTicksTopE (not . tickishIsCode) rhs - upd_flag | isUsedOnce (idDemandInfo bndr) = SingleEntry - | otherwise = Updatable + upd_flag | isUsedOnceDmd (idDemandInfo bndr) = SingleEntry + | otherwise = Updatable {- SDM: disabled. Eval/Apply can't handle functions with arity zero very ===================================== compiler/GHC/Stg/Lift/Analysis.hs ===================================== @@ -95,7 +95,7 @@ import Data.Maybe ( mapMaybe ) -- -- * 'ClosureSk', representing closure allocation. -- * 'RhsSk', representing a RHS of a binding and how many times it's called --- by an appropriate 'DmdShell'. +-- by an appropriate 'Card'. -- * 'AltSk', 'BothSk' and 'NilSk' for choice, sequence and empty element. -- -- This abstraction is mostly so that the main analysis function 'closureGrowth' @@ -124,7 +124,7 @@ freeVarsOfRhs (StgRhsClosure fvs _ _ _ _) = fvs -- closures, multi-shot lambdas and case expressions. data Skeleton = ClosureSk !Id !DIdSet {- ^ free vars -} !Skeleton - | RhsSk !DmdShell {- ^ how often the RHS was entered -} !Skeleton + | RhsSk !Card {- ^ how often the RHS was entered -} !Skeleton | AltSk !Skeleton !Skeleton | BothSk !Skeleton !Skeleton | NilSk @@ -139,7 +139,7 @@ altSk NilSk b = b altSk a NilSk = a altSk a b = AltSk a b -rhsSk :: DmdShell -> Skeleton -> Skeleton +rhsSk :: Card -> Skeleton -> Skeleton rhsSk _ NilSk = NilSk rhsSk body_dmd skel = RhsSk body_dmd skel @@ -172,22 +172,12 @@ instance Outputable Skeleton where ] ppr (BothSk l r) = ppr l $$ ppr r ppr (ClosureSk f fvs body) = ppr f <+> ppr fvs $$ nest 2 (ppr body) - ppr (RhsSk body_dmd body) = hcat - [ text "λ[" - , ppr str - , text ", " - , ppr use - , text "]. " + ppr (RhsSk card body) = hcat + [ char 'λ' + , ppr card + , text ". " , ppr body ] - where - str - | isStrictDmd body_dmd = '1' - | otherwise = '0' - use - | isAbsDmd body_dmd = '0' - | isUsedOnce body_dmd = '1' - | otherwise = 'ω' instance Outputable BinderInfo where ppr = ppr . binderInfoBndr @@ -333,19 +323,19 @@ tagSkeletonRhs bndr (StgRhsClosure fvs ccs upd bndrs body) where bndrs' = map BoringBinder bndrs (body_skel, body_arg_occs, body') = tagSkeletonExpr body - rhs_skel = rhsSk (rhsDmdShell bndr) body_skel + rhs_skel = rhsSk (rhsCard bndr) body_skel -- | How many times will the lambda body of the RHS bound to the given -- identifier be evaluated, relative to its defining context? This function --- computes the answer in form of a 'DmdShell'. -rhsDmdShell :: Id -> DmdShell -rhsDmdShell bndr - | is_thunk = oneifyDmd ds +-- computes the answer in form of a 'Card'. +rhsCard :: Id -> Card +rhsCard bndr + | is_thunk = oneifyCard n | otherwise = peelManyCalls (idArity bndr) cd where is_thunk = idArity bndr == 0 -- Let's pray idDemandInfo is still OK after unarise... - (ds, cd) = toCleanDmd (idDemandInfo bndr) + n :* cd = idDemandInfo bndr tagSkeletonAlt :: CgStgAlt -> (Skeleton, IdSet, LlStgAlt) tagSkeletonAlt (con, bndrs, rhs) @@ -550,7 +540,7 @@ closureGrowth expander sizer group abs_ids = go -- Lifting @f@ removes @f@ from the closure but adds all @newbies@ cost = nonDetStrictFoldDVarSet (\id size -> sizer id + size) 0 newbies - n_occs -- Using a non-deterministic fold is OK here because addition is commutative. - go (RhsSk body_dmd body) + go (RhsSk n body) -- The conservative assumption would be that -- 1. Every RHS with positive growth would be called multiple times, -- modulo thunks. @@ -561,11 +551,11 @@ closureGrowth expander sizer group abs_ids = go -- considering information from the demand analyser, which provides us -- with conservative estimates on minimum and maximum evaluation -- cardinality. The @body_dmd@ part of 'RhsSk' is the result of - -- 'rhsDmdShell' and accurately captures the cardinality of the RHSs body + -- 'rhsCard' and accurately captures the cardinality of the RHSs body -- relative to its defining context. - | isAbsDmd body_dmd = 0 - | cg <= 0 = if isStrictDmd body_dmd then cg else 0 - | isUsedOnce body_dmd = cg - | otherwise = infinity + | isAbs n = 0 + | cg <= 0 = if isStrict n then cg else 0 + | isUsedOnce n = cg + | otherwise = infinity where cg = go body ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -12,19 +12,19 @@ -} module GHC.Types.Demand ( - StrDmd, UseDmd(..), Count, - - Demand, DmdShell, CleanDemand, getStrDmd, getUseDmd, - mkProdDmd, mkOnceUsedDmd, mkManyUsedDmd, mkHeadStrict, oneifyDmd, - toCleanDmd, + Card, Demand(..), CleanDemand(Prod), viewProd, + mkOnceUsedDmd, mkManyUsedDmd, oneifyDmd, oneifyCard, absDmd, topDmd, botDmd, seqDmd, - lubDmd, bothDmd, + lubCard, lubDmd, lubCleanDmd, + plusCard, plusDmd, plusCleanDmd, + multCard, multDmd, multCleanDmd, lazyApply1Dmd, lazyApply2Dmd, strictApply1Dmd, - isTopDmd, isAbsDmd, isSeqDmd, - peelUseCall, strictenDmd, bothCleanDmd, + isAbs, isUsedOnce, isStrict, isAbsDmd, isUsedOnceDmd, isStrictDmd, + isTopDmd, isSeqDmd, + strictenDmd, addCaseBndrDmd, - DmdType(..), dmdTypeDepth, lubDmdType, bothDmdType, + DmdType(..), dmdTypeDepth, lubDmdType, plusDmdType, BothDmdArg, mkBothDmdArg, toBothDmdArg, nopDmdType, botDmdType, addDemand, @@ -42,16 +42,16 @@ module GHC.Types.Demand ( seqDemand, seqDemandList, seqDmdType, seqStrictSig, - evalDmd, cleanEvalDmd, cleanEvalProdDmd, isStrictDmd, + evalDmd, cleanEvalDmd, cleanEvalProdDmd, splitDmdTy, isWeakDmd, deferAfterPreciseException, - postProcessUnsat, postProcessDmdType, + multUnsat, multDmdType, peelCallDmd, peelManyCalls, mkCallDmd, mkCallDmds, mkWorkerDemand, dmdTransformSig, dmdTransformDataConSig, dmdTransformDictSelSig, argOneShots, argsOneShots, saturatedByOneShots, TypeShape(..), trimToType, - isUsedOnce, reuseEnv, + reuseEnv, zapUsageDemand, zapUsageEnvSig, zapUsedOnceDemand, zapUsedOnceSig, strictifyDictDmd, strictifyDmd @@ -79,8 +79,6 @@ import GHC.Utils.Misc import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Driver.Ppr - {- ************************************************************************ * * @@ -89,27 +87,6 @@ import GHC.Driver.Ppr ************************************************************************ -} -data JointDmd s u = JD { sd :: s, ud :: u } - deriving ( Eq, Show ) - -getStrDmd :: JointDmd s u -> s -getStrDmd = sd - -getUseDmd :: JointDmd s u -> u -getUseDmd = ud - --- Pretty-printing -instance (Outputable s, Outputable u) => Outputable (JointDmd s u) where - ppr (JD {sd = s, ud = u}) = angleBrackets (ppr s <> char ',' <> ppr u) - --- Well-formedness preserving constructors for the joint domain -mkJointDmd :: s -> u -> JointDmd s u -mkJointDmd s u = JD { sd = s, ud = u } - -mkJointDmds :: [s] -> [u] -> [JointDmd s u] -mkJointDmds ss as = zipWithEqual "mkJointDmds" mkJointDmd ss as - - {- ************************************************************************ * * @@ -149,7 +126,7 @@ Motivated to reproduce the gains of 7c0fff4 without the breakage of #10712, Ben opened #11222. Simon made the demand analyser "understand catch" in 9915b656 (Jan 16) by adding a new 'catchArgDmd', which basically said to call its argument strictly, but also swallow any thrown exceptions in -'postProcessDivergence'. This was realized by extending the 'Str' constructor of +'multDivergence'. This was realized by extending the 'Str' constructor of 'ArgStr' with a 'ExnStr' field, indicating that it catches the exception, and adding a 'ThrowsExn' constructor to the 'Divergence' lattice as an element between 'Dunno' and 'Diverges'. Then along came #11555 and finally #13330, @@ -196,67 +173,6 @@ See Note [Precise exceptions and strictness analysis]. -} --- | Vanilla strictness domain -data StrDmd - = HyperStr -- ^ Hyper-strict (bottom of the lattice). - -- See Note [HyperStr and Use demands] - - | SCall StrDmd -- ^ Call demand - -- Used only for values of function type - - | SProd [ArgStr] -- ^ Product - -- Used only for values of product type - -- Invariant: not all components are HyperStr (use HyperStr) - -- not all components are Lazy (use HeadStr) - - | HeadStr -- ^ Head-Strict - -- A polymorphic demand: used for values of all types, - -- including a type variable - - deriving ( Eq, Show ) - --- | Strictness of a function argument. -type ArgStr = Str StrDmd - --- | Strictness demand. -data Str s = Lazy -- ^ Lazy (top of the lattice) - | Str s -- ^ Strict - deriving ( Eq, Show ) - --- Well-formedness preserving constructors for the Strictness domain -strBot, strTop :: ArgStr -strBot = Str HyperStr -strTop = Lazy - --- utility functions to deal with memory leaks -seqStrDmd :: StrDmd -> () -seqStrDmd (SProd ds) = seqStrDmdList ds -seqStrDmd (SCall s) = seqStrDmd s -seqStrDmd _ = () - -seqStrDmdList :: [ArgStr] -> () -seqStrDmdList [] = () -seqStrDmdList (d:ds) = seqArgStr d `seq` seqStrDmdList ds - -seqArgStr :: ArgStr -> () -seqArgStr Lazy = () -seqArgStr (Str s) = seqStrDmd s - --- Splitting polymorphic demands -splitArgStrProdDmd :: Int -> ArgStr -> Maybe [ArgStr] -splitArgStrProdDmd n Lazy = Just (replicate n Lazy) -splitArgStrProdDmd n (Str s) = splitStrProdDmd n s - -splitStrProdDmd :: Int -> StrDmd -> Maybe [ArgStr] -splitStrProdDmd n HyperStr = Just (replicate n strBot) -splitStrProdDmd n HeadStr = Just (replicate n strTop) -splitStrProdDmd n (SProd ds) = WARN( not (ds `lengthIs` n), - text "splitStrProdDmd" $$ ppr n $$ ppr ds ) - Just ds -splitStrProdDmd _ (SCall {}) = Nothing - -- This can happen when the programmer uses unsafeCoerce, - -- and we don't then want to crash the compiler (#9208) - {- ************************************************************************ * * @@ -275,144 +191,13 @@ splitStrProdDmd _ (SCall {}) = Nothing Abs -} --- | Domain for genuine usage -data UseDmd - = UCall Count UseDmd -- ^ Call demand for absence. - -- Used only for values of function type - - | UProd [ArgUse] -- ^ Product. - -- Used only for values of product type - -- See Note [Don't optimise UProd(Used) to Used] - -- - -- Invariant: Not all components are Abs - -- (in that case, use UHead) - - | UHead -- ^ May be used but its sub-components are - -- definitely *not* used. For product types, UHead - -- is equivalent to U(AAA); see mkUProd. - -- - -- UHead is needed only to express the demand - -- of 'seq' and 'case' which are polymorphic; - -- i.e. the scrutinised value is of type 'a' - -- rather than a product type. That's why we - -- can't use UProd [A,A,A] - -- - -- Since (UCall _ Abs) is ill-typed, UHead doesn't - -- make sense for lambdas - - | Used -- ^ May be used and its sub-components may be used. - -- (top of the lattice) - deriving ( Eq, Show ) - --- Extended usage demand for absence and counting -type ArgUse = Use UseDmd - -data Use u - = Abs -- Definitely unused - -- Bottom of the lattice - - | Use Count u -- May be used with some cardinality - deriving ( Eq, Show ) - --- | Abstract counting of usages -data Count = One | Many - deriving ( Eq, Show ) - --- Pretty-printing -instance Outputable ArgUse where - ppr Abs = char 'A' - ppr (Use Many a) = ppr a - ppr (Use One a) = char '1' <> char '*' <> ppr a - -instance Outputable UseDmd where - ppr Used = char 'U' - ppr (UCall c a) = char 'C' <> ppr c <> parens (ppr a) - ppr UHead = char 'H' - ppr (UProd as) = char 'U' <> parens (hcat (punctuate (char ',') (map ppr as))) - -instance Outputable Count where - ppr One = char '1' - ppr Many = text "" - -useBot, useTop :: ArgUse -useBot = Abs -useTop = Use Many Used - -mkUCall :: Count -> UseDmd -> UseDmd ---mkUCall c Used = Used c -mkUCall c a = UCall c a - -mkUProd :: [ArgUse] -> UseDmd -mkUProd ux - | all (== Abs) ux = UHead - | otherwise = UProd ux - -lubCount :: Count -> Count -> Count -lubCount _ Many = Many -lubCount Many _ = Many -lubCount x _ = x - -lubArgUse :: ArgUse -> ArgUse -> ArgUse -lubArgUse Abs x = x -lubArgUse x Abs = x -lubArgUse (Use c1 a1) (Use c2 a2) = Use (lubCount c1 c2) (lubUse a1 a2) - -lubUse :: UseDmd -> UseDmd -> UseDmd -lubUse UHead u = u -lubUse (UCall c u) UHead = UCall c u -lubUse (UCall c1 u1) (UCall c2 u2) = UCall (lubCount c1 c2) (lubUse u1 u2) -lubUse (UCall _ _) _ = Used -lubUse (UProd ux) UHead = UProd ux -lubUse (UProd ux1) (UProd ux2) - | ux1 `equalLength` ux2 = UProd $ zipWith lubArgUse ux1 ux2 - | otherwise = Used -lubUse (UProd {}) (UCall {}) = Used --- lubUse (UProd {}) Used = Used -lubUse (UProd ux) Used = UProd (map (`lubArgUse` useTop) ux) -lubUse Used (UProd ux) = UProd (map (`lubArgUse` useTop) ux) -lubUse Used _ = Used -- Note [Used should win] - --- `both` is different from `lub` in its treatment of counting; if --- `both` is computed for two used, the result always has --- cardinality `Many` (except for the inner demands of UCall demand -- [TODO] explain). --- Also, x `bothUse` x /= x (for anything but Abs). - -bothArgUse :: ArgUse -> ArgUse -> ArgUse -bothArgUse Abs x = x -bothArgUse x Abs = x -bothArgUse (Use _ a1) (Use _ a2) = Use Many (bothUse a1 a2) - - -bothUse :: UseDmd -> UseDmd -> UseDmd -bothUse UHead u = u -bothUse (UCall c u) UHead = UCall c u - --- Exciting special treatment of inner demand for call demands: --- use `lubUse` instead of `bothUse`! -bothUse (UCall _ u1) (UCall _ u2) = UCall Many (u1 `lubUse` u2) - -bothUse (UCall {}) _ = Used -bothUse (UProd ux) UHead = UProd ux -bothUse (UProd ux1) (UProd ux2) - | ux1 `equalLength` ux2 = UProd $ zipWith bothArgUse ux1 ux2 - | otherwise = Used -bothUse (UProd {}) (UCall {}) = Used --- bothUse (UProd {}) Used = Used -- Note [Used should win] -bothUse Used (UProd ux) = UProd (map (`bothArgUse` useTop) ux) -bothUse (UProd ux) Used = UProd (map (`bothArgUse` useTop) ux) -bothUse Used _ = Used -- Note [Used should win] - -peelUseCall :: UseDmd -> Maybe (Count, UseDmd) -peelUseCall (UCall c u) = Just (c,u) -peelUseCall _ = Nothing - addCaseBndrDmd :: Demand -- On the case binder -> [Demand] -- On the components of the constructor -> [Demand] -- Final demands for the components of the constructor -- See Note [Demand on case-alternative binders] addCaseBndrDmd (n :* cd) alt_dmds | isAbs n = alt_dmds - | otherwise = zipWith bothDmd alt_dmds ds + | otherwise = zipWith plusDmd alt_dmds ds where Just ds = viewProd (length alt_dmds) cd -- Guaranteed not to be a call @@ -470,7 +255,7 @@ little bit of boxity analysis. Not very nice. Note [Used should win] ~~~~~~~~~~~~~~~~~~~~~~ -Both in lubUse and bothUse we want (Used `both` UProd us) to be Used. +Both in lubUse and plusUse we want (Used `plus` UProd us) to be Used. Why? Because Used carries the implication the whole thing is used, box and all, so we don't want to w/w it. If we use it both boxed and unboxed, then we are definitely using the box, and so we are quite @@ -486,25 +271,13 @@ Compare with: (B) making Used win for lub and both Geometric Mean -0.0% +0.5% +0.3% +0.2% -0.8% Baseline: (B) Making Used win for both lub and both -Compare with: (C) making Used win for both, but UProd win for lub +Compare with: (C) making Used win for plus, but UProd win for lub Min -0.1% -0.3% -7.9% -8.0% -6.5% Max +0.1% +1.0% +21.0% +21.0% +0.5% Geometric Mean +0.0% +0.0% -0.0% -0.1% -0.1% -} --- Splitting polymorphic Maybe-Used demands -splitUseProdDmd :: Int -> UseDmd -> Maybe [ArgUse] -splitUseProdDmd n Used = Just (replicate n useTop) -splitUseProdDmd n UHead = Just (replicate n Abs) -splitUseProdDmd n (UProd ds) = WARN( not (ds `lengthIs` n), - text "splitUseProdDmd" $$ ppr n - $$ ppr ds ) - Just ds -splitUseProdDmd _ (UCall _ _) = Nothing - -- This can happen when the programmer uses unsafeCoerce, - -- and we don't then want to crash the compiler (#9208) - {- ************************************************************************ * * @@ -599,10 +372,35 @@ instance Show Card where show C_1N = "1_" show C_10 = "⊥" -botCard, topCard :: Card -botCard = C_10 +_botCard, topCard :: Card +_botCard = C_10 topCard = C_0N +-- | True <=> lower bound is 1. +isStrict :: Card -> Bool +isStrict C_10 = True +isStrict C_11 = True +isStrict C_1N = True +isStrict _ = False + +-- | True <=> upper bound is 0. +isAbs :: Card -> Bool +isAbs C_00 = True +isAbs C_10 = True -- Bottom cardinality is also absent +isAbs _ = False + +-- | True <=> upper bound is 1. +isUsedOnce :: Card -> Bool +isUsedOnce C_0N = False +isUsedOnce C_1N = False +isUsedOnce _ = True + +-- | Intersect with [0,1]. +oneifyCard :: Card -> Card +oneifyCard C_0N = C_01 +oneifyCard C_1N = C_11 +oneifyCard c = c + -- | Denotes '∪' on 'Card'. lubCard :: Card -> Card -> Card -- Handle C_10 (bot) @@ -626,29 +424,57 @@ lubCard _ C_01 = C_01 -- {0} ∪ {0,1} = {0,1} lubCard C_00 C_00 = C_00 -- reflexivity -- | Denotes '+' on 'Card'. -bothCard :: Card -> Card -> Card +plusCard :: Card -> Card -> Card -- Handle C_00 -bothCard C_00 n = n -- {0}+n = n -bothCard n C_00 = n -- {0}+n = n +plusCard C_00 n = n -- {0}+n = n +plusCard n C_00 = n -- {0}+n = n -- Handle C_10 -bothCard C_10 C_01 = C_11 -- These follow by applying + to lower and upper -bothCard C_10 C_0N = C_1N -- bounds individually -bothCard C_10 n = n -bothCard C_01 C_10 = C_11 -bothCard C_0N C_10 = C_1N -bothCard n C_10 = n +plusCard C_10 C_01 = C_11 -- These follow by applying + to lower and upper +plusCard C_10 C_0N = C_1N -- bounds individually +plusCard C_10 n = n +plusCard C_01 C_10 = C_11 +plusCard C_0N C_10 = C_1N +plusCard n C_10 = n -- Handle the rest (C_01, C_0N, C_11, C_1N) -bothCard C_01 C_01 = C_0N -- The upper bound is at least 1, so upper bound of -bothCard C_01 C_0N = C_0N -- the result must be 1+1 ~= N. -bothCard C_0N C_01 = C_0N -- But for the lower bound we have 4 cases where -bothCard C_0N C_0N = C_0N -- 0+0 ~= 0 (as opposed to 1), so we match on these. -bothCard _ _ = C_1N -- Otherwise we return topCard +plusCard C_01 C_01 = C_0N -- The upper bound is at least 1, so upper bound of +plusCard C_01 C_0N = C_0N -- the result must be 1+1 ~= N. +plusCard C_0N C_01 = C_0N -- But for the lower bound we have 4 cases where +plusCard C_0N C_0N = C_0N -- 0+0 ~= 0 (as opposed to 1), so we match on these. +plusCard _ _ = C_1N -- Otherwise we return topCard + +-- | Denotes '*' on 'Card'. +multCard :: Card -> Card -> Card +-- Handle C_11 (neutral element) +multCard C_11 c = c +multCard c C_11 = c +-- Handle C_00 (annihilating element) +multCard C_00 _ = C_00 +multCard _ C_00 = C_00 +-- Handle C_10 +multCard C_10 c = if isStrict c then C_10 else C_00 +multCard c C_10 = if isStrict c then C_10 else C_00 +-- Handle reflexive C_1N, C_01 +multCard C_1N C_1N = C_1N +multCard C_01 C_01 = C_01 +-- Handle C_0N and the rest (C_01, C_1N): +multCard _ _ = C_0N -- It's similar to @'Scaled' 'CleanDemand'@, but it's scaled by 'Card', which -- is an interval on 'Multiplicity'. data Demand = !Card :* !CleanDemand deriving ( Eq, Show ) +instance Outputable Card where + ppr = text . show + +instance Outputable Demand where + ppr (n :* cd) = ppr n <> char '*' <> ppr cd + +instance Outputable CleanDemand where + ppr (Poly cd) = ppr cd + ppr (Call n cd) = char 'C' <> ppr n <> parens (ppr cd) + ppr (Prod ds) = parens (interpp'SP (map ppr ds)) + data CleanDemand = Poly !Card -- ^ Polymorphic head demand with nested evaluation -- cardinalities. @@ -664,7 +490,7 @@ data CleanDemand deriving ( Eq, Show ) poly00, poly01, poly0N, poly11, poly1N, poly10 :: CleanDemand -topCleanDmd, botCleanDmd, seqCleanDmd :: CleanDemand +topCleanDmd, _botCleanDmd, seqCleanDmd :: CleanDemand poly00 = Poly C_00 poly01 = Poly C_01 poly0N = Poly C_0N @@ -672,7 +498,7 @@ poly11 = Poly C_11 poly1N = Poly C_1N poly10 = Poly C_10 topCleanDmd = poly0N -botCleanDmd = poly10 +_botCleanDmd = poly10 seqCleanDmd = poly00 polyDmd :: Card -> Demand @@ -683,14 +509,6 @@ polyDmd C_11 = C_11 :* poly11 polyDmd C_1N = C_1N :* poly1N polyDmd C_10 = C_10 :* poly10 -polyCleanDmd :: Card -> CleanDemand -polyCleanDmd C_00 = poly00 -polyCleanDmd C_01 = poly01 -polyCleanDmd C_0N = poly0N -polyCleanDmd C_11 = poly11 -polyCleanDmd C_1N = poly1N -polyCleanDmd C_10 = poly10 - topDmd, absDmd, botDmd, seqDmd :: Demand strictApply1Dmd, lazyApply1Dmd, lazyApply2Dmd :: Demand topDmd = polyDmd C_0N @@ -731,29 +549,27 @@ lubCleanDmd _ _ = topCleanDmd lubDmd :: Demand -> Demand -> Demand lubDmd (n1 :* cd1) (n2 :* cd2) = lubCard n1 n2 :* lubCleanDmd cd1 cd2 -bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand +plusCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand -- Handle Prod -bothCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = - Prod $ zipWith bothDmd ds1 ds2 +plusCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = + Prod $ zipWith plusDmd ds1 ds2 -- Handle Call -- TODO: Exciting special treatment of inner demand for call demands: --- use `lubUse` instead of `bothUse`! -bothCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = - Call (bothCard n1 n2) (lubCleanDmd d1 d2) +-- use `lubUse` instead of `plusUse`! +plusCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = + Call (plusCard n1 n2) (lubCleanDmd d1 d2) -- Handle Poly -bothCleanDmd (Poly n1) (Poly n2) = Poly (bothCard n1 n2) +plusCleanDmd (Poly n1) (Poly n2) = Poly (plusCard n1 n2) -- Make use of reflexivity (so we'll match the Prod or Call cases again). -bothCleanDmd cd1 at Poly{} cd2 = bothCleanDmd cd2 cd1 +plusCleanDmd cd1 at Poly{} cd2 = plusCleanDmd cd2 cd1 -- Otherwise (Call `lub` Prod) return Top -bothCleanDmd _ _ = topCleanDmd +plusCleanDmd _ _ = topCleanDmd -bothDmd :: Demand -> Demand -> Demand -bothDmd (n1 :* cd1) (n2 :* cd2) = bothCard n1 n2 :* bothCleanDmd cd1 cd2 +plusDmd :: Demand -> Demand -> Demand +plusDmd (n1 :* cd1) (n2 :* cd2) = plusCard n1 n2 :* plusCleanDmd cd1 cd2 oneifyDmd :: Demand -> Demand -oneifyDmd (C_0N :* cd) = C_01 :* cd -oneifyDmd (C_1N :* cd) = C_11 :* cd -oneifyDmd dmd = dmd +oneifyDmd (n :* cd) = oneifyCard n :* cd isTopDmd :: Demand -> Bool -- ^ Used to suppress pretty-printing of an uninformative demand @@ -762,16 +578,18 @@ isTopDmd dmd = dmd == topDmd isAbsDmd :: Demand -> Bool isAbsDmd (n :* _) = isAbs n +isStrictDmd :: Demand -> Bool +-- See Note [Strict demands] +isStrictDmd (n :* _) = isStrict n + isSeqDmd :: Demand -> Bool isSeqDmd (C_11 :* cd) = cd == seqCleanDmd isSeqDmd (C_1N :* cd) = cd == seqCleanDmd -- I wonder if we need this case. isSeqDmd _ = False -- | Is the value used at most once? -isUsedOnce :: Demand -> Bool -isUsedOnce (C_0N :* _) = False -isUsedOnce (C_1N :* _) = False -isUsedOnce _ = True +isUsedOnceDmd :: Demand -> Bool +isUsedOnceDmd (n :* _) = isUsedOnce n -- More utility functions for strictness seqDemand :: Demand -> () @@ -781,25 +599,6 @@ seqDemand _ = () seqDemandList :: [Demand] -> () seqDemandList = foldr (seq . seqDemand) () -isStrictDmd :: Demand -> Bool --- See Note [Strict demands] -isStrictDmd (C_10 :* _) = True -isStrictDmd (C_11 :* _) = True -isStrictDmd (C_1N :* _) = True -isStrictDmd _ = False - --- | True <=> lower bound is 0. -isLazy :: Card -> Bool -isLazy C_01 = False -isLazy C_0N = False -isLazy _ = True - --- | True <=> upper bound is 0. -isAbs :: Card -> Bool -isAbs C_00 = True -isAbs C_10 = True -- Bottom cardinality is also absent -isAbs _ = False - {- Note [Scaling demands] ~~~~~~~~~~~~~~~~~~~~~~~~~ If a demand is used multiple times (/reused/), for example the argument in an @@ -809,11 +608,11 @@ upper bound of n. Essentially, the cardinality in all demands are /scaled/ by a factor >1. Since - * 'both*' roughly amounts to + on the involved cardinalities + * 'plus*' roughly amounts to + on the involved cardinalities * scaling by n is the same as performing + n times, meaning we can scale by - doing n 'both*'s - * 'both*' is idempotent, e.g. @a `both` a `both` a == a `both` a@ -A simple specification for scaling @a@ is by doing @a `both` a at . + doing n 'plus*'s + * 'plus*' is idempotent, e.g. @a `plus` a `plus` a == a `plus` a@ +A simple specification for scaling @a@ is by doing @a `plus` a at . In practice, we implement this operation by the 'scale*' family of functions, which is a bit more optimised. @@ -831,48 +630,25 @@ yields C(C1(U)) ("Called multiple times, but each time with at least two PAP is also called multiple times with one argument"). This also follows from the specification - scaleCleanDmd cd = bothCleanDmd cd cd, + scaleCleanDmd cd = plusCleanDmd cd cd, which dictates that scaleCleanDmd (Call n cd) = Call (scaleCard n) (lubCleanDmd cd cd) and 'lubCleanDmd' is reflexive, hence scaleCleanDmd (Call n cd) = Call (scaleCard n) cd. -} --- | Scale the given 'Card' with a factor >1, as if it was used multiple --- times. Invariant on 0 and n bounds, but turns 1 bounds into n bounds. --- Example: @scaleCard C_01 == C_0N@, but @scaleCard C_1N == C_1N at . --- NB: There is no lower bound (strictness) n, hence no change there. --- --- See Note [Scaling demands]. -scaleCard :: Card -> Card --- scaling by 2 is sufficient, because bothCard is idempotent --- I double-checked that this will generate optimal code -scaleCard c = bothCard c c - --- | Whether the given 'Card' is invariant to scaling, such as with --- 'scaleDmd' (which scales by n). +-- | Whether the given 'Card' is invariant to scaling, as if it was used +-- multiple times. -- See Note [Scaling demands]. isScaleInvariantCard :: Card -> Bool -- I double-checked that this will generate optimal code -isScaleInvariantCard c = scaleCard c == c - --- | See Note [Scaling demands]. -scaleDmd :: Demand -> Demand --- scaleDmd dmd = bothDmd dmd dmd -scaleDmd (n :* cd) = scaleCard n :* scaleCleanDmd cd +isScaleInvariantCard c = plusCard c c == c -- | See Note [Scaling demands]. isScaleInvariantDmd :: Demand -> Bool -- isScaleInvariantDmd dmd = scaleDmd dmd == dmd isScaleInvariantDmd (n :* cd) = isScaleInvariantCard n && isScaleInvariantCleanDmd cd --- | See Note [Scaling demands]. -scaleCleanDmd :: CleanDemand -> CleanDemand --- scaleCleanDmd cd = bothCleanDmd cd cd -scaleCleanDmd (Poly n) = Poly $ scaleCard n -scaleCleanDmd (Prod ds) = Prod $ map scaleDmd ds -scaleCleanDmd (Call n cd) = Call (scaleCard n) cd -- See Note [Scaling Call demands] - -- | See Note [Scaling demands]. isScaleInvariantCleanDmd :: CleanDemand -> Bool -- isScaleInvariantCleanDmd cd = scaleCleanDmd cd == cd @@ -887,7 +663,7 @@ isScaleInvariantCleanDmd (Call n _) = isScaleInvariantCard n -- See Note [Scalin -- was incomplete. -- See Note [Lazy and unleashable free variables] in "GHC.Core.Opt.DmdAnal". isWeakDmd :: Demand -> Bool -isWeakDmd (n :* cd) = isLazy n && isScaleInvariantCleanDmd cd +isWeakDmd (n :* cd) = not (isStrict n) && isScaleInvariantCleanDmd cd keepAliveDmdEnv :: DmdEnv -> IdSet -> DmdEnv -- (keepAliveDmdType dt vs) makes sure that the Ids in vs have @@ -981,18 +757,18 @@ lubDivergence _ _ = Dunno -- defaultFvDmd (r1 `lubDivergence` r2) = defaultFvDmd r1 `lubDmd` defaultFvDmd r2 -- (See Note [Default demand on free variables and arguments] for why) -bothDivergence :: Divergence -> Divergence -> Divergence --- See Note [Asymmetry of 'both*'], which concludes that 'bothDivergence' needs +plusDivergence :: Divergence -> Divergence -> Divergence +-- See Note [Asymmetry of 'plus*'], which concludes that 'plusDivergence' needs -- to be symmetric. --- Strictly speaking, we should have @bothDivergence Dunno Diverges = ExnOrDiv at . +-- Strictly speaking, we should have @plusDivergence Dunno Diverges = ExnOrDiv at . -- But that regresses in too many places (every infinite loop, basically) to be -- worth it and is only relevant in higher-order scenarios -- (e.g. Divergence of @f (throwIO blah)@). --- So 'bothDivergence' currently is 'glbDivergence', really. -bothDivergence Dunno Dunno = Dunno -bothDivergence Diverges _ = Diverges -bothDivergence _ Diverges = Diverges -bothDivergence _ _ = ExnOrDiv +-- So 'plusDivergence' currently is 'glbDivergence', really. +plusDivergence Dunno Dunno = Dunno +plusDivergence Diverges _ = Diverges +plusDivergence _ Diverges = Diverges +plusDivergence _ _ = ExnOrDiv instance Outputable Divergence where ppr Diverges = char 'b' -- for (b)ottom @@ -1196,22 +972,22 @@ on err via the App rule. In contrast to weaker head strictness, this demand is strong enough to unleash err's signature and hence we see that the whole expression diverges! -Note [Asymmetry of 'both*'] +Note [Asymmetry of 'plus*'] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -'both' for DmdTypes is *asymmetrical*, because there can only one +'plus' for DmdTypes is *asymmetrical*, because there can only one be one type contributing argument demands! For example, given (e1 e2), we get a DmdType dt1 for e1, use its arg demand to analyse e2 giving dt2, and then do -(dt1 `bothType` dt2). Similarly with +(dt1 `plusType` dt2). Similarly with case e of { p -> rhs } we get dt_scrut from the scrutinee and dt_rhs from the RHS, and then -compute (dt_rhs `bothType` dt_scrut). +compute (dt_rhs `plusType` dt_scrut). We 1. combine the information on the free variables, 2. take the demand on arguments from the first argument - 3. combine the termination results, as in bothDivergence. + 3. combine the termination results, as in plusDivergence. -Since we don't use argument demands of the second argument anyway, 'both's +Since we don't use argument demands of the second argument anyway, 'plus's second argument is just a 'BothDmdType'. But note that the argument demand types are not guaranteed to be observed in @@ -1220,7 +996,7 @@ demand type for the alts as the left argument and the type for the scrutinee as the right argument. Also, it is not at all clear if there is such an order; consider the LetUp case, where the RHS might be forced at any point while evaluating the let body. -Therefore, it is crucial that 'bothDivergence' is symmetric! +Therefore, it is crucial that 'plusDivergence' is symmetric! -} -- Equality needed for fixpoints in GHC.Core.Opt.DmdAnal @@ -1254,14 +1030,14 @@ mkBothDmdArg env = (env, topDiv) toBothDmdArg :: DmdType -> BothDmdArg toBothDmdArg (DmdType fv _ r) = (fv, r) -bothDmdType :: DmdType -> BothDmdArg -> DmdType -bothDmdType (DmdType fv1 ds1 r1) (fv2, t2) - -- See Note [Asymmetry of 'both*'] - -- 'both' takes the argument/result info from its *first* arg, +plusDmdType :: DmdType -> BothDmdArg -> DmdType +plusDmdType (DmdType fv1 ds1 r1) (fv2, t2) + -- See Note [Asymmetry of 'plus*'] + -- 'plus' takes the argument/result info from its *first* arg, -- using its second arg just for its free-var info. - = DmdType (plusVarEnv_CD bothDmd fv1 (defaultFvDmd r1) fv2 (defaultFvDmd t2)) + = DmdType (plusVarEnv_CD plusDmd fv1 (defaultFvDmd r1) fv2 (defaultFvDmd t2)) ds1 - (r1 `bothDivergence` t2) + (r1 `plusDivergence` t2) instance Outputable DmdType where ppr (DmdType fv ds res) @@ -1351,110 +1127,81 @@ deferAfterPreciseException :: DmdType -> DmdType deferAfterPreciseException = lubDmdType exnDmdType strictenDmd :: Demand -> Demand -strictenDmd (n :* cd) = bothCard C_10 n :* cd - --- Deferring and peeling - -type DmdShell -- Describes the "outer shell" - -- of a Demand - = Card - -toCleanDmd :: Demand -> (DmdShell, CleanDemand) --- Splits a Demand into its "shell" and the inner "clean demand" -toCleanDmd (n :* cd) = (n, cd) - -- See Note [Analyzing with lazy demand and lambdas] - -- See Note [Analysing with absent demand] +strictenDmd (n :* cd) = plusCard C_10 n :* cd -- This is used in dmdAnalStar when post-processing -- a function's argument demand. So we only care about what -- does to free variables, and whether it terminates. --- see Note [Asymmetry of 'both*'] -postProcessDmdType :: DmdShell -> DmdType -> BothDmdArg -postProcessDmdType n (DmdType fv _ res_ty) - = (postProcessDmdEnv n fv, postProcessDivergence n res_ty) - -postProcessDivergence :: DmdShell -> Divergence -> Divergence --- In a Lazy scenario, we might not force the Divergence, in which case we --- converge, hence Dunno. -postProcessDivergence n _ | isLazy n = Dunno -postProcessDivergence _ d = d - -postProcessDmdEnv :: DmdShell -> DmdEnv -> DmdEnv -postProcessDmdEnv n env +-- see Note [Asymmetry of 'plus*'] +multDmdType :: Card -> DmdType -> BothDmdArg +multDmdType n (DmdType fv _ res_ty) + = (multDmdEnv n fv, multDivergence n res_ty) + +-- | In a non-strict scenario, we might not force the Divergence, in which case +-- we might converge, hence Dunno. +multDivergence :: Card -> Divergence -> Divergence +multDivergence n _ | not (isStrict n) = Dunno +multDivergence _ d = d + +multDmdEnv :: Card -> DmdEnv -> DmdEnv +multDmdEnv n env | isAbs n = emptyDmdEnv - -- In this case (postProcessDmd ds) == id; avoid a redundant rebuild + -- In this case (multDmd ds) == id; avoid a redundant rebuild -- of the environment. Be careful, bad things will happen if this doesn't - -- match postProcessDmd (see #13977). + -- match multDmd (see #13977). | n == C_11 = env - | otherwise = mapVarEnv (postProcessDmd n) env + | otherwise = mapVarEnv (multDmd n) env -- For the Absent case just discard alC_ sage information -- We only processed the thing at all to analyse the body -- See Note [Always analyse in virgin pass] -- | See Note [Scaling demands] reuseEnv :: DmdEnv -> DmdEnv -reuseEnv = mapVarEnv (postProcessDmd C_1N) - -postProcessUnsat :: DmdShell -> DmdType -> DmdType -postProcessUnsat n (DmdType fv args res_ty) - = DmdType (postProcessDmdEnv n fv) - (map (postProcessDmd n) args) - (postProcessDivergence n res_ty) - -postProcessDmd :: DmdShell -> Demand -> Demand -postProcessDmd C_11 dmd = dmd -postProcessDmd n _ - | isAbs n = absDmd -postProcessDmd C_01 (n :* dmd) = lubCard C_01 n :* dmd -postProcessDmd C_10 _ = Dmd -postProcessDmd n (JD { sd = s, ud = a}) - = JD { sd = s', ud = a' } - where - s' = case ss of - Lazy -> Lazy - Str _ -> s - a' = case us of - Abs -> Abs - Use Many _ -> scaleDmd a - Use One _ -> a - --- Peels one call level from the demand, and also returns --- whether it was unsaturated (separately for strictness and usage) -peelCallDmd :: CleanDemand -> (CleanDemand, DmdShell) --- Exploiting the fact that --- on the strictness side C(B) = B --- and on the usage side C(U) = U -peelCallDmd (JD {sd = s, ud = u}) - = (JD { sd = s', ud = u' }, JD { sd = ss, ud = us }) - where - (s', ss) = case s of - SCall s' -> (s', Str ()) - HyperStr -> (HyperStr, Str ()) - _ -> (HeadStr, Lazy) - (u', us) = case u of - UCall c u' -> (u', Use c ()) - _ -> (Used, Use Many ()) - -- The _ cases for usage includes UHead which seems a bit wrong - -- because the body isn't used at all! - -- c.f. the Abs case in toCleanDmd +reuseEnv = mapVarEnv (multDmd C_1N) + +-- | The trivial cases of the @mult*@ functions. +-- If @multTrivial n abs a = ma@, we have the following outcomes +-- depending on @n@: +-- +-- * 'C_11' => multiply by one, @ma = Just a@ +-- * 'C_00', 'C_10' (e.g. @'isAbs' n@) => return the absent thing, +-- @ma = Just abs@ +-- * Otherwise ('C_01', 'C_*N') it's not a trivial case, @ma = Nothing at . +multTrivial :: Card -> a -> a -> Maybe a +multTrivial C_11 _ a = Just a +multTrivial n abs _ | isAbs n = Just abs +multTrivial _ _ _ = Nothing + +multUnsat :: Card -> DmdType -> DmdType +multUnsat n (DmdType fv args res_ty) + = DmdType (multDmdEnv n fv) + (map (multDmd n) args) + (multDivergence n res_ty) + +multCleanDmd :: Card -> CleanDemand -> CleanDemand +multCleanDmd n cd + | Just cd' <- multTrivial n seqCleanDmd cd = cd' +multCleanDmd n (Poly n') = Poly (multCard n n') +multCleanDmd n (Call n' cd) = Call (multCard n n') cd -- TODO Note +multCleanDmd n (Prod ds) = Prod (map (multDmd n) ds) + +multDmd :: Card -> Demand -> Demand +multDmd n dmd + | Just dmd' <- multTrivial n absDmd dmd = dmd' +multDmd n (m :* dmd) = multCard n m :* multCleanDmd n dmd + +-- | Peels one call level from the demand, and also returns how many times we +-- entered the lambda body. +peelCallDmd :: CleanDemand -> (Card, CleanDemand) +peelCallDmd cd = viewCall cd `orElse` (topCard, topCleanDmd) -- Peels that multiple nestings of calls clean demand and also returns -- whether it was unsaturated (separately for strictness and usage -- see Note [Demands from unsaturated function calls] -peelManyCalls :: Int -> CleanDemand -> DmdShell -peelManyCalls n (JD { sd = str, ud = abs }) - = JD { sd = go_str n str, ud = go_abs n abs } - where - go_str :: Int -> StrDmd -> Str () -- True <=> unsaturated, defer - go_str 0 _ = Str () - go_str _ HyperStr = Str () -- == go_str (n-1) HyperStr, as HyperStr = Call(HyperStr) - go_str n (SCall d') = go_str (n-1) d' - go_str _ _ = Lazy - - go_abs :: Int -> UseDmd -> Use () -- Many <=> unsaturated, or at least - go_abs 0 _ = Use One () -- one UCall Many in the demand - go_abs n (UCall One d') = go_abs (n-1) d' - go_abs _ _ = Use Many () +peelManyCalls :: Int -> CleanDemand -> Card +peelManyCalls 0 _ = C_11 +peelManyCalls n (viewCall -> Just (m, cd)) = m `multCard` peelManyCalls (n-1) cd +peelManyCalls _ _ = C_0N {- Note [Demands from unsaturated function calls] @@ -1486,7 +1233,7 @@ But the demand fed into f might be less than . There are a f multiple times. So forget about any occurrence of "One" in the demand. In dmdTransformSig, we call peelManyCalls to find out if we are in any of these -cases, and then call postProcessUnsat to reduce the demand appropriately. +cases, and then call multUnsat to reduce the demand appropriately. Similarly, dmdTransformDictSelSig and dmdAnal, when analyzing a Lambda, use peelCallDmd, which peels only one level, but also returns the demand put on the @@ -1562,7 +1309,7 @@ There are several wrinkles: Reason: Note [Always analyse in virgin pass] But we can post-process the results to ignore all the usage - demands coming back. This is done by postProcessDmdType. + demands coming back. This is done by multDmdType. * In a previous incarnation of GHC we needed to be extra careful in the case of an *unlifted type*, because unlifted values are evaluated @@ -1759,7 +1506,7 @@ dmdTransformSig :: StrictSig -> CleanDemand -> DmdType -- signature is fun_sig, with demand dmd. We return the demand -- that the function places on its context (eg its args) dmdTransformSig (StrictSig dmd_ty@(DmdType _ arg_ds _)) cd - = postProcessUnsat (peelManyCalls (length arg_ds) cd) dmd_ty + = multUnsat (peelManyCalls (length arg_ds) cd) dmd_ty -- see Note [Demands from unsaturated function calls] dmdTransformDataConSig :: Arity -> CleanDemand -> DmdType @@ -1767,31 +1514,22 @@ dmdTransformDataConSig :: Arity -> CleanDemand -> DmdType -- which has a special kind of demand transformer. -- If the constructor is saturated, we feed the demand on -- the result into the constructor arguments. -dmdTransformDataConSig arity (JD { sd = str, ud = abs }) - | Just str_dmds <- go_str arity str - , Just abs_dmds <- go_abs arity abs - = DmdType emptyDmdEnv (mkJointDmds str_dmds abs_dmds) topDiv - - | otherwise -- Not saturated - = nopDmdType +dmdTransformDataConSig arity cd = case go arity cd of + Just dmds -> DmdType emptyDmdEnv dmds topDiv + Nothing -> nopDmdType -- Not saturated where - go_str 0 dmd = splitStrProdDmd arity dmd - go_str n (SCall s') = go_str (n-1) s' - go_str n HyperStr = go_str (n-1) HyperStr - go_str _ _ = Nothing - - go_abs 0 dmd = splitUseProdDmd arity dmd - go_abs n (UCall One u') = go_abs (n-1) u' - go_abs _ _ = Nothing + go 0 cd = viewProd arity cd + go n (viewCall -> Just (C_11, cd)) = go (n-1) cd -- strict calls only! + go _ _ = Nothing dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType -- Like dmdTransformDataConSig, we have a special demand transformer -- for dictionary selectors. If the selector is saturated (ie has one -- argument: the dictionary), we feed the demand on the result into -- the indicated dictionary component. -dmdTransformDictSelSig (StrictSig (DmdType _ [Prod ds] _)) cd - | (cd',defer_use) <- peelCallDmd cd - = postProcessUnsat defer_use $ +dmdTransformDictSelSig (StrictSig (DmdType _ [_ :* Prod ds] _)) cd + | (n, cd') <- peelCallDmd cd + = multUnsat n $ DmdType emptyDmdEnv [mkOnceUsedDmd $ Prod $ map (enhance cd') ds] topDiv | otherwise = nopDmdType -- See Note [Demand transformer for a dictionary selector] @@ -1826,7 +1564,7 @@ it should not fall over. -} argsOneShots :: StrictSig -> Arity -> [[OneShotInfo]] --- See Note [Computing one-shot info] +-- ^ See Note [Computing one-shot info] argsOneShots (StrictSig (DmdType _ arg_ds _)) n_val_args | unsaturated_call = [] | otherwise = go arg_ds @@ -1840,30 +1578,22 @@ argsOneShots (StrictSig (DmdType _ arg_ds _)) n_val_args cons [] [] = [] cons a as = a:as +argOneShots :: Demand -- ^ depending on saturation + -> [OneShotInfo] +-- ^ See Note [Computing one-shot info] +argOneShots (_ :* cd) = go cd + where + go (Call n cd) + | isUsedOnce n = OneShotLam : go cd + | otherwise = NoOneShotInfo : go cd + go _ = [] + -- saturatedByOneShots n C1(C1(...)) = True, -- <=> -- there are at least n nested C1(..) calls -- See Note [Demand on the worker] in GHC.Core.Opt.WorkWrap saturatedByOneShots :: Int -> Demand -> Bool -saturatedByOneShots n (JD { ud = usg }) - = case usg of - Use _ arg_usg -> go n arg_usg - _ -> False - where - go 0 _ = True - go n (UCall One u) = go (n-1) u - go _ _ = False - -argOneShots :: Demand -- depending on saturation - -> [OneShotInfo] -argOneShots (JD { ud = usg }) - = case usg of - Use _ arg_usg -> go arg_usg - _ -> [] - where - go (UCall One u) = OneShotLam : go u - go (UCall Many u) = NoOneShotInfo : go u - go _ = [] +saturatedByOneShots n (_ :* cd) = isUsedOnce (peelManyCalls n cd) {- Note [Computing one-shot info] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1900,7 +1630,7 @@ zapUsageEnvSig (StrictSig (DmdType _ ds r)) = mkClosedStrictSig ds r zapUsageDemand :: Demand -> Demand -- Remove the usage info, but not the strictness info, from the demand -zapUsageDemand = kilC__sage $ KillFlags +zapUsageDemand = kill_usage $ KillFlags { kf_abs = True , kf_used_once = True , kf_called_once = True @@ -1908,7 +1638,7 @@ zapUsageDemand = kilC__sage $ KillFlags -- | Remove all 1* information (but not C1 information) from the demand zapUsedOnceDemand :: Demand -> Demand -zapUsedOnceDemand = kilC__sage $ KillFlags +zapUsedOnceDemand = kill_usage $ KillFlags { kf_abs = False , kf_used_once = True , kf_called_once = False @@ -1926,23 +1656,22 @@ data KillFlags = KillFlags , kf_called_once :: Bool } -kilC__sage :: KillFlags -> Demand -> Demand -kilC__sage kfs (JD {sd = s, ud = u}) = JD {sd = s, ud = zap_musg kfs u} +kill_usage_card :: KillFlags -> Card -> Card +kill_usage_card kfs C_00 | kf_abs kfs = C_0N +kill_usage_card kfs C_10 | kf_abs kfs = C_1N +kill_usage_card kfs C_01 | kf_used_once kfs = C_0N +kill_usage_card kfs C_11 | kf_used_once kfs = C_1N +kill_usage_card _ n = n -zap_musg :: KillFlags -> ArgUse -> ArgUse -zap_musg kfs Abs - | kf_abs kfs = useTop - | otherwise = Abs -zap_musg kfs (Use c u) - | kf_used_once kfs = Use Many (zap_usg kfs u) - | otherwise = Use c (zap_usg kfs u) +kill_usage :: KillFlags -> Demand -> Demand +kill_usage kfs (n :* cd) = kill_usage_card kfs n :* kill_usage_cd kfs cd -zap_usg :: KillFlags -> UseDmd -> UseDmd -zap_usg kfs (UCall c u) - | kf_called_once kfs = UCall Many (zap_usg kfs u) - | otherwise = UCall c (zap_usg kfs u) -zap_usg kfs (UProd us) = UProd (map (zap_musg kfs) us) -zap_usg _ u = u +kill_usage_cd :: KillFlags -> CleanDemand -> CleanDemand +kill_usage_cd kfs (Call n cd) + | kf_called_once kfs = Call (lubCard C_1N n) (kill_usage_cd kfs cd) + | otherwise = Call n (kill_usage_cd kfs cd) +kill_usage_cd kfs (Prod ds) = Prod (map (kill_usage kfs) ds) +kill_usage_cd _ cd = cd -- | If the argument is a used non-newtype dictionary, give it strict demand. -- Also split the product type & demand and recur in order to similarly @@ -1951,7 +1680,7 @@ zap_usg _ u = u strictifyDictDmd :: Type -> Demand -> Demand strictifyDictDmd ty (n :* Prod ds) | not (isAbs n) - , Just (tycon, field_tys) <- as_non_newtype_dict ty + , Just field_tys <- as_non_newtype_dict ty = C_1N :* -- main idea: ensure it's strict if all (not . isAbsDmd) ds then topCleanDmd -- abstract to strict w/ arbitrary component use, @@ -1964,17 +1693,17 @@ strictifyDictDmd ty (n :* Prod ds) -- | Return a TyCon and a list of field types if the given -- type is a non-newtype dictionary type as_non_newtype_dict ty - | Just (tycon, _arg_tys, _data_con, scaledThing -> inst_con_arg_tys) + | Just (tycon, _arg_tys, _data_con, map scaledThing -> inst_con_arg_tys) <- splitDataProductType_maybe ty , not (isNewTyCon tycon) , isClassTyCon tycon - = Just (tycon, inst_con_arg_tys) + = Just inst_con_arg_tys | otherwise = Nothing strictifyDictDmd _ dmd = dmd strictifyDmd :: Demand -> Demand -strictifyDmd (n :* cd) = bothCard n C_10 :* cd +strictifyDmd (n :* cd) = plusCard n C_10 :* cd {- Note [HyperStr and Use demands] @@ -1998,92 +1727,39 @@ out how deeply we can unpack x, or that we do not have to pass y. ************************************************************************ -} -instance Binary StrDmd where - put_ bh HyperStr = do putByte bh 0 - put_ bh HeadStr = do putByte bh 1 - put_ bh (SCall s) = do putByte bh 2 - put_ bh s - put_ bh (SProd sx) = do putByte bh 3 - put_ bh sx +instance Binary Card where + put_ bh C_00 = putByte bh 0 + put_ bh C_01 = putByte bh 1 + put_ bh C_0N = putByte bh 2 + put_ bh C_11 = putByte bh 3 + put_ bh C_1N = putByte bh 4 + put_ bh C_10 = putByte bh 5 + get bh = do + h <- getByte bh + case h of + 0 -> return C_00 + 1 -> return C_01 + 2 -> return C_0N + 3 -> return C_11 + 4 -> return C_1N + 5 -> return C_10 + _ -> pprPanic "Binary:Card" (ppr (fromIntegral h :: Int)) + +instance Binary Demand where + put_ bh (n :* cd) = put_ bh n *> put_ bh cd + get bh = (:*) <$> get bh <*> get bh + +instance Binary CleanDemand where + put_ bh (Poly cd) = putByte bh 0 *> put_ bh cd + put_ bh (Call n cd) = putByte bh 1 *> put_ bh n *> put_ bh cd + put_ bh (Prod ds) = putByte bh 2 *> put_ bh ds get bh = do - h <- getByte bh - case h of - 0 -> do return HyperStr - 1 -> do return HeadStr - 2 -> do s <- get bh - return (SCall s) - _ -> do sx <- get bh - return (SProd sx) - -instance Binary ArgStr where - put_ bh Lazy = do - putByte bh 0 - put_ bh (Str s) = do - putByte bh 1 - put_ bh s - - get bh = do - h <- getByte bh - case h of - 0 -> return Lazy - _ -> do s <- get bh - return $ Str s - -instance Binary Count where - put_ bh One = do putByte bh 0 - put_ bh Many = do putByte bh 1 - - get bh = do h <- getByte bh - case h of - 0 -> return One - _ -> return Many - -instance Binary ArgUse where - put_ bh Abs = do - putByte bh 0 - put_ bh (Use c u) = do - putByte bh 1 - put_ bh c - put_ bh u - - get bh = do - h <- getByte bh - case h of - 0 -> return Abs - _ -> do c <- get bh - u <- get bh - return $ Use c u - -instance Binary UseDmd where - put_ bh Used = do - putByte bh 0 - put_ bh UHead = do - putByte bh 1 - put_ bh (UCall c u) = do - putByte bh 2 - put_ bh c - put_ bh u - put_ bh (UProd ux) = do - putByte bh 3 - put_ bh ux - - get bh = do - h <- getByte bh - case h of - 0 -> return $ Used - 1 -> return $ UHead - 2 -> do c <- get bh - u <- get bh - return (UCall c u) - _ -> do ux <- get bh - return (UProd ux) - -instance (Binary s, Binary u) => Binary (JointDmd s u) where - put_ bh (JD { sd = x, ud = y }) = do put_ bh x; put_ bh y - get bh = do - x <- get bh - y <- get bh - return $ JD { sd = x, ud = y } + h <- getByte bh + case h of + 0 -> Poly <$> get bh + 1 -> Call <$> get bh <*> get bh + 2 -> Prod <$> get bh + _ -> pprPanic "Binary:CleanDemand" (ppr (fromIntegral h :: Int)) instance Binary StrictSig where put_ bh (StrictSig aa) = do ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -514,8 +514,8 @@ mkDictSelId name clas strict_sig = mkClosedStrictSig [arg_dmd] topDiv arg_dmd | new_tycon = evalDmd | otherwise = mkManyUsedDmd $ - mkProdDmd [ if name == sel_name then evalDmd else absDmd - | sel_name <- sel_names ] + Prod [ if name == sel_name then evalDmd else absDmd + | sel_name <- sel_names ] mkDictSelRhs :: Class -> Int -- 0-indexed selector among (superclasses ++ methods) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e82493f1bfb9c984c81fad18208f375acc61a9c2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e82493f1bfb9c984c81fad18208f375acc61a9c2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 17:35:21 2020 From: gitlab at gitlab.haskell.org (Simon Peyton Jones) Date: Wed, 28 Oct 2020 13:35:21 -0400 Subject: [Git][ghc/ghc][wip/T16762] More wibbles Message-ID: <5f99abd95c429_8972042b9c93032d@gitlab.haskell.org.mail> Simon Peyton Jones pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 9ffdc4d9 by Simon Peyton Jones at 2020-10-28T17:34:46+00:00 More wibbles - - - - - 2 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Utils/Monad.hs Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3003,7 +3003,7 @@ bindOuterFamEqnTKBndrs_Q_Tv :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a) bindOuterFamEqnTKBndrs_Q_Tv hs_bndrs thing_inside - = applyToFstM getOuterTyVars $ + = liftFstM getOuterTyVars $ bindOuterTKBndrsX (smVanilla { sm_clone = False, sm_parent = True , sm_tvtv = True }) hs_bndrs thing_inside @@ -3013,7 +3013,7 @@ bindOuterFamEqnTKBndrs :: HsOuterFamEqnTyVarBndrs GhcRn -> TcM a -> TcM ([TcTyVar], a) bindOuterFamEqnTKBndrs hs_bndrs thing_inside - = applyToFstM getOuterTyVars $ + = liftFstM getOuterTyVars $ bindOuterTKBndrsX (smVanilla { sm_clone = False, sm_parent = True }) hs_bndrs thing_inside -- sm_clone=False: see Note [Cloning for type variable binders] @@ -3096,14 +3096,14 @@ bindExplicitTKBndrs_Q_Skol, bindExplicitTKBndrs_Q_Tv -> TcM ([TcTyVar], a) -- These do not clone: see Note [Cloning for type variable binders] bindExplicitTKBndrs_Q_Skol ctxt_kind hs_bndrs thing_inside - = applyToFstM binderVars $ + = liftFstM binderVars $ bindExplicitTKBndrsX (smVanilla { sm_clone = False, sm_parent = True , sm_kind = ctxt_kind }) hs_bndrs thing_inside -- sm_clone=False: see Note [Cloning for type variable binders] bindExplicitTKBndrs_Q_Tv ctxt_kind hs_bndrs thing_inside - = applyToFstM binderVars $ + = liftFstM binderVars $ bindExplicitTKBndrsX (smVanilla { sm_clone = False, sm_parent = True , sm_tvtv = True, sm_kind = ctxt_kind }) hs_bndrs thing_inside @@ -3118,7 +3118,7 @@ bindExplicitTKBndrsX :: (OutputableBndrFlag flag) bindExplicitTKBndrsX skol_mode@(SM { sm_parent = check_parent, sm_kind = ctxt_kind , sm_holes = hole_info }) hs_tvs thing_inside - = do { traceTc "bindExplicTKBndrs" (ppr hs_tvs) + = do { traceTc "bindExplicitTKBndrs" (ppr hs_tvs) ; go hs_tvs } where tc_ki_mode = TcTyMode { mode_tyki = KindLevel, mode_holes = hole_info } @@ -3232,7 +3232,7 @@ bindImplicitTKBndrsX skol_mode@(SM { sm_parent = check_parent, sm_kind = ctxt_ki -- SkolemMode -------------------------------------- --- | 'SkolemMode' decribes how to typecheck an explict ('HsTyVarBndr') or +-- | 'SkolemMode' decribes how to typecheck an explicit ('HsTyVarBndr') or -- implicit ('Name') binder in a type. It is just a record of flags -- that describe what sort of 'TcTyVar' to create. data SkolemMode @@ -3283,15 +3283,15 @@ When we /must not/ clone (in tcDataFamInstDecl) bring p,q into scope before looking at the the constructor decls. -* bindExplictTKBndrs_Q_Tv/bindImplicitTKBndrs_Q_Tv do not clone +* bindExplicitTKBndrs_Q_Tv/bindImplicitTKBndrs_Q_Tv do not clone We take advantage of this in kcInferDeclHeader: all_tv_prs = mkTyVarNamePairs (scoped_kvs ++ tc_tvs) If we cloned, we'd need to take a bit more care here; not hard. -* bindExplictTKBndrs_Q_Skol, bindExplictTKBndrs_Skol, do not clone. +* bindExplicitTKBndrs_Q_Skol, bindExplicitTKBndrs_Skol, do not clone. There is no need, I think. - The payoff here is that avoiding gratuitious cloning means that we can + The payoff here is that avoiding gratuitous cloning means that we can almost always take the fast path in swizzleTcTyConBndrs. When we /must/ clone. ===================================== compiler/GHC/Utils/Monad.hs ===================================== @@ -11,7 +11,7 @@ module GHC.Utils.Monad , zipWith3M, zipWith3M_, zipWith4M, zipWithAndUnzipM , mapAndUnzipM, mapAndUnzip3M, mapAndUnzip4M, mapAndUnzip5M , mapAccumLM - , applyToFstM, applyToSndM + , liftFstM, liftSndM , mapSndM , concatMapM , mapMaybeM @@ -165,11 +165,11 @@ mapSndM f xs = go xs go [] = return [] go ((a,b):xs) = do { c <- f b; rs <- go xs; return ((a,c):rs) } -applyToFstM :: Monad m => (a -> b) -> m (a, r) -> m (b, r) -applyToFstM f thing = do { (a,r) <- thing; return (f a, r) } +liftFstM :: Monad m => (a -> b) -> m (a, r) -> m (b, r) +liftFstM f thing = do { (a,r) <- thing; return (f a, r) } -applyToSndM :: Monad m => (a -> b) -> m (r, a) -> m (r, b) -applyToSndM f thing = do { (r,a) <- thing; return (r, f a) } +liftSndM :: Monad m => (a -> b) -> m (r, a) -> m (r, b) +liftSndM f thing = do { (r,a) <- thing; return (r, f a) } -- | Monadic version of concatMap concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ffdc4d9ffc595882ba5398634ca37a2bf4a307d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9ffdc4d9ffc595882ba5398634ca37a2bf4a307d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 19:11:39 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 28 Oct 2020 15:11:39 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: hadrian: Don't quote metric baseline argument Message-ID: <5f99c26bf409f_8973fa3a6aa385c9637cc@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 499ed7ac by Ben Gamari at 2020-10-28T15:11:33-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - 544b3964 by Alan Zimmerman at 2020-10-28T15:11:33-04:00 API Annotations: put constructors in alphabetical order - - - - - 2 changed files: - compiler/GHC/Parser/Annotation.hs - hadrian/src/Settings/Builders/RunTest.hs Changes: ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,7 +301,6 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule - | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf @@ -318,7 +317,8 @@ data AnnKeywordId | AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell | AnnPackageName | AnnPattern - | AnnPercent -- ^ '%' -- for HsExplicitMult + | AnnPercent -- ^ '%' -- for HsExplicitMult + | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnProc | AnnQualified | AnnRarrow -- ^ '->' ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -140,7 +140,7 @@ runTestBuilderArgs = builder RunTest ? do , arg "--config", arg $ "stats_files_dir=" ++ statsFilesDir , arg $ "--threads=" ++ show threads , case perfBaseline of - Just commit | not (null commit) -> arg ("--perf-baseline=" ++ show commit) + Just commit | not (null commit) -> arg ("--perf-baseline=" ++ commit) _ -> mempty , emitWhenSet testEnv $ \env -> arg ("--test-env=" ++ env) , emitWhenSet testMetricsFile $ \file -> arg ("--metrics-file=" ++ file) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b159d5b97f5eedecfb0dfcb241a9da54ec8c175d...544b39641eb76af76fbfddbdc02fbf1f4e49b74b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b159d5b97f5eedecfb0dfcb241a9da54ec8c175d...544b39641eb76af76fbfddbdc02fbf1f4e49b74b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 20:33:20 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Wed, 28 Oct 2020 16:33:20 -0400 Subject: [Git][ghc/ghc][wip/T16762] Replace HsImplicitBndrs with HsOuterTyVarBndrs Message-ID: <5f99d590b1ff2_897e523358976947@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 03d0a247 by Ryan Scott at 2020-10-28T16:30:56-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 21 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03d0a247a9f5e3bc8f5637b260e98be3f030253d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03d0a247a9f5e3bc8f5637b260e98be3f030253d You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 21:53:51 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Wed, 28 Oct 2020 17:53:51 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/neuter Message-ID: <5f99e86f3f93d_8973fa31ce863b498319f@gitlab.haskell.org.mail> Richard Eisenberg pushed new branch wip/neuter at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/neuter You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Wed Oct 28 23:12:23 2020 From: gitlab at gitlab.haskell.org (Alan Zimmerman) Date: Wed, 28 Oct 2020 19:12:23 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18888 Message-ID: <5f99fad744d0c_8973fa31cd64b20986782@gitlab.haskell.org.mail> Alan Zimmerman pushed new branch wip/T18888 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18888 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 01:11:05 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 28 Oct 2020 21:11:05 -0400 Subject: [Git][ghc/ghc][wip/unloading] 4 commits: Fix and enable object unloading in GHCi Message-ID: <5f9a16a97a0b6_8973fa31b018eb89939c@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: 0d422cd5 by Ömer Sinan Ağacan at 2020-10-22T17:15:19+00:00 Fix and enable object unloading in GHCi Fixes #16525 See Note [Object unloading] in CheckUnload.c for details. NoFib results: -------------------------------------------------------------------------------- Program Size Allocs Instrs Reads Writes -------------------------------------------------------------------------------- CS -0.2% 0.0% +0.0% +0.0% +0.0% CSD -0.2% 0.0% +0.0% +0.0% +0.0% FS -0.2% 0.0% +0.0% +0.0% -0.0% S -0.2% 0.0% +1.0% +1.1% +0.0% VS -0.2% 0.0% +0.0% +0.0% -0.0% VSD -0.1% 0.0% +0.0% +0.0% +0.0% VSM -0.1% 0.0% +0.0% +0.0% -0.0% anna -0.1% 0.0% +0.0% +0.0% +0.0% ansi -0.1% 0.0% +0.0% +0.0% 0.0% atom -0.1% 0.0% +0.0% +0.0% 0.0% awards -0.1% 0.0% +0.0% +0.0% 0.0% banner -0.1% 0.0% +0.0% +0.0% +0.0% bernouilli -0.1% 0.0% +0.0% +0.0% +0.0% binary-trees -0.1% 0.0% +0.0% +0.0% -0.0% boyer -0.1% 0.0% +0.1% +0.1% 0.0% boyer2 -0.1% 0.0% +0.0% +0.1% 0.0% bspt -0.1% 0.0% +0.0% +0.0% 0.0% cacheprof -0.1% 0.0% +0.0% +0.0% -0.0% calendar -0.1% 0.0% +0.0% +0.0% 0.0% cichelli -0.1% 0.0% +0.1% +0.2% +0.0% circsim -0.1% 0.0% +0.0% +0.0% +0.0% clausify -0.1% 0.0% +0.0% +0.0% +0.0% comp_lab_zift -0.1% 0.0% +0.0% +0.0% -0.0% compress -0.1% 0.0% +0.0% +0.0% +0.0% compress2 -0.1% 0.0% +0.0% +0.0% 0.0% constraints -0.1% 0.0% +0.0% +0.0% +0.0% cryptarithm1 -0.1% 0.0% +0.0% +0.0% 0.0% cryptarithm2 -0.1% 0.0% +0.0% +0.0% +0.0% cse -0.1% 0.0% +0.0% +0.0% 0.0% digits-of-e1 -0.1% 0.0% +0.0% +0.0% +0.0% digits-of-e2 -0.1% 0.0% +0.0% +0.0% -0.0% dom-lt -0.1% 0.0% +0.0% +0.0% -0.0% eliza -0.1% 0.0% +0.0% +0.0% +0.0% event -0.1% 0.0% +0.0% +0.1% 0.0% exact-reals -0.1% 0.0% +0.0% +0.0% -0.0% exp3_8 -0.1% 0.0% +0.0% +0.0% 0.0% expert -0.1% 0.0% +0.0% +0.0% +0.0% fannkuch-redux -0.1% 0.0% +0.0% +0.0% 0.0% fasta -0.1% 0.0% +0.0% +0.0% -0.0% fem -0.1% 0.0% +0.0% +0.0% 0.0% fft -0.1% 0.0% +0.0% +0.0% -0.0% fft2 -0.1% 0.0% +0.0% +0.0% 0.0% fibheaps -0.1% 0.0% +0.0% +0.0% -0.0% fish -0.1% 0.0% +0.0% +0.0% -0.0% fluid -0.1% 0.0% +0.1% +0.1% -0.0% fulsom -0.1% 0.0% +0.0% +0.0% 0.0% gamteb -0.1% 0.0% +0.0% +0.0% 0.0% gcd -0.1% 0.0% +0.0% +0.0% +0.0% gen_regexps -0.2% 0.0% +0.0% +0.0% -0.0% genfft -0.1% 0.0% +0.0% +0.0% -0.0% gg -0.1% 0.0% +0.1% +0.1% 0.0% grep -0.1% 0.0% +0.0% +0.0% 0.0% hidden -0.1% 0.0% +0.0% +0.0% +0.0% hpg -0.1% 0.0% +0.0% +0.0% +0.0% ida -0.1% 0.0% +0.0% +0.0% -0.0% infer -0.1% 0.0% +0.0% +0.0% +0.0% integer -0.1% 0.0% +0.0% +0.0% 0.0% integrate -0.1% 0.0% +0.0% +0.0% 0.0% k-nucleotide -0.1% 0.0% +0.0% +0.0% -0.0% kahan -0.1% 0.0% +0.0% +0.0% +0.0% knights -0.1% 0.0% +0.0% +0.0% 0.0% lambda -0.1% 0.0% +0.0% +0.0% +0.0% last-piece -0.1% 0.0% +0.0% +0.0% -0.0% lcss -0.1% 0.0% +0.0% +0.0% 0.0% life -0.1% 0.0% +0.0% +0.0% -0.0% lift -0.1% 0.0% +0.0% +0.0% +0.0% linear -0.1% 0.0% +0.0% +0.0% +0.0% listcompr -0.1% 0.0% +0.0% +0.0% -0.0% listcopy -0.1% 0.0% +0.0% +0.0% -0.0% maillist -0.1% 0.0% +0.0% +0.0% +0.0% mandel -0.1% 0.0% +0.0% +0.0% -0.0% mandel2 -0.1% 0.0% +0.0% +0.0% -0.0% mate -0.1% 0.0% +0.0% +0.0% -0.0% minimax -0.1% 0.0% +0.0% +0.0% -0.0% mkhprog -0.1% 0.0% +0.0% +0.0% +0.0% multiplier -0.1% 0.0% +0.0% +0.0% +0.0% n-body -0.1% 0.0% +0.0% +0.0% 0.0% nucleic2 -0.1% 0.0% +0.0% +0.0% -0.0% para -0.1% 0.0% +0.0% +0.0% 0.0% paraffins -0.1% 0.0% +0.0% +0.0% 0.0% parser -0.1% 0.0% +0.0% +0.0% +0.0% parstof -0.1% 0.0% +0.2% +0.2% -0.0% pic -0.1% 0.0% +0.1% +0.1% +0.0% pidigits -0.1% 0.0% +0.0% +0.0% -0.0% power -0.1% 0.0% +0.0% +0.0% +0.0% pretty -0.1% 0.0% +0.5% +0.6% -0.0% primes -0.1% 0.0% +0.0% +0.0% 0.0% primetest -0.1% 0.0% +0.0% +0.0% +0.0% prolog -0.1% 0.0% +0.0% +0.0% +0.0% puzzle -0.1% 0.0% +0.0% +0.0% -0.0% queens -0.1% 0.0% +0.0% +0.0% 0.0% reptile -0.1% 0.0% +0.0% +0.0% +0.0% reverse-complem -0.2% 0.0% +0.0% +0.0% 0.0% rewrite -0.1% 0.0% +0.0% +0.0% 0.0% rfib -0.1% 0.0% +0.0% +0.0% -0.0% rsa -0.1% 0.0% +0.0% +0.0% +0.0% scc -0.2% 0.0% +0.5% +0.7% +0.0% sched -0.1% 0.0% +0.0% +0.0% -0.0% scs -0.1% 0.0% +0.0% +0.0% +0.0% simple -0.1% 0.0% +0.3% +0.4% 0.0% solid -0.1% 0.0% +0.0% +0.0% 0.0% sorting -0.1% 0.0% +0.0% +0.0% -0.0% spectral-norm -0.1% 0.0% +0.0% +0.0% -0.0% sphere -0.1% 0.0% +0.0% +0.0% 0.0% symalg -0.1% 0.0% +0.0% +0.0% +0.0% tak -0.1% 0.0% +0.0% +0.0% +0.0% transform -0.1% 0.0% +0.0% +0.0% +0.0% treejoin -0.1% 0.0% +0.1% +0.1% 0.0% typecheck -0.1% 0.0% +0.0% +0.0% 0.0% veritas -0.1% 0.0% +0.0% +0.0% +0.0% wang -0.1% 0.0% +0.0% +0.0% +0.0% wave4main -0.1% 0.0% +0.0% +0.0% -0.0% wheel-sieve1 -0.1% 0.0% +0.0% +0.0% +0.0% wheel-sieve2 -0.1% 0.0% +0.0% +0.0% -0.0% x2n1 -0.1% 0.0% +0.0% +0.0% +0.0% -------------------------------------------------------------------------------- Min -0.2% 0.0% +0.0% +0.0% -0.0% Max -0.1% 0.0% +1.0% +1.1% +0.0% Geometric Mean -0.1% -0.0% +0.0% +0.0% -0.0% - - - - - 35547f8e by Ray Shih at 2020-10-22T17:15:19+00:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - 852129d3 by GHC GitLab CI at 2020-10-22T17:21:23+00:00 rts: Introduce highMemDynamic - - - - - 6f5e9883 by GHC GitLab CI at 2020-10-22T17:21:40+00:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - compiler/GHC/Runtime/Linker.hs - includes/rts/Linker.h - includes/rts/storage/GC.h - rts/CheckUnload.c - rts/CheckUnload.h - rts/Hash.c - rts/Hash.h - rts/Linker.c - rts/LinkerInternals.h - rts/RtsStartup.c - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/MachO.c - rts/linker/PEi386.c - rts/linker/elf_got.c - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/Storage.c - testsuite/tests/ghci/T16525a/T16525a.script - testsuite/tests/ghci/T16525a/T16525a.stdout - testsuite/tests/ghci/T16525a/all.T - + testsuite/tests/ghci/T16525b/A.hs - + testsuite/tests/ghci/T16525b/B.hs - + testsuite/tests/ghci/T16525b/T16525b.script - + testsuite/tests/ghci/T16525b/T16525b.stdout - + testsuite/tests/ghci/T16525b/all.T - testsuite/tests/rts/linker/Makefile - testsuite/tests/rts/linker/all.T - testsuite/tests/rts/linker/linker_error.c - + testsuite/tests/rts/linker/linker_unload_native.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1549b05fce98ed3aeac459bdbdb150b67ccfbb4c...6f5e9883ed189a7c4890dcf7a9661d810e1b0867 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1549b05fce98ed3aeac459bdbdb150b67ccfbb4c...6f5e9883ed189a7c4890dcf7a9661d810e1b0867 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 01:11:44 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 28 Oct 2020 21:11:44 -0400 Subject: [Git][ghc/ghc][master] hadrian: Don't quote metric baseline argument Message-ID: <5f9a16d0c38dd_8973fa31b018eb8995684@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - 1 changed file: - hadrian/src/Settings/Builders/RunTest.hs Changes: ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -140,7 +140,7 @@ runTestBuilderArgs = builder RunTest ? do , arg "--config", arg $ "stats_files_dir=" ++ statsFilesDir , arg $ "--threads=" ++ show threads , case perfBaseline of - Just commit | not (null commit) -> arg ("--perf-baseline=" ++ show commit) + Just commit | not (null commit) -> arg ("--perf-baseline=" ++ commit) _ -> mempty , emitWhenSet testEnv $ \env -> arg ("--test-env=" ++ env) , emitWhenSet testMetricsFile $ \file -> arg ("--metrics-file=" ++ file) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60322f930c544fabd7e68231db26e3a1fb8ed037 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/60322f930c544fabd7e68231db26e3a1fb8ed037 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 01:12:23 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 28 Oct 2020 21:12:23 -0400 Subject: [Git][ghc/ghc][master] API Annotations: put constructors in alphabetical order Message-ID: <5f9a16f766d0d_8973fa3eb94a8d0100053d@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 1 changed file: - compiler/GHC/Parser/Annotation.hs Changes: ===================================== compiler/GHC/Parser/Annotation.hs ===================================== @@ -301,7 +301,6 @@ data AnnKeywordId | AnnMdo | AnnMinus -- ^ '-' | AnnModule - | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnNewtype | AnnName -- ^ where a name loses its location in the AST, this carries it | AnnOf @@ -318,7 +317,8 @@ data AnnKeywordId | AnnDollarDollar -- ^ prefix '$$' -- TemplateHaskell | AnnPackageName | AnnPattern - | AnnPercent -- ^ '%' -- for HsExplicitMult + | AnnPercent -- ^ '%' -- for HsExplicitMult + | AnnPercentOne -- ^ '%1' -- for HsLinearArrow | AnnProc | AnnQualified | AnnRarrow -- ^ '->' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c85eb3722bc68999dee023c98a8da0ffbbd89760 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c85eb3722bc68999dee023c98a8da0ffbbd89760 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 01:25:09 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Wed, 28 Oct 2020 21:25:09 -0400 Subject: [Git][ghc/ghc][wip/bump-time] Bump time submodule to 1.11 Message-ID: <5f9a19f564bc_897e1358b81004457@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-time at Glasgow Haskell Compiler / GHC Commits: 91c0ae51 by Ben Gamari at 2020-10-28T21:25:00-04:00 Bump time submodule to 1.11 - - - - - 2 changed files: - libraries/time - libraries/unix Changes: ===================================== libraries/time ===================================== @@ -1 +1 @@ -Subproject commit 5319bed3b14c21de5410ead88ec8aaa838d7339c +Subproject commit 866ed2501fe1acf31abeaaddefcdc730436d87fa ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit ea13d990580273a883368793dfbb826cab5a22d4 +Subproject commit a33e3d2d8fb5c9b2ccfad7cd63a456d38ac8bb7a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91c0ae5129a357a4dcea95244b97d2802c6abace -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/91c0ae5129a357a4dcea95244b97d2802c6abace You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 01:43:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Wed, 28 Oct 2020 21:43:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: hadrian: Don't quote metric baseline argument Message-ID: <5f9a1e3d82180_8973fa3bb9cbd7010097f8@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - a01f59af by John Ericson at 2020-10-28T21:43:01-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - bef5a00f by Sylvain Henry at 2020-10-28T21:43:06-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 62685c06 by Sylvain Henry at 2020-10-28T21:43:06-04:00 GC: Avoid data race (#18717, #17964) - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg/Prep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/544b39641eb76af76fbfddbdc02fbf1f4e49b74b...62685c0639338613ab7a7a82515d57f9109ff32b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/544b39641eb76af76fbfddbdc02fbf1f4e49b74b...62685c0639338613ab7a7a82515d57f9109ff32b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 07:53:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 29 Oct 2020 03:53:27 -0400 Subject: [Git][ghc/ghc][master] Widen acceptance threshold for T10421a Message-ID: <5f9a74f7a7bb2_8973fa3d9c44354103026e@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 1 changed file: - testsuite/tests/perf/compiler/all.T Changes: ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -409,7 +409,7 @@ test('T10421', ['T10421', '-v0 -O']) test('T10421a', [ only_ways(['normal']), - collect_compiler_stats('bytes allocated', 1) + collect_compiler_stats('bytes allocated', 10) ], multimod_compile, ['T10421a', '-v0 -O']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/795908dc4eab8e8b40cb318a2adbe4a4d4126c74 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/795908dc4eab8e8b40cb318a2adbe4a4d4126c74 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 07:54:01 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 29 Oct 2020 03:54:01 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Split GHC.Driver.Types Message-ID: <5f9a7519cceb6_8977731a841032916@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToByteCode.hs - compiler/GHC/CoreToStg/Prep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/795908dc4eab8e8b40cb318a2adbe4a4d4126c74...22f5d9a951dbc9cfdf55984c5e2a6fad28a6f650 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/795908dc4eab8e8b40cb318a2adbe4a4d4126c74...22f5d9a951dbc9cfdf55984c5e2a6fad28a6f650 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 08:16:32 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 29 Oct 2020 04:16:32 -0400 Subject: [Git][ghc/ghc][wip/T18844] 17 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f9a7a6023ce4_8973fa3a6b1b4b010336b2@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 575e438d by Ryan Scott at 2020-10-29T04:13:01-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77bb260484de84fca54dbc9ddb95eb74a28511f5...575e438d14e50cfff051b7a2ba6cccac7e38036e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77bb260484de84fca54dbc9ddb95eb74a28511f5...575e438d14e50cfff051b7a2ba6cccac7e38036e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 08:24:07 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 29 Oct 2020 04:24:07 -0400 Subject: [Git][ghc/ghc][wip/T18723] 20 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f9a7c278cb7_8977f0cefc1034492@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18723 at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d54abe257241a73a86c39cff98ad39ef339f3714...2ef2fac4c412a25fa64f79b759d69d22a4ebc784 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d54abe257241a73a86c39cff98ad39ef339f3714...2ef2fac4c412a25fa64f79b759d69d22a4ebc784 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 09:06:24 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 29 Oct 2020 05:06:24 -0400 Subject: [Git][ghc/ghc][wip/T16762] 62 commits: Bump LLVM version to 10.0 Message-ID: <5f9a8610323ea_8973fa3b8cce5201039020@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - d2b9e53d by Ryan Scott at 2020-10-29T05:05:23-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/Pipeline.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03d0a247a9f5e3bc8f5637b260e98be3f030253d...d2b9e53d812ce2e89c9cdbc5a0b9694d84b1570a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03d0a247a9f5e3bc8f5637b260e98be3f030253d...d2b9e53d812ce2e89c9cdbc5a0b9694d84b1570a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 10:51:35 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Thu, 29 Oct 2020 06:51:35 -0400 Subject: [Git][ghc/ghc][wip/T18844] Split HsConDecl{H98,GADT}Details Message-ID: <5f9a9eb7e845f_897100d5434104815c@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 16331f16 by Ryan Scott at 2020-10-29T06:51:19-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 22 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1476,9 +1476,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1495,7 +1495,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1626,27 +1626,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1726,15 +1734,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1103,9 +1103,22 @@ instance OutputableBndrId p => Outputable (ConDeclField (GhcPass p)) where ppr (ConDeclField _ fld_n fld_ty _) = ppr fld_n <+> dcolon <+> ppr fld_ty --- HsConDetails is used for patterns/expressions *and* for data type --- declarations --- | Haskell Constructor Details +-- | Describes the arguments to a data constructor. This is a common +-- representation for several constructor-related concepts, including: +-- +-- * The arguments in a Haskell98-style constructor declaration +-- (see 'HsConDeclH98Details' in "GHC.Hs.Decls"). +-- +-- * The arguments in constructor patterns in @case@/function definitions +-- (see 'HsConPatDetails' in "GHC.Hs.Pat"). +-- +-- * The left-hand side arguments in a pattern synonym binding +-- (see 'HsPatSynDetails' in "GHC.Hs.Binds"). +-- +-- One notable exception is the arguments in a GADT constructor, which uses +-- a separate data type entirely (see 'HsConDeclGADTDetails' in +-- "GHC.Hs.Decls"). This is because GADT constructors cannot be declared with +-- infix syntax, unlike the concepts above (#18844). data HsConDetails arg rec = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1259,29 +1259,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -885,7 +885,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -897,7 +897,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2589,49 +2589,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2640,16 +2642,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1321,6 +1321,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1532,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1543,7 +1547,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1557,13 +1563,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2330,7 +2330,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -611,7 +611,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -636,17 +636,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1618,7 +1618,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2181,7 +2181,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2198,15 +2198,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2214,9 +2211,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2224,7 +2221,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2239,7 +2236,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2250,27 +2247,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -775,7 +775,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1573,7 +1573,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1586,6 +1586,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1614,14 +1629,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1635,7 +1650,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3206,7 +3221,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3276,7 +3291,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3293,7 +3308,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3372,48 +3387,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3425,6 +3442,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -622,7 +622,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -631,9 +631,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -641,7 +641,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 904a3c276643d15da24303493b62e95dfb0b7726 +Subproject commit 0493589a445ad3ca56aaefdf072c0b42a57d1b9a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16331f16046beb106dab0974b74d0ddcea9aa074 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16331f16046beb106dab0974b74d0ddcea9aa074 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 13:40:17 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 29 Oct 2020 09:40:17 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] It bootstraps Message-ID: <5f9ac641484e3_897a069b1810613d0@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: 7f20604e by Sebastian Graf at 2020-10-29T14:40:09+01:00 It bootstraps - - - - - 4 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -44,6 +44,8 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set +-- import GHC.Driver.Ppr + {- ************************************************************************ * * @@ -435,7 +437,7 @@ worker, so the worker will rebuild x = (a, absent-error) and that'll crash. -Note [Aggregated demand for cardinality] +Note [Aggregated demand for cardinality] -- TODO: This Note should be named [LetUp vs. LetDown] and probably predates said separation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We use different strategies for strictness and usage/cardinality to "unleash" demands captured on free variables by bindings. Let us @@ -498,7 +500,8 @@ dmdTransform env var dmd -- Used to be controlled by a flag. -- See #18429 for some perf measurements. | Just _ <- isClassOpId_maybe var - = dmdTransformDictSelSig (idStrictness var) dmd + = -- pprTrace "dmdTransform:DictSel" (ppr var $$ ppr dmd) $ + dmdTransformDictSelSig (idStrictness var) dmd -- Imported functions | isGlobalId var , let res = dmdTransformSig (idStrictness var) dmd @@ -511,14 +514,14 @@ dmdTransform env var dmd = -- pprTrace "dmdTransform:LetDown" (vcat [ppr var, ppr sig, ppr dmd, ppr fn_ty]) $ if isTopLevel top_lvl then fn_ty -- Don't record demand on top-level things - else addVarDmd fn_ty var (mkOnceUsedDmd dmd) + else addVarDmd fn_ty var (C_11 :* dmd) -- Everything else: -- * Local let binders for which we use LetUp (cf. 'useLetUp') -- * Lambda binders -- * Case and constructor field binders | otherwise = -- pprTrace "dmdTransform:other" (vcat [ppr var, ppr sig, ppr dmd, ppr res]) $ - unitDmdType (unitVarEnv var (mkOnceUsedDmd dmd)) + unitDmdType (unitVarEnv var (C_11 :* dmd)) {- ********************************************************************* * * @@ -566,6 +569,16 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs sig = mkStrictSigForArity rhs_arity (DmdType sig_fv rhs_dmds rhs_div) -- See Note [Aggregated demand for cardinality] + -- TODO: That Note doesn't explain the following lines at all. The reason + -- is really much different: When we have a recursive function, we'd + -- have to also consider the free vars of the strictness signature + -- when checking whether we found a fixed-point. That is expensive; we + -- only want to check whether argument demands of the sig changed. + -- reuseEnv makes it so that the FV results are stable as long as the + -- last argument demands were. Strictness won't change. But used-once + -- might turn into used-many even if the signature was stable and we'd + -- have to do an additional iteration. reuseEnv makes sure that we + -- never get used-once info for FVs of recursive fucntions. rhs_fv1 = case rec_flag of Just bs -> reuseEnv (delVarEnvList rhs_fv bs) Nothing -> rhs_fv ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -607,18 +607,25 @@ mkWWstr_one dflags fam_envs has_inlineable_prag arg dmd = idDemandInfo arg wantToUnbox :: FamInstEnvs -> Bool -> Type -> Demand -> Maybe ([Demand], DataConAppContext) -wantToUnbox fam_envs has_inlineable_prag ty dmd@(_ :* cd) = +wantToUnbox fam_envs has_inlineable_prag ty dmd = case deepSplitProductType_maybe fam_envs ty of Just dcac at DataConAppContext{ dcac_arg_tys = con_arg_tys } | isStrictDmd dmd -- See Note [Unpacking arguments with product and polymorphic demands] - , Just cs <- viewProd (length con_arg_tys) cd + , Just cs <- split_prod_dmd_arity dmd (length con_arg_tys) -- See Note [Do not unpack class dictionaries] , not (has_inlineable_prag && isClassPred ty) -- See Note [mkWWstr and unsafeCoerce] , cs `equalLength` con_arg_tys -> Just (cs, dcac) _ -> Nothing + where + split_prod_dmd_arity dmd arty + -- For seqDmd, it should behave like , for some + -- suitable arity + | isSeqDmd dmd = Just (replicate arty absDmd) + | _ :* Prod ds <- dmd = Just ds + | otherwise = Nothing unbox_one :: DynFlags -> FamInstEnvs -> Var -> [Demand] ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -12,8 +12,8 @@ -} module GHC.Types.Demand ( - Card, Demand(..), CleanDemand(Prod), viewProd, - mkOnceUsedDmd, mkManyUsedDmd, oneifyDmd, oneifyCard, + Card(..), Demand(..), CleanDemand(Prod), viewProd, + oneifyDmd, oneifyCard, absDmd, topDmd, botDmd, seqDmd, lubCard, lubDmd, lubCleanDmd, plusCard, plusDmd, plusCleanDmd, @@ -319,13 +319,9 @@ f g = (snd (g 3), True) should be: m -} -mkOnceUsedDmd, mkManyUsedDmd :: CleanDemand -> Demand -mkOnceUsedDmd cd = C_11 :* cd -mkManyUsedDmd cd = C_1N :* cd - +-- | Evaluated strictly, and used arbitrarily deeply evalDmd :: Demand --- Evaluated strictly, and used arbitrarily deeply -evalDmd = C_1N :* topCleanDmd +evalDmd = C_1N :* cleanEvalDmd -- | Wraps the 'CleanDemand' with a one-shot call demand: @d@ -> @C1(d)@. mkCallDmd :: CleanDemand -> CleanDemand @@ -360,17 +356,21 @@ data Card | C_01 -- ^ {0,1} | C_0N -- ^ {0,1,n} Every possible cardinality; the top element. | C_11 -- ^ {1,1} - | C_1N -- ^ {1,n} + | C_1N -- ^ {1,n} TODO: Think about whether this cardinality is of any + -- practical relevance. If we are strict, we can + -- assume that it is used at most once because of + -- call-by-value. Ah yes, it's relevant for call + -- demands. | C_10 -- ^ {} The empty interval; the bottom element of the powerset lattice. deriving ( Eq ) instance Show Card where - show C_00 = "0" - show C_01 = "01" - show C_0N = "_" - show C_11 = "1" - show C_1N = "1_" - show C_10 = "⊥" + show C_00 = "A" + show C_01 = "1" + show C_0N = "U" + show C_11 = "S" + show C_1N = "S" + show C_10 = "B" _botCard, topCard :: Card _botCard = C_10 @@ -464,17 +464,6 @@ multCard _ _ = C_0N data Demand = !Card :* !CleanDemand deriving ( Eq, Show ) -instance Outputable Card where - ppr = text . show - -instance Outputable Demand where - ppr (n :* cd) = ppr n <> char '*' <> ppr cd - -instance Outputable CleanDemand where - ppr (Poly cd) = ppr cd - ppr (Call n cd) = char 'C' <> ppr n <> parens (ppr cd) - ppr (Prod ds) = parens (interpp'SP (map ppr ds)) - data CleanDemand = Poly !Card -- ^ Polymorphic head demand with nested evaluation -- cardinalities. @@ -1041,7 +1030,7 @@ plusDmdType (DmdType fv1 ds1 r1) (fv2, t2) instance Outputable DmdType where ppr (DmdType fv ds res) - = hsep [hcat (map ppr ds) <> ppr res, + = hsep [hcat (map (angleBrackets . ppr) ds) <> ppr res, if null fv_elts then empty else braces (fsep (map pp_elt fv_elts))] where @@ -1157,7 +1146,7 @@ multDmdEnv n env -- | See Note [Scaling demands] reuseEnv :: DmdEnv -> DmdEnv -reuseEnv = mapVarEnv (multDmd C_1N) +reuseEnv = multDmdEnv C_1N -- | The trivial cases of the @mult*@ functions. -- If @multTrivial n abs a = ma@, we have the following outcomes @@ -1527,17 +1516,20 @@ dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType -- for dictionary selectors. If the selector is saturated (ie has one -- argument: the dictionary), we feed the demand on the result into -- the indicated dictionary component. -dmdTransformDictSelSig (StrictSig (DmdType _ [_ :* Prod ds] _)) cd - | (n, cd') <- peelCallDmd cd +-- NB: This currently doesn't handle newtype dictionaries and it's unclear how +-- it could without additional parameters. +dmdTransformDictSelSig (StrictSig (DmdType _ [(_ :* sig_cd)] _)) call_cd + | (n, cd') <- peelCallDmd call_cd + , Prod sig_ds <- sig_cd = multUnsat n $ - DmdType emptyDmdEnv [mkOnceUsedDmd $ Prod $ map (enhance cd') ds] topDiv + DmdType emptyDmdEnv [C_11 :* Prod (map (enhance cd') sig_ds)] topDiv | otherwise = nopDmdType -- See Note [Demand transformer for a dictionary selector] where enhance cd old | isAbsDmd old = old - | otherwise = mkOnceUsedDmd cd -- This is the one! + | otherwise = C_11 :* cd -- This is the one! -dmdTransformDictSelSig _ _ = panic "dmdTransformDictSelSig: no args" +dmdTransformDictSelSig sig cd = pprPanic "dmdTransformDictSelSig: no args" (ppr sig $$ ppr cd) {- Note [Demand transformer for a dictionary selector] @@ -1718,8 +1710,27 @@ the demand signature, because we still want to know about the demand on things. The signature of f should be m. If we were not distinguishing the uses on x and y in the True case, we could either not figure out how deeply we can unpack x, or that we do not have to pass y. +-} +instance Outputable Card where + ppr = text . show +instance Outputable Demand where + ppr dmd@(n :* cd) + | isAbs n = ppr n + | dmd == polyDmd n = ppr n + | otherwise = ppr n <> ppr cd + +instance Outputable CleanDemand where + ppr (Poly cd) = ppr cd + ppr (Call n cd) = char 'C' <> ppr n <> parens (ppr cd) + ppr (Prod ds) = parens (fields ds) + where + fields [] = empty + fields [x] = ppr x + fields (x:xs) = ppr x <> char ',' <> fields xs + +{- ************************************************************************ * * Serialisation @@ -1762,29 +1773,22 @@ instance Binary CleanDemand where _ -> pprPanic "Binary:CleanDemand" (ppr (fromIntegral h :: Int)) instance Binary StrictSig where - put_ bh (StrictSig aa) = do - put_ bh aa - get bh = do - aa <- get bh - return (StrictSig aa) + put_ bh (StrictSig aa) = put_ bh aa + get bh = StrictSig <$> get bh instance Binary DmdType where -- Ignore DmdEnv when spitting out the DmdType - put_ bh (DmdType _ ds dr) - = do put_ bh ds - put_ bh dr - get bh - = do ds <- get bh - dr <- get bh - return (DmdType emptyDmdEnv ds dr) + put_ bh (DmdType _ ds dr) = put_ bh ds *> put_ bh dr + get bh = DmdType emptyDmdEnv <$> get bh <*> get bh instance Binary Divergence where put_ bh Dunno = putByte bh 0 put_ bh ExnOrDiv = putByte bh 1 put_ bh Diverges = putByte bh 2 - - get bh = do { h <- getByte bh - ; case h of - 0 -> return Dunno - 1 -> return ExnOrDiv - _ -> return Diverges } + get bh = do + h <- getByte bh + case h of + 0 -> return Dunno + 1 -> return ExnOrDiv + 2 -> return Diverges + _ -> pprPanic "Binary:Divergence" (ppr (fromIntegral h :: Int)) ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -513,7 +513,7 @@ mkDictSelId name clas strict_sig = mkClosedStrictSig [arg_dmd] topDiv arg_dmd | new_tycon = evalDmd - | otherwise = mkManyUsedDmd $ + | otherwise = C_1N :* Prod [ if name == sel_name then evalDmd else absDmd | sel_name <- sel_names ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f20604ea6ea134eb6298529ff61cd539865877e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f20604ea6ea134eb6298529ff61cd539865877e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 14:31:54 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 10:31:54 -0400 Subject: [Git][ghc/ghc][wip/bump-time] Bump time submodule to 1.11 Message-ID: <5f9ad25a5a5e5_897c91c95c1065392@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bump-time at Glasgow Haskell Compiler / GHC Commits: 19897f63 by Ben Gamari at 2020-10-29T10:31:43-04:00 Bump time submodule to 1.11 - - - - - 3 changed files: - libraries/directory - libraries/time - libraries/unix Changes: ===================================== libraries/directory ===================================== @@ -1 +1 @@ -Subproject commit b697b3ea77dd4803f2f8f676dd64c8ea5277fcf0 +Subproject commit fe2d0129c019eb4be8841b20cc66f798edca217f ===================================== libraries/time ===================================== @@ -1 +1 @@ -Subproject commit 5319bed3b14c21de5410ead88ec8aaa838d7339c +Subproject commit 866ed2501fe1acf31abeaaddefcdc730436d87fa ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit ea13d990580273a883368793dfbb826cab5a22d4 +Subproject commit a33e3d2d8fb5c9b2ccfad7cd63a456d38ac8bb7a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19897f63e22f01fa7781ce862addf2225b08dc42 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/19897f63e22f01fa7781ce862addf2225b08dc42 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 16:37:56 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 12:37:56 -0400 Subject: [Git][ghc/ghc][wip/local-symbols-2] Enable -fexpose-all-symbols when debug level is set Message-ID: <5f9aefe44f0f9_89710b87a8010832d4@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/local-symbols-2 at Glasgow Haskell Compiler / GHC Commits: f91ff21c by Ben Gamari at 2020-10-29T12:37:07-04:00 Enable -fexpose-all-symbols when debug level is set - - - - - 3 changed files: - compiler/GHC/Driver/Session.hs - docs/users_guide/debug-info.rst - docs/users_guide/phases.rst Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -4392,7 +4392,13 @@ setVerbosity :: Maybe Int -> DynP () setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 }) setDebugLevel :: Maybe Int -> DynP () -setDebugLevel mb_n = upd (\dfs -> dfs{ debugLevel = mb_n `orElse` 2 }) +setDebugLevel mb_n = + upd (\dfs -> exposeSyms $ dfs{ debugLevel = n }) + where + n = mb_n `orElse` 2 + exposeSyms + | n > 0 = setGeneralFlag' Opt_ExposeInternalSymbols + | otherwise = id data PkgDbRef = GlobalPkgDb ===================================== docs/users_guide/debug-info.rst ===================================== @@ -14,6 +14,7 @@ useable by most UNIX debugging tools. :category: debugging :since: 7.10, numeric levels since 8.0 + :implies: :ghc-flag:`-fexpose-all-symbols` Emit debug information in object code. Currently only DWARF debug information is supported on x86-64 and i386. Currently debug levels 0 ===================================== docs/users_guide/phases.rst ===================================== @@ -728,10 +728,11 @@ Options affecting code generation Request that GHC emits verbose symbol tables which include local symbols for module-internal functions. These can be useful for tools like :ref:`perf ` but increase object file sizes. + This is implied by :ghc-flag:`-g2 <-g>` and above. - :ghc-flag:`-fno-expose-internal-symbols` suppresses all non-global symbol - table entries, resulting in smaller object file sizes at the expense of - debuggability. + :ghc-flag:`-fno-expose-internal-symbols <-fexpose-internals-symbols>` + suppresses all non-global symbol table entries, resulting in smaller object + file sizes at the expense of debuggability. .. _options-linker: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f91ff21ca0f329956e69cb266dbab96049ecd924 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f91ff21ca0f329956e69cb266dbab96049ecd924 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 16:49:35 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 29 Oct 2020 12:49:35 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] 2 commits: Accept some test outputs Message-ID: <5f9af29f3b186_8973fa3ba6c99c0108422@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: 48f6ac14 by Sebastian Graf at 2020-10-29T17:28:55+01:00 Accept some test outputs - - - - - fc784641 by Sebastian Graf at 2020-10-29T17:49:27+01:00 Fix absDmd - - - - - 20 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/numeric/should_compile/T14465.stdout - testsuite/tests/numeric/should_compile/T7116.stdout - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T3717.stderr - testsuite/tests/simplCore/should_compile/T3772.stdout - testsuite/tests/simplCore/should_compile/T4201.stdout - testsuite/tests/simplCore/should_compile/T4930.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/simplCore/should_compile/par01.stderr - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr - testsuite/tests/stranal/sigs/NewtypeArity.stderr - testsuite/tests/stranal/sigs/StrAnalExample.stderr - testsuite/tests/stranal/sigs/T12370.stderr - testsuite/tests/stranal/sigs/T17932.stderr - testsuite/tests/stranal/sigs/T18086.stderr - testsuite/tests/stranal/sigs/T8569.stderr - testsuite/tests/stranal/sigs/T8598.stderr Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -217,7 +217,7 @@ dmdAnal' env dmd (Lam var body) (body_ty, Lam var body') | otherwise - = let (n, body_dmd) = peelCallDmd dmd + = let (n, body_dmd) = peelCallDmd dmd -- body_dmd: a demand to analyze the body (body_ty, body') = dmdAnal env body_dmd body @@ -965,7 +965,8 @@ dmdFix top_lvl env let_dmd orig_pairs -- so this can significantly reduce the number of iterations needed my_downRhs (env, lazy_fv) (id,rhs) - = ((env', lazy_fv'), (id', rhs')) + = -- pprTrace "my_downRhs" (ppr id $$ ppr (idStrictness id) $$ ppr sig) $ + ((env', lazy_fv'), (id', rhs')) where (lazy_fv1, sig, rhs') = dmdAnalRhsLetDown (Just bndrs) env let_dmd id rhs lazy_fv' = plusVarEnv_C plusDmd lazy_fv lazy_fv1 @@ -1120,7 +1121,7 @@ annotateLamIdBndr env arg_of_dfun dmd_ty id -- For lambdas we add the demand to the argument demands -- Only called for Ids = ASSERT( isId id ) - -- pprTrace "annLamBndr" (vcat [ppr id, ppr _dmd_ty]) $ + -- pprTrace "annLamBndr" (vcat [ppr id, ppr dmd_ty, ppr final_ty]) $ (final_ty, setIdDemandInfo id dmd) where -- Watch out! See note [Lambda-bound unfoldings] @@ -1325,7 +1326,8 @@ findBndrsDmds env dmd_ty bndrs findBndrDmd :: AnalEnv -> Bool -> DmdType -> Id -> (DmdType, Demand) -- See Note [Trimming a demand to a type] findBndrDmd env arg_of_dfun dmd_ty id - = (dmd_ty', dmd') + = -- pprTrace "findBndrDmd" (ppr id $$ ppr dmd_ty $$ ppr starting_dmd $$ ppr dmd') $ + (dmd_ty', dmd') where dmd' = strictify $ trimToType starting_dmd (findTypeShape fam_envs id_ty) ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -501,7 +501,7 @@ polyDmd C_10 = C_10 :* poly10 topDmd, absDmd, botDmd, seqDmd :: Demand strictApply1Dmd, lazyApply1Dmd, lazyApply2Dmd :: Demand topDmd = polyDmd C_0N -absDmd = polyDmd C_01 +absDmd = polyDmd C_00 botDmd = polyDmd C_10 seqDmd = C_11 :* seqCleanDmd strictApply1Dmd = C_1N :* Call C_1N topCleanDmd @@ -1124,7 +1124,8 @@ strictenDmd (n :* cd) = plusCard C_10 n :* cd -- see Note [Asymmetry of 'plus*'] multDmdType :: Card -> DmdType -> BothDmdArg multDmdType n (DmdType fv _ res_ty) - = (multDmdEnv n fv, multDivergence n res_ty) + = -- pprTrace "multDmdType" (ppr n $$ ppr fv $$ ppr (multDmdEnv n fv)) $ + (multDmdEnv n fv, multDivergence n res_ty) -- | In a non-strict scenario, we might not force the Divergence, in which case -- we might converge, hence Dunno. @@ -1163,7 +1164,8 @@ multTrivial _ _ _ = Nothing multUnsat :: Card -> DmdType -> DmdType multUnsat n (DmdType fv args res_ty) - = DmdType (multDmdEnv n fv) + = -- pprTrace "multUnsat" (ppr n $$ ppr fv $$ ppr (multDmdEnv n fv)) $ + DmdType (multDmdEnv n fv) (map (multDmd n) args) (multDivergence n res_ty) @@ -1423,8 +1425,7 @@ instance Outputable StrictSig where -- Used for printing top-level strictness pragmas in interface files pprIfaceStrictSig :: StrictSig -> SDoc -pprIfaceStrictSig (StrictSig (DmdType _ dmds res)) - = hcat (map ppr dmds) <> ppr res +pprIfaceStrictSig = ppr -- | Turns a 'DmdType' computed for the particular 'Arity' into a 'StrictSig' -- unleashable at that arity. See Note [Understanding DmdType and StrictSig] ===================================== testsuite/tests/numeric/should_compile/T14465.stdout ===================================== @@ -78,7 +78,7 @@ twoTimesTwo = 4 plusOne :: Natural -> Natural [GblId, Arity=1, - Str=, + Str=, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) ===================================== testsuite/tests/numeric/should_compile/T7116.stdout ===================================== @@ -43,7 +43,7 @@ T7116.$trModule dr :: Double -> Double [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -60,7 +60,7 @@ dr dl :: Double -> Double [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -73,7 +73,7 @@ dl = dr fr :: Float -> Float [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -92,7 +92,7 @@ fr fl :: Float -> Float [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -7,7 +7,7 @@ Rec { -- RHS size: {terms: 4, types: 4, coercions: 0, joins: 0/0} T13143.$wf [InlPrag=NOINLINE, Occ=LoopBreaker] :: forall {a}. (# #) -> a -[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] +[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] T13143.$wf = \ (@a) _ [Occ=Dead] -> T13143.$wf @a GHC.Prim.(##) end Rec } @@ -15,7 +15,7 @@ end Rec } f [InlPrag=[final]] :: forall a. Int -> a [GblId, Arity=1, - Str=b, + Str=b, Cpr=b, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -65,47 +65,43 @@ lvl :: Int lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} +-- RHS size: {terms: 31, types: 9, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] - :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=3, Str=, Unf=OtherCon []] + :: Bool -> Bool -> Int -> GHC.Prim.Int# +[GblId, Arity=3, Str=, Unf=OtherCon []] T13143.$wg - = \ (w :: Bool) (w1 :: Bool) (ww :: GHC.Prim.Int#) -> + = \ (w :: Bool) (w1 :: Bool) (w2 :: Int) -> case w of { False -> case w1 of { - False -> T13143.$wg GHC.Types.False GHC.Types.True ww; - True -> GHC.Prim.+# ww 1# + False -> T13143.$wg GHC.Types.False GHC.Types.True w2; + True -> case w2 of { GHC.Types.I# x -> GHC.Prim.+# x 1# } }; True -> case w1 of { - False -> T13143.$wg GHC.Types.True GHC.Types.True ww; + False -> T13143.$wg GHC.Types.True GHC.Types.True w2; True -> case lvl of wild2 { } } } end Rec } --- RHS size: {terms: 14, types: 6, coercions: 0, joins: 0/0} +-- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int [GblId, Arity=3, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (w [Occ=Once1] :: Bool) (w1 [Occ=Once1] :: Bool) - (w2 [Occ=Once1!] :: Int) -> - case w2 of { GHC.Types.I# ww1 [Occ=Once1] -> - case T13143.$wg w w1 ww1 of ww2 [Occ=Once1] { __DEFAULT -> - GHC.Types.I# ww2 - } + (w2 [Occ=Once1] :: Int) -> + case T13143.$wg w w1 w2 of ww [Occ=Once1] { __DEFAULT -> + GHC.Types.I# ww }}] g = \ (w :: Bool) (w1 :: Bool) (w2 :: Int) -> - case w2 of { GHC.Types.I# ww1 -> - case T13143.$wg w w1 ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 } - } + case T13143.$wg w w1 w2 of ww { __DEFAULT -> GHC.Types.I# ww } ===================================== testsuite/tests/simplCore/should_compile/T3717.stderr ===================================== @@ -43,7 +43,7 @@ Rec { -- RHS size: {terms: 10, types: 2, coercions: 0, joins: 0/0} T3717.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] T3717.$wfoo = \ (ww :: GHC.Prim.Int#) -> case ww of ds { @@ -56,7 +56,7 @@ end Rec } foo [InlPrag=[2]] :: Int -> Int [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/simplCore/should_compile/T3772.stdout ===================================== @@ -42,7 +42,7 @@ T3772.$trModule Rec { -- RHS size: {terms: 10, types: 2, coercions: 0, joins: 0/0} $wxs :: GHC.Prim.Int# -> () -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] $wxs = \ (ww :: GHC.Prim.Int#) -> case ww of ds1 { @@ -53,7 +53,7 @@ end Rec } -- RHS size: {terms: 10, types: 2, coercions: 0, joins: 0/0} T3772.$wfoo [InlPrag=NOINLINE] :: GHC.Prim.Int# -> () -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] T3772.$wfoo = \ (ww :: GHC.Prim.Int#) -> case GHC.Prim.<# 0# ww of { @@ -65,7 +65,7 @@ T3772.$wfoo foo [InlPrag=[final]] :: Int -> () [GblId, Arity=1, - Str=, + Str=, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) ===================================== testsuite/tests/simplCore/should_compile/T4201.stdout ===================================== @@ -1,4 +1,4 @@ [HasNoCafRefs, LambdaFormInfo: LFReEntrant 1, Arity: 1, - Strictness: , + Strictness: , Unfolding: InlineRule (0, True, True) bof `cast` (Sym (N:Foo[0]) %<'Many>_N ->_R _R)] ===================================== testsuite/tests/simplCore/should_compile/T4930.stderr ===================================== @@ -43,7 +43,7 @@ Rec { -- RHS size: {terms: 17, types: 3, coercions: 0, joins: 0/0} T4930.$wfoo [InlPrag=[2], Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] T4930.$wfoo = \ (ww :: GHC.Prim.Int#) -> case GHC.Prim.<# ww 5# of { @@ -56,7 +56,7 @@ end Rec } foo [InlPrag=[2]] :: Int -> Int [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -8,7 +8,7 @@ T7360.$WFoo3 [InlPrag=INLINE[final] CONLIKE] :: Int %1 -> Foo [GblId[DataConWrapper], Arity=1, Caf=NoCafRefs, - Str=, + Str=, Cpr=m3, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -21,7 +21,7 @@ T7360.$WFoo3 -- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} fun1 [InlPrag=NOINLINE] :: Foo -> () -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] fun1 = \ (x :: Foo) -> case x of { __DEFAULT -> GHC.Tuple.() } -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} @@ -35,7 +35,7 @@ T7360.fun4 = fun1 T7360.Foo1 fun2 :: forall {a}. [a] -> ((), Int) [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/simplCore/should_compile/par01.stderr ===================================== @@ -6,7 +6,7 @@ Result size of CorePrep Rec { -- RHS size: {terms: 7, types: 3, coercions: 0, joins: 0/0} Par01.depth [Occ=LoopBreaker] :: GHC.Types.Int -> GHC.Types.Int -[GblId, Arity=1, Str=, Unf=OtherCon []] +[GblId, Arity=1, Str=, Unf=OtherCon []] Par01.depth = \ (d :: GHC.Types.Int) -> case GHC.Prim.par# @GHC.Types.Int d of { __DEFAULT -> ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -54,7 +54,7 @@ Rec { -- RHS size: {terms: 40, types: 5, coercions: 0, joins: 0/0} Roman.foo_$s$wgo [Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=2, Str=, Unf=OtherCon []] +[GblId, Arity=2, Str=, Unf=OtherCon []] Roman.foo_$s$wgo = \ (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) -> case GHC.Prim.<=# sc1 0# of { @@ -76,7 +76,7 @@ end Rec } Roman.$wgo [InlPrag=[2]] :: Maybe Int -> Maybe Int -> GHC.Prim.Int# [GblId, Arity=2, - Str=, + Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [61 30] 249 0}] Roman.$wgo @@ -111,7 +111,7 @@ Roman.$wgo Roman.foo_go [InlPrag=[2]] :: Maybe Int -> Maybe Int -> Int [GblId, Arity=2, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -143,7 +143,7 @@ Roman.foo1 = GHC.Maybe.Just @Int Roman.foo2 foo :: Int -> Int [GblId, Arity=1, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== BottomFromInnerLambda.$trModule: -BottomFromInnerLambda.expensive: -BottomFromInnerLambda.f: +BottomFromInnerLambda.expensive: +BottomFromInnerLambda.f: @@ -15,7 +15,7 @@ BottomFromInnerLambda.f: ==================== Strictness signatures ==================== BottomFromInnerLambda.$trModule: -BottomFromInnerLambda.expensive: -BottomFromInnerLambda.f: +BottomFromInnerLambda.expensive: +BottomFromInnerLambda.f: ===================================== testsuite/tests/stranal/sigs/NewtypeArity.stderr ===================================== @@ -3,8 +3,8 @@ Test.$tc'MkT: Test.$tcT: Test.$trModule: -Test.t: -Test.t2: +Test.t: +Test.t2: @@ -21,7 +21,7 @@ Test.t2: m1 Test.$tc'MkT: Test.$tcT: Test.$trModule: -Test.t: -Test.t2: +Test.t: +Test.t2: ===================================== testsuite/tests/stranal/sigs/StrAnalExample.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== StrAnalExample.$trModule: -StrAnalExample.foo: +StrAnalExample.foo: @@ -13,6 +13,6 @@ StrAnalExample.foo: ==================== Strictness signatures ==================== StrAnalExample.$trModule: -StrAnalExample.foo: +StrAnalExample.foo: ===================================== testsuite/tests/stranal/sigs/T12370.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== T12370.$trModule: -T12370.bar: -T12370.foo: +T12370.bar: +T12370.foo: @@ -15,7 +15,7 @@ T12370.foo: m1 ==================== Strictness signatures ==================== T12370.$trModule: -T12370.bar: -T12370.foo: +T12370.bar: +T12370.foo: ===================================== testsuite/tests/stranal/sigs/T17932.stderr ===================================== @@ -5,7 +5,7 @@ T17932.$tc'X: T17932.$tcOptions: T17932.$tcX: T17932.$trModule: -T17932.flags: +T17932.flags: @@ -25,6 +25,6 @@ T17932.$tc'X: T17932.$tcOptions: T17932.$tcX: T17932.$trModule: -T17932.flags: +T17932.flags: ===================================== testsuite/tests/stranal/sigs/T18086.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== T18086.$trModule: -T18086.m: x -T18086.panic: x +T18086.m: x +T18086.panic: x @@ -15,7 +15,7 @@ T18086.panic: ==================== Strictness signatures ==================== T18086.$trModule: -T18086.m: x -T18086.panic: x +T18086.m: x +T18086.panic: x ===================================== testsuite/tests/stranal/sigs/T8569.stderr ===================================== @@ -4,7 +4,7 @@ T8569.$tc'Rdata: T8569.$tc'Rint: T8569.$tcRep: T8569.$trModule: -T8569.addUp: +T8569.addUp: @@ -22,6 +22,6 @@ T8569.$tc'Rdata: T8569.$tc'Rint: T8569.$tcRep: T8569.$trModule: -T8569.addUp: +T8569.addUp: ===================================== testsuite/tests/stranal/sigs/T8598.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== T8598.$trModule: -T8598.fun: +T8598.fun: @@ -13,6 +13,6 @@ T8598.fun: m1 ==================== Strictness signatures ==================== T8598.$trModule: -T8598.fun: +T8598.fun: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f20604ea6ea134eb6298529ff61cd539865877e...fc7846415edc626333e636780ba959d397401265 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7f20604ea6ea134eb6298529ff61cd539865877e...fc7846415edc626333e636780ba959d397401265 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 17:11:07 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Thu, 29 Oct 2020 13:11:07 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] More accepted test outputs Message-ID: <5f9af7abf25c7_8973fa3a79f6e9410883f3@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: a2fbe3c9 by Sebastian Graf at 2020-10-29T18:09:22+01:00 More accepted test outputs - - - - - 12 changed files: - testsuite/tests/deSugar/should_compile/T2431.stderr - testsuite/tests/simplCore/should_compile/T13143.stderr - testsuite/tests/simplCore/should_compile/T13543.stderr - testsuite/tests/simplCore/should_compile/T18013.stderr - testsuite/tests/simplCore/should_compile/T18328.stderr - testsuite/tests/simplCore/should_compile/noinline01.stderr - testsuite/tests/simplCore/should_compile/spec-inline.stderr - testsuite/tests/stranal/should_compile/T10694.stderr - testsuite/tests/stranal/sigs/CaseBinderCPR.stderr - testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr - testsuite/tests/stranal/sigs/HyperStrUse.stderr - testsuite/tests/stranal/sigs/T13380f.stderr Changes: ===================================== testsuite/tests/deSugar/should_compile/T2431.stderr ===================================== @@ -17,7 +17,7 @@ T2431.$WRefl -- RHS size: {terms: 4, types: 8, coercions: 0, joins: 0/0} absurd :: forall a. (Int :~: Bool) -> a -[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] +[GblId, Arity=1, Str=b, Cpr=b, Unf=OtherCon []] absurd = \ (@a) (x :: Int :~: Bool) -> case x of { } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} ===================================== testsuite/tests/simplCore/should_compile/T13143.stderr ===================================== @@ -65,43 +65,47 @@ lvl :: Int lvl = T13143.$wf @Int GHC.Prim.(##) Rec { --- RHS size: {terms: 31, types: 9, coercions: 0, joins: 0/0} +-- RHS size: {terms: 28, types: 7, coercions: 0, joins: 0/0} T13143.$wg [InlPrag=[2], Occ=LoopBreaker] - :: Bool -> Bool -> Int -> GHC.Prim.Int# -[GblId, Arity=3, Str=, Unf=OtherCon []] + :: Bool -> Bool -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=3, Str=, Unf=OtherCon []] T13143.$wg - = \ (w :: Bool) (w1 :: Bool) (w2 :: Int) -> + = \ (w :: Bool) (w1 :: Bool) (ww :: GHC.Prim.Int#) -> case w of { False -> case w1 of { - False -> T13143.$wg GHC.Types.False GHC.Types.True w2; - True -> case w2 of { GHC.Types.I# x -> GHC.Prim.+# x 1# } + False -> T13143.$wg GHC.Types.False GHC.Types.True ww; + True -> GHC.Prim.+# ww 1# }; True -> case w1 of { - False -> T13143.$wg GHC.Types.True GHC.Types.True w2; + False -> T13143.$wg GHC.Types.True GHC.Types.True ww; True -> case lvl of wild2 { } } } end Rec } --- RHS size: {terms: 11, types: 4, coercions: 0, joins: 0/0} +-- RHS size: {terms: 14, types: 6, coercions: 0, joins: 0/0} g [InlPrag=[2]] :: Bool -> Bool -> Int -> Int [GblId, Arity=3, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (w [Occ=Once1] :: Bool) (w1 [Occ=Once1] :: Bool) - (w2 [Occ=Once1] :: Int) -> - case T13143.$wg w w1 w2 of ww [Occ=Once1] { __DEFAULT -> - GHC.Types.I# ww + (w2 [Occ=Once1!] :: Int) -> + case w2 of { GHC.Types.I# ww1 [Occ=Once1] -> + case T13143.$wg w w1 ww1 of ww2 [Occ=Once1] { __DEFAULT -> + GHC.Types.I# ww2 + } }}] g = \ (w :: Bool) (w1 :: Bool) (w2 :: Int) -> - case T13143.$wg w w1 w2 of ww { __DEFAULT -> GHC.Types.I# ww } + case w2 of { GHC.Types.I# ww1 -> + case T13143.$wg w w1 ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 } + } ===================================== testsuite/tests/simplCore/should_compile/T13543.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== Foo.$trModule: -Foo.f: -Foo.g: +Foo.f: +Foo.g: @@ -15,7 +15,7 @@ Foo.g: m1 ==================== Strictness signatures ==================== Foo.$trModule: -Foo.f: -Foo.g: +Foo.f: +Foo.g: ===================================== testsuite/tests/simplCore/should_compile/T18013.stderr ===================================== @@ -136,7 +136,7 @@ mapMaybeRule :: forall a b. Rule IO a b -> Rule IO (Maybe a) (Maybe b) [GblId, Arity=1, - Str=, + Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 150 10}] mapMaybeRule ===================================== testsuite/tests/simplCore/should_compile/T18328.stderr ===================================== @@ -4,19 +4,18 @@ Result size of Tidy Core = {terms: 69, types: 61, coercions: 0, joins: 1/1} -- RHS size: {terms: 42, types: 28, coercions: 0, joins: 1/1} -T18328.$wf [InlPrag=NOUSERINLINE[2]] +T18328.$wf [InlPrag=[2]] :: forall {a}. GHC.Prim.Int# -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=, + Str=, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [182 0 0] 312 0}] T18328.$wf = \ (@a) (ww :: GHC.Prim.Int#) (w :: [a]) (w1 :: [a]) -> join { - $wj [InlPrag=NOINLINE, Dmd=] - :: forall {p}. GHC.Prim.Void# -> [a] - [LclId[JoinId(2)], Arity=1, Str=, Unf=OtherCon []] + $wj [InlPrag=NOINLINE, Dmd=1C1(U)] :: forall {p}. (# #) -> [a] + [LclId[JoinId(2)], Arity=1, Str=, Unf=OtherCon []] $wj (@p) _ [Occ=Dead, OS=OneShot] = case ww of { __DEFAULT -> ++ @a w (++ @a w (++ @a w w1)); @@ -24,24 +23,24 @@ T18328.$wf } } in case ww of { __DEFAULT -> ++ @a w w1; - 1# -> jump $wj @Integer GHC.Prim.void#; - 2# -> jump $wj @Integer GHC.Prim.void#; - 3# -> jump $wj @Integer GHC.Prim.void# + 1# -> jump $wj @Integer GHC.Prim.(##); + 2# -> jump $wj @Integer GHC.Prim.(##); + 3# -> jump $wj @Integer GHC.Prim.(##) } -- RHS size: {terms: 11, types: 10, coercions: 0, joins: 0/0} -f [InlPrag=NOUSERINLINE[2]] :: forall a. Int -> [a] -> [a] -> [a] +f [InlPrag=[2]] :: forall a. Int -> [a] -> [a] -> [a] [GblId, Arity=3, - Str=, + Str=, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) Tmpl= \ (@a) - (w [Occ=Once!] :: Int) - (w1 [Occ=Once] :: [a]) - (w2 [Occ=Once] :: [a]) -> - case w of { GHC.Types.I# ww1 [Occ=Once] -> + (w [Occ=Once1!] :: Int) + (w1 [Occ=Once1] :: [a]) + (w2 [Occ=Once1] :: [a]) -> + case w of { GHC.Types.I# ww1 [Occ=Once1] -> T18328.$wf @a ww1 w1 w2 }}] f = \ (@a) (w :: Int) (w1 :: [a]) (w2 :: [a]) -> @@ -58,7 +57,7 @@ T18328.$trModule4 = "main"# T18328.$trModule3 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18328.$trModule3 = GHC.Types.TrNameS T18328.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -72,14 +71,14 @@ T18328.$trModule2 = "T18328"# T18328.$trModule1 :: GHC.Types.TrName [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18328.$trModule1 = GHC.Types.TrNameS T18328.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T18328.$trModule :: GHC.Types.Module [GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, - WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T18328.$trModule = GHC.Types.Module T18328.$trModule3 T18328.$trModule1 ===================================== testsuite/tests/simplCore/should_compile/noinline01.stderr ===================================== @@ -2,7 +2,7 @@ ==================== Initial STG: ==================== Noinline01.f [InlPrag=INLINE (sat-args=1)] :: forall {p}. p -> GHC.Types.Bool -[GblId, Arity=1, Str=, Unf=OtherCon []] = +[GblId, Arity=1, Str=, Unf=OtherCon []] = \r [eta] GHC.Types.True []; Noinline01.g :: GHC.Types.Bool ===================================== testsuite/tests/simplCore/should_compile/spec-inline.stderr ===================================== @@ -54,7 +54,7 @@ Rec { -- RHS size: {terms: 40, types: 5, coercions: 0, joins: 0/0} Roman.foo_$s$wgo [Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -[GblId, Arity=2, Str=, Unf=OtherCon []] +[GblId, Arity=2, Str=, Unf=OtherCon []] Roman.foo_$s$wgo = \ (sc :: GHC.Prim.Int#) (sc1 :: GHC.Prim.Int#) -> case GHC.Prim.<=# sc1 0# of { ===================================== testsuite/tests/stranal/should_compile/T10694.stderr ===================================== @@ -4,47 +4,47 @@ Result size of Tidy Core = {terms: 74, types: 65, coercions: 0, joins: 0/4} -- RHS size: {terms: 39, types: 25, coercions: 0, joins: 0/4} T10694.$wpm [InlPrag=NOINLINE] :: Int -> Int -> (# Int, Int #) -[GblId, Arity=2, Str=, Unf=OtherCon []] +[GblId, Arity=2, Str=, Unf=OtherCon []] T10694.$wpm = \ (w :: Int) (w1 :: Int) -> let { - l :: Int + lvl :: Int [LclId] - l = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } } in + lvl = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.+# x y) } } } in let { - l1 :: Int + lvl1 :: Int [LclId] - l1 = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.-# x y) } } } in + lvl1 = case w of { GHC.Types.I# x -> case w1 of { GHC.Types.I# y -> GHC.Types.I# (GHC.Prim.-# x y) } } } in let { - l2 :: [Int] + l :: [Int] [LclId, Unf=OtherCon []] - l2 = GHC.Types.: @Int l1 (GHC.Types.[] @Int) } in + l = GHC.Types.: @Int lvl1 (GHC.Types.[] @Int) } in let { - l3 :: [Int] + l1 :: [Int] [LclId, Unf=OtherCon []] - l3 = GHC.Types.: @Int l l2 } in - (# GHC.List.$w!! @Int l3 0#, GHC.List.$w!! @Int l3 1# #) + l1 = GHC.Types.: @Int lvl l } in + (# GHC.List.$w!! @Int l1 0#, GHC.List.$w!! @Int l1 1# #) -- RHS size: {terms: 10, types: 11, coercions: 0, joins: 0/0} -pm [InlPrag=NOUSERINLINE[0]] :: Int -> Int -> (Int, Int) +pm [InlPrag=[final]] :: Int -> Int -> (Int, Int) [GblId, Arity=2, - Str=, + Str=, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (w [Occ=Once] :: Int) (w1 [Occ=Once] :: Int) -> - case T10694.$wpm w w1 of { (# ww1 [Occ=Once], ww2 [Occ=Once] #) -> (ww1, ww2) }}] + Tmpl= \ (w [Occ=Once1] :: Int) (w1 [Occ=Once1] :: Int) -> + case T10694.$wpm w w1 of { (# ww1 [Occ=Once1], ww2 [Occ=Once1] #) -> (ww1, ww2) }}] pm = \ (w :: Int) (w1 :: Int) -> case T10694.$wpm w w1 of { (# ww1, ww2 #) -> (ww1, ww2) } -- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} m :: Int -> Int -> Int [GblId, Arity=2, - Str=, + Str=, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once] :: Int) (y [Occ=Once] :: Int) -> case pm x y of { (_ [Occ=Dead], mr [Occ=Once]) -> mr }}] + Tmpl= \ (x [Occ=Once1] :: Int) (y [Occ=Once1] :: Int) -> case pm x y of { (_ [Occ=Dead], mr [Occ=Once1]) -> mr }}] m = \ (x :: Int) (y :: Int) -> case T10694.$wpm x y of { (# ww1, ww2 #) -> ww2 } -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -54,7 +54,7 @@ T10694.$trModule4 = "main"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T10694.$trModule3 :: GHC.Types.TrName -[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T10694.$trModule3 = GHC.Types.TrNameS T10694.$trModule4 -- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} @@ -64,12 +64,12 @@ T10694.$trModule2 = "T10694"# -- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} T10694.$trModule1 :: GHC.Types.TrName -[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}] +[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T10694.$trModule1 = GHC.Types.TrNameS T10694.$trModule2 -- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} T10694.$trModule :: GHC.Types.Module -[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}] +[GblId, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] T10694.$trModule = GHC.Types.Module T10694.$trModule3 T10694.$trModule1 ===================================== testsuite/tests/stranal/sigs/CaseBinderCPR.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== CaseBinderCPR.$trModule: -CaseBinderCPR.f_list_cmp: +CaseBinderCPR.f_list_cmp: @@ -13,6 +13,6 @@ CaseBinderCPR.f_list_cmp: m1 ==================== Strictness signatures ==================== CaseBinderCPR.$trModule: -CaseBinderCPR.f_list_cmp: +CaseBinderCPR.f_list_cmp: ===================================== testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr ===================================== @@ -5,11 +5,11 @@ DmdAnalGADTs.$tc'B: DmdAnalGADTs.$tcD: DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b -DmdAnalGADTs.f: -DmdAnalGADTs.f': -DmdAnalGADTs.g: +DmdAnalGADTs.f: +DmdAnalGADTs.f': +DmdAnalGADTs.g: DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: +DmdAnalGADTs.hasStrSig: @@ -33,10 +33,10 @@ DmdAnalGADTs.$tc'B: DmdAnalGADTs.$tcD: DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b -DmdAnalGADTs.f: -DmdAnalGADTs.f': -DmdAnalGADTs.g: +DmdAnalGADTs.f: +DmdAnalGADTs.f': +DmdAnalGADTs.g: DmdAnalGADTs.hasCPR: -DmdAnalGADTs.hasStrSig: +DmdAnalGADTs.hasStrSig: ===================================== testsuite/tests/stranal/sigs/HyperStrUse.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== HyperStrUse.$trModule: -HyperStrUse.f: +HyperStrUse.f: @@ -13,6 +13,6 @@ HyperStrUse.f: m1 ==================== Strictness signatures ==================== HyperStrUse.$trModule: -HyperStrUse.f: +HyperStrUse.f: ===================================== testsuite/tests/stranal/sigs/T13380f.stderr ===================================== @@ -1,12 +1,12 @@ ==================== Strictness signatures ==================== T13380f.$trModule: -T13380f.f: -T13380f.g: -T13380f.h: -T13380f.interruptibleCall: -T13380f.safeCall: -T13380f.unsafeCall: +T13380f.f: +T13380f.g: <1(U)> +T13380f.h: <1(U)> +T13380f.interruptibleCall: +T13380f.safeCall: +T13380f.unsafeCall: @@ -23,11 +23,11 @@ T13380f.unsafeCall: ==================== Strictness signatures ==================== T13380f.$trModule: -T13380f.f: -T13380f.g: -T13380f.h: -T13380f.interruptibleCall: -T13380f.safeCall: -T13380f.unsafeCall: +T13380f.f: +T13380f.g: <1(U)> +T13380f.h: <1(U)> +T13380f.interruptibleCall: +T13380f.safeCall: +T13380f.unsafeCall: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a2fbe3c9f949e3fc8635fa99f5bf1a9085b113ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a2fbe3c9f949e3fc8635fa99f5bf1a9085b113ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 18:13:25 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 14:13:25 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/bytearray-docs Message-ID: <5f9b06454e3c4_8973fa3a6fc6c801096288@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/bytearray-docs at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/bytearray-docs You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 18:17:24 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 14:17:24 -0400 Subject: [Git][ghc/ghc][wip/bytearray-docs] primops: Generate ByteArray# index/read/write primops Message-ID: <5f9b0734ae908_897978f4481098093@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bytearray-docs at Glasgow Haskell Compiler / GHC Commits: 408ddf1d by Ben Gamari at 2020-10-29T14:17:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 2 changed files: - compiler/GHC/Builtin/bytearray-ops.txt.pp - + utils/genprimopcode/gen_bytearray_ops.py Changes: ===================================== compiler/GHC/Builtin/bytearray-ops.txt.pp ===================================== @@ -1,449 +1,585 @@ + +------------------------------------ +-- ByteArray# operations +------------------------------------ + + +-- Do not edit. This file is generated by utils/genprimops/gen_bytearray_ops.py. +-- To regenerate run, +-- +-- python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp + + +------------------------------------ +-- aligned index operations +------------------------------------ + primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp ByteArray# -> Int# -> Char# - {Read 8-bit character; offset in bytes.} + {Read a 8-bit character; offset in bytes.} with can_fail = True primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp ByteArray# -> Int# -> Char# - {Read 31-bit character; offset in 4-byte words.} + {Read a 32-bit character; offset in 4-byte words.} with can_fail = True primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp ByteArray# -> Int# -> Int# + {Read a word-sized integer; offset in machine words.} with can_fail = True primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp ByteArray# -> Int# -> Word# + {Read a word-sized unsigned integer; offset in machine words.} with can_fail = True primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp ByteArray# -> Int# -> Addr# + {Read a machine address; offset in machine words.} with can_fail = True primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp ByteArray# -> Int# -> Float# + {Read a single-precision floating-point value; offset in 4-byte words.} with can_fail = True primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp ByteArray# -> Int# -> Double# + {Read a double-precision floating-point value; offset in 8-byte words.} with can_fail = True primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp ByteArray# -> Int# -> StablePtr# a + {Read a {\tt StablePtr#} value; offset in machine words.} with can_fail = True primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp ByteArray# -> Int# -> Int# - {Read 8-bit integer; offset in bytes.} + {Read a 8-bit signed integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp ByteArray# -> Int# -> Int# - {Read 16-bit integer; offset in 16-bit words.} + {Read a 16-bit signed integer; offset in 2-byte words.} with can_fail = True primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp ByteArray# -> Int# -> INT32 - {Read 32-bit integer; offset in 32-bit words.} + {Read a 32-bit signed integer; offset in 4-byte words.} with can_fail = True primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp ByteArray# -> Int# -> INT64 - {Read 64-bit integer; offset in 64-bit words.} + {Read a 64-bit signed integer; offset in 8-byte words.} with can_fail = True primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp ByteArray# -> Int# -> Word# - {Read 8-bit word; offset in bytes.} + {Read a 8-bit unsigned integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp ByteArray# -> Int# -> Word# - {Read 16-bit word; offset in 16-bit words.} + {Read a 16-bit unsigned integer; offset in 2-byte words.} with can_fail = True primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp ByteArray# -> Int# -> WORD32 - {Read 32-bit word; offset in 32-bit words.} + {Read a 32-bit unsigned integer; offset in 4-byte words.} with can_fail = True primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp ByteArray# -> Int# -> WORD64 - {Read 64-bit word; offset in 64-bit words.} + {Read a 64-bit unsigned integer; offset in 8-byte words.} with can_fail = True + +------------------------------------ +-- unaligned index operations +------------------------------------ + primop IndexByteArrayOp_Word8AsChar "indexWord8ArrayAsChar#" GenPrimOp ByteArray# -> Int# -> Char# - {Read 8-bit character; offset in bytes.} + {Read a 8-bit character; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsWideChar "indexWord8ArrayAsWideChar#" GenPrimOp ByteArray# -> Int# -> Char# - {Read 31-bit character; offset in bytes.} + {Read a 32-bit character; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a word-sized integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a word-sized unsigned integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsAddr "indexWord8ArrayAsAddr#" GenPrimOp ByteArray# -> Int# -> Addr# - {Read address; offset in bytes.} + {Read a machine address; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsFloat "indexWord8ArrayAsFloat#" GenPrimOp ByteArray# -> Int# -> Float# - {Read float; offset in bytes.} + {Read a single-precision floating-point value; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsDouble "indexWord8ArrayAsDouble#" GenPrimOp ByteArray# -> Int# -> Double# - {Read double; offset in bytes.} + {Read a double-precision floating-point value; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp ByteArray# -> Int# -> StablePtr# a - {Read stable pointer; offset in bytes.} + {Read a {\tt StablePtr#} value; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt8 "indexWord8ArrayAsInt8#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a 8-bit signed integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp ByteArray# -> Int# -> Int# - {Read 16-bit int; offset in bytes.} + {Read a 16-bit signed integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp ByteArray# -> Int# -> INT32 - {Read 32-bit int; offset in bytes.} + {Read a 32-bit signed integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp ByteArray# -> Int# -> INT64 - {Read 64-bit int; offset in bytes.} + {Read a 64-bit signed integer; offset in bytes.} with can_fail = True -primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp - ByteArray# -> Int# -> Int# - {Read int; offset in bytes.} +primop IndexByteArrayOp_Word8AsWord8 "indexWord8ArrayAsWord8#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a 8-bit unsigned integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp ByteArray# -> Int# -> Word# - {Read 16-bit word; offset in bytes.} + {Read a 16-bit unsigned integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp ByteArray# -> Int# -> WORD32 - {Read 32-bit word; offset in bytes.} + {Read a 32-bit unsigned integer; offset in bytes.} with can_fail = True primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp ByteArray# -> Int# -> WORD64 - {Read 64-bit word; offset in bytes.} + {Read a 64-bit unsigned integer; offset in bytes.} with can_fail = True -primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp - ByteArray# -> Int# -> Word# - {Read word; offset in bytes.} - with can_fail = True -primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp +------------------------------------ +-- aligned read operations +------------------------------------ + +primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - {Read 8-bit character; offset in bytes.} + {Read a 8-bit character; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp +primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - {Read 31-bit character; offset in 4-byte words.} + {Read a 32-bit character; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp +primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - {Read integer; offset in machine words.} + {Read a word-sized integer; offset in machine words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp +primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - {Read word; offset in machine words.} + {Read a word-sized unsigned integer; offset in machine words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp +primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) + {Read a machine address; offset in machine words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp +primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) + {Read a single-precision floating-point value; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp +primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) + {Read a double-precision floating-point value; offset in 8-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp +primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) + {Read a {\tt StablePtr#} value; offset in machine words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp +primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 8-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp +primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 16-bit signed integer; offset in 2-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp +primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) + {Read a 32-bit signed integer; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp +primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + {Read a 64-bit signed integer; offset in 8-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp +primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 8-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp +primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 16-bit unsigned integer; offset in 2-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp +primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) + {Read a 32-bit unsigned integer; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp +primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + {Read a 64-bit unsigned integer; offset in 8-byte words.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp + +------------------------------------ +-- unaligned read operations +------------------------------------ + +primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 8-bit character; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp +primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 32-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a word-sized integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a word-sized unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp +primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) + {Read a machine address; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp +primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) + {Read a single-precision floating-point value; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp +primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) + {Read a double-precision floating-point value; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp +primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) + {Read a {\tt StablePtr#} value; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp +primop ReadByteArrayOp_Word8AsInt8 "readWord8ArrayAsInt8#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 8-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp +primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 16-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) + {Read a 32-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp +primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + {Read a 64-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) +primop ReadByteArrayOp_Word8AsWord8 "readWord8ArrayAsWord8#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 8-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp +primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 16-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp +primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) + {Read a 32-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp +primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + {Read a 64-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True -primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp +------------------------------------ +-- aligned write operations +------------------------------------ + +primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - {Write 8-bit character; offset in bytes.} + {Write a 8-bit character; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp +primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - {Write 31-bit character; offset in 4-byte words.} + {Write a 32-bit character; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp +primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a word-sized integer; offset in machine words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp +primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a word-sized unsigned integer; offset in machine words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp +primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s + {Write a machine address; offset in machine words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp +primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp MutableByteArray# s -> Int# -> Float# -> State# s -> State# s + {Write a single-precision floating-point value; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp +primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp MutableByteArray# s -> Int# -> Double# -> State# s -> State# s + {Write a double-precision floating-point value; offset in 8-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp +primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s + {Write a {\tt StablePtr#} value; offset in machine words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp +primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 8-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp +primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 16-bit signed integer; offset in 2-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp +primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s + {Write a 32-bit signed integer; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp +primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s - with can_fail = True - has_side_effects = True + {Write a 64-bit signed integer; offset in 8-byte words.} + with has_side_effects = True + can_fail = True -primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp +primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 8-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp +primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 16-bit unsigned integer; offset in 2-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp +primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s + {Write a 32-bit unsigned integer; offset in 4-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp +primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + {Write a 64-bit unsigned integer; offset in 8-byte words.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp + +------------------------------------ +-- unaligned write operations +------------------------------------ + +primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 8-bit character; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp +primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 32-bit character; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp +primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a word-sized integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a word-sized unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s + {Write a machine address; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp +primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp MutableByteArray# s -> Int# -> Float# -> State# s -> State# s + {Write a single-precision floating-point value; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp +primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp MutableByteArray# s -> Int# -> Double# -> State# s -> State# s + {Write a double-precision floating-point value; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp +primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s + {Write a {\tt StablePtr#} value; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp +primop WriteByteArrayOp_Word8AsInt8 "writeWord8ArrayAsInt8#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 8-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp +primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 16-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s + {Write a 32-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp +primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + {Write a 64-bit signed integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s +primop WriteByteArrayOp_Word8AsWord8 "writeWord8ArrayAsWord8#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 8-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp +primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 16-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp +primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s + {Write a 32-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp +primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + {Write a 64-bit unsigned integer; offset in bytes.} with has_side_effects = True can_fail = True -primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True ===================================== utils/genprimopcode/gen_bytearray_ops.py ===================================== @@ -0,0 +1,141 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from typing import Optional, NamedTuple +import textwrap + +class ElementType(NamedTuple): + name: str + rep_ty: str + desc: str + width: Optional[int] + +MACH_WORD = None + +element_types = [ + # (name, representation type, human description, width) + # + # width in bytes. + # width == None denotes machine word + + ElementType("Char", "Char#", "8-bit character", 1), + ElementType("WideChar", "Char#", "32-bit character", 4), + ElementType("Int", "Int#", "word-sized integer", MACH_WORD), + ElementType("Word", "Word#", "word-sized unsigned integer", MACH_WORD), + ElementType("Addr", "Addr#", "machine address", MACH_WORD), + ElementType("Float", "Float#", "single-precision floating-point value", 4), + ElementType("Double", "Double#", "double-precision floating-point value", 8), + ElementType("StablePtr", "StablePtr# a", "{\\tt StablePtr#} value", MACH_WORD), +] + +# TODO: Eventually when the sized integer primops use proper unboxed types we +# should rather do: +# +#for n in [8,16,32,64]: +# element_types += [ ElementType(f"Int{n}", f"Int{n}#", f"{n}-bit signed integer", n // 8) ] +# +#for n in [8,16,32,64]: +# element_types += [ ElementType(f"Word{n}", f"Word{n}#", f"{n}-bit unsigned integer", n // 8) ] + +element_types += [ + ElementType("Int8", "Int#", "8-bit signed integer", 1), + ElementType("Int16", "Int#", "16-bit signed integer", 2), + ElementType("Int32", "INT32", "32-bit signed integer", 4), + ElementType("Int64", "INT64", "64-bit signed integer", 8), + + ElementType("Word8", "Word#", "8-bit unsigned integer", 1), + ElementType("Word16", "Word#", "16-bit unsigned integer", 2), + ElementType("Word32", "WORD32", "32-bit unsigned integer", 4), + ElementType("Word64", "WORD64", "64-bit unsigned integer", 8), +] + +def pretty_offset(n: Optional[int]) -> str: + if n == MACH_WORD: + return 'machine words' + elif n == 1: + return 'bytes' + else: + return f'{n}-byte words' + +def print_block(template: str, **kwargs) -> None: + print(textwrap.dedent(template.format(**kwargs)).lstrip()) + +def header(s: str): + print('') + print_block(''' + ------------------------------------ + -- {s} + ------------------------------------ + ''', s=s) + + +header("ByteArray# operations") + +print(''' +-- Do not edit. This file is generated by utils/genprimops/gen_bytearray_ops.py. +-- To regenerate run, +-- +-- python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp +''') + +header('aligned index operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop IndexByteArrayOp_{name} "index{name}Array#" GenPrimOp + ByteArray# -> Int# -> {rep_ty} + {{Read a {desc}; offset in {offset}.}} + with can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned index operations') +for t in element_types: + print_block(''' + primop IndexByteArrayOp_Word8As{name} "indexWord8ArrayAs{name}#" GenPrimOp + ByteArray# -> Int# -> {rep_ty} + {{Read a {desc}; offset in bytes.}} + with can_fail = True + ''', **t._asdict()) + +header('aligned read operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop ReadByteArrayOp_{name} "read{name}Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #) + {{Read a {desc}; offset in {offset}.}} + with has_side_effects = True + can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned read operations') +for t in element_types: + print_block(''' + primop ReadByteArrayOp_Word8As{name} "readWord8ArrayAs{name}#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #) + {{Read a {desc}; offset in bytes.}} + with has_side_effects = True + can_fail = True + ''', **t._asdict()) + +header('aligned write operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop WriteByteArrayOp_{name} "write{name}Array#" GenPrimOp + MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s + {{Write a {desc}; offset in {offset}.}} + with has_side_effects = True + can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned write operations') +for t in element_types: + print_block(''' + primop WriteByteArrayOp_Word8As{name} "writeWord8ArrayAs{name}#" GenPrimOp + MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s + {{Write a {desc}; offset in bytes.}} + with has_side_effects = True + can_fail = True + ''', **t._asdict()) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/408ddf1d38cf9905fadffa9e40dc025c31c81aea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/408ddf1d38cf9905fadffa9e40dc025c31c81aea You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 18:57:38 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 29 Oct 2020 14:57:38 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Widen acceptance threshold for T10421a Message-ID: <5f9b10a2405ac_8973fa3eb871cb011073cf@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 95b0d75d by Richard Eisenberg at 2020-10-29T14:57:28-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 30 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCo/Rep.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Core/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62685c0639338613ab7a7a82515d57f9109ff32b...95b0d75d17ec5c37ca07f37c6649d5739d2439e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/62685c0639338613ab7a7a82515d57f9109ff32b...95b0d75d17ec5c37ca07f37c6649d5739d2439e9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Thu Oct 29 23:56:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 19:56:21 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T15808 Message-ID: <5f9b56a546280_8973fa3b82a08f011544b@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/T15808 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T15808 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 02:07:44 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 29 Oct 2020 22:07:44 -0400 Subject: [Git][ghc/ghc][master] Check for large tuples more thoroughly Message-ID: <5f9b75706fd54_8976e2218c1175750@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 26 changed files: - compiler/GHC/Hs/Type.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/TyCl.hs - − testsuite/tests/rename/should_fail/T6148.stderr - + testsuite/tests/rename/should_fail/T6148a.hs - + testsuite/tests/rename/should_fail/T6148a.stderr - + testsuite/tests/rename/should_fail/T6148b.hs - + testsuite/tests/rename/should_fail/T6148b.stderr - testsuite/tests/rename/should_fail/T6148.hs → testsuite/tests/rename/should_fail/T6148c.hs - + testsuite/tests/rename/should_fail/T6148c.stderr - + testsuite/tests/rename/should_fail/T6148d.hs - + testsuite/tests/rename/should_fail/T6148d.stderr - testsuite/tests/rename/should_fail/all.T - + testsuite/tests/typecheck/should_fail/T18723a.hs - + testsuite/tests/typecheck/should_fail/T18723a.stderr - + testsuite/tests/typecheck/should_fail/T18723b.hs - + testsuite/tests/typecheck/should_fail/T18723b.stderr - + testsuite/tests/typecheck/should_fail/T18723c.hs - + testsuite/tests/typecheck/should_fail/T18723c.stderr - testsuite/tests/typecheck/should_fail/all.T - utils/haddock Changes: ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1060,20 +1060,19 @@ namely HsTupleTy, but keep track of the tuple kind (in the first argument to HsTupleTy, a HsTupleSort). We can tell if a tuple is unboxed while parsing, because of the #. However, with -XConstraintKinds we can only distinguish between constraint and boxed tuples during type checking, in general. Hence the -four constructors of HsTupleSort: +two constructors of HsTupleSort: HsUnboxedTuple -> Produced by the parser - HsBoxedTuple -> Certainly a boxed tuple - HsConstraintTuple -> Certainly a constraint tuple HsBoxedOrConstraintTuple -> Could be a boxed or a constraint tuple. Produced by the parser only, disappears after type checking + +After typechecking, we use TupleSort (which clearly distinguishes between +constraint tuples and boxed tuples) rather than HsTupleSort. -} -- | Haskell Tuple Sort data HsTupleSort = HsUnboxedTuple - | HsBoxedTuple - | HsConstraintTuple | HsBoxedOrConstraintTuple deriving Data @@ -1988,11 +1987,9 @@ hsTypeNeedsParens p = go_hs_ty -- Special-case unary boxed tuple applications so that they are -- parenthesized as `Identity (Solo x)`, not `Identity Solo x` (#18612) -- See Note [One-tuples] in GHC.Builtin.Types - go_hs_ty (HsTupleTy _ con [L _ ty]) + go_hs_ty (HsTupleTy _ con [_]) = case con of - HsBoxedTuple -> p >= appPrec HsBoxedOrConstraintTuple -> p >= appPrec - HsConstraintTuple -> go_hs_ty ty HsUnboxedTuple -> False go_hs_ty (HsTupleTy{}) = False go_hs_ty (HsSumTy{}) = False ===================================== compiler/GHC/Rename/Expr.hs ===================================== @@ -282,7 +282,6 @@ rnExpr (ExplicitList x _ exps) rnExpr (ExplicitTuple x tup_args boxity) = do { checkTupleSection tup_args - ; checkTupSize (length tup_args) ; (tup_args', fvs) <- mapAndUnzipM rnTupArg tup_args ; return (ExplicitTuple x tup_args' boxity, plusFVs fvs) } where ===================================== compiler/GHC/Rename/Pat.hs ===================================== @@ -37,8 +37,8 @@ module GHC.Rename.Pat (-- main entry points -- Literals rnLit, rnOverLit, - -- Pattern Error messages that are also used elsewhere - checkTupSize, patSigErr + -- Pattern Error message that is also used elsewhere + patSigErr ) where -- ENH: thin imports to only what is necessary for patterns @@ -59,7 +59,7 @@ import GHC.Rename.Utils ( HsDocContext(..), newLocalBndrRn, bindLocalNames , warnUnusedMatches, newLocalBndrRn , checkUnusedRecordWildcard , checkDupNames, checkDupAndShadowedNames - , checkTupSize , unknownSubordinateErr ) + , unknownSubordinateErr ) import GHC.Rename.HsType import GHC.Builtin.Names import GHC.Types.Name @@ -498,8 +498,7 @@ rnPatAndThen mk (ListPat _ pats) False -> return (ListPat Nothing pats') } rnPatAndThen mk (TuplePat x pats boxed) - = do { liftCps $ checkTupSize (length pats) - ; pats' <- rnLPatsAndThen mk pats + = do { pats' <- rnLPatsAndThen mk pats ; return (TuplePat x pats' boxed) } rnPatAndThen mk (SumPat x pat alt arity) ===================================== compiler/GHC/Rename/Utils.hs ===================================== @@ -11,7 +11,7 @@ This module contains miscellaneous functions related to renaming. module GHC.Rename.Utils ( checkDupRdrNames, checkShadowedRdrNames, checkDupNames, checkDupAndShadowedNames, dupNamesErr, - checkTupSize, + checkTupSize, checkCTupSize, addFvRn, mapFvRn, mapMaybeFvRn, warnUnusedMatches, warnUnusedTypePatterns, warnUnusedTopBinds, warnUnusedLocalBinds, @@ -57,7 +57,7 @@ import GHC.Driver.Session import GHC.Data.FastString import Control.Monad import Data.List -import GHC.Settings.Constants ( mAX_TUPLE_SIZE ) +import GHC.Settings.Constants ( mAX_TUPLE_SIZE, mAX_CTUPLE_SIZE ) import qualified Data.List.NonEmpty as NE import qualified GHC.LanguageExtensions as LangExt @@ -572,7 +572,9 @@ typeAppErr what (L _ k) <+> quotes (char '@' <> ppr k)) 2 (text "Perhaps you intended to use TypeApplications") -checkTupSize :: Int -> RnM () +-- | Ensure that a boxed or unboxed tuple has arity no larger than +-- 'mAX_TUPLE_SIZE'. +checkTupSize :: Int -> TcM () checkTupSize tup_size | tup_size <= mAX_TUPLE_SIZE = return () @@ -581,6 +583,16 @@ checkTupSize tup_size nest 2 (parens (text "max size is" <+> int mAX_TUPLE_SIZE)), nest 2 (text "Workaround: use nested tuples or define a data type")]) +-- | Ensure that a constraint tuple has arity no larger than 'mAX_CTUPLE_SIZE'. +checkCTupSize :: Int -> TcM () +checkCTupSize tup_size + | tup_size <= mAX_CTUPLE_SIZE + = return () + | otherwise + = addErr (hang (text "Constraint tuple arity too large:" <+> int tup_size + <+> parens (text "max arity =" <+> int mAX_CTUPLE_SIZE)) + 2 (text "Instead, use a nested tuple")) + {- ************************************************************************ ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Tc.Gen.Splice( tcSpliceExpr, tcTypedBracket, tcUntypedBracket ) import GHC.Hs +import GHC.Rename.Utils import GHC.Tc.Utils.Zonk import GHC.Tc.Utils.Monad import GHC.Tc.Utils.Unify @@ -1036,7 +1037,9 @@ arithSeqEltType (Just fl) res_ty ---------------- tcTupArgs :: [LHsTupArg GhcRn] -> [TcSigmaType] -> TcM [LHsTupArg GhcTc] tcTupArgs args tys - = ASSERT( equalLength args tys ) mapM go (args `zip` tys) + = do MASSERT( equalLength args tys ) + checkTupSize (length args) + mapM go (args `zip` tys) where go (L l (Missing {}), arg_ty) = do { mult <- newFlexiTyVarTy multiplicityTy ; return (L l (Missing (Scaled mult arg_ty))) } ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -71,6 +71,7 @@ module GHC.Tc.Gen.HsType ( import GHC.Prelude import GHC.Hs +import GHC.Rename.Utils import GHC.Tc.Utils.Monad import GHC.Tc.Types.Origin import GHC.Core.Predicate @@ -103,8 +104,6 @@ import GHC.Types.Var.Env import GHC.Builtin.Types import GHC.Types.Basic import GHC.Types.SrcLoc -import GHC.Settings.Constants ( mAX_CTUPLE_SIZE ) -import GHC.Utils.Error( MsgDoc ) import GHC.Types.Unique import GHC.Types.Unique.FM import GHC.Types.Unique.Set @@ -1133,16 +1132,8 @@ tc_hs_type mode rn_ty@(HsTupleTy _ HsBoxedOrConstraintTuple hs_tys) exp_kind ; finish_tuple rn_ty tup_sort tys' (map (const arg_kind) tys') exp_kind } -tc_hs_type mode rn_ty@(HsTupleTy _ hs_tup_sort tys) exp_kind - = tc_tuple rn_ty mode tup_sort tys exp_kind - where - tup_sort = case hs_tup_sort of -- Fourth case dealt with above - HsUnboxedTuple -> UnboxedTuple - HsBoxedTuple -> BoxedTuple - HsConstraintTuple -> ConstraintTuple -#if __GLASGOW_HASKELL__ <= 810 - _ -> panic "tc_hs_type HsTupleTy" -#endif +tc_hs_type mode rn_ty@(HsTupleTy _ HsUnboxedTuple tys) exp_kind + = tc_tuple rn_ty mode UnboxedTuple tys exp_kind tc_hs_type mode rn_ty@(HsSumTy _ hs_tys) exp_kind = do { let arity = length hs_tys @@ -1173,6 +1164,7 @@ tc_hs_type mode rn_ty@(HsExplicitTupleTy _ tys) exp_kind ; let kind_con = tupleTyCon Boxed arity ty_con = promotedTupleDataCon Boxed arity tup_k = mkTyConApp kind_con ks + ; checkTupSize arity ; checkExpectedKind rn_ty (mkTyConApp ty_con (ks ++ taus)) tup_k exp_kind } where arity = length tys @@ -1327,33 +1319,28 @@ finish_tuple rn_ty tup_sort tau_tys tau_kinds exp_kind = do -- Drop any uses of 1-tuple constraints here. -- See Note [Ignore unary constraint tuples] -> check_expected_kind tau_ty constraintKind - | arity > mAX_CTUPLE_SIZE - -> failWith (bigConstraintTuple arity) | otherwise - -> let tycon = cTupleTyCon arity in - check_expected_kind (mkTyConApp tycon tau_tys) constraintKind + -> do let tycon = cTupleTyCon arity + checkCTupSize arity + check_expected_kind (mkTyConApp tycon tau_tys) constraintKind BoxedTuple -> do let tycon = tupleTyCon Boxed arity + checkTupSize arity checkWiredInTyCon tycon check_expected_kind (mkTyConApp tycon tau_tys) liftedTypeKind - UnboxedTuple -> + UnboxedTuple -> do let tycon = tupleTyCon Unboxed arity tau_reps = map kindRep tau_kinds -- See also Note [Unboxed tuple RuntimeRep vars] in GHC.Core.TyCon arg_tys = tau_reps ++ tau_tys - res_kind = unboxedTupleKind tau_reps in + res_kind = unboxedTupleKind tau_reps + checkTupSize arity check_expected_kind (mkTyConApp tycon arg_tys) res_kind where arity = length tau_tys check_expected_kind ty act_kind = checkExpectedKind rn_ty ty act_kind exp_kind -bigConstraintTuple :: Arity -> MsgDoc -bigConstraintTuple arity - = hang (text "Constraint tuple arity too large:" <+> int arity - <+> parens (text "max arity =" <+> int mAX_CTUPLE_SIZE)) - 2 (text "Instead, use a nested tuple") - {- Note [Ignore unary constraint tuples] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Tc/Gen/Pat.hs ===================================== @@ -32,6 +32,7 @@ import GHC.Prelude import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcSyntaxOp, tcSyntaxOpGen, tcInferRho ) import GHC.Hs +import GHC.Rename.Utils import GHC.Tc.Utils.Zonk import GHC.Tc.Gen.Sig( TcPragEnv, lookupPragEnv, addInlinePrags ) import GHC.Tc.Utils.Monad @@ -509,6 +510,7 @@ Fortunately that's what matchExpectedFunTySigma returns anyway. tc = tupleTyCon boxity arity -- NB: tupleTyCon does not flatten 1-tuples -- See Note [Don't flatten tuples from HsSyn] in GHC.Core.Make + ; checkTupSize arity ; (coi, arg_tys) <- matchExpectedPatTy (matchExpectedTyConApp tc) penv (scaledThing pat_ty) -- Unboxed tuples have RuntimeRep vars, which we discard: ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -678,7 +678,8 @@ kcTyClGroup kisig_env decls -- NB: the environment extension overrides the tycon -- promotion-errors bindings -- See Note [Type environment evolution] - ; tcExtendKindEnvWithTyCons mono_tcs $ + ; checkNoErrs $ + tcExtendKindEnvWithTyCons mono_tcs $ mapM_ kcLTyClDecl kindless_decls ; return mono_tcs } ===================================== testsuite/tests/rename/should_fail/T6148.stderr deleted ===================================== @@ -1,15 +0,0 @@ - -T6148.hs:3:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:7:5: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type - -T6148.hs:11:6: - A 65-tuple is too large for GHC - (max size is 64) - Workaround: use nested tuples or define a data type ===================================== testsuite/tests/rename/should_fail/T6148a.hs ===================================== @@ -0,0 +1,4 @@ +module T6148a where + +a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) ===================================== testsuite/tests/rename/should_fail/T6148a.stderr ===================================== @@ -0,0 +1,14 @@ + +T6148a.hs:3:5: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the expression: + (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + In an equation for ‘a’: + a = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0) ===================================== testsuite/tests/rename/should_fail/T6148b.hs ===================================== @@ -0,0 +1,3 @@ +module T6148b where + +b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) ===================================== testsuite/tests/rename/should_fail/T6148b.stderr ===================================== @@ -0,0 +1,5 @@ + +T6148b.hs:3:5: error: + A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type ===================================== testsuite/tests/rename/should_fail/T6148.hs → testsuite/tests/rename/should_fail/T6148c.hs ===================================== @@ -1,10 +1,4 @@ -module T6148 where - -a = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) - - -b = (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +module T6148c where data T = T ===================================== testsuite/tests/rename/should_fail/T6148c.stderr ===================================== @@ -0,0 +1,5 @@ + +T6148c.hs:5:6: error: + A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type ===================================== testsuite/tests/rename/should_fail/T6148d.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskellQuotes #-} +{-# LANGUAGE UnboxedTuples #-} +module T6148d where + +d1 = ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +d2 = '(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) +d3 = ''(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) +d4 = '(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) ===================================== testsuite/tests/rename/should_fail/T6148d.stderr ===================================== @@ -0,0 +1,28 @@ + +T6148d.hs:5:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + ''(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + +T6148d.hs:6:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + '(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,) + +T6148d.hs:7:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + ''(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) + +T6148d.hs:8:6: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the Template Haskell quotation + '(#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#) ===================================== testsuite/tests/rename/should_fail/all.T ===================================== @@ -87,7 +87,10 @@ test('T5892b', normal, compile_fail, ['-package containers']) test('T5951', normal, compile_fail, ['']) test('T6018rnfail', normal, compile_fail, ['']) test('T6060', normal, compile_fail, ['']) -test('T6148', normal, compile_fail, ['']) +test('T6148a', normal, compile_fail, ['']) +test('T6148b', normal, compile_fail, ['']) +test('T6148c', normal, compile_fail, ['']) +test('T6148d', normal, compile_fail, ['']) test('T7164', normal, compile_fail, ['']) test('T7338', normal, compile_fail, ['']) test('T7338a', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_fail/T18723a.hs ===================================== @@ -0,0 +1,11 @@ +module T18723a where + +data T1 = MkT1 + ( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + ) ===================================== testsuite/tests/typecheck/should_fail/T18723a.stderr ===================================== @@ -0,0 +1,13 @@ + +T18723a.hs:4:3: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int)’ + In the definition of data constructor ‘MkT1’ + In the data declaration for ‘T1’ ===================================== testsuite/tests/typecheck/should_fail/T18723b.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE DataKinds #-} +module T18723b where + +import Data.Proxy + +data T2 = MkT2 (Proxy + '( Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + )) ===================================== testsuite/tests/typecheck/should_fail/T18723b.stderr ===================================== @@ -0,0 +1,137 @@ + +T18723b.hs:7:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the first argument of ‘Proxy’, namely + ‘'(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int)’ + In the type ‘(Proxy '(Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int, + Int))’ + In the definition of data constructor ‘MkT2’ ===================================== testsuite/tests/typecheck/should_fail/T18723c.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE UnboxedTuples #-} +module T18723c where + +data T3 = MkT3 + (# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int, Int, Int, Int, Int, Int + , Int, Int, Int, Int, Int + #) ===================================== testsuite/tests/typecheck/should_fail/T18723c.stderr ===================================== @@ -0,0 +1,13 @@ + +T18723c.hs:5:2: error: + • A 65-tuple is too large for GHC + (max size is 64) + Workaround: use nested tuples or define a data type + • In the type ‘(# Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, + Int, Int, Int #)’ + In the definition of data constructor ‘MkT3’ + In the data declaration for ‘T3’ ===================================== testsuite/tests/typecheck/should_fail/all.T ===================================== @@ -580,6 +580,9 @@ test('T18357b', normal, compile_fail, ['']) test('T18455', normal, compile_fail, ['']) test('T18534', normal, compile_fail, ['']) test('T18714', normal, compile_fail, ['']) +test('T18723a', normal, compile_fail, ['']) +test('T18723b', normal, compile_fail, ['']) +test('T18723c', normal, compile_fail, ['']) test('too-many', normal, compile_fail, ['']) test('T18640a', normal, compile_fail, ['']) test('T18640b', normal, compile_fail, ['']) ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 904a3c276643d15da24303493b62e95dfb0b7726 +Subproject commit 87a9f86d1ad7de67ff011311905ecf76578b26e9 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ef2fac4c412a25fa64f79b759d69d22a4ebc784 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2ef2fac4c412a25fa64f79b759d69d22a4ebc784 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 02:08:27 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Thu, 29 Oct 2020 22:08:27 -0400 Subject: [Git][ghc/ghc][master] Remove unnecessary gender from comments/docs Message-ID: <5f9b759be1674_8973fa3bb137128117845b@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 16 changed files: - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/partial_type_signatures.rst Changes: ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -895,7 +895,7 @@ Old "solution": of iterateList in the first place But in principle the user *might* want rules that only apply to the Id -he says. And inline pragmas are similar +they say. And inline pragmas are similar {-# NOINLINE f #-} f = local local = ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -1744,8 +1744,8 @@ Note [spec_usg includes rhs_usg] In calls to 'specialise', the returned ScUsage must include the rhs_usg in the passed-in SpecInfo, unless there are no calls at all to the function. -The caller can, indeed must, assume this. He should not combine in rhs_usg -himself, or he'll get rhs_usg twice -- and that can lead to an exponential +The caller can, indeed must, assume this. They should not combine in rhs_usg +themselves, or they'll get rhs_usg twice -- and that can lead to an exponential blowup of duplicates in the CallEnv. This is what gave rise to the massive performance loss in #8852. ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -224,8 +224,8 @@ See also Note [Wrappers for data instance tycons] in GHC.Types.Id.Make * Reply "yes" to isDataFamilyTyCon, and isFamilyTyCon -* The user does not see any "equivalent types" as he did with type - synonym families. He just sees constructors with types +* The user does not see any "equivalent types" as they did with type + synonym families. They just see constructors with types T1 :: T Int T2 :: Bool -> T Int ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -1511,7 +1511,7 @@ Note [Expandable overloadings] Suppose the user wrote this {-# RULE forall x. foo (negate x) = h x #-} f x = ....(foo (negate x)).... -He'd expect the rule to fire. But since negate is overloaded, we might +They'd expect the rule to fire. But since negate is overloaded, we might get this: f = \d -> let n = negate d in \x -> ...foo (n x)... So we treat the application of a function (negate in this case) to a @@ -2621,4 +2621,3 @@ isUnsafeEqualityProof e = idName v == unsafeEqualityProofName | otherwise = False - ===================================== compiler/GHC/HsToCore/Pmc/Solver/Types.hs ===================================== @@ -90,7 +90,7 @@ initNabla = MkNabla initTyState initTmState instance Outputable Nabla where ppr nabla = hang (text "Nabla") 2 $ vcat [ -- intentionally formatted this way enable the dev to comment in only - -- the info she needs + -- the info they need ppr (nabla_tm_st nabla), ppr (nabla_ty_st nabla) ] ===================================== compiler/GHC/HsToCore/Utils.hs ===================================== @@ -454,7 +454,7 @@ There are a few subtleties in the desugaring of `seq`: I# _ -> ...case b of {True -> fst x; False -> 0}... We can try to avoid doing this by ensuring that the binder-swap in the - case happens, so we get his at an early stage: + case happens, so we get this at an early stage: case chp of chp2 { I# -> ...chp2... } But this is fragile. The real culprit is the source program. Perhaps we should have said explicitly ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -338,8 +338,8 @@ mkSpliceDecl :: LHsExpr GhcPs -> HsDecl GhcPs -- If the user wrote -- [pads| ... ] then return a QuasiQuoteD -- $(e) then return a SpliceD --- but if she wrote, say, --- f x then behave as if she'd written $(f x) +-- but if they wrote, say, +-- f x then behave as if they'd written $(f x) -- ie a SpliceD -- -- Typed splices are not allowed at the top level, thus we do not represent them ===================================== compiler/GHC/Runtime/Interpreter.hs ===================================== @@ -411,7 +411,7 @@ handleSeqHValueStatus :: HscEnv -> EvalStatus () -> IO (EvalResult ()) handleSeqHValueStatus hsc_env eval_status = do case eval_status of (EvalBreak is_exception _ ix mod_uniq resume_ctxt _) -> do - -- A breakpoint was hit, inform the user and tell him + -- A breakpoint was hit; inform the user and tell them -- which breakpoint was hit. resume_ctxt_fhv <- liftIO $ mkFinalizedHValue hsc_env resume_ctxt let hmi = expectJust "handleRunStatus" $ ===================================== compiler/GHC/Tc/Gen/Expr.hs ===================================== @@ -103,7 +103,7 @@ tcCheckPolyExpr, tcCheckPolyExprNC -- tcCheckPolyExpr is a convenient place (frequent but not too frequent) -- place to add context information. -- The NC version does not do so, usually because the caller wants --- to do so himself. +-- to do so themselves. tcCheckPolyExpr expr res_ty = tcPolyExpr expr (mkCheckExpType res_ty) tcCheckPolyExprNC expr res_ty = tcPolyExprNC expr (mkCheckExpType res_ty) ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -565,7 +565,7 @@ We only produce warnings for TH splices when the user requests so (-fenable-th-splice-warnings). There are multiple reasons: * It's not clear that the user that compiles a splice is the author of the code - that produces the warning. Think of the situation where she just splices in + that produces the warning. Think of the situation where they just splice in code from a third-party library that produces incomplete pattern matches. In this scenario, the user isn't even able to fix that warning. * Gathering information for producing the warnings (pattern-match check ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -88,7 +88,7 @@ Note [Basic Simplifier Plan] - If (ContinueWith ct) is returned by a stage, we feed 'ct' on to the next stage in the pipeline. 4. If the element has survived (i.e. ContinueWith x) the last stage - then we add him in the inerts and jump back to Step 1. + then we add it in the inerts and jump back to Step 1. If in Step 1 no such element exists, we have exceeded our context-stack depth and will simply fail. @@ -1671,7 +1671,7 @@ variable *on the left* of the equality. Here is what happens if not: Original wanted: (a ~ alpha), (alpha ~ Int) We spontaneously solve the first wanted, without changing the order! given : a ~ alpha [having unified alpha := a] -Now the second wanted comes along, but he cannot rewrite the given, so we simply continue. +Now the second wanted comes along, but it cannot rewrite the given, so we simply continue. At the end we spontaneously solve that guy, *reunifying* [alpha := Int] We avoid this problem by orienting the resulting given so that the unification ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -953,7 +953,7 @@ The question for this Note is this: Much of the debate is memorialized in #15743. Here is our design choice. When inferring the ordering of variables -for a TyCl declaration (that is, for those variables that he user +for a TyCl declaration (that is, for those variables that the user has not specified the order with an explicit `forall`), we use the following order: ===================================== compiler/GHC/Types/Basic.hs ===================================== @@ -1352,7 +1352,7 @@ If you want to know where InlinePragmas take effect: Look in GHC.HsToCore.Binds. Note [inl_inline and inl_act] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* inl_inline says what the user wrote: did she say INLINE, NOINLINE, +* inl_inline says what the user wrote: did they say INLINE, NOINLINE, INLINABLE, or nothing at all * inl_act says in what phases the unfolding is active or inactive ===================================== compiler/GHC/Types/Name/Reader.hs ===================================== @@ -1345,7 +1345,7 @@ pprLoc (UnhelpfulSpan {}) = empty -- (b) it is always in scope -- (c) it is a synonym for Data.Kind.Type -- --- However, the user might not know that he's working on a module with +-- However, the user might not know that they are working on a module with -- NoStarIsType and write code that still assumes (a), (b), and (c), which -- actually do not hold in that module. -- ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -1287,8 +1287,8 @@ speakNth n = hcat [ int n, text suffix ] -- > speakN 5 = text "five" -- > speakN 10 = text "10" speakN :: Int -> SDoc -speakN 0 = text "none" -- E.g. "he has none" -speakN 1 = text "one" -- E.g. "he has one" +speakN 0 = text "none" -- E.g. "they have none" +speakN 1 = text "one" -- E.g. "they have one" speakN 2 = text "two" speakN 3 = text "three" speakN 4 = text "four" ===================================== docs/users_guide/exts/partial_type_signatures.rst ===================================== @@ -224,7 +224,7 @@ extra-constraints wildcard is used to infer three extra constraints. arbitCs :: _ => a -> String An extra-constraints wildcard shouldn't prevent the programmer from -already listing the constraints he knows or wants to annotate, e.g. +already listing the constraints they know or want to annotate, e.g. :: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f8be3eb3440a152246a1aef7b4020be4c03cf2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7f8be3eb3440a152246a1aef7b4020be4c03cf2e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 02:51:40 2020 From: gitlab at gitlab.haskell.org (Richard Eisenberg) Date: Thu, 29 Oct 2020 22:51:40 -0400 Subject: [Git][ghc/ghc][wip/cfuneqcan-refactor] Don't simplify extra-constraint holes Message-ID: <5f9b7fbcd1ebc_8973fa3b92c9dd01182489@gitlab.haskell.org.mail> Richard Eisenberg pushed to branch wip/cfuneqcan-refactor at Glasgow Haskell Compiler / GHC Commits: cd5585da by Richard Eisenberg at 2020-10-29T22:51:26-04:00 Don't simplify extra-constraint holes - - - - - 30 changed files: - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Types/Constraint.hs - compiler/GHC/Tc/Utils/Monad.hs - testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr - testsuite/tests/partial-sigs/should_compile/SuperCls.stderr - testsuite/tests/partial-sigs/should_compile/T10403.stderr - testsuite/tests/partial-sigs/should_compile/T10519.stderr - testsuite/tests/partial-sigs/should_compile/T11016.stderr - testsuite/tests/partial-sigs/should_compile/T11670.stderr - testsuite/tests/partial-sigs/should_compile/T12844.stderr - testsuite/tests/partial-sigs/should_compile/T12845.stderr - testsuite/tests/partial-sigs/should_compile/T13482.stderr - testsuite/tests/partial-sigs/should_compile/T14217.stderr - testsuite/tests/partial-sigs/should_compile/T14643.stderr - testsuite/tests/partial-sigs/should_compile/T14643a.stderr - testsuite/tests/partial-sigs/should_compile/T14715.stderr - testsuite/tests/partial-sigs/should_compile/T15039a.stderr - testsuite/tests/partial-sigs/should_compile/T15039b.stderr - testsuite/tests/partial-sigs/should_compile/T15039c.stderr - testsuite/tests/partial-sigs/should_compile/T15039d.stderr - testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr - testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr - testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr - testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr - testsuite/tests/partial-sigs/should_fail/T10999.stderr - testsuite/tests/partial-sigs/should_fail/T11515.stderr - testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr - testsuite/tests/typecheck/should_compile/UnliftedNewtypesUnifySig.hs Changes: ===================================== compiler/GHC/Tc/Errors.hs ===================================== @@ -882,7 +882,10 @@ maybeReportHoleError ctxt hole err -- Unlike maybeReportError, these "hole" errors are -- /not/ suppressed by cec_suppress. We want to see them! -maybeReportHoleError ctxt (Hole { hole_sort = TypeHole }) err +maybeReportHoleError ctxt (Hole { hole_sort = hole_sort }) err + | case hole_sort of TypeHole -> True + ConstraintHole -> True + _ -> False -- When -XPartialTypeSignatures is on, warnings (instead of errors) are -- generated for holes in partial type signatures. -- Unless -fwarn-partial-type-signatures is not on, @@ -894,7 +897,7 @@ maybeReportHoleError ctxt (Hole { hole_sort = TypeHole }) err HoleWarn -> reportWarning (Reason Opt_WarnPartialTypeSignatures) err HoleDefer -> return () -maybeReportHoleError ctxt hole@(Hole { hole_sort = ExprHole _ }) err +maybeReportHoleError ctxt hole err -- Otherwise this is a typed hole in an expression, -- but not for an out-of-scope variable (because that goes through a -- different function) @@ -961,6 +964,8 @@ maybeAddDeferredHoleBinding ctxt err (Hole { hole_sort = ExprHole ev_id }) = return () maybeAddDeferredHoleBinding _ _ (Hole { hole_sort = TypeHole }) = return () +maybeAddDeferredHoleBinding _ _ (Hole { hole_sort = ConstraintHole }) + = return () tryReporters :: ReportErrCtxt -> [ReporterSpec] -> [Ct] -> TcM (ReportErrCtxt, [Ct]) -- Use the first reporter in the list whose predicate says True @@ -1209,6 +1214,9 @@ mkHoleError tidy_simples ctxt hole@(Hole { hole_occ = occ TypeHole -> vcat [ hang (text "Found type wildcard" <+> quotes (ppr occ)) 2 (text "standing for" <+> quotes pp_hole_type_with_kind) , tyvars_msg, type_hole_hint ] + ConstraintHole -> vcat [ hang (text "Found extra-constraints wildcard standing for") + 2 (quotes $ pprType hole_ty) -- always kind constraint + , tyvars_msg, type_hole_hint ] pp_hole_type_with_kind | isLiftedTypeKind hole_kind ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1210,7 +1210,9 @@ tc_hs_type mode ty@(HsAppKindTy{}) ek = tc_infer_hs_type_ek mode ty ek tc_hs_type mode ty@(HsOpTy {}) ek = tc_infer_hs_type_ek mode ty ek tc_hs_type mode ty@(HsKindSig {}) ek = tc_infer_hs_type_ek mode ty ek tc_hs_type mode ty@(XHsType (NHsCoreTy{})) ek = tc_infer_hs_type_ek mode ty ek -tc_hs_type mode ty@(HsWildCardTy _) ek = tcAnonWildCardOcc mode ty ek + +tc_hs_type mode ty@(HsWildCardTy _) ek + = tcAnonWildCardOcc NoExtraConstraint mode ty ek {- Note [Variable Specificity and Forall Visibility] @@ -2089,8 +2091,9 @@ newNamedWildTyVar _name -- Currently ignoring the "_x" wildcard name used in t ; return tyvar } --------------------------- -tcAnonWildCardOcc :: TcTyMode -> HsType GhcRn -> Kind -> TcM TcType -tcAnonWildCardOcc (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) }) +tcAnonWildCardOcc :: IsExtraConstraint + -> TcTyMode -> HsType GhcRn -> Kind -> TcM TcType +tcAnonWildCardOcc is_extra (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) }) ty exp_kind -- hole_lvl: see Note [Checking partial type signatures] -- esp the bullet on nested forall types @@ -2104,7 +2107,7 @@ tcAnonWildCardOcc (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) }) ; traceTc "tcAnonWildCardOcc" (ppr hole_lvl <+> ppr emit_holes) ; when emit_holes $ - emitAnonTypeHole wc_tv + emitAnonTypeHole is_extra wc_tv -- Why the 'when' guard? -- See Note [Wildcards in visible kind application] @@ -2125,7 +2128,7 @@ tcAnonWildCardOcc (TcTyMode { mode_holes = Just (hole_lvl, hole_mode) }) HM_FamPat -> False HM_VTA -> False -tcAnonWildCardOcc mode ty _ +tcAnonWildCardOcc _ mode ty _ -- mode_holes is Nothing. Should not happen, because renamer -- should already have rejected holes in unexpected places = pprPanic "tcWildCardOcc" (ppr mode $$ ppr ty) @@ -3639,7 +3642,7 @@ tcPartialContext mode hs_theta | Just (hs_theta1, hs_ctxt_last) <- snocView hs_theta , L wc_loc ty@(HsWildCardTy _) <- ignoreParens hs_ctxt_last = do { wc_tv_ty <- setSrcSpan wc_loc $ - tcAnonWildCardOcc mode ty constraintKind + tcAnonWildCardOcc YesExtraConstraint mode ty constraintKind ; theta <- mapM (tc_lhs_pred mode) hs_theta1 ; return (theta, Just wc_tv_ty) } | otherwise ===================================== compiler/GHC/Tc/Solver.hs ===================================== @@ -2029,6 +2029,15 @@ simplifyHoles :: Bag Hole -> TcS (Bag Hole) simplifyHoles = mapBagM simpl_hole where simpl_hole :: Hole -> TcS Hole + + -- do not simplify an extra-constraints wildcard. These holes + -- are filled with already-simplified constraints in + -- chooseInferredQuantifiers (choose_psig_context) + simpl_hole h@(Hole { hole_sort = ConstraintHole }) = return h + + -- other wildcards should be simplified for printing + -- we must do so here, and not in the error-message generation + -- code, because we have all the givens already set up simpl_hole h@(Hole { hole_ty = ty, hole_loc = loc }) = do { ty' <- flattenType loc ty ; return (h { hole_ty = ty' }) } ===================================== compiler/GHC/Tc/Types/Constraint.hs ===================================== @@ -239,20 +239,23 @@ data HoleSort = ExprHole Id -- will be an erroring expression for -fdefer-type-errors. | TypeHole -- ^ A hole in a type (PartialTypeSignatures) + | ConstraintHole + -- ^ A hole in a constraint, like @f :: (_, Eq a) => ... instance Outputable Hole where ppr (Hole { hole_sort = ExprHole id , hole_occ = occ , hole_ty = ty }) = parens $ (braces $ ppr occ <> colon <> ppr id) <+> dcolon <+> ppr ty - ppr (Hole { hole_sort = TypeHole + ppr (Hole { hole_sort = _other , hole_occ = occ , hole_ty = ty }) = braces $ ppr occ <> colon <> ppr ty instance Outputable HoleSort where - ppr (ExprHole id) = text "ExprHole:" <> ppr id - ppr TypeHole = text "TypeHole" + ppr (ExprHole id) = text "ExprHole:" <> ppr id + ppr TypeHole = text "TypeHole" + ppr ConstraintHole = text "CosntraintHole" ------------ -- | Used to indicate extra information about why a CIrredCan is irreducible ===================================== compiler/GHC/Tc/Utils/Monad.hs ===================================== @@ -109,7 +109,7 @@ module GHC.Tc.Utils.Monad( getTcLevel, setTcLevel, isTouchableTcM, getLclTypeEnv, setLclTypeEnv, traceTcConstraints, - emitNamedTypeHole, emitAnonTypeHole, + emitNamedTypeHole, IsExtraConstraint(..), emitAnonTypeHole, -- * Template Haskell context recordThUse, recordThSpliceUse, @@ -1757,16 +1757,26 @@ traceTcConstraints msg hang (text (msg ++ ": LIE:")) 2 (ppr lie) } -emitAnonTypeHole :: TcTyVar -> TcM () -emitAnonTypeHole tv +data IsExtraConstraint = YesExtraConstraint + | NoExtraConstraint + +instance Outputable IsExtraConstraint where + ppr YesExtraConstraint = text "YesExtraConstraint" + ppr NoExtraConstraint = text "NoExtraConstraint" + +emitAnonTypeHole :: IsExtraConstraint + -> TcTyVar -> TcM () +emitAnonTypeHole extra_constraints tv = do { ct_loc <- getCtLocM (TypeHoleOrigin occ) Nothing - ; let hole = Hole { hole_sort = TypeHole + ; let hole = Hole { hole_sort = sort , hole_occ = occ , hole_ty = mkTyVarTy tv , hole_loc = ct_loc } ; emitHole hole } where occ = mkTyVarOcc "_" + sort | YesExtraConstraint <- extra_constraints = ConstraintHole + | otherwise = TypeHole emitNamedTypeHole :: (Name, TcTyVar) -> TcM () emitNamedTypeHole (name, tv) ===================================== testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr ===================================== @@ -65,7 +65,7 @@ SplicesUsed.hs:16:2: warning: [-Wpartial-type-signatures (in -Wdefault)] • In the type signature: foo :: _ => _ SplicesUsed.hs:16:2: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Eq a’ + • Found extra-constraints wildcard standing for ‘Eq a’ Where: ‘a’ is a rigid type variable bound by the inferred type of foo :: Eq a => a -> a -> Bool at SplicesUsed.hs:16:2-11 ===================================== testsuite/tests/partial-sigs/should_compile/SuperCls.stderr ===================================== @@ -1,4 +1,4 @@ SuperCls.hs:4:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: f :: (Ord a, _) => a -> Bool ===================================== testsuite/tests/partial-sigs/should_compile/T10403.stderr ===================================== @@ -1,6 +1,6 @@ T10403.hs:15:7: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Functor f’ + • Found extra-constraints wildcard standing for ‘Functor f’ Where: ‘f’ is a rigid type variable bound by the inferred type of h1 :: Functor f => (a -> a1) -> f a -> H f at T10403.hs:17:1-41 ===================================== testsuite/tests/partial-sigs/should_compile/T10519.stderr ===================================== @@ -1,6 +1,6 @@ T10519.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Eq a’ + • Found extra-constraints wildcard standing for ‘Eq a’ Where: ‘a’ is a rigid type variable bound by the inferred type of foo :: Eq a => a -> a -> Bool at T10519.hs:5:15 ===================================== testsuite/tests/partial-sigs/should_compile/T11016.stderr ===================================== @@ -1,6 +1,6 @@ T11016.hs:5:19: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: f1 :: (?x :: Int, _) => Int T11016.hs:8:22: warning: [-Wpartial-type-signatures (in -Wdefault)] ===================================== testsuite/tests/partial-sigs/should_compile/T11670.stderr ===================================== @@ -9,7 +9,7 @@ T11670.hs:10:42: warning: [-Wpartial-type-signatures (in -Wdefault)] peek :: Ptr a -> IO CLong (bound at T11670.hs:10:1) T11670.hs:13:40: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Storable w’ + • Found extra-constraints wildcard standing for ‘Storable w’ Where: ‘w’ is a rigid type variable bound by the inferred type of :: Storable w => IO w at T11670.hs:13:40-48 ===================================== testsuite/tests/partial-sigs/should_compile/T12844.stderr ===================================== @@ -1,7 +1,7 @@ T12844.hs:12:9: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ - standing for ‘(Head rngs ~ '(r, r'), Foo rngs)’ + • Found extra-constraints wildcard standing for + ‘(Head rngs ~ '(r, r'), Foo rngs)’ Where: ‘r’, ‘r'’, ‘k’, ‘k1’, ‘rngs’ are rigid type variables bound by the inferred type of ===================================== testsuite/tests/partial-sigs/should_compile/T12845.stderr ===================================== @@ -1,6 +1,6 @@ T12845.hs:18:70: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: broken :: forall r r' rngs. ('(r, r') ~ Head rngs, Bar r r' ~ 'True, _) => ===================================== testsuite/tests/partial-sigs/should_compile/T13482.stderr ===================================== @@ -1,6 +1,6 @@ T13482.hs:10:32: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘(Eq m, Monoid m)’ + • Found extra-constraints wildcard standing for ‘(Eq m, Monoid m)’ Where: ‘m’ is a rigid type variable bound by the inferred type of minimal1_noksig :: (Eq m, Monoid m) => Int -> Bool @@ -9,21 +9,21 @@ T13482.hs:10:32: warning: [-Wpartial-type-signatures (in -Wdefault)] minimal1_noksig :: forall m. _ => Int -> Bool T13482.hs:13:33: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘(Eq m, Monoid m)’ + • Found extra-constraints wildcard standing for ‘(Eq m, Monoid m)’ Where: ‘m’ is a rigid type variable bound by the inferred type of minimal1 :: (Eq m, Monoid m) => Bool at T13482.hs:13:21 • In the type signature: minimal1 :: forall (m :: Type). _ => Bool T13482.hs:16:30: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Monoid m’ + • Found extra-constraints wildcard standing for ‘Monoid m’ Where: ‘m’ is a rigid type variable bound by the inferred type of minimal2 :: (Eq m, Monoid m) => Bool at T13482.hs:16:20 • In the type signature: minimal2 :: forall m. (Eq m, _) => Bool T13482.hs:19:34: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Eq m’ + • Found extra-constraints wildcard standing for ‘Eq m’ Where: ‘m’ is a rigid type variable bound by the inferred type of minimal3 :: (Monoid m, Eq m) => Bool at T13482.hs:19:20 ===================================== testsuite/tests/partial-sigs/should_compile/T14217.stderr ===================================== @@ -1,14 +1,14 @@ T14217.hs:32:11: error: - • Found type wildcard ‘_’ - standing for ‘(Eq a1, Eq a2, Eq a3, Eq a4, Eq a5, Eq a6, Eq a7, - Eq a8, Eq a9, Eq a10, Eq a11, Eq a12, Eq a13, Eq a14, Eq a15, - Eq a16, Eq a17, Eq a18, Eq a19, Eq a20, Eq a21, Eq a22, Eq a23, - Eq a24, Eq a25, Eq a26, Eq a27, Eq a28, Eq a29, Eq a30, Eq a31, - Eq a32, Eq a33, Eq a34, Eq a35, Eq a36, Eq a37, Eq a38, Eq a39, - Eq a40, Eq a41, Eq a42, Eq a43, Eq a44, Eq a45, Eq a46, Eq a47, - Eq a48, Eq a49, Eq a50, Eq a51, Eq a52, Eq a53, Eq a54, Eq a55, - Eq a56, Eq a57, Eq a58, Eq a59, Eq a60, Eq a61, Eq a62, Eq a63)’ + • Found extra-constraints wildcard standing for + ‘(Eq a1, Eq a2, Eq a3, Eq a4, Eq a5, Eq a6, Eq a7, Eq a8, Eq a9, + Eq a10, Eq a11, Eq a12, Eq a13, Eq a14, Eq a15, Eq a16, Eq a17, + Eq a18, Eq a19, Eq a20, Eq a21, Eq a22, Eq a23, Eq a24, Eq a25, + Eq a26, Eq a27, Eq a28, Eq a29, Eq a30, Eq a31, Eq a32, Eq a33, + Eq a34, Eq a35, Eq a36, Eq a37, Eq a38, Eq a39, Eq a40, Eq a41, + Eq a42, Eq a43, Eq a44, Eq a45, Eq a46, Eq a47, Eq a48, Eq a49, + Eq a50, Eq a51, Eq a52, Eq a53, Eq a54, Eq a55, Eq a56, Eq a57, + Eq a58, Eq a59, Eq a60, Eq a61, Eq a62, Eq a63)’ Where: ‘a1’, ‘a2’, ‘a3’, ‘a4’, ‘a5’, ‘a6’, ‘a7’, ‘a8’, ‘a9’, ‘a10’, ‘a11’, ‘a12’, ‘a13’, ‘a14’, ‘a15’, ‘a16’, ‘a17’, ‘a18’, ‘a19’, ‘a20’, ‘a21’, ‘a22’, ‘a23’, ‘a24’, ‘a25’, ‘a26’, ‘a27’, ‘a28’, ===================================== testsuite/tests/partial-sigs/should_compile/T14643.stderr ===================================== @@ -1,8 +1,8 @@ T14643.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: ag :: (Num a, _) => a -> a T14643.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: af :: (Num a, _) => a -> a ===================================== testsuite/tests/partial-sigs/should_compile/T14643a.stderr ===================================== @@ -1,8 +1,8 @@ T14643a.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: af :: (Num a, _) => a -> a T14643a.hs:8:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ • In the type signature: ag :: (Num a, _) => a -> a ===================================== testsuite/tests/partial-sigs/should_compile/T14715.stderr ===================================== @@ -1,11 +1,12 @@ T14715.hs:13:53: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Reduce z zq’ - Where: ‘z’, ‘zq’ are rigid type variables bound by + • Found extra-constraints wildcard standing for + ‘Reduce (LiftOf zq) zq’ + Where: ‘zq’ is a rigid type variable bound by the inferred type of bench_mulPublic :: (z ~ LiftOf zq, Reduce (LiftOf zq) zq) => Cyc zp -> Cyc z -> IO (zp, zq) - at T14715.hs:13:27-33 + at T14715.hs:13:32-33 • In the type signature: bench_mulPublic :: forall z zp zq. (z ~ LiftOf zq, _) => Cyc zp -> Cyc z -> IO (zp, zq) ===================================== testsuite/tests/partial-sigs/should_compile/T15039a.stderr ===================================== @@ -48,7 +48,7 @@ T15039a.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex6 :: Dict (Coercible a b) -> () (bound at T15039a.hs:33:1) T15039a.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible a b’ + • Found extra-constraints wildcard standing for ‘Coercible a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible a b => Coercion a b at T15039a.hs:35:1-44 ===================================== testsuite/tests/partial-sigs/should_compile/T15039b.stderr ===================================== @@ -49,7 +49,8 @@ T15039b.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex6 :: Dict (Coercible @(*) a b) -> () (bound at T15039b.hs:33:1) T15039b.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible @(*) a b’ + • Found extra-constraints wildcard standing for + ‘Coercible @(*) a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible @(*) a b => Coercion @{*} a b at T15039b.hs:35:1-44 ===================================== testsuite/tests/partial-sigs/should_compile/T15039c.stderr ===================================== @@ -48,7 +48,7 @@ T15039c.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex6 :: Dict (Coercible a b) -> () (bound at T15039c.hs:33:1) T15039c.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible a b’ + • Found extra-constraints wildcard standing for ‘Coercible a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible a b => Coercion a b at T15039c.hs:35:1-44 ===================================== testsuite/tests/partial-sigs/should_compile/T15039d.stderr ===================================== @@ -50,7 +50,8 @@ T15039d.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] ex6 :: Dict (Coercible @(*) a b) -> () (bound at T15039d.hs:33:1) T15039d.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible @(*) a b’ + • Found extra-constraints wildcard standing for + ‘Coercible @(*) a b’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible @(*) a b => Coercion @{*} a b at T15039d.hs:35:1-44 ===================================== testsuite/tests/partial-sigs/should_compile/WarningWildcardInstantiations.stderr ===================================== @@ -2,7 +2,7 @@ TYPE SIGNATURES bar :: forall {t} {w}. t -> (t -> w) -> w foo :: forall {a}. (Show a, Enum a) => a -> String Dependent modules: [] -Dependent packages: [base-4.14.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] +Dependent packages: [base-4.15.0.0, ghc-bignum-1.0, ghc-prim-0.7.0] WarningWildcardInstantiations.hs:5:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_a’ standing for ‘a’ @@ -12,7 +12,7 @@ WarningWildcardInstantiations.hs:5:14: warning: [-Wpartial-type-signatures (in - • In the type signature: foo :: (Show _a, _) => _a -> _ WarningWildcardInstantiations.hs:5:18: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Enum a’ + • Found extra-constraints wildcard standing for ‘Enum a’ Where: ‘a’ is a rigid type variable bound by the inferred type of foo :: (Show a, Enum a) => a -> String at WarningWildcardInstantiations.hs:6:1-21 ===================================== testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardInExpressionSignature.stderr ===================================== @@ -1,6 +1,6 @@ ExtraConstraintsWildcardInExpressionSignature.hs:5:20: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Eq a1’ + • Found extra-constraints wildcard standing for ‘Eq a1’ Where: ‘a1’ is a rigid type variable bound by the inferred type of :: Eq a1 => a1 -> a1 -> Bool at ExtraConstraintsWildcardInExpressionSignature.hs:5:20-25 ===================================== testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr ===================================== @@ -1,6 +1,6 @@ ExtraConstraintsWildcardNotEnabled.hs:4:10: error: - • Found type wildcard ‘_’ standing for ‘Show a’ + • Found extra-constraints wildcard standing for ‘Show a’ Where: ‘a’ is a rigid type variable bound by the inferred type of show' :: Show a => a -> String at ExtraConstraintsWildcardNotEnabled.hs:4:1-25 ===================================== testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr ===================================== @@ -8,7 +8,7 @@ InstantiatedNamedWildcardsInConstraints.hs:4:14: error: • In the type signature: foo :: (Enum _a, _) => _a -> (String, b) InstantiatedNamedWildcardsInConstraints.hs:4:18: error: - • Found type wildcard ‘_’ standing for ‘Show b’ + • Found extra-constraints wildcard standing for ‘Show b’ Where: ‘b’ is a rigid type variable bound by the inferred type of foo :: (Enum b, Show b) => b -> (String, b) at InstantiatedNamedWildcardsInConstraints.hs:4:1-40 ===================================== testsuite/tests/partial-sigs/should_fail/T10999.stderr ===================================== @@ -1,6 +1,6 @@ T10999.hs:5:6: error: - • Found type wildcard ‘_’ standing for ‘Ord a’ + • Found extra-constraints wildcard standing for ‘Ord a’ Where: ‘a’ is a rigid type variable bound by the inferred type of f :: Ord a => () -> Set.Set a at T10999.hs:6:1-28 ===================================== testsuite/tests/partial-sigs/should_fail/T11515.stderr ===================================== @@ -1,5 +1,5 @@ T11515.hs:7:20: error: - • Found type wildcard ‘_’ standing for ‘()’ + • Found extra-constraints wildcard standing for ‘()’ To use the inferred type, enable PartialTypeSignatures • In the type signature: foo :: (ShowSyn a, _) => a -> String ===================================== testsuite/tests/partial-sigs/should_fail/WildcardInstantiations.stderr ===================================== @@ -8,7 +8,7 @@ WildcardInstantiations.hs:5:14: error: • In the type signature: foo :: (Show _a, _) => _a -> _ WildcardInstantiations.hs:5:18: error: - • Found type wildcard ‘_’ standing for ‘Enum a’ + • Found extra-constraints wildcard standing for ‘Enum a’ Where: ‘a’ is a rigid type variable bound by the inferred type of foo :: (Show a, Enum a) => a -> String at WildcardInstantiations.hs:6:1-21 ===================================== testsuite/tests/typecheck/should_compile/UnliftedNewtypesUnifySig.hs ===================================== @@ -20,4 +20,4 @@ data family D (a :: TYPE r) :: TYPE r newtype instance D a = MkWordD Word# newtype instance D a :: TYPE (KindOf a) where - MkIntD :: forall (a :: TYPE 'IntRep). Int# -> D a + MkIntD :: forall a. Int# -> D a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd5585dafd49f5fa35bc2d14a92c2c40c45c34a7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cd5585dafd49f5fa35bc2d14a92c2c40c45c34a7 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 02:56:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 22:56:37 -0400 Subject: [Git][ghc/ghc][wip/tsan/storage] 226 commits: Introduce OutputableP Message-ID: <5f9b80e58fa6f_8973fa31aff4cc01183365@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/storage at Glasgow Haskell Compiler / GHC Commits: ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - b9d4dd9c by Ben Gamari at 2020-10-24T20:44:17-04:00 SMP.h: Add C11-style atomic operations - - - - - ccf2d4b0 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Infrastructure for testing with ThreadSanitizer - - - - - a61f66d6 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/CNF: Initialize all bdescrs in group It seems wise and cheap to ensure that the whole bdescr of all blocks of a compact group is valid, even if most cases only look at the flags field. - - - - - 65136c13 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Capability: Intialize interrupt field Previously this was left uninitialized. Also clarify some comments. - - - - - b3ce6aca by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/Task: Make comments proper Notes - - - - - d3890ac7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/SpinLock: Move to proper atomics This is fairly straightforward; we just needed to use relaxed operations for the PROF_SPIN counters and a release store instead of a write barrier. - - - - - ef88712f by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/OSThreads: Fix data race Previously we would race on the cached processor count. Avoiding this is straightforward; just use relaxed operations. - - - - - 33a719c3 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts/ClosureMaros: Use relaxed atomics - - - - - f08951fd by Ben Gamari at 2020-10-24T20:59:39-04:00 configure: Bump minimum-supported gcc version to 4.7 Since the __atomic_* builtins are not supported until gcc 4.7. Given that this version was released in 2012 I think this is acceptable. - - - - - d584923a by Ben Gamari at 2020-10-24T20:59:39-04:00 testsuite: Fix thread leak in hs_try_putmvar00[13] - - - - - bf1b0bc7 by Ben Gamari at 2020-10-24T20:59:39-04:00 rts: Introduce SET_HDR_RELEASE Also ensure that we also store the info table pointer last to ensure that the synchronization covers all stores. - - - - - 1f4cbc29 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/BlockAlloc: Use relaxed operations - - - - - d0d07cff by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Rework handling of mutlist scavenging statistics - - - - - 9e5c7f6d by Ben Gamari at 2020-10-24T21:00:57-04:00 rts: Avoid data races in StablePtr implementation This fixes two potentially problematic data races in the StablePtr implementation: * We would fail to RELEASE the stable pointer table when enlarging it, causing other cores to potentially see uninitialized memory. * We would fail to ACQUIRE when dereferencing a stable pointer. - - - - - 316add67 by Ben Gamari at 2020-10-24T21:00:57-04:00 rts/Storage: Use atomics - - - - - 5c23bc4c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Updates: Use proper atomic operations - - - - - 3d0f033c by Ben Gamari at 2020-10-24T21:00:58-04:00 rts/Weak: Eliminate data races By taking all_tasks_mutex in stat_exit. Also better-document the fact that the task statistics are protected by all_tasks_mutex. - - - - - 24cfad4d by Ben Gamari at 2020-10-29T22:50:11-04:00 rts/GC: Use atomics - - - - - 1514f535 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - 57a1e976 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts/Storage: Accept races on heap size counters - - - - - 2a123034 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - 4aa10bd6 by GHC GitLab CI at 2020-10-29T22:50:11-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - bb03b660 by Ben Gamari at 2020-10-29T22:53:26-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - d208adc5 by Ben Gamari at 2020-10-29T22:55:15-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lexer.x The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65bfa4ebf5482f8b2a1386d872de3378ca5ee4e7...d208adc51bd64cde234c9f50c5d3d097c69b3032 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65bfa4ebf5482f8b2a1386d872de3378ca5ee4e7...d208adc51bd64cde234c9f50c5d3d097c69b3032 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 02:57:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 22:57:41 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 9 commits: rts/GC: Use atomics Message-ID: <5f9b8125aeeb9_8973fa3b8c0d474118399a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 24cfad4d by Ben Gamari at 2020-10-29T22:50:11-04:00 rts/GC: Use atomics - - - - - 1514f535 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - 57a1e976 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts/Storage: Accept races on heap size counters - - - - - 2a123034 by Ben Gamari at 2020-10-29T22:50:11-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - 4aa10bd6 by GHC GitLab CI at 2020-10-29T22:50:11-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - bb03b660 by Ben Gamari at 2020-10-29T22:53:26-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - d208adc5 by Ben Gamari at 2020-10-29T22:55:15-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 3cba8f31 by Ben Gamari at 2020-10-29T22:57:00-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr', 'wip/tsan/timer' and 'wip/tsan/stats' into wip/tsan/all - - - - - 81b14875 by Ben Gamari at 2020-10-29T22:57:04-04:00 testing - - - - - 30 changed files: - .gitlab-ci.yml - hadrian/src/Flavour.hs - includes/rts/OSThreads.h - includes/rts/SpinLock.h - includes/rts/StablePtr.h - includes/rts/TSANUtils.h - includes/rts/storage/Closures.h - includes/rts/storage/GC.h - includes/stg/SMP.h - libraries/base/GHC/Event/Control.hs - rts/.tsan-suppressions - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/Proftimer.c - rts/RaiseAsync.c - rts/RtsStartup.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.c - + rts/SpinLock.c - rts/StablePtr.c - rts/Task.c - rts/ThreadPaused.c - rts/Threads.c - rts/Timer.c - rts/Updates.h - rts/WSDeque.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/642f2ed0a68dc40abb9379e5c561c8c37d8ddfc4...81b148752f79523d25a94f1dae860d9476a608b5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/642f2ed0a68dc40abb9379e5c561c8c37d8ddfc4...81b148752f79523d25a94f1dae860d9476a608b5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 03:26:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Thu, 29 Oct 2020 23:26:35 -0400 Subject: [Git][ghc/ghc][wip/unloading] 102 commits: Use UnitId in the backend instead of Unit Message-ID: <5f9b87ebbbc4e_897a0021841187298@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - abf8ab4f by Ömer Sinan Ağacan at 2020-10-29T23:26:09-04:00 Fix and enable object unloading in GHCi Fixes #16525 See Note [Object unloading] in CheckUnload.c for details. - - - - - ce9c905a by Ray Shih at 2020-10-29T23:26:09-04:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - 64311343 by GHC GitLab CI at 2020-10-29T23:26:09-04:00 rts: Introduce highMemDynamic - - - - - e63e58f6 by GHC GitLab CI at 2020-10-29T23:26:09-04:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/Dataflow/Collections.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Monad.hs → compiler/GHC/Cmm/Parser/Monad.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG.hs - compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f5e9883ed189a7c4890dcf7a9661d810e1b0867...e63e58f6d29bc50bb602fa2797484b4fb9791e4b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6f5e9883ed189a7c4890dcf7a9661d810e1b0867...e63e58f6d29bc50bb602fa2797484b4fb9791e4b You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 04:19:56 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 00:19:56 -0400 Subject: [Git][ghc/ghc][wip/tsan/storage] 2 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9b946c30609_89782ea29012009b8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/storage at Glasgow Haskell Compiler / GHC Commits: 5cbad1f1 by Ben Gamari at 2020-10-30T00:19:50-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - eaa95417 by Ben Gamari at 2020-10-30T00:19:50-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 4 changed files: - includes/rts/SpinLock.h - includes/stg/SMP.h - + rts/SpinLock.c - rts/rts.cabal.in Changes: ===================================== includes/rts/SpinLock.h ===================================== @@ -39,19 +39,14 @@ typedef struct SpinLock_ #define IF_PROF_SPIN(x) #endif +void acquire_spin_lock_slow_path(SpinLock * p); + // acquire spin lock INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { - do { - for (uint32_t i = 0; i < SPIN_COUNT; i++) { - StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); - if (r != 0) return; - IF_PROF_SPIN(__atomic_fetch_add(&p->spin, 1, __ATOMIC_RELAXED)); - busy_wait_nop(); - } - IF_PROF_SPIN(__atomic_fetch_add(&p->yield, 1, __ATOMIC_RELAXED)); - yieldThread(); - } while (1); + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (RTS_UNLIKELY(r != 0)) + acquire_spin_lock_slow_path(p); } // release spin lock ===================================== includes/stg/SMP.h ===================================== @@ -440,6 +440,7 @@ load_load_barrier(void) { // Relaxed atomic operations. #define RELAXED_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_RELAXED) #define RELAXED_STORE(ptr,val) __atomic_store_n(ptr, val, __ATOMIC_RELAXED) +#define RELAXED_ADD(ptr,val) __atomic_add_fetch(ptr, val, __ATOMIC_RELAXED) // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_ACQUIRE) @@ -466,6 +467,7 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */ // Relaxed atomic operations #define RELAXED_LOAD(ptr) *ptr #define RELAXED_STORE(ptr,val) *ptr = val +#define RELAXED_ADD(ptr,val) *ptr += val // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) *ptr ===================================== rts/SpinLock.c ===================================== @@ -0,0 +1,36 @@ +/* ---------------------------------------------------------------------------- + * + * (c) The GHC Team, 2006-2009 + * + * Spin locks + * + * These are simple spin-only locks as opposed to Mutexes which + * probably spin for a while before blocking in the kernel. We use + * these when we are sure that all our threads are actively running on + * a CPU, eg. in the GC. + * + * TODO: measure whether we really need these, or whether Mutexes + * would do (and be a bit safer if a CPU becomes loaded). + * + * Do not #include this file directly: #include "Rts.h" instead. + * + * To understand the structure of the RTS headers, see the wiki: + * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes + * + * -------------------------------------------------------------------------- */ + +#include "Rts.h" + +void acquire_spin_lock_slow_path(SpinLock * p) +{ + do { + for (uint32_t i = 0; i < SPIN_COUNT; i++) { + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (r != 0) return; + IF_PROF_SPIN(RELAXED_ADD(&p->spin, 1)); + busy_wait_nop(); + } + IF_PROF_SPIN(RELAXED_ADD(&p->yield, 1)); + yieldThread(); + } while (1); +} ===================================== rts/rts.cabal.in ===================================== @@ -462,6 +462,7 @@ library STM.c Schedule.c Sparks.c + SpinLock.c StableName.c StablePtr.c StaticPtrTable.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d208adc51bd64cde234c9f50c5d3d097c69b3032...eaa95417b69729783995c4ebd36b1537d75e0fff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d208adc51bd64cde234c9f50c5d3d097c69b3032...eaa95417b69729783995c4ebd36b1537d75e0fff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 04:20:18 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 00:20:18 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 3 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9b94828706b_89782ea29012015e@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 5cbad1f1 by Ben Gamari at 2020-10-30T00:19:50-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - eaa95417 by Ben Gamari at 2020-10-30T00:19:50-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 3e12241c by Ben Gamari at 2020-10-30T00:20:09-04:00 Merge branch 'wip/tsan/storage' into wip/tsan/all - - - - - 1 changed file: - rts/rts.cabal.in Changes: ===================================== rts/rts.cabal.in ===================================== @@ -462,6 +462,7 @@ library STM.c Schedule.c Sparks.c + SpinLock.c StableName.c StablePtr.c StaticPtrTable.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81b148752f79523d25a94f1dae860d9476a608b5...3e12241cf5bdf1824fb4d84d3cb66d56518f2e71 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81b148752f79523d25a94f1dae860d9476a608b5...3e12241cf5bdf1824fb4d84d3cb66d56518f2e71 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 04:41:28 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 00:41:28 -0400 Subject: [Git][ghc/ghc][wip/tsan/storage] 7 commits: rts/GC: Use atomics Message-ID: <5f9b997882a6c_897cb00c8c1202126@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/storage at Glasgow Haskell Compiler / GHC Commits: aad1f803 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/GC: Use atomics - - - - - d0bc0517 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - d44f5232 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/Storage: Accept races on heap size counters - - - - - 4e4a7386 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - a80cc857 by GHC GitLab CI at 2020-10-30T00:41:14-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - 7dcd5f53 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - 96f8bde7 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 21 changed files: - includes/rts/OSThreads.h - includes/rts/SpinLock.h - includes/rts/storage/GC.h - includes/stg/SMP.h - rts/Capability.h - rts/SMPClosureOps.h - rts/Schedule.c - + rts/SpinLock.c - rts/posix/OSThreads.c - rts/rts.cabal.in - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GCAux.c - rts/sm/GCUtils.c - rts/sm/GCUtils.h - rts/sm/MarkWeak.c - rts/sm/NonMoving.c - rts/sm/Scav.c - rts/sm/Storage.c - rts/sm/Storage.h - rts/win32/OSThreads.c Changes: ===================================== includes/rts/OSThreads.h ===================================== @@ -164,7 +164,8 @@ typedef void* OSThreadProcAttr OSThreadProc(void *); extern int createOSThread ( OSThreadId* tid, char *name, OSThreadProc *startProc, void *param); extern bool osThreadIsAlive ( OSThreadId id ); -extern void interruptOSThread (OSThreadId id); +extern void interruptOSThread ( OSThreadId id ); +extern void joinOSThread ( OSThreadId id ); // // Condition Variables ===================================== includes/rts/SpinLock.h ===================================== @@ -39,19 +39,14 @@ typedef struct SpinLock_ #define IF_PROF_SPIN(x) #endif +void acquire_spin_lock_slow_path(SpinLock * p); + // acquire spin lock INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { - do { - for (uint32_t i = 0; i < SPIN_COUNT; i++) { - StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); - if (r != 0) return; - IF_PROF_SPIN(__atomic_fetch_add(&p->spin, 1, __ATOMIC_RELAXED)); - busy_wait_nop(); - } - IF_PROF_SPIN(__atomic_fetch_add(&p->yield, 1, __ATOMIC_RELAXED)); - yieldThread(); - } while (1); + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (RTS_UNLIKELY(r != 0)) + acquire_spin_lock_slow_path(p); } // release spin lock ===================================== includes/rts/storage/GC.h ===================================== @@ -247,9 +247,9 @@ extern bool keepCAFs; INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest) { - bd->gen = gen; - bd->gen_no = gen->no; - bd->dest_no = dest->no; + RELAXED_STORE(&bd->gen, gen); + RELAXED_STORE(&bd->gen_no, gen->no); + RELAXED_STORE(&bd->dest_no, dest->no); #if !IN_STG_CODE /* See Note [RtsFlags is a pointer in STG code] */ ===================================== includes/stg/SMP.h ===================================== @@ -440,6 +440,7 @@ load_load_barrier(void) { // Relaxed atomic operations. #define RELAXED_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_RELAXED) #define RELAXED_STORE(ptr,val) __atomic_store_n(ptr, val, __ATOMIC_RELAXED) +#define RELAXED_ADD(ptr,val) __atomic_add_fetch(ptr, val, __ATOMIC_RELAXED) // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_ACQUIRE) @@ -466,6 +467,7 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */ // Relaxed atomic operations #define RELAXED_LOAD(ptr) *ptr #define RELAXED_STORE(ptr,val) *ptr = val +#define RELAXED_ADD(ptr,val) *ptr += val // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) *ptr ===================================== rts/Capability.h ===================================== @@ -419,14 +419,16 @@ recordMutableCap (const StgClosure *p, Capability *cap, uint32_t gen) // ASSERT(cap->running_task == myTask()); // NO: assertion is violated by performPendingThrowTos() bd = cap->mut_lists[gen]; - if (bd->free >= bd->start + BLOCK_SIZE_W) { + if (RELAXED_LOAD(&bd->free) >= bd->start + BLOCK_SIZE_W) { bdescr *new_bd; new_bd = allocBlockOnNode_lock(cap->node); new_bd->link = bd; + new_bd->free = new_bd->start; bd = new_bd; cap->mut_lists[gen] = bd; } - *bd->free++ = (StgWord)p; + RELAXED_STORE(bd->free, (StgWord) p); + NONATOMIC_ADD(&bd->free, 1); } EXTERN_INLINE void ===================================== rts/SMPClosureOps.h ===================================== @@ -119,9 +119,8 @@ tryLockClosure(StgClosure *p) EXTERN_INLINE void unlockClosure(StgClosure *p, const StgInfoTable *info) { - // This is a strictly ordered write, so we need a write_barrier(): - write_barrier(); - p->header.info = info; + // This is a strictly ordered write, so we need a RELEASE ordering. + RELEASE_STORE(&p->header.info, info); } #endif /* CMINUSMINUS */ ===================================== rts/Schedule.c ===================================== @@ -433,7 +433,7 @@ run_thread: cap->interrupt = 0; cap->in_haskell = true; - cap->idle = 0; + RELAXED_STORE(&cap->idle, false); dirty_TSO(cap,t); dirty_STACK(cap,t->stackobj); @@ -1780,7 +1780,7 @@ scheduleDoGC (Capability **pcap, Task *task USED_IF_THREADS, debugTrace(DEBUG_sched, "%d idle caps", n_idle_caps); for (i=0; i < n_capabilities; i++) { - capabilities[i]->idle++; + NONATOMIC_ADD(&capabilities[i]->idle, 1); } // For all capabilities participating in this GC, wait until ===================================== rts/SpinLock.c ===================================== @@ -0,0 +1,36 @@ +/* ---------------------------------------------------------------------------- + * + * (c) The GHC Team, 2006-2009 + * + * Spin locks + * + * These are simple spin-only locks as opposed to Mutexes which + * probably spin for a while before blocking in the kernel. We use + * these when we are sure that all our threads are actively running on + * a CPU, eg. in the GC. + * + * TODO: measure whether we really need these, or whether Mutexes + * would do (and be a bit safer if a CPU becomes loaded). + * + * Do not #include this file directly: #include "Rts.h" instead. + * + * To understand the structure of the RTS headers, see the wiki: + * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes + * + * -------------------------------------------------------------------------- */ + +#include "Rts.h" + +void acquire_spin_lock_slow_path(SpinLock * p) +{ + do { + for (uint32_t i = 0; i < SPIN_COUNT; i++) { + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (r != 0) return; + IF_PROF_SPIN(RELAXED_ADD(&p->spin, 1)); + busy_wait_nop(); + } + IF_PROF_SPIN(RELAXED_ADD(&p->yield, 1)); + yieldThread(); + } while (1); +} ===================================== rts/posix/OSThreads.c ===================================== @@ -398,6 +398,14 @@ interruptOSThread (OSThreadId id) pthread_kill(id, SIGPIPE); } +void +joinOSThread (OSThreadId id) +{ + if (pthread_join(id, NULL) != 0) { + sysErrorBelch("joinOSThread: error %d", errno); + } +} + KernelThreadId kernelThreadId (void) { #if defined(linux_HOST_OS) ===================================== rts/rts.cabal.in ===================================== @@ -462,6 +462,7 @@ library STM.c Schedule.c Sparks.c + SpinLock.c StableName.c StablePtr.c StaticPtrTable.c ===================================== rts/sm/Evac.c ===================================== @@ -171,7 +171,11 @@ copy_tag(StgClosure **p, const StgInfoTable *info, #endif return evacuate(p); // does the failed_to_evac stuff } else { - *p = TAG_CLOSURE(tag,(StgClosure*)to); + // This doesn't need to have RELEASE ordering since we are guaranteed + // to scavenge the to-space object on the current core therefore + // no-one else will follow this pointer (FIXME: Is this true in + // light of the selector optimization?). + RELEASE_STORE(p, TAG_CLOSURE(tag,(StgClosure*)to)); } } #else @@ -206,9 +210,9 @@ copy_tag_nolock(StgClosure **p, const StgInfoTable *info, // if somebody else reads the forwarding pointer, we better make // sure there's a closure at the end of it. - write_barrier(); - *p = TAG_CLOSURE(tag,(StgClosure*)to); - src->header.info = (const StgInfoTable *)MK_FORWARDING_PTR(to); + RELEASE_STORE(p, TAG_CLOSURE(tag,(StgClosure*)to)); + RELEASE_STORE(&src->header.info, \ + (const StgInfoTable *)MK_FORWARDING_PTR(to)); // if (to+size+2 < bd->start + BLOCK_SIZE_W) { // __builtin_prefetch(to + size + 2, 1); @@ -245,7 +249,7 @@ spin: goto spin; } if (IS_FORWARDING_PTR(info)) { - src->header.info = (const StgInfoTable *)info; + RELEASE_STORE(&src->header.info, (const StgInfoTable *)info); evacuate(p); // does the failed_to_evac stuff return false; } @@ -261,9 +265,8 @@ spin: to[i] = from[i]; } - write_barrier(); - *p = (StgClosure *)to; - src->header.info = (const StgInfoTable*)MK_FORWARDING_PTR(to); + RELEASE_STORE(p, (StgClosure *) to); + RELEASE_STORE(&src->header.info, (const StgInfoTable*)MK_FORWARDING_PTR(to)); #if defined(PROFILING) // We store the size of the just evacuated object in the LDV word so that @@ -306,12 +309,12 @@ evacuate_large(StgPtr p) gen_workspace *ws; bd = Bdescr(p); - gen = bd->gen; - gen_no = bd->gen_no; + gen = RELAXED_LOAD(&bd->gen); + gen_no = RELAXED_LOAD(&bd->gen_no); ACQUIRE_SPIN_LOCK(&gen->sync); // already evacuated? - if (bd->flags & BF_EVACUATED) { + if (RELAXED_LOAD(&bd->flags) & BF_EVACUATED) { /* Don't forget to set the gct->failed_to_evac flag if we didn't get * the desired destination (see comments in evacuate()). */ @@ -344,9 +347,9 @@ evacuate_large(StgPtr p) ws = &gct->gens[new_gen_no]; new_gen = &generations[new_gen_no]; - bd->flags |= BF_EVACUATED; + __atomic_fetch_or(&bd->flags, BF_EVACUATED, __ATOMIC_ACQ_REL); if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving && new_gen == oldest_gen)) { - bd->flags |= BF_NONMOVING; + __atomic_fetch_or(&bd->flags, BF_NONMOVING, __ATOMIC_ACQ_REL); } initBdescr(bd, new_gen, new_gen->to); @@ -354,7 +357,7 @@ evacuate_large(StgPtr p) // these objects, because they aren't allowed to contain any outgoing // pointers. For these blocks, we skip the scavenge stage and put // them straight on the scavenged_large_objects list. - if (bd->flags & BF_PINNED) { + if (RELAXED_LOAD(&bd->flags) & BF_PINNED) { ASSERT(get_itbl((StgClosure *)p)->type == ARR_WORDS); if (new_gen != gen) { ACQUIRE_SPIN_LOCK(&new_gen->sync); } @@ -389,7 +392,7 @@ evacuate_static_object (StgClosure **link_field, StgClosure *q) return; } - StgWord link = (StgWord)*link_field; + StgWord link = RELAXED_LOAD((StgWord*) link_field); // See Note [STATIC_LINK fields] for how the link field bits work if (((link & STATIC_BITS) | prev_static_flag) != 3) { @@ -435,7 +438,7 @@ evacuate_compact (StgPtr p) bd = Bdescr((StgPtr)str); gen_no = bd->gen_no; - if (bd->flags & BF_NONMOVING) { + if (RELAXED_LOAD(&bd->flags) & BF_NONMOVING) { // We may have evacuated the block to the nonmoving generation. If so // we need to make sure it is added to the mark queue since the only // reference to it may be from the moving heap. @@ -500,7 +503,7 @@ evacuate_compact (StgPtr p) // in the GC, and that should never see blocks other than the first) bd->flags |= BF_EVACUATED; if (RTS_UNLIKELY(RtsFlags.GcFlags.useNonmoving && new_gen == oldest_gen)) { - bd->flags |= BF_NONMOVING; + __atomic_fetch_or(&bd->flags, BF_NONMOVING, __ATOMIC_RELAXED); } initBdescr(bd, new_gen, new_gen->to); @@ -581,7 +584,7 @@ evacuate(StgClosure **p) const StgInfoTable *info; StgWord tag; - q = *p; + q = RELAXED_LOAD(p); loop: /* The tag and the pointer are split, to be merged after evacing */ @@ -638,10 +641,11 @@ loop: bd = Bdescr((P_)q); - if ((bd->flags & (BF_LARGE | BF_MARKED | BF_EVACUATED | BF_COMPACT | BF_NONMOVING)) != 0) { + uint16_t flags = RELAXED_LOAD(&bd->flags); + if ((flags & (BF_LARGE | BF_MARKED | BF_EVACUATED | BF_COMPACT | BF_NONMOVING)) != 0) { // Pointer to non-moving heap. Non-moving heap is collected using // mark-sweep so this object should be marked and then retained in sweep. - if (RTS_UNLIKELY(bd->flags & BF_NONMOVING)) { + if (RTS_UNLIKELY(RELAXED_LOAD(&bd->flags) & BF_NONMOVING)) { // NOTE: large objects in nonmoving heap are also marked with // BF_NONMOVING. Those are moved to scavenged_large_objects list in // mark phase. @@ -656,11 +660,11 @@ loop: // happen often, but allowing it makes certain things a bit // easier; e.g. scavenging an object is idempotent, so it's OK to // have an object on the mutable list multiple times. - if (bd->flags & BF_EVACUATED) { + if (flags & BF_EVACUATED) { // We aren't copying this object, so we have to check // whether it is already in the target generation. (this is // the write barrier). - if (bd->gen_no < gct->evac_gen_no) { + if (RELAXED_LOAD(&bd->gen_no) < gct->evac_gen_no) { gct->failed_to_evac = true; TICK_GC_FAILED_PROMOTION(); } @@ -671,20 +675,20 @@ loop: // right thing for objects that are half way in the middle of the first // block of a compact (and would be treated as large objects even though // they are not) - if (bd->flags & BF_COMPACT) { + if (flags & BF_COMPACT) { evacuate_compact((P_)q); return; } /* evacuate large objects by re-linking them onto a different list. */ - if (bd->flags & BF_LARGE) { + if (flags & BF_LARGE) { evacuate_large((P_)q); // We may have evacuated the block to the nonmoving generation. If so // we need to make sure it is added to the mark queue since the only // reference to it may be from the moving heap. - if (major_gc && bd->flags & BF_NONMOVING && !deadlock_detect_gc) { + if (major_gc && flags & BF_NONMOVING && !deadlock_detect_gc) { markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, q); } return; @@ -702,7 +706,7 @@ loop: gen_no = bd->dest_no; - info = q->header.info; + info = ACQUIRE_LOAD(&q->header.info); if (IS_FORWARDING_PTR(info)) { /* Already evacuated, just return the forwarding address. @@ -722,9 +726,12 @@ loop: * check if gen is too low. */ StgClosure *e = (StgClosure*)UN_FORWARDING_PTR(info); - *p = TAG_CLOSURE(tag,e); + RELAXED_STORE(p, TAG_CLOSURE(tag,e)); if (gen_no < gct->evac_gen_no) { // optimisation - if (Bdescr((P_)e)->gen_no < gct->evac_gen_no) { + // The ACQUIRE here is necessary to ensure that we see gen_no if the + // evacuted object lives in a block newly-allocated by a GC thread on + // another core. + if (ACQUIRE_LOAD(&Bdescr((P_)e)->gen_no) < gct->evac_gen_no) { gct->failed_to_evac = true; TICK_GC_FAILED_PROMOTION(); } @@ -752,15 +759,17 @@ loop: if (info == Czh_con_info && // unsigned, so always true: (StgChar)w >= MIN_CHARLIKE && (StgChar)w <= MAX_CHARLIKE) { - *p = TAG_CLOSURE(tag, - (StgClosure *)CHARLIKE_CLOSURE((StgChar)w) - ); + RELAXED_STORE(p, \ + TAG_CLOSURE(tag, \ + (StgClosure *)CHARLIKE_CLOSURE((StgChar)w) + )); } else if (info == Izh_con_info && (StgInt)w >= MIN_INTLIKE && (StgInt)w <= MAX_INTLIKE) { - *p = TAG_CLOSURE(tag, - (StgClosure *)INTLIKE_CLOSURE((StgInt)w) - ); + RELAXED_STORE(p, \ + TAG_CLOSURE(tag, \ + (StgClosure *)INTLIKE_CLOSURE((StgInt)w) + )); } else { copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag); @@ -814,10 +823,10 @@ loop: const StgInfoTable *i; r = ((StgInd*)q)->indirectee; if (GET_CLOSURE_TAG(r) == 0) { - i = r->header.info; + i = ACQUIRE_LOAD(&r->header.info); if (IS_FORWARDING_PTR(i)) { r = (StgClosure *)UN_FORWARDING_PTR(i); - i = r->header.info; + i = ACQUIRE_LOAD(&r->header.info); } if (i == &stg_TSO_info || i == &stg_WHITEHOLE_info @@ -842,7 +851,7 @@ loop: ASSERT(i != &stg_IND_info); } q = r; - *p = r; + RELEASE_STORE(p, r); goto loop; } @@ -868,8 +877,8 @@ loop: case IND: // follow chains of indirections, don't evacuate them - q = ((StgInd*)q)->indirectee; - *p = q; + q = RELAXED_LOAD(&((StgInd*)q)->indirectee); + RELAXED_STORE(p, q); goto loop; case RET_BCO: @@ -983,11 +992,12 @@ evacuate_BLACKHOLE(StgClosure **p) ASSERT(GET_CLOSURE_TAG(q) == 0); bd = Bdescr((P_)q); + const uint16_t flags = RELAXED_LOAD(&bd->flags); // blackholes can't be in a compact - ASSERT((bd->flags & BF_COMPACT) == 0); + ASSERT((flags & BF_COMPACT) == 0); - if (RTS_UNLIKELY(bd->flags & BF_NONMOVING)) { + if (RTS_UNLIKELY(RELAXED_LOAD(&bd->flags) & BF_NONMOVING)) { if (major_gc && !deadlock_detect_gc) markQueuePushClosureGC(&gct->cap->upd_rem_set.queue, q); return; @@ -996,18 +1006,18 @@ evacuate_BLACKHOLE(StgClosure **p) // blackholes *can* be in a large object: when raiseAsync() creates an // AP_STACK the payload might be large enough to create a large object. // See #14497. - if (bd->flags & BF_LARGE) { + if (flags & BF_LARGE) { evacuate_large((P_)q); return; } - if (bd->flags & BF_EVACUATED) { + if (flags & BF_EVACUATED) { if (bd->gen_no < gct->evac_gen_no) { gct->failed_to_evac = true; TICK_GC_FAILED_PROMOTION(); } return; } - if (bd->flags & BF_MARKED) { + if (flags & BF_MARKED) { if (!is_marked((P_)q,bd)) { mark((P_)q,bd); push_mark_stack((P_)q); @@ -1015,13 +1025,13 @@ evacuate_BLACKHOLE(StgClosure **p) return; } gen_no = bd->dest_no; - info = q->header.info; + info = ACQUIRE_LOAD(&q->header.info); if (IS_FORWARDING_PTR(info)) { StgClosure *e = (StgClosure*)UN_FORWARDING_PTR(info); *p = e; if (gen_no < gct->evac_gen_no) { // optimisation - if (Bdescr((P_)e)->gen_no < gct->evac_gen_no) { + if (ACQUIRE_LOAD(&Bdescr((P_)e)->gen_no) < gct->evac_gen_no) { gct->failed_to_evac = true; TICK_GC_FAILED_PROMOTION(); } @@ -1090,13 +1100,11 @@ unchain_thunk_selectors(StgSelector *p, StgClosure *val) // XXX we do not have BLACKHOLEs any more; replace with // a THUNK_SELECTOR again. This will go into a loop if it is // entered, and should result in a NonTermination exception. - ((StgThunk *)p)->payload[0] = val; - write_barrier(); - SET_INFO((StgClosure *)p, &stg_sel_0_upd_info); + RELAXED_STORE(&((StgThunk *)p)->payload[0], val); + SET_INFO_RELEASE((StgClosure *)p, &stg_sel_0_upd_info); } else { - ((StgInd *)p)->indirectee = val; - write_barrier(); - SET_INFO((StgClosure *)p, &stg_IND_info); + RELAXED_STORE(&((StgInd *)p)->indirectee, val); + SET_INFO_RELEASE((StgClosure *)p, &stg_IND_info); } // For the purposes of LDV profiling, we have created an @@ -1143,7 +1151,7 @@ selector_chain: // save any space in any case, and updating with an indirection is // trickier in a non-collected gen: we would have to update the // mutable list. - if (bd->flags & (BF_EVACUATED | BF_NONMOVING)) { + if (RELAXED_LOAD(&bd->flags) & (BF_EVACUATED | BF_NONMOVING)) { unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); *q = (StgClosure *)p; // shortcut, behave as for: if (evac) evacuate(q); @@ -1198,8 +1206,7 @@ selector_chain: // need the write-barrier stuff. // - undo the chain we've built to point to p. SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr); - write_barrier(); - *q = (StgClosure *)p; + RELEASE_STORE(q, (StgClosure *) p); if (evac) evacuate(q); unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p); return; @@ -1225,7 +1232,7 @@ selector_loop: // from-space during marking, for example. We rely on the property // that evacuate() doesn't mind if it gets passed a to-space pointer. - info = (StgInfoTable*)selectee->header.info; + info = RELAXED_LOAD((StgInfoTable**) &selectee->header.info); if (IS_FORWARDING_PTR(info)) { // We don't follow pointers into to-space; the constructor @@ -1252,7 +1259,7 @@ selector_loop: info->layout.payload.nptrs)); // Select the right field from the constructor - StgClosure *val = selectee->payload[field]; + StgClosure *val = RELAXED_LOAD(&selectee->payload[field]); #if defined(PROFILING) // For the purposes of LDV profiling, we have destroyed @@ -1278,19 +1285,19 @@ selector_loop: // evaluating until we find the real value, and then // update the whole chain to point to the value. val_loop: - info_ptr = (StgWord)UNTAG_CLOSURE(val)->header.info; + info_ptr = ACQUIRE_LOAD((StgWord*) &UNTAG_CLOSURE(val)->header.info); if (!IS_FORWARDING_PTR(info_ptr)) { info = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr); switch (info->type) { case IND: case IND_STATIC: - val = ((StgInd *)val)->indirectee; + val = RELAXED_LOAD(&((StgInd *)val)->indirectee); goto val_loop; case THUNK_SELECTOR: // Use payload to make a list of thunk selectors, to be // used in unchain_thunk_selectors - ((StgClosure*)p)->payload[0] = (StgClosure *)prev_thunk_selector; + RELAXED_STORE(&((StgClosure*)p)->payload[0], (StgClosure *)prev_thunk_selector); prev_thunk_selector = p; p = (StgSelector*)val; goto selector_chain; @@ -1298,7 +1305,7 @@ selector_loop: break; } } - ((StgClosure*)p)->payload[0] = (StgClosure *)prev_thunk_selector; + RELAXED_STORE(&((StgClosure*)p)->payload[0], (StgClosure *)prev_thunk_selector); prev_thunk_selector = p; *q = val; @@ -1320,22 +1327,22 @@ selector_loop: case IND: case IND_STATIC: // Again, we might need to untag a constructor. - selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); + selectee = UNTAG_CLOSURE( RELAXED_LOAD(&((StgInd *)selectee)->indirectee) ); goto selector_loop; case BLACKHOLE: { StgClosure *r; const StgInfoTable *i; - r = ((StgInd*)selectee)->indirectee; + r = ACQUIRE_LOAD(&((StgInd*)selectee)->indirectee); // establish whether this BH has been updated, and is now an // indirection, as in evacuate(). if (GET_CLOSURE_TAG(r) == 0) { - i = r->header.info; + i = ACQUIRE_LOAD(&r->header.info); if (IS_FORWARDING_PTR(i)) { r = (StgClosure *)UN_FORWARDING_PTR(i); - i = r->header.info; + i = RELAXED_LOAD(&r->header.info); } if (i == &stg_TSO_info || i == &stg_WHITEHOLE_info @@ -1346,7 +1353,7 @@ selector_loop: ASSERT(i != &stg_IND_info); } - selectee = UNTAG_CLOSURE( ((StgInd *)selectee)->indirectee ); + selectee = UNTAG_CLOSURE( RELAXED_LOAD(&((StgInd *)selectee)->indirectee) ); goto selector_loop; } ===================================== rts/sm/GC.c ===================================== @@ -537,37 +537,37 @@ GarbageCollect (uint32_t collect_gen, const gc_thread* thread; for (i=0; i < n_gc_threads; i++) { - copied += gc_threads[i]->copied; + copied += RELAXED_LOAD(&gc_threads[i]->copied); } for (i=0; i < n_gc_threads; i++) { thread = gc_threads[i]; if (n_gc_threads > 1) { debugTrace(DEBUG_gc,"thread %d:", i); debugTrace(DEBUG_gc," copied %ld", - thread->copied * sizeof(W_)); + RELAXED_LOAD(&thread->copied) * sizeof(W_)); debugTrace(DEBUG_gc," scanned %ld", - thread->scanned * sizeof(W_)); + RELAXED_LOAD(&thread->scanned) * sizeof(W_)); debugTrace(DEBUG_gc," any_work %ld", - thread->any_work); + RELAXED_LOAD(&thread->any_work)); debugTrace(DEBUG_gc," no_work %ld", - thread->no_work); + RELAXED_LOAD(&thread->no_work)); debugTrace(DEBUG_gc," scav_find_work %ld", - thread->scav_find_work); + RELAXED_LOAD(&thread->scav_find_work)); #if defined(THREADED_RTS) && defined(PROF_SPIN) - gc_spin_spin += thread->gc_spin.spin; - gc_spin_yield += thread->gc_spin.yield; - mut_spin_spin += thread->mut_spin.spin; - mut_spin_yield += thread->mut_spin.yield; + gc_spin_spin += RELAXED_LOAD(&thread->gc_spin.spin); + gc_spin_yield += RELAXED_LOAD(&thread->gc_spin.yield); + mut_spin_spin += RELAXED_LOAD(&thread->mut_spin.spin); + mut_spin_yield += RELAXED_LOAD(&thread->mut_spin.yield); #endif - any_work += thread->any_work; - no_work += thread->no_work; - scav_find_work += thread->scav_find_work; + any_work += RELAXED_LOAD(&thread->any_work); + no_work += RELAXED_LOAD(&thread->no_work); + scav_find_work += RELAXED_LOAD(&thread->scav_find_work); - par_max_copied = stg_max(gc_threads[i]->copied, par_max_copied); + par_max_copied = stg_max(RELAXED_LOAD(&thread->copied), par_max_copied); par_balanced_copied_acc += - stg_min(n_gc_threads * gc_threads[i]->copied, copied); + stg_min(n_gc_threads * RELAXED_LOAD(&thread->copied), copied); } } if (n_gc_threads > 1) { @@ -1130,7 +1130,7 @@ inc_running (void) static StgWord dec_running (void) { - ASSERT(gc_running_threads != 0); + ASSERT(RELAXED_LOAD(&gc_running_threads) != 0); return atomic_dec(&gc_running_threads); } @@ -1140,7 +1140,7 @@ any_work (void) int g; gen_workspace *ws; - gct->any_work++; + NONATOMIC_ADD(&gct->any_work, 1); write_barrier(); @@ -1173,7 +1173,7 @@ any_work (void) } #endif - gct->no_work++; + __atomic_fetch_add(&gct->no_work, 1, __ATOMIC_RELAXED); #if defined(THREADED_RTS) yieldThread(); #endif @@ -1214,7 +1214,7 @@ loop: debugTrace(DEBUG_gc, "%d GC threads still running", r); - while (gc_running_threads != 0) { + while (SEQ_CST_LOAD(&gc_running_threads) != 0) { // usleep(1); if (any_work()) { inc_running(); @@ -1251,7 +1251,7 @@ gcWorkerThread (Capability *cap) // measurements more accurate on Linux, perhaps because it syncs // the CPU time across the multiple cores. Without this, CPU time // is heavily skewed towards GC rather than MUT. - gct->wakeup = GC_THREAD_STANDING_BY; + SEQ_CST_STORE(&gct->wakeup, GC_THREAD_STANDING_BY); debugTrace(DEBUG_gc, "GC thread %d standing by...", gct->thread_index); ACQUIRE_SPIN_LOCK(&gct->gc_spin); @@ -1278,10 +1278,13 @@ gcWorkerThread (Capability *cap) // Wait until we're told to continue RELEASE_SPIN_LOCK(&gct->gc_spin); - gct->wakeup = GC_THREAD_WAITING_TO_CONTINUE; debugTrace(DEBUG_gc, "GC thread %d waiting to continue...", gct->thread_index); stat_endGCWorker (cap, gct); + // This must come *after* stat_endGCWorker since it serves to + // synchronize us with the GC leader, which will later aggregate the + // GC statistics. + SEQ_CST_STORE(&gct->wakeup, GC_THREAD_WAITING_TO_CONTINUE); ACQUIRE_SPIN_LOCK(&gct->mut_spin); debugTrace(DEBUG_gc, "GC thread %d on my way...", gct->thread_index); @@ -1306,7 +1309,7 @@ waitForGcThreads (Capability *cap USED_IF_THREADS, bool idle_cap[]) while(retry) { for (i=0; i < n_threads; i++) { if (i == me || idle_cap[i]) continue; - if (gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) { + if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_STANDING_BY) { prodCapability(capabilities[i], cap->running_task); } } @@ -1316,7 +1319,7 @@ waitForGcThreads (Capability *cap USED_IF_THREADS, bool idle_cap[]) if (i == me || idle_cap[i]) continue; write_barrier(); interruptCapability(capabilities[i]); - if (gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) { + if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_STANDING_BY) { retry = true; } } @@ -1373,10 +1376,10 @@ wakeup_gc_threads (uint32_t me USED_IF_THREADS, if (i == me || idle_cap[i]) continue; inc_running(); debugTrace(DEBUG_gc, "waking up gc thread %d", i); - if (gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) + if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_STANDING_BY) barf("wakeup_gc_threads"); - gc_threads[i]->wakeup = GC_THREAD_RUNNING; + SEQ_CST_STORE(&gc_threads[i]->wakeup, GC_THREAD_RUNNING); ACQUIRE_SPIN_LOCK(&gc_threads[i]->mut_spin); RELEASE_SPIN_LOCK(&gc_threads[i]->gc_spin); } @@ -1397,9 +1400,8 @@ shutdown_gc_threads (uint32_t me USED_IF_THREADS, for (i=0; i < n_gc_threads; i++) { if (i == me || idle_cap[i]) continue; - while (gc_threads[i]->wakeup != GC_THREAD_WAITING_TO_CONTINUE) { + while (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE) { busy_wait_nop(); - write_barrier(); } } #endif @@ -1414,10 +1416,10 @@ releaseGCThreads (Capability *cap USED_IF_THREADS, bool idle_cap[]) uint32_t i; for (i=0; i < n_threads; i++) { if (i == me || idle_cap[i]) continue; - if (gc_threads[i]->wakeup != GC_THREAD_WAITING_TO_CONTINUE) + if (RELAXED_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE) barf("releaseGCThreads"); - gc_threads[i]->wakeup = GC_THREAD_INACTIVE; + RELAXED_STORE(&gc_threads[i]->wakeup, GC_THREAD_INACTIVE); ACQUIRE_SPIN_LOCK(&gc_threads[i]->gc_spin); RELEASE_SPIN_LOCK(&gc_threads[i]->mut_spin); } @@ -1433,7 +1435,7 @@ static void stash_mut_list (Capability *cap, uint32_t gen_no) { cap->saved_mut_lists[gen_no] = cap->mut_lists[gen_no]; - cap->mut_lists[gen_no] = allocBlockOnNode_sync(cap->node); + RELEASE_STORE(&cap->mut_lists[gen_no], allocBlockOnNode_sync(cap->node)); } /* ---------------------------------------------------------------------------- @@ -1459,9 +1461,11 @@ prepare_collected_gen (generation *gen) // mutable list always has at least one block; this means we can avoid // a check for NULL in recordMutable(). for (i = 0; i < n_capabilities; i++) { - freeChain(capabilities[i]->mut_lists[g]); - capabilities[i]->mut_lists[g] = - allocBlockOnNode(capNoToNumaNode(i)); + bdescr *old = RELAXED_LOAD(&capabilities[i]->mut_lists[g]); + freeChain(old); + + bdescr *new = allocBlockOnNode(capNoToNumaNode(i)); + RELAXED_STORE(&capabilities[i]->mut_lists[g], new); } } @@ -1675,7 +1679,7 @@ collect_pinned_object_blocks (void) bdescr *last = NULL; if (use_nonmoving && gen == oldest_gen) { // Mark objects as belonging to the nonmoving heap - for (bdescr *bd = capabilities[n]->pinned_object_blocks; bd != NULL; bd = bd->link) { + for (bdescr *bd = RELAXED_LOAD(&capabilities[n]->pinned_object_blocks); bd != NULL; bd = bd->link) { bd->flags |= BF_NONMOVING; bd->gen = oldest_gen; bd->gen_no = oldest_gen->no; @@ -1694,8 +1698,8 @@ collect_pinned_object_blocks (void) if (gen->large_objects != NULL) { gen->large_objects->u.back = last; } - gen->large_objects = capabilities[n]->pinned_object_blocks; - capabilities[n]->pinned_object_blocks = NULL; + g0->large_objects = RELAXED_LOAD(&capabilities[n]->pinned_object_blocks); + RELAXED_STORE(&capabilities[n]->pinned_object_blocks, NULL); } } } ===================================== rts/sm/GCAux.c ===================================== @@ -83,7 +83,7 @@ isAlive(StgClosure *p) return p; } - info = q->header.info; + info = RELAXED_LOAD(&q->header.info); if (IS_FORWARDING_PTR(info)) { // alive! ===================================== rts/sm/GCUtils.c ===================================== @@ -249,8 +249,8 @@ todo_block_full (uint32_t size, gen_workspace *ws) return p; } - gct->copied += ws->todo_free - bd->free; - bd->free = ws->todo_free; + gct->copied += ws->todo_free - RELAXED_LOAD(&bd->free); + RELAXED_STORE(&bd->free, ws->todo_free); ASSERT(bd->u.scan >= bd->start && bd->u.scan <= bd->free); @@ -330,10 +330,11 @@ alloc_todo_block (gen_workspace *ws, uint32_t size) gct->free_blocks = bd->link; } } - // blocks in to-space get the BF_EVACUATED flag. - bd->flags = BF_EVACUATED; - bd->u.scan = bd->start; initBdescr(bd, ws->gen, ws->gen->to); + RELAXED_STORE(&bd->u.scan, RELAXED_LOAD(&bd->start)); + // blocks in to-space get the BF_EVACUATED flag. + // RELEASE here to ensure that bd->gen is visible to other cores. + RELEASE_STORE(&bd->flags, BF_EVACUATED); } bd->link = NULL; @@ -345,7 +346,7 @@ alloc_todo_block (gen_workspace *ws, uint32_t size) // See Note [big objects] debugTrace(DEBUG_gc, "alloc new todo block %p for gen %d", - bd->free, ws->gen->no); + RELAXED_LOAD(&bd->free), ws->gen->no); return ws->todo_free; } ===================================== rts/sm/GCUtils.h ===================================== @@ -67,7 +67,9 @@ recordMutableGen_GC (StgClosure *p, uint32_t gen_no) bd = new_bd; gct->mut_lists[gen_no] = bd; } - *bd->free++ = (StgWord)p; + *bd->free++ = (StgWord) p; + // N.B. we are allocating into our Capability-local mut_list, therefore + // we don't need an atomic increment. } #include "EndPrivate.h" ===================================== rts/sm/MarkWeak.c ===================================== @@ -414,7 +414,7 @@ markWeakPtrList ( void ) StgWeak *w, **last_w; last_w = &gen->weak_ptr_list; - for (w = gen->weak_ptr_list; w != NULL; w = w->link) { + for (w = gen->weak_ptr_list; w != NULL; w = RELAXED_LOAD(&w->link)) { // w might be WEAK, EVACUATED, or DEAD_WEAK (actually CON_STATIC) here #if defined(DEBUG) ===================================== rts/sm/NonMoving.c ===================================== @@ -726,6 +726,7 @@ void nonmovingStop(void) "waiting for nonmoving collector thread to terminate"); ACQUIRE_LOCK(&concurrent_coll_finished_lock); waitCondition(&concurrent_coll_finished, &concurrent_coll_finished_lock); + joinOSThread(mark_thread); } #endif } ===================================== rts/sm/Scav.c ===================================== @@ -203,9 +203,9 @@ scavenge_compact(StgCompactNFData *str) gct->eager_promotion = saved_eager; if (gct->failed_to_evac) { - ((StgClosure *)str)->header.info = &stg_COMPACT_NFDATA_DIRTY_info; + RELEASE_STORE(&((StgClosure *)str)->header.info, &stg_COMPACT_NFDATA_DIRTY_info); } else { - ((StgClosure *)str)->header.info = &stg_COMPACT_NFDATA_CLEAN_info; + RELEASE_STORE(&((StgClosure *)str)->header.info, &stg_COMPACT_NFDATA_CLEAN_info); } } @@ -466,9 +466,9 @@ scavenge_block (bdescr *bd) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - mvar->header.info = &stg_MVAR_DIRTY_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_DIRTY_info); } else { - mvar->header.info = &stg_MVAR_CLEAN_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_CLEAN_info); } p += sizeofW(StgMVar); break; @@ -483,9 +483,9 @@ scavenge_block (bdescr *bd) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - tvar->header.info = &stg_TVAR_DIRTY_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_DIRTY_info); } else { - tvar->header.info = &stg_TVAR_CLEAN_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_CLEAN_info); } p += sizeofW(StgTVar); break; @@ -617,9 +617,9 @@ scavenge_block (bdescr *bd) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_VAR_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_VAR_CLEAN_info); } p += sizeofW(StgMutVar); break; @@ -636,9 +636,9 @@ scavenge_block (bdescr *bd) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - bq->header.info = &stg_BLOCKING_QUEUE_DIRTY_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_DIRTY_info); } else { - bq->header.info = &stg_BLOCKING_QUEUE_CLEAN_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_CLEAN_info); } p += sizeofW(StgBlockingQueue); break; @@ -688,9 +688,9 @@ scavenge_block (bdescr *bd) p = scavenge_mut_arr_ptrs((StgMutArrPtrs*)p); if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_CLEAN_info); } gct->eager_promotion = saved_eager_promotion; @@ -705,9 +705,9 @@ scavenge_block (bdescr *bd) p = scavenge_mut_arr_ptrs((StgMutArrPtrs*)p); if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -730,9 +730,9 @@ scavenge_block (bdescr *bd) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_SMALL_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_SMALL_MUT_ARR_PTRS_CLEAN_info); } gct->failed_to_evac = true; // always put it on the mutable list. @@ -751,9 +751,9 @@ scavenge_block (bdescr *bd) } if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -836,7 +836,7 @@ scavenge_block (bdescr *bd) if (p > bd->free) { gct->copied += ws->todo_free - bd->free; - bd->free = p; + RELEASE_STORE(&bd->free, p); } debugTrace(DEBUG_gc, " scavenged %ld bytes", @@ -891,9 +891,9 @@ scavenge_mark_stack(void) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - mvar->header.info = &stg_MVAR_DIRTY_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_DIRTY_info); } else { - mvar->header.info = &stg_MVAR_CLEAN_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_CLEAN_info); } break; } @@ -907,9 +907,9 @@ scavenge_mark_stack(void) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - tvar->header.info = &stg_TVAR_DIRTY_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_DIRTY_info); } else { - tvar->header.info = &stg_TVAR_CLEAN_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_CLEAN_info); } break; } @@ -1013,9 +1013,9 @@ scavenge_mark_stack(void) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_VAR_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_VAR_CLEAN_info); } break; } @@ -1032,9 +1032,9 @@ scavenge_mark_stack(void) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - bq->header.info = &stg_BLOCKING_QUEUE_DIRTY_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_DIRTY_info); } else { - bq->header.info = &stg_BLOCKING_QUEUE_CLEAN_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_CLEAN_info); } break; } @@ -1080,9 +1080,9 @@ scavenge_mark_stack(void) scavenge_mut_arr_ptrs((StgMutArrPtrs *)p); if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_CLEAN_info); } gct->eager_promotion = saved_eager_promotion; @@ -1099,9 +1099,9 @@ scavenge_mark_stack(void) scavenge_mut_arr_ptrs((StgMutArrPtrs *)p); if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *) q)->header.info, &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -1126,9 +1126,9 @@ scavenge_mark_stack(void) gct->eager_promotion = saved_eager; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_CLEAN_info); } gct->failed_to_evac = true; // mutable anyhow. @@ -1147,9 +1147,9 @@ scavenge_mark_stack(void) } if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -1253,9 +1253,9 @@ scavenge_one(StgPtr p) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - mvar->header.info = &stg_MVAR_DIRTY_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_DIRTY_info); } else { - mvar->header.info = &stg_MVAR_CLEAN_info; + RELEASE_STORE(&mvar->header.info, &stg_MVAR_CLEAN_info); } break; } @@ -1269,9 +1269,9 @@ scavenge_one(StgPtr p) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - tvar->header.info = &stg_TVAR_DIRTY_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_DIRTY_info); } else { - tvar->header.info = &stg_TVAR_CLEAN_info; + RELEASE_STORE(&tvar->header.info, &stg_TVAR_CLEAN_info); } break; } @@ -1333,9 +1333,9 @@ scavenge_one(StgPtr p) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_DIRTY_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_MUT_VAR_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_MUT_VAR_CLEAN_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_MUT_VAR_CLEAN_info); } break; } @@ -1352,9 +1352,9 @@ scavenge_one(StgPtr p) gct->eager_promotion = saved_eager_promotion; if (gct->failed_to_evac) { - bq->header.info = &stg_BLOCKING_QUEUE_DIRTY_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_DIRTY_info); } else { - bq->header.info = &stg_BLOCKING_QUEUE_CLEAN_info; + RELEASE_STORE(&bq->header.info, &stg_BLOCKING_QUEUE_CLEAN_info); } break; } @@ -1400,9 +1400,9 @@ scavenge_one(StgPtr p) scavenge_mut_arr_ptrs((StgMutArrPtrs *)p); if (gct->failed_to_evac) { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_CLEAN_info); } gct->eager_promotion = saved_eager_promotion; @@ -1417,9 +1417,9 @@ scavenge_one(StgPtr p) scavenge_mut_arr_ptrs((StgMutArrPtrs *)p); if (gct->failed_to_evac) { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -1444,9 +1444,9 @@ scavenge_one(StgPtr p) gct->eager_promotion = saved_eager; if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_CLEAN_info); } gct->failed_to_evac = true; @@ -1465,9 +1465,9 @@ scavenge_one(StgPtr p) } if (gct->failed_to_evac) { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info); } else { - ((StgClosure *)q)->header.info = &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info; + RELEASE_STORE(&((StgClosure *)q)->header.info, &stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info); } break; } @@ -1653,9 +1653,9 @@ scavenge_mutable_list(bdescr *bd, generation *gen) scavenge_mut_arr_ptrs_marked((StgMutArrPtrs *)p); if (gct->failed_to_evac) { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_DIRTY_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_DIRTY_info); } else { - ((StgClosure *)p)->header.info = &stg_MUT_ARR_PTRS_CLEAN_info; + RELEASE_STORE(&((StgClosure *)p)->header.info, &stg_MUT_ARR_PTRS_CLEAN_info); } gct->eager_promotion = saved_eager_promotion; @@ -1753,8 +1753,9 @@ scavenge_static(void) /* Take this object *off* the static_objects list, * and put it on the scavenged_static_objects list. */ - gct->static_objects = *STATIC_LINK(info,p); - *STATIC_LINK(info,p) = gct->scavenged_static_objects; + StgClosure **link = STATIC_LINK(info,p); + gct->static_objects = RELAXED_LOAD(link); + RELAXED_STORE(link, gct->scavenged_static_objects); gct->scavenged_static_objects = flagged_p; switch (info -> type) { ===================================== rts/sm/Storage.c ===================================== @@ -1032,8 +1032,8 @@ allocateMightFail (Capability *cap, W_ n) g0->n_new_large_words += n; RELEASE_SM_LOCK; initBdescr(bd, g0, g0); - bd->flags = BF_LARGE; - bd->free = bd->start + n; + RELAXED_STORE(&bd->flags, BF_LARGE); + RELAXED_STORE(&bd->free, bd->start + n); cap->total_allocated += n; return bd->start; } @@ -1561,10 +1561,13 @@ calcNeeded (bool force_major, memcount *blocks_needed) for (uint32_t g = 0; g < RtsFlags.GcFlags.generations; g++) { generation *gen = &generations[g]; - W_ blocks = gen->live_estimate ? (gen->live_estimate / BLOCK_SIZE_W) : gen->n_blocks; - blocks += gen->n_large_blocks - + gen->n_compact_blocks; + + // This can race with allocate() and compactAllocateBlockInternal() + // but only needs to be approximate + TSAN_ANNOTATE_BENIGN_RACE(&gen->n_large_blocks, "n_large_blocks"); + blocks += RELAXED_LOAD(&gen->n_large_blocks) + + RELAXED_LOAD(&gen->n_compact_blocks); // we need at least this much space needed += blocks; ===================================== rts/sm/Storage.h ===================================== @@ -72,8 +72,11 @@ bool getNewNursery (Capability *cap); INLINE_HEADER bool doYouWantToGC(Capability *cap) { + // This is necessarily approximate since otherwise we would need to take + // SM_LOCK to safely look at n_new_large_words. + TSAN_ANNOTATE_BENIGN_RACE(&g0->n_new_large_words, "doYouWantToGC(n_new_large_words)"); return ((cap->r.rCurrentNursery->link == NULL && !getNewNursery(cap)) || - g0->n_new_large_words >= large_alloc_lim); + RELAXED_LOAD(&g0->n_new_large_words) >= large_alloc_lim); } /* ----------------------------------------------------------------------------- @@ -91,7 +94,7 @@ INLINE_HEADER void finishedNurseryBlock (Capability *cap, bdescr *bd) { } INLINE_HEADER void newNurseryBlock (bdescr *bd) { - bd->free = bd->start; + RELAXED_STORE(&bd->free, bd->start); } void updateNurseriesStats (void); ===================================== rts/win32/OSThreads.c ===================================== @@ -444,6 +444,15 @@ interruptOSThread (OSThreadId id) CloseHandle(hdl); } +void +joinOSThread (OSThreadId id) +{ + int ret = WaitForSingleObject(id, INFINITE); + if (ret != WAIT_OBJECT_0) { + sysErrorBelch("joinOSThread: error %d", ret); + } +} + void setThreadNode (uint32_t node) { if (osNumaAvailable()) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eaa95417b69729783995c4ebd36b1537d75e0fff...96f8bde7efa53078238ddb0736795b3f98a8f1ce -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eaa95417b69729783995c4ebd36b1537d75e0fff...96f8bde7efa53078238ddb0736795b3f98a8f1ce You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 04:42:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 00:42:41 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 9 commits: rts/GC: Use atomics Message-ID: <5f9b99c147bce_897e4f61b41202941@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: aad1f803 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/GC: Use atomics - - - - - d0bc0517 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Use RELEASE ordering in unlockClosure - - - - - d44f5232 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/Storage: Accept races on heap size counters - - - - - 4e4a7386 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Join to concurrent mark thread during shutdown Previously we would take all capabilities but fail to join on the thread itself, potentially resulting in a leaked thread. - - - - - a80cc857 by GHC GitLab CI at 2020-10-30T00:41:14-04:00 rts: Fix race in GC CPU time accounting Ensure that the GC leader synchronizes with workers before calling stat_endGC. - - - - - 7dcd5f53 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - 96f8bde7 by Ben Gamari at 2020-10-30T00:41:14-04:00 rts: Use relaxed ordering on spinlock counters - - - - - e213d99e by Ben Gamari at 2020-10-30T00:41:52-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr', 'wip/tsan/timer' and 'wip/tsan/stats' into wip/tsan/all - - - - - ef98942b by Ben Gamari at 2020-10-30T00:41:56-04:00 testing - - - - - 30 changed files: - .gitlab-ci.yml - hadrian/src/Flavour.hs - includes/rts/OSThreads.h - includes/rts/SpinLock.h - includes/rts/StablePtr.h - includes/rts/TSANUtils.h - includes/rts/storage/Closures.h - includes/rts/storage/GC.h - includes/stg/SMP.h - libraries/base/GHC/Event/Control.hs - rts/.tsan-suppressions - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/Proftimer.c - rts/RaiseAsync.c - rts/RtsStartup.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.c - + rts/SpinLock.c - rts/StablePtr.c - rts/Task.c - rts/ThreadPaused.c - rts/Threads.c - rts/Timer.c - rts/Updates.h - rts/WSDeque.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e12241cf5bdf1824fb4d84d3cb66d56518f2e71...ef98942bff66004c5c8b2ca1d4df1d240f9633da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3e12241cf5bdf1824fb4d84d3cb66d56518f2e71...ef98942bff66004c5c8b2ca1d4df1d240f9633da You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 04:45:34 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 00:45:34 -0400 Subject: [Git][ghc/ghc][wip/bytearray-docs] 31 commits: Implement -Woperator-whitespace (#18834) Message-ID: <5f9b9a6ecdd58_897e4f61b41203752@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/bytearray-docs at Glasgow Haskell Compiler / GHC Commits: b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - ca456249 by Ben Gamari at 2020-10-30T00:35:35-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - 1c9f6185 by Ben Gamari at 2020-10-30T00:45:15-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/CallConv.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Regs.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/408ddf1d38cf9905fadffa9e40dc025c31c81aea...1c9f618574e9f72aa04db6ae31c40dbd6b65c52a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/408ddf1d38cf9905fadffa9e40dc025c31c81aea...1c9f618574e9f72aa04db6ae31c40dbd6b65c52a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 05:21:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 01:21:01 -0400 Subject: [Git][ghc/ghc][wip/tsan/storage] 2 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9ba2bd31ab6_8973fa3eb9e8968120816a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/storage at Glasgow Haskell Compiler / GHC Commits: ab5713e0 by Ben Gamari at 2020-10-30T01:20:54-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - f538641f by Ben Gamari at 2020-10-30T01:20:54-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 4 changed files: - includes/rts/SpinLock.h - includes/stg/SMP.h - + rts/SpinLock.c - rts/rts.cabal.in Changes: ===================================== includes/rts/SpinLock.h ===================================== @@ -39,19 +39,14 @@ typedef struct SpinLock_ #define IF_PROF_SPIN(x) #endif +void acquire_spin_lock_slow_path(SpinLock * p); + // acquire spin lock INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { - do { - for (uint32_t i = 0; i < SPIN_COUNT; i++) { - StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); - if (r != 0) return; - IF_PROF_SPIN(__atomic_fetch_add(&p->spin, 1, __ATOMIC_RELAXED)); - busy_wait_nop(); - } - IF_PROF_SPIN(__atomic_fetch_add(&p->yield, 1, __ATOMIC_RELAXED)); - yieldThread(); - } while (1); + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (RTS_UNLIKELY(r != 0)) + acquire_spin_lock_slow_path(p); } // release spin lock ===================================== includes/stg/SMP.h ===================================== @@ -440,6 +440,7 @@ load_load_barrier(void) { // Relaxed atomic operations. #define RELAXED_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_RELAXED) #define RELAXED_STORE(ptr,val) __atomic_store_n(ptr, val, __ATOMIC_RELAXED) +#define RELAXED_ADD(ptr,val) __atomic_add_fetch(ptr, val, __ATOMIC_RELAXED) // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_ACQUIRE) @@ -466,6 +467,7 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */ // Relaxed atomic operations #define RELAXED_LOAD(ptr) *ptr #define RELAXED_STORE(ptr,val) *ptr = val +#define RELAXED_ADD(ptr,val) *ptr += val // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) *ptr ===================================== rts/SpinLock.c ===================================== @@ -0,0 +1,41 @@ +/* ---------------------------------------------------------------------------- + * + * (c) The GHC Team, 2006-2009 + * + * Spin locks + * + * These are simple spin-only locks as opposed to Mutexes which + * probably spin for a while before blocking in the kernel. We use + * these when we are sure that all our threads are actively running on + * a CPU, eg. in the GC. + * + * TODO: measure whether we really need these, or whether Mutexes + * would do (and be a bit safer if a CPU becomes loaded). + * + * Do not #include this file directly: #include "Rts.h" instead. + * + * To understand the structure of the RTS headers, see the wiki: + * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes + * + * -------------------------------------------------------------------------- */ + +#include "PosixSource.h" +#include "Rts.h" + +#if defined(THREADED_RTS) + +void acquire_spin_lock_slow_path(SpinLock * p) +{ + do { + for (uint32_t i = 0; i < SPIN_COUNT; i++) { + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (r != 0) return; + IF_PROF_SPIN(RELAXED_ADD(&p->spin, 1)); + busy_wait_nop(); + } + IF_PROF_SPIN(RELAXED_ADD(&p->yield, 1)); + yieldThread(); + } while (1); +} + +#endif ===================================== rts/rts.cabal.in ===================================== @@ -462,6 +462,7 @@ library STM.c Schedule.c Sparks.c + SpinLock.c StableName.c StablePtr.c StaticPtrTable.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96f8bde7efa53078238ddb0736795b3f98a8f1ce...f538641f2319370c88fd3dee3770d5f8ac970ccc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/96f8bde7efa53078238ddb0736795b3f98a8f1ce...f538641f2319370c88fd3dee3770d5f8ac970ccc You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 05:21:21 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 01:21:21 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 4 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9ba2d19e01f_8973fa3d8c84e781208784@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: ab5713e0 by Ben Gamari at 2020-10-30T01:20:54-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - f538641f by Ben Gamari at 2020-10-30T01:20:54-04:00 rts: Use relaxed ordering on spinlock counters - - - - - f7b91d39 by Ben Gamari at 2020-10-30T01:21:11-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr', 'wip/tsan/timer' and 'wip/tsan/stats' into wip/tsan/all - - - - - cb267182 by Ben Gamari at 2020-10-30T01:21:15-04:00 testing - - - - - 30 changed files: - .gitlab-ci.yml - hadrian/src/Flavour.hs - includes/rts/SpinLock.h - includes/rts/TSANUtils.h - includes/rts/storage/Closures.h - includes/stg/SMP.h - libraries/base/GHC/Event/Control.hs - rts/.tsan-suppressions - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/Proftimer.c - rts/RaiseAsync.c - rts/RtsStartup.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.c - + rts/SpinLock.c - rts/Stats.c - rts/Stats.h - rts/Task.c - rts/ThreadPaused.c - rts/Threads.c - rts/Timer.c - rts/WSDeque.c - rts/WSDeque.h - rts/posix/GetTime.c - rts/posix/Signals.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef98942bff66004c5c8b2ca1d4df1d240f9633da...cb2671825a324f9fabededd9d3c3ca3963951d95 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef98942bff66004c5c8b2ca1d4df1d240f9633da...cb2671825a324f9fabededd9d3c3ca3963951d95 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 09:01:05 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 30 Oct 2020 05:01:05 -0400 Subject: [Git][ghc/ghc][wip/T18844] 3 commits: Check for large tuples more thoroughly Message-ID: <5f9bd6516f551_8973fa31da9581c1224036@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18844 at Glasgow Haskell Compiler / GHC Commits: 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 3f3e4f6c by Ryan Scott at 2020-10-30T04:53:26-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16331f16046beb106dab0974b74d0ddcea9aa074...3f3e4f6c5f7d66ced4bf8657fb8c5fda85b23e5f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16331f16046beb106dab0974b74d0ddcea9aa074...3f3e4f6c5f7d66ced4bf8657fb8c5fda85b23e5f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 09:02:06 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 30 Oct 2020 05:02:06 -0400 Subject: [Git][ghc/ghc][wip/T16762] 3 commits: Check for large tuples more thoroughly Message-ID: <5f9bd68e1d11f_8973fa3b87e14401225959@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 19f717ba by Ryan Scott at 2020-10-30T04:55:45-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 30 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Expr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2b9e53d812ce2e89c9cdbc5a0b9694d84b1570a...19f717ba6414e3d15b3960f27619ae84b6a21fae -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d2b9e53d812ce2e89c9cdbc5a0b9694d84b1570a...19f717ba6414e3d15b3960f27619ae84b6a21fae You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 12:50:58 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 30 Oct 2020 08:50:58 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f9c0c3279138_8973fa31acfaba012494a8@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: 65e6b386 by David Eichmann at 2020-10-30T12:50:43+00:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - includes/rts/Threads.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65e6b386c9e50c29a1ead7d8db2dc00195f6c6af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65e6b386c9e50c29a1ead7d8db2dc00195f6c6af You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 13:43:53 2020 From: gitlab at gitlab.haskell.org (David Eichmann) Date: Fri, 30 Oct 2020 09:43:53 -0400 Subject: [Git][ghc/ghc][wip/ghc-debug_pause_and_resume] RtsAPI: pause and resume the RTS Message-ID: <5f9c189934640_8973fa38e7caf94125863d@gitlab.haskell.org.mail> David Eichmann pushed to branch wip/ghc-debug_pause_and_resume at Glasgow Haskell Compiler / GHC Commits: c83b97d1 by David Eichmann at 2020-10-30T13:43:44+00:00 RtsAPI: pause and resume the RTS The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and allow an external process to completely pause and resume the RTS. Co-authored-by: Sven Tennie <sven.tennie at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> - - - - - 30 changed files: - includes/RtsAPI.h - includes/rts/Threads.h - rts/Capability.c - rts/RtsAPI.c - rts/Schedule.c - rts/Task.c - rts/Task.h - rts/sm/NonMoving.c - + testsuite/tests/rts/pause-resume/all.T - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.hs - + testsuite/tests/rts/pause-resume/pause_and_use_rts_api.stdout - + testsuite/tests/rts/pause-resume/pause_resume.c - + testsuite/tests/rts/pause-resume/pause_resume.h - + testsuite/tests/rts/pause-resume/pause_resume_via_pthread.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.hs - + testsuite/tests/rts/pause-resume/pause_resume_via_safe_ffi_concurrent.stdout - + testsuite/tests/rts/pause-resume/shouldfail/all.T - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_double_pause.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_lock_when_paused.stdout - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.c - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_lock.h - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.hs - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stderr - + testsuite/tests/rts/pause-resume/shouldfail/rts_pause_when_locked.stdout - + testsuite/tests/rts/pause-resume/shouldfail/unsafe_rts_pause.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c83b97d19889d0844f73a26f36d3169f698e92c8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c83b97d19889d0844f73a26f36d3169f698e92c8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 13:48:58 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 30 Oct 2020 09:48:58 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] Fix oversight in lubCard Message-ID: <5f9c19ca38577_89710b542e812614a2@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: c26e25e6 by Sebastian Graf at 2020-10-30T14:48:48+01:00 Fix oversight in lubCard - - - - - 1 changed file: - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -415,6 +415,7 @@ lubCard C_11 C_00 = C_01 -- {0} ∪ {1} = {0,1} lubCard C_11 n = n -- {1} is a subset of all other intervals lubCard n C_11 = n -- {1} is a subset of all other intervals -- Handle C_1N +lubCard C_1N C_1N = C_1N -- reflexivity lubCard _ C_1N = C_0N -- {0} ∪ {1,n} = top lubCard C_1N _ = C_0N -- {0} ∪ {1,n} = top -- Handle C_01 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c26e25e6e1cecdc636993bd2e33a9d36b966d936 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c26e25e6e1cecdc636993bd2e33a9d36b966d936 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 14:42:15 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 30 Oct 2020 10:42:15 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Remove unnecessary gender from comments/docs Message-ID: <5f9c264778cf_8973fa3a6e47be81277511@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 5ac6f880 by Ryan Scott at 2020-10-30T10:42:06-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 30 changed files: - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/9.2.1-notes.rst - docs/users_guide/exts/partial_type_signatures.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95b0d75d17ec5c37ca07f37c6649d5739d2439e9...5ac6f8806bb9524d2e7cd8f9518e8391c07e3d79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/95b0d75d17ec5c37ca07f37c6649d5739d2439e9...5ac6f8806bb9524d2e7cd8f9518e8391c07e3d79 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 14:45:33 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 30 Oct 2020 10:45:33 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] 2 commits: Accept more tests Message-ID: <5f9c270d6aa10_897a1f1a1c1280987@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: 6ae44ca2 by Sebastian Graf at 2020-10-30T15:39:53+01:00 Accept more tests - - - - - 3d33a3e0 by Sebastian Graf at 2020-10-30T15:45:27+01:00 Smart constructor for product demands - - - - - 9 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs - testsuite/tests/simplCore/should_compile/EvalTest.stdout - testsuite/tests/simplCore/should_compile/T13543.stderr - testsuite/tests/simplCore/should_compile/T4908.stderr - testsuite/tests/simplCore/should_compile/T7360.stderr - testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr - testsuite/tests/stranal/sigs/T5075.stderr - testsuite/tests/stranal/sigs/UnsatFun.stderr Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -244,7 +244,7 @@ dmdAnal' env dmd (Case scrut case_bndr ty [(DataAlt dc, bndrs, rhs)]) -- Compute demand on the scrutinee -- See Note [Demand on scrutinee of a product case] - scrut_dmd = Prod id_dmds + scrut_dmd = mkProd id_dmds (scrut_ty, scrut') = dmdAnal env scrut_dmd scrut res_ty = alt_ty3 `plusDmdType` toBothDmdArg scrut_ty case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -12,7 +12,7 @@ -} module GHC.Types.Demand ( - Card(..), Demand(..), CleanDemand(Prod), viewProd, + Card(..), Demand(..), CleanDemand(Prod), mkProd, viewProd, oneifyDmd, oneifyCard, absDmd, topDmd, botDmd, seqDmd, lubCard, lubDmd, lubCleanDmd, @@ -369,7 +369,7 @@ instance Show Card where show C_01 = "1" show C_0N = "U" show C_11 = "S" - show C_1N = "S" + show C_1N = "S*" show C_10 = "B" _botCard, topCard :: Card @@ -480,7 +480,7 @@ data CleanDemand deriving ( Eq, Show ) poly00, poly01, poly0N, poly11, poly1N, poly10 :: CleanDemand -topCleanDmd, _botCleanDmd, seqCleanDmd :: CleanDemand +topCleanDmd, botCleanDmd, seqCleanDmd :: CleanDemand poly00 = Poly C_00 poly01 = Poly C_01 poly0N = Poly C_0N @@ -488,7 +488,7 @@ poly11 = Poly C_11 poly1N = Poly C_1N poly10 = Poly C_10 topCleanDmd = poly0N -_botCleanDmd = poly10 +botCleanDmd = poly10 seqCleanDmd = poly00 polyDmd :: Card -> Demand @@ -512,6 +512,16 @@ lazyApply1Dmd = C_01 :* Call C_01 topCleanDmd -- but is lazy (might not be called at all) lazyApply2Dmd = C_01 :* Call C_01 (Call C_01 topCleanDmd) +-- | A smart constructor for 'Prod', applying rewrite rules along the semantic +-- equalities @Prod [polyDmd n, ...] === polyDmd n@, simplifying to polymorphic +-- demands when possible. Note that this degrades boxity information! E.g. a +-- polymorphic demand will never unbox. +mkProd :: [Demand] -> CleanDemand +mkProd [] = botCleanDmd +mkProd ds@(n:*cd : _) + | all (== polyDmd n) ds = cd + | otherwise = Prod ds + viewProd :: Arity -> CleanDemand -> Maybe [Demand] viewProd n (Prod ds) | ds `lengthIs` n = Just ds viewProd n (Poly card) = Just (replicate n (polyDmd card)) ===================================== testsuite/tests/simplCore/should_compile/EvalTest.stdout ===================================== @@ -1 +1 @@ -rght [Dmd=] :: AList a +rght [Dmd=S*U] :: AList a ===================================== testsuite/tests/simplCore/should_compile/T13543.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== Foo.$trModule: -Foo.f: +Foo.f: Foo.g: ===================================== testsuite/tests/simplCore/should_compile/T4908.stderr ===================================== @@ -42,7 +42,7 @@ T4908.$trModule Rec { -- RHS size: {terms: 19, types: 5, coercions: 0, joins: 0/0} T4908.f_$s$wf [Occ=LoopBreaker] :: Int -> Int# -> Int# -> Bool -[GblId, Arity=3, Str=, Unf=OtherCon []] +[GblId, Arity=3, Str=<1U>, Unf=OtherCon []] T4908.f_$s$wf = \ (sc :: Int) (sc1 :: Int#) (sc2 :: Int#) -> case sc2 of ds { @@ -59,7 +59,7 @@ end Rec } T4908.$wf [InlPrag=[2]] :: Int# -> (Int, Int) -> Bool [GblId, Arity=2, - Str=, + Str=<1(A,1(1U))>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=IF_ARGS [30 20] 101 20}] T4908.$wf @@ -81,7 +81,7 @@ T4908.$wf f [InlPrag=[2]] :: Int -> (Int, Int) -> Bool [GblId, Arity=2, - Str=, + Str=<1(A,1(1U))>, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False) ===================================== testsuite/tests/simplCore/should_compile/T7360.stderr ===================================== @@ -8,7 +8,7 @@ T7360.$WFoo3 [InlPrag=INLINE[final] CONLIKE] :: Int %1 -> Foo [GblId[DataConWrapper], Arity=1, Caf=NoCafRefs, - Str=, + Str=, Cpr=m3, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, @@ -35,7 +35,7 @@ T7360.fun4 = fun1 T7360.Foo1 fun2 :: forall {a}. [a] -> ((), Int) [GblId, Arity=1, - Str=, + Str=<1U>, Cpr=m1, Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, ===================================== testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr ===================================== @@ -1,8 +1,8 @@ ==================== Strictness signatures ==================== BottomFromInnerLambda.$trModule: -BottomFromInnerLambda.expensive: -BottomFromInnerLambda.f: +BottomFromInnerLambda.expensive: +BottomFromInnerLambda.f: ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: +T5075.loop: @@ -13,6 +13,6 @@ T5075.loop: ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: +T5075.loop: ===================================== testsuite/tests/stranal/sigs/UnsatFun.stderr ===================================== @@ -1,13 +1,13 @@ ==================== Strictness signatures ==================== UnsatFun.$trModule: -UnsatFun.f: b -UnsatFun.g: b -UnsatFun.g': -UnsatFun.g3: -UnsatFun.h: -UnsatFun.h2: -UnsatFun.h3: +UnsatFun.f: b +UnsatFun.g: b +UnsatFun.g': <1(U)> +UnsatFun.g3: +UnsatFun.h: +UnsatFun.h2: <1C1(U)> +UnsatFun.h3: @@ -25,12 +25,12 @@ UnsatFun.h3: m1 ==================== Strictness signatures ==================== UnsatFun.$trModule: -UnsatFun.f: b -UnsatFun.g: b -UnsatFun.g': -UnsatFun.g3: -UnsatFun.h: -UnsatFun.h2: -UnsatFun.h3: +UnsatFun.f: b +UnsatFun.g: b +UnsatFun.g': <1(U)> +UnsatFun.g3: +UnsatFun.h: +UnsatFun.h2: <1C1(U)> +UnsatFun.h3: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e25e6e1cecdc636993bd2e33a9d36b966d936...3d33a3e02e2a22bd2c4d7d62cd41254ba1de2820 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c26e25e6e1cecdc636993bd2e33a9d36b966d936...3d33a3e02e2a22bd2c4d7d62cd41254ba1de2820 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 14:45:40 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 10:45:40 -0400 Subject: [Git][ghc/ghc][wip/T15808] 5 commits: Check for large tuples more thoroughly Message-ID: <5f9c2714f2baf_8973fa3a73619d01281429@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T15808 at Glasgow Haskell Compiler / GHC Commits: 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - ed3b3da3 by Ben Gamari at 2020-10-30T10:21:02-04:00 rts/linker: Fix relocation overflow in PE linker Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808. - - - - - b9b16c94 by Ben Gamari at 2020-10-30T10:21:20-04:00 rts/linker: Fold IMAGE_REL_AMD64_REL32 case into IMAGE_REL_AMD64_ADDR32 After fixing #15808 these cases are all essentially equivalent. Avoids some repetition and hopefully eliminates the potential for divergence in the future. - - - - - 42492e4a by Ben Gamari at 2020-10-30T10:45:14-04:00 rts/linker: Try using m32 to allocate PE symbol extras - - - - - 30 changed files: - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/HsToCore/Pmc/Solver/Types.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Pat.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Interpreter.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Pat.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Types/Basic.hs - compiler/GHC/Types/Name/Reader.hs - compiler/GHC/Utils/Outputable.hs - docs/users_guide/exts/partial_type_signatures.rst - rts/Linker.c - rts/linker/PEi386.c - − testsuite/tests/rename/should_fail/T6148.stderr - + testsuite/tests/rename/should_fail/T6148a.hs - + testsuite/tests/rename/should_fail/T6148a.stderr - + testsuite/tests/rename/should_fail/T6148b.hs - + testsuite/tests/rename/should_fail/T6148b.stderr - testsuite/tests/rename/should_fail/T6148.hs → testsuite/tests/rename/should_fail/T6148c.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c798a168cffa45d3edc71f9c69de70053d6290c2...42492e4a73b85ba1a5aea9af78eba42bd25699ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c798a168cffa45d3edc71f9c69de70053d6290c2...42492e4a73b85ba1a5aea9af78eba42bd25699ff You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 14:50:57 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 30 Oct 2020 10:50:57 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] Smart constructor for product demands Message-ID: <5f9c2851b574f_8973fa3a70dc3b8128245c@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: 3b237ed9 by Sebastian Graf at 2020-10-30T15:50:51+01:00 Smart constructor for product demands - - - - - 2 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -244,7 +244,7 @@ dmdAnal' env dmd (Case scrut case_bndr ty [(DataAlt dc, bndrs, rhs)]) -- Compute demand on the scrutinee -- See Note [Demand on scrutinee of a product case] - scrut_dmd = Prod id_dmds + scrut_dmd = mkProd id_dmds (scrut_ty, scrut') = dmdAnal env scrut_dmd scrut res_ty = alt_ty3 `plusDmdType` toBothDmdArg scrut_ty case_bndr' = setIdDemandInfo case_bndr case_bndr_dmd ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -12,7 +12,7 @@ -} module GHC.Types.Demand ( - Card(..), Demand(..), CleanDemand(Prod), viewProd, + Card(..), Demand(..), CleanDemand(Prod), mkProd, viewProd, oneifyDmd, oneifyCard, absDmd, topDmd, botDmd, seqDmd, lubCard, lubDmd, lubCleanDmd, @@ -480,7 +480,7 @@ data CleanDemand deriving ( Eq, Show ) poly00, poly01, poly0N, poly11, poly1N, poly10 :: CleanDemand -topCleanDmd, _botCleanDmd, seqCleanDmd :: CleanDemand +topCleanDmd, botCleanDmd, seqCleanDmd :: CleanDemand poly00 = Poly C_00 poly01 = Poly C_01 poly0N = Poly C_0N @@ -488,7 +488,7 @@ poly11 = Poly C_11 poly1N = Poly C_1N poly10 = Poly C_10 topCleanDmd = poly0N -_botCleanDmd = poly10 +botCleanDmd = poly10 seqCleanDmd = poly00 polyDmd :: Card -> Demand @@ -512,6 +512,21 @@ lazyApply1Dmd = C_01 :* Call C_01 topCleanDmd -- but is lazy (might not be called at all) lazyApply2Dmd = C_01 :* Call C_01 (Call C_01 topCleanDmd) +-- | A smart constructor for 'Prod', applying rewrite rules along the semantic +-- equalities @Prod [polyDmd n, ...] === polyDmd n@, simplifying to polymorphic +-- demands when possible. Note that this degrades boxity information! E.g. a +-- polymorphic demand will never unbox. +mkProd :: [Demand] -> CleanDemand +mkProd [] = botCleanDmd +mkProd ds@(n:*cd : _) + | want_to_simplify n, all (== polyDmd n) ds = cd + | otherwise = Prod ds + where + -- we only want to simplify absent and bottom demands + want_to_simplify C_00 = True + want_to_simplify C_10 = True + want_to_simplify _ = False + viewProd :: Arity -> CleanDemand -> Maybe [Demand] viewProd n (Prod ds) | ds `lengthIs` n = Just ds viewProd n (Poly card) = Just (replicate n (polyDmd card)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b237ed92121a9ecb884879c5b2da2b3f5f56437 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b237ed92121a9ecb884879c5b2da2b3f5f56437 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 14:59:42 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 10:59:42 -0400 Subject: [Git][ghc/ghc][wip/angerman/ghc-9.0-runpath-backport] 8 commits: Care with implicit-parameter superclasses Message-ID: <5f9c2a5ea662a_8973fa38008538c1283619@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/angerman/ghc-9.0-runpath-backport at Glasgow Haskell Compiler / GHC Commits: 7e257575 by Simon Peyton Jones at 2020-10-13T23:35:26+02:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. (cherry picked from commit c7182a5c67fe8b5bd256cb8eb805562636853ea2) - - - - - 9060a9dd by Ben Gamari at 2020-10-13T23:36:56+02:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. (cherry picked from commit 9657f6f34a1a00008a0db935dbf25733cb483cd4) - - - - - fb5eb8ab by Simon Peyton Jones at 2020-10-13T23:37:29+02:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. (cherry picked from commit bfdccac6acce84e15292a454d12f4e0d87ef6f10) - - - - - 64ab97bf by Krzysztof Gogolewski at 2020-10-13T23:39:06+02:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. (cherry picked from commit fd302e938ebf48c73d9f715d67ce8cd990f972ff) - - - - - b1a2c5e4 by Tamar Christina at 2020-10-16T10:21:20-04:00 winio: add release note - - - - - 51b09fe4 by Alan Zimmerman at 2020-10-21T23:53:56-04:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule (cherry picked from commit ea736839d85594c95490dcf02d3325c2bbc68f33) - - - - - 5a2400c6 by Viktor Dukhovni at 2020-10-23T20:51:00-04:00 Naming, value types and tests for Addr# atomics The atomic Exchange and CAS operations on integral types are updated to take and return more natural `Word#` rather than `Int#` values. These are bit-block not arithmetic operations, and the sign bit plays no special role. Standardises the names to `atomic<OpType><ValType>Addr#`, where `OpType` is one of `Cas` or `Exchange` and `ValType` is presently either `Word` or `Addr`. Eventually, variants for `Word32` and `Word64` can and should be added, once #11953 and related issues (e.g. #13825) are resolved. Adds tests for `Addr#` CAS that mirror existing tests for `MutableByteArray#`. - - - - - 7644d85c by Moritz Angermann at 2020-10-30T10:59:36-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 89a753308deb2c7ed012e875e220b1d39e1798d8) Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30 changed files: - aclocal.m4 - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Predicate.hs - compiler/GHC/Core/TyCo/Subst.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Class.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Solver.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Interact.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07385545bed6099c7e5b7fd28f0b0a7fa7910fae...7644d85ca21ca8af9cd81d64d6c88afc80e03eb5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07385545bed6099c7e5b7fd28f0b0a7fa7910fae...7644d85ca21ca8af9cd81d64d6c88afc80e03eb5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 16:56:50 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 12:56:50 -0400 Subject: [Git][ghc/ghc][wip/unloading] 4 commits: Fix and enable object unloading in GHCi Message-ID: <5f9c45d21b17b_8973fa3b2b20a081308868@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: 2883a0d9 by Ömer Sinan Ağacan at 2020-10-30T12:56:34-04:00 Fix and enable object unloading in GHCi Fixes #16525 See Note [Object unloading] in CheckUnload.c for details. - - - - - fb2471ba by Ray Shih at 2020-10-30T12:56:35-04:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - e6baa78c by GHC GitLab CI at 2020-10-30T12:56:35-04:00 rts: Introduce highMemDynamic - - - - - e3cff938 by GHC GitLab CI at 2020-10-30T12:56:35-04:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - compiler/GHC/Runtime/Linker.hs - includes/rts/Linker.h - includes/rts/storage/GC.h - rts/CheckUnload.c - rts/CheckUnload.h - rts/Hash.c - rts/Hash.h - rts/Linker.c - rts/LinkerInternals.h - rts/RtsStartup.c - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/MachO.c - rts/linker/PEi386.c - rts/linker/elf_got.c - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GC.h - rts/sm/Storage.c - testsuite/tests/ghci/T16525a/T16525a.script - testsuite/tests/ghci/T16525a/T16525a.stdout - testsuite/tests/ghci/T16525a/all.T - + testsuite/tests/ghci/T16525b/A.hs - + testsuite/tests/ghci/T16525b/B.hs - + testsuite/tests/ghci/T16525b/T16525b.script - + testsuite/tests/ghci/T16525b/T16525b.stdout - + testsuite/tests/ghci/T16525b/all.T - testsuite/tests/rts/linker/Makefile - testsuite/tests/rts/linker/all.T - testsuite/tests/rts/linker/linker_error.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e63e58f6d29bc50bb602fa2797484b4fb9791e4b...e3cff938c3f97f7072a6e1c6d79c0ad644694878 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e63e58f6d29bc50bb602fa2797484b4fb9791e4b...e3cff938c3f97f7072a6e1c6d79c0ad644694878 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 17:00:22 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 13:00:22 -0400 Subject: [Git][ghc/ghc][wip/T15808] rts/linker: Try using m32 to allocate PE symbol extras Message-ID: <5f9c46a64db17_8973fa3b2b20a0813100bb@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T15808 at Glasgow Haskell Compiler / GHC Commits: 7547b5b6 by Ben Gamari at 2020-10-30T13:00:05-04:00 rts/linker: Try using m32 to allocate PE symbol extras - - - - - 3 changed files: - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c Changes: ===================================== rts/Linker.c ===================================== @@ -1351,7 +1351,7 @@ void freeObjectCode (ObjectCode *oc) ocDeinit_ELF(oc); #endif -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) m32_allocator_free(oc->rx_m32); m32_allocator_free(oc->rw_m32); #endif @@ -1422,7 +1422,7 @@ mkOc( pathchar *path, char *image, int imageSize, /* chain it onto the list of objects */ oc->next = NULL; -#if RTS_LINKER_USE_MMAP +#if defined(USE_M32) oc->rw_m32 = m32_allocator_new(false); oc->rx_m32 = m32_allocator_new(true); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -236,7 +236,7 @@ typedef struct _ObjectCode { require extra information.*/ StrHashTable *extraInfos; -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) /* The m32 allocators used for allocating small sections and symbol extras * during loading. We have two: one for (writeable) data and one for * (read-only/executable) code. */ @@ -336,6 +336,12 @@ resolveSymbolAddr (pathchar* buffer, int size, #define USE_CONTIGUOUS_MMAP 0 #endif +// We use the m32 allocator on Windows and Unix platforms using mmap +#if (RTS_LINKER_USE_MMAP == 1) || defined(PE_OBJFORMAT) +#define USE_M32 +#endif + + HsInt isAlreadyLoaded( pathchar *path ); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( pathchar *path, char *image, int imageSize, ===================================== rts/linker/PEi386.c ===================================== @@ -1294,7 +1294,7 @@ ocVerifyImage_PEi386 ( ObjectCode* oc ) = (PEi386_IMAGE_OFFSET + 2 * default_alignment + oc->info->secBytesTotal) & ~0x7; oc->info->secBytesTotal - = oc->info->trampoline + info->numberOfSymbols * sizeof(SymbolExtra); + = oc->info->trampoline; /* No further verification after this point; only debug printing. */ i = 0; @@ -1792,12 +1792,15 @@ ocAllocateExtras_PEi386 ( ObjectCode* oc ) if (!oc->info) return false; - const int mask = default_alignment - 1; - size_t origin = oc->info->trampoline; + COFF_HEADER_INFO *info = oc->info->ch_info; + size_t extras_size = info->numberOfSymbols * sizeof(SymbolExtra); + oc->symbol_extras - = (SymbolExtra*)((uintptr_t)(oc->info->image + origin + mask) & ~mask); + = (SymbolExtra*) m32_alloc(oc->rx_m32, extras_size, 8); + if (oc->symbol_extras == NULL) + return false; + oc->first_symbol_extra = 0; - COFF_HEADER_INFO *info = oc->info->ch_info; oc->n_symbol_extras = info->numberOfSymbols; return true; @@ -1955,7 +1958,7 @@ ocResolve_PEi386 ( ObjectCode* oc ) int64_t offset = (- (intptr_t) pP - 4) ? (reloc->Type == 4) : 0; int64_t v = S + A + offset; - // N.B. in the case of the sign-extended relocations we must ensure that v is + // N.B. in the case of the sign-extended relocations we must ensure that v // fits in a signed 32-bit value. See #15808. if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { copyName (getSymShortName (info, sym), oc, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7547b5b63e362a3f165fa8980e35325b7322ada4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7547b5b63e362a3f165fa8980e35325b7322ada4 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 17:12:54 2020 From: gitlab at gitlab.haskell.org (Sebastian Graf) Date: Fri, 30 Oct 2020 13:12:54 -0400 Subject: [Git][ghc/ghc][wip/refactor-demand] 3 commits: Unrelated pretty-printing improvement Message-ID: <5f9c4996ac480_8973816944131245d@gitlab.haskell.org.mail> Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC Commits: e7f632bd by Sebastian Graf at 2020-10-30T15:51:55+01:00 Unrelated pretty-printing improvement - - - - - 09ecf0e8 by Sebastian Graf at 2020-10-30T15:53:47+01:00 typo - - - - - 87f49c7a by Sebastian Graf at 2020-10-30T18:11:10+01:00 Discard absent call demands in `lub` and `plus` (#18903) Call demands are *relative* in the sense that a call demand `Cn(cd)` on `g` says "`g` is called `n` times. Whenever `g` is called, the result is used according to `cd`". Example from #18903: ``` h :: Int -> Int h m = let g :: Int -> (Int,Int) g 1 = (m, 0) g n = (2 * n, 2 `div` n) {-# NOINLINE g #-} in case m of 1 -> 0 2 -> snd (g m) _ -> uncurry (+) (g m) ``` We want `1C1((1(U),S(U)))` as the demand on `g`, meaning that whenever `g` is called, its second component is used strictly. But from the first case alternative, where `g` is not called at all, we get what is effectively an absent demand, which expands to `ACA(A)`. If we blindly `lub` the A with the `(1(U),S(U))` from the other case branches, we'll get `(1(U),1(U))`, so lazy in the second component. But the `A` certainly means that the nested demands are redundant! The premise for the information they encode is not met and should be ignored, effectively treated like a bottom cardinality. Thus, when we compute the `lub` or the `plus` of such an absent demand with a proper call demand like `1C1((1(U),S(U)))`, we lub with `botCleanDmd`. Thus we get `1C1((1(U),S(U)))` as the result, not `1C1((1(U),1(U)))`, as wanted. Fixes #18903. - - - - - 9 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Stg/Lift/Analysis.hs - compiler/GHC/Types/Demand.hs - compiler/GHC/Utils/Outputable.hs - + testsuite/tests/stranal/should_compile/T18903.hs - + testsuite/tests/stranal/should_compile/T18903.stderr - testsuite/tests/stranal/should_compile/all.T - testsuite/tests/stranal/sigs/CaseBinderCPR.stderr - testsuite/tests/stranal/sigs/T5075.stderr Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -578,7 +578,7 @@ dmdAnalRhsLetDown rec_flag env let_dmd id rhs -- last argument demands were. Strictness won't change. But used-once -- might turn into used-many even if the signature was stable and we'd -- have to do an additional iteration. reuseEnv makes sure that we - -- never get used-once info for FVs of recursive fucntions. + -- never get used-once info for FVs of recursive functions. rhs_fv1 = case rec_flag of Just bs -> reuseEnv (delVarEnvList rhs_fv bs) Nothing -> rhs_fv ===================================== compiler/GHC/Stg/Lift/Analysis.hs ===================================== @@ -173,9 +173,9 @@ instance Outputable Skeleton where ppr (BothSk l r) = ppr l $$ ppr r ppr (ClosureSk f fvs body) = ppr f <+> ppr fvs $$ nest 2 (ppr body) ppr (RhsSk card body) = hcat - [ char 'λ' + [ lambda , ppr card - , text ". " + , dot , ppr body ] ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -542,8 +542,10 @@ lubCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand lubCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = Prod $ zipWith lubDmd ds1 ds2 -- TODO: What about Note [Used should win]? -- Handle Call -lubCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = - Call (lubCard n1 n2) (lubCleanDmd d1 d2) +lubCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) + -- See Note [Call demands are relative] + | isAbs n2 = Call (lubCard n1 n2) (lubCleanDmd d1 botCleanDmd) + | otherwise = Call (lubCard n1 n2) (lubCleanDmd d1 d2) -- Handle Poly lubCleanDmd (Poly n1) (Poly n2) = Poly (lubCard n1 n2) -- Make use of reflexivity (so we'll match the Prod or Call cases again). @@ -559,10 +561,10 @@ plusCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand plusCleanDmd (Prod ds1) (viewProd (length ds1) -> Just ds2) = Prod $ zipWith plusDmd ds1 ds2 -- Handle Call --- TODO: Exciting special treatment of inner demand for call demands: --- use `lubUse` instead of `plusUse`! -plusCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) = - Call (plusCard n1 n2) (lubCleanDmd d1 d2) +plusCleanDmd (Call n1 d1) (viewCall -> Just (n2, d2)) + -- See Note [Call demands are relative] + | isAbs n2 = Call (plusCard n1 n2) (lubCleanDmd d1 botCleanDmd) + | otherwise = Call (plusCard n1 n2) (lubCleanDmd d1 d2) -- Handle Poly plusCleanDmd (Poly n1) (Poly n2) = Poly (plusCard n1 n2) -- Make use of reflexivity (so we'll match the Prod or Call cases again). @@ -604,6 +606,44 @@ seqDemand _ = () seqDemandList :: [Demand] -> () seqDemandList = foldr (seq . seqDemand) () +{- Note [Call demands are relative] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The expression @if b then 0 else f 1 2 + f 3 4@ uses @f@ according to the demand + at UCU(CS(S(U)))@, meaning + + "f is called multiple times (CU) or not at all, but each time it is called, + it's called with *exactly one* (CS) more argument. + Whenever it is called with two arguments, the result is used exactly once + (S(..)), but we have no info on how often the field is used (U)." + +So the 'CleanDemand' nested in a 'Call' demand is relative to exactly one call. +And that extends to the information we have how its results are used in each +call site. Consider (#18903) + + h :: Int -> Int + h m = + let g :: Int -> (Int,Int) + g 1 = (m, 0) + g n = (2 * n, 2 `div` n) + {-# NOINLINE g #-} + in case m of + 1 -> 0 + 2 -> snd (g m) + _ -> uncurry (+) (g m) + +We want to give @g@ the demand @1C1((1(U),S(U)))@, so we see that in each call +site of @g@, we are strict in the second component of the returned pair. + +This relative cardinality leads to an otherwise unexpected call to 'lubCleanDmd' +in 'plusCleanDmd', but if you do the math it's just the right thing. + +There's one more subtlety: Since the nested demand is relative to exactly one +call, in the case where we have *at most zero calls* (e.g. CA(...)), the premise +is hurt and we can assume that the nested demand is 'botCleanDmd'. That ensures +that @g@ above actually gets the @S(U)@ demand on its second pair component, +rather than the lazy @1(U)@ if we 'lub'bed with an absent demand. +-} + {- Note [Scaling demands] ~~~~~~~~~~~~~~~~~~~~~~~~~ If a demand is used multiple times (/reused/), for example the argument in an @@ -1189,7 +1229,7 @@ multCleanDmd :: Card -> CleanDemand -> CleanDemand multCleanDmd n cd | Just cd' <- multTrivial n seqCleanDmd cd = cd' multCleanDmd n (Poly n') = Poly (multCard n n') -multCleanDmd n (Call n' cd) = Call (multCard n n') cd -- TODO Note +multCleanDmd n (Call n' cd) = Call (multCard n n') cd -- See Note [Call demands are relative] multCleanDmd n (Prod ds) = Prod (map (multDmd n) ds) multDmd :: Card -> Demand -> Demand ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -35,6 +35,7 @@ module GHC.Utils.Outputable ( doubleQuotes, angleBrackets, semi, comma, colon, dcolon, space, equals, dot, vbar, arrow, lollipop, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt, + lambda, lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore, mulArrow, blankLine, forAllLit, bullet, (<>), (<+>), hcat, hsep, @@ -648,7 +649,7 @@ quotes d = sdocOption sdocCanUseUnicode $ \case | otherwise -> Pretty.quotes pp_d semi, comma, colon, equals, space, dcolon, underscore, dot, vbar :: SDoc -arrow, lollipop, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt :: SDoc +arrow, lollipop, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt, lambda :: SDoc lparen, rparen, lbrack, rbrack, lbrace, rbrace, blankLine :: SDoc blankLine = docToSDoc $ Pretty.text "" @@ -661,6 +662,7 @@ arrowt = unicodeSyntax (char '⤚') (docToSDoc $ Pretty.text ">-") larrowt = unicodeSyntax (char '⤙') (docToSDoc $ Pretty.text "-<") arrowtt = unicodeSyntax (char '⤜') (docToSDoc $ Pretty.text ">>-") larrowtt = unicodeSyntax (char '⤛') (docToSDoc $ Pretty.text "-<<") +lambda = unicodeSyntax (char 'λ') (char '\\') semi = docToSDoc $ Pretty.semi comma = docToSDoc $ Pretty.comma colon = docToSDoc $ Pretty.colon ===================================== testsuite/tests/stranal/should_compile/T18903.hs ===================================== @@ -0,0 +1,16 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} + +-- | The point of this test is that @g@ get's a demand that says "whenever @g@ +-- is called, the second component of the pair is evaluated strictly". +module T18903 where + +h :: Int -> Int +h m = + let g :: Int -> (Int,Int) + g 1 = (m, 0) + g n = (2 * n, 2 `div` n) + {-# NOINLINE g #-} + in case m of + 1 -> 0 + 2 -> snd (g m) + _ -> uncurry (+) (g m) ===================================== testsuite/tests/stranal/should_compile/T18903.stderr ===================================== @@ -0,0 +1,113 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 84, types: 55, coercions: 0, joins: 0/1} + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18903.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T18903.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18903.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18903.$trModule3 = GHC.Types.TrNameS T18903.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T18903.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T18903.$trModule2 = "T18903"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18903.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18903.$trModule1 = GHC.Types.TrNameS T18903.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T18903.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18903.$trModule + = GHC.Types.Module T18903.$trModule3 T18903.$trModule1 + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18903.h1 :: Int +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18903.h1 = GHC.Types.I# 0# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T18903.h2 :: Int +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T18903.h2 = GHC.Types.I# -2# + +-- RHS size: {terms: 56, types: 41, coercions: 0, joins: 0/1} +T18903.$wh [InlPrag=[2]] :: GHC.Prim.Int# -> Int +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [70] 262 10}] +T18903.$wh + = \ (ww_s11L :: GHC.Prim.Int#) -> + let { + $wg_s11H [InlPrag=NOINLINE, Dmd=1C1((1(U),S(U)))] + :: GHC.Prim.Int# -> (# Int, Int #) + [LclId, Arity=1, Str=, Unf=OtherCon []] + $wg_s11H + = \ (ww1_s11C [OS=OneShot] :: GHC.Prim.Int#) -> + case ww1_s11C of ds_X3 { + __DEFAULT -> + (# GHC.Types.I# (GHC.Prim.*# 2# ds_X3), + case ds_X3 of { + __DEFAULT -> + case GHC.Classes.divInt# 2# ds_X3 of ww4_aZI { __DEFAULT -> + GHC.Types.I# ww4_aZI + }; + -1# -> T18903.h2; + 0# -> case GHC.Real.divZeroError of wild1_00 { } + } #); + 1# -> (# GHC.Types.I# ww_s11L, T18903.h1 #) + } } in + case ww_s11L of ds_X2 { + __DEFAULT -> + case $wg_s11H ds_X2 of { (# ww2_s11O, ww3_s11P #) -> + case ww2_s11O of { GHC.Types.I# x_aZS -> + case ww3_s11P of { GHC.Types.I# y_aZV -> + GHC.Types.I# (GHC.Prim.+# x_aZS y_aZV) + } + } + }; + 1# -> T18903.h1; + 2# -> case $wg_s11H 2# of { (# ww2_s11O, ww3_s11P #) -> ww3_s11P } + } + +-- RHS size: {terms: 6, types: 3, coercions: 0, joins: 0/0} +h [InlPrag=[2]] :: Int -> Int +[GblId, + Arity=1, + Str=, + Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (w_s11I [Occ=Once1!] :: Int) -> + case w_s11I of { GHC.Types.I# ww1_s11L [Occ=Once1] -> + T18903.$wh ww1_s11L + }}] +h = \ (w_s11I :: Int) -> + case w_s11I of { GHC.Types.I# ww1_s11L -> T18903.$wh ww1_s11L } + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -55,3 +55,6 @@ test('T13380b', [ grep_errmsg('bigDeadAction') ], compile, ['-dppr-cols=200 -dd # We just want to find the worker of foo in there: test('T18122', [ grep_errmsg(r'wfoo =') ], compile, ['-ddump-simpl']) + +# We care about the call demand on $wg +test('T18903', [ grep_errmsg(r'Dmd=\S+C\S+') ], compile, ['-ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/CaseBinderCPR.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== CaseBinderCPR.$trModule: -CaseBinderCPR.f_list_cmp: +CaseBinderCPR.f_list_cmp: @@ -13,6 +13,6 @@ CaseBinderCPR.f_list_cmp: m1 ==================== Strictness signatures ==================== CaseBinderCPR.$trModule: -CaseBinderCPR.f_list_cmp: +CaseBinderCPR.f_list_cmp: ===================================== testsuite/tests/stranal/sigs/T5075.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: +T5075.loop: @@ -13,6 +13,6 @@ T5075.loop: ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: +T5075.loop: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b237ed92121a9ecb884879c5b2da2b3f5f56437...87f49c7af6db5813549bdad74a53d0c3c89a3ec0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b237ed92121a9ecb884879c5b2da2b3f5f56437...87f49c7af6db5813549bdad74a53d0c3c89a3ec0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 18:02:24 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 14:02:24 -0400 Subject: [Git][ghc/ghc][wip/tsan/storage] 2 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9c5530e42f9_8973fa3b21c17dc132362@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/storage at Glasgow Haskell Compiler / GHC Commits: 105d43db by Ben Gamari at 2020-10-30T14:02:19-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - f7b45cde by Ben Gamari at 2020-10-30T14:02:19-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 4 changed files: - includes/rts/SpinLock.h - includes/stg/SMP.h - + rts/SpinLock.c - rts/rts.cabal.in Changes: ===================================== includes/rts/SpinLock.h ===================================== @@ -39,19 +39,14 @@ typedef struct SpinLock_ #define IF_PROF_SPIN(x) #endif +void acquire_spin_lock_slow_path(SpinLock * p); + // acquire spin lock INLINE_HEADER void ACQUIRE_SPIN_LOCK(SpinLock * p) { - do { - for (uint32_t i = 0; i < SPIN_COUNT; i++) { - StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); - if (r != 0) return; - IF_PROF_SPIN(__atomic_fetch_add(&p->spin, 1, __ATOMIC_RELAXED)); - busy_wait_nop(); - } - IF_PROF_SPIN(__atomic_fetch_add(&p->yield, 1, __ATOMIC_RELAXED)); - yieldThread(); - } while (1); + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (RTS_UNLIKELY(r == 0)) + acquire_spin_lock_slow_path(p); } // release spin lock ===================================== includes/stg/SMP.h ===================================== @@ -440,6 +440,7 @@ load_load_barrier(void) { // Relaxed atomic operations. #define RELAXED_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_RELAXED) #define RELAXED_STORE(ptr,val) __atomic_store_n(ptr, val, __ATOMIC_RELAXED) +#define RELAXED_ADD(ptr,val) __atomic_add_fetch(ptr, val, __ATOMIC_RELAXED) // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) __atomic_load_n(ptr, __ATOMIC_ACQUIRE) @@ -466,6 +467,7 @@ EXTERN_INLINE void load_load_barrier () {} /* nothing */ // Relaxed atomic operations #define RELAXED_LOAD(ptr) *ptr #define RELAXED_STORE(ptr,val) *ptr = val +#define RELAXED_ADD(ptr,val) *ptr += val // Acquire/release atomic operations #define ACQUIRE_LOAD(ptr) *ptr ===================================== rts/SpinLock.c ===================================== @@ -0,0 +1,41 @@ +/* ---------------------------------------------------------------------------- + * + * (c) The GHC Team, 2006-2009 + * + * Spin locks + * + * These are simple spin-only locks as opposed to Mutexes which + * probably spin for a while before blocking in the kernel. We use + * these when we are sure that all our threads are actively running on + * a CPU, eg. in the GC. + * + * TODO: measure whether we really need these, or whether Mutexes + * would do (and be a bit safer if a CPU becomes loaded). + * + * Do not #include this file directly: #include "Rts.h" instead. + * + * To understand the structure of the RTS headers, see the wiki: + * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes + * + * -------------------------------------------------------------------------- */ + +#include "PosixSource.h" +#include "Rts.h" + +#if defined(THREADED_RTS) + +void acquire_spin_lock_slow_path(SpinLock * p) +{ + do { + for (uint32_t i = 0; i < SPIN_COUNT; i++) { + StgWord32 r = cas((StgVolatilePtr)&(p->lock), 1, 0); + if (r != 0) return; + IF_PROF_SPIN(RELAXED_ADD(&p->spin, 1)); + busy_wait_nop(); + } + IF_PROF_SPIN(RELAXED_ADD(&p->yield, 1)); + yieldThread(); + } while (1); +} + +#endif ===================================== rts/rts.cabal.in ===================================== @@ -462,6 +462,7 @@ library STM.c Schedule.c Sparks.c + SpinLock.c StableName.c StablePtr.c StaticPtrTable.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f538641f2319370c88fd3dee3770d5f8ac970ccc...f7b45cde43f47f94b77411477aabdb56f8f63d66 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f538641f2319370c88fd3dee3770d5f8ac970ccc...f7b45cde43f47f94b77411477aabdb56f8f63d66 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 18:03:02 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 14:03:02 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 4 commits: rts/SpinLock: Separate out slow path Message-ID: <5f9c5556ed2d1_8973fa3b21c17dc132421b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 105d43db by Ben Gamari at 2020-10-30T14:02:19-04:00 rts/SpinLock: Separate out slow path Not only is this in general a good idea, but it turns out that GCC unrolls the retry loop, resulting is massive code bloat in critical parts of the RTS (e.g. `evacuate`). - - - - - f7b45cde by Ben Gamari at 2020-10-30T14:02:19-04:00 rts: Use relaxed ordering on spinlock counters - - - - - 4c162e67 by Ben Gamari at 2020-10-30T14:02:50-04:00 Merge branches 'wip/tsan/sched', 'wip/tsan/ci', 'wip/tsan/storage', 'wip/tsan/wsdeque', 'wip/tsan/misc', 'wip/tsan/stm', 'wip/tsan/event-mgr', 'wip/tsan/timer' and 'wip/tsan/stats' into wip/tsan/all - - - - - b8be6fde by Ben Gamari at 2020-10-30T14:02:56-04:00 testing - - - - - 30 changed files: - .gitlab-ci.yml - hadrian/src/Flavour.hs - includes/rts/SpinLock.h - includes/rts/TSANUtils.h - includes/rts/storage/Closures.h - includes/stg/SMP.h - libraries/base/GHC/Event/Control.hs - rts/.tsan-suppressions - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/Proftimer.c - rts/RaiseAsync.c - rts/RtsStartup.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Sparks.c - + rts/SpinLock.c - rts/Stats.c - rts/Stats.h - rts/Task.c - rts/ThreadPaused.c - rts/Threads.c - rts/Timer.c - rts/WSDeque.c - rts/WSDeque.h - rts/posix/GetTime.c - rts/posix/Signals.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb2671825a324f9fabededd9d3c3ca3963951d95...b8be6fdee5377d4fcd7eacd935b2644461c6e2bb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cb2671825a324f9fabededd9d3c3ca3963951d95...b8be6fdee5377d4fcd7eacd935b2644461c6e2bb You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 18:23:51 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 14:23:51 -0400 Subject: [Git][ghc/ghc][wip/T18857] 23 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f9c5a3759483_8973fa3d95d702013263a3@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18857 at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 27301b9b by Ben Gamari at 2020-10-30T14:23:49-04:00 CmmToLlvm: Declare signature for memcmp Otherwise `opt` fails with: error: use of undefined value '@memcmp$def' Fixes #18857. - - - - - 33845867 by Ben Gamari at 2020-10-30T14:23:49-04:00 gitlab-ci: Run LLVM job on appropriately-labelled MRs Namely, those marked with the ~"LLVM backend" label - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65b3830617726ff33fd57dbfa3287562fb544095...33845867954b01524fa2cde51cdd639908eb8a9f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/65b3830617726ff33fd57dbfa3287562fb544095...33845867954b01524fa2cde51cdd639908eb8a9f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 18:38:37 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 14:38:37 -0400 Subject: [Git][ghc/ghc][wip/T18857] 4 commits: CmmToLlvm: Declare signature for memcmp Message-ID: <5f9c5dad9b40f_8973fa3d8c11dc41328743@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18857 at Glasgow Haskell Compiler / GHC Commits: e82d03da by Ben Gamari at 2020-10-30T14:34:26-04:00 CmmToLlvm: Declare signature for memcmp Otherwise `opt` fails with: error: use of undefined value '@memcmp$def' Fixes #18857. - - - - - b2b10d0c by Ben Gamari at 2020-10-30T14:34:26-04:00 gitlab-ci: Run LLVM job on appropriately-labelled MRs Namely, those marked with the ~"LLVM backend" label - - - - - 79195366 by Ben Gamari at 2020-10-30T14:34:26-04:00 gitlab-ci: Run LLVM builds on Debian 10 The current Debian 9 image doesn't provide LLVM 7. - - - - - 00e08ea0 by Ben Gamari at 2020-10-30T14:36:52-04:00 hadrian: Don't use -fllvm to bootstrap under LLVM flavour Previously Hadrian's LLVM build flavours would use `-fllvm` for all invocations, even those to stage0 GHC. This meant that we needed to keep two LLVM versions around in all of the CI images. Moreover, it differed from the behavior of the old make build system's llvm flavours. Change this to reflect the behavior of the `make` build system, using `-fllvm` only with the stage1 and stage2 compilers. - - - - - 3 changed files: - .gitlab-ci.yml - compiler/GHC/CmmToLlvm/Base.hs - hadrian/src/Settings/Flavours/Llvm.hs Changes: ===================================== .gitlab-ci.yml ===================================== @@ -647,22 +647,6 @@ validate-x86_64-linux-deb9-debug: when: always expire_in: 2 week -# Disabled to alleviate CI load -.validate-x86_64-linux-deb9-llvm: - extends: .build-x86_64-linux-deb9 - stage: full-build - variables: - BUILD_FLAVOUR: perf-llvm - TEST_ENV: "x86_64-linux-deb9-llvm" - -nightly-x86_64-linux-deb9-llvm: - <<: *nightly - extends: .build-x86_64-linux-deb9 - stage: full-build - variables: - BUILD_FLAVOUR: perf-llvm - TEST_ENV: "x86_64-linux-deb9-llvm" - validate-x86_64-linux-deb9-integer-simple: extends: .build-x86_64-linux-deb9 stage: full-build @@ -719,6 +703,23 @@ release-x86_64-linux-deb10: <<: *release extends: .build-x86_64-linux-deb10 +validate-x86_64-linux-deb10-llvm: + extends: .build-x86_64-linux-deb10 + stage: full-build + rules: + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*LLVM backend.*/' + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb10-llvm" + +nightly-x86_64-linux-deb10-llvm: + <<: *nightly + extends: .build-x86_64-linux-deb10 + stage: full-build + variables: + BUILD_FLAVOUR: perf-llvm + TEST_ENV: "x86_64-linux-deb10-llvm" + ################################# # x86_64-linux-ubuntu 20.04 ################################# ===================================== compiler/GHC/CmmToLlvm/Base.hs ===================================== @@ -476,6 +476,7 @@ ghcInternalFunctions :: LlvmM () ghcInternalFunctions = do platform <- getPlatform let w = llvmWord platform + mk "memcmp" w [i8Ptr, i8Ptr, w] mk "memcpy" i8Ptr [i8Ptr, i8Ptr, w] mk "memmove" i8Ptr [i8Ptr, i8Ptr, w] mk "memset" i8Ptr [i8Ptr, w, w] ===================================== hadrian/src/Settings/Flavours/Llvm.hs ===================================== @@ -25,5 +25,5 @@ mkLlvmFlavour :: Flavour -> Flavour mkLlvmFlavour flav = flav { name = name flav ++ "-llvm" , args = mconcat [ args flav - , builder Ghc ? arg "-fllvm" ] + , notStage0 ? builder Ghc ? arg "-fllvm" ] } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33845867954b01524fa2cde51cdd639908eb8a9f...00e08ea0e232257d1957de9f9fae0bd6f985186f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/33845867954b01524fa2cde51cdd639908eb8a9f...00e08ea0e232257d1957de9f9fae0bd6f985186f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 22:52:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 30 Oct 2020 18:52:25 -0400 Subject: [Git][ghc/ghc][master] [skip ci] Fix typo in `callocBytes` haddock. Message-ID: <5f9c99291ee97_897ca88c001374683@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 1 changed file: - libraries/base/Foreign/Marshal/Alloc.hs Changes: ===================================== libraries/base/Foreign/Marshal/Alloc.hs ===================================== @@ -99,7 +99,7 @@ calloc = callocBytes (sizeOf (undefined :: a)) mallocBytes :: Int -> IO (Ptr a) mallocBytes size = failWhenNULL "malloc" (_malloc (fromIntegral size)) --- |Llike 'mallocBytes' but memory is filled with bytes of value zero. +-- |Like 'mallocBytes', but memory is filled with bytes of value zero. -- callocBytes :: Int -> IO (Ptr a) callocBytes size = failWhenNULL "calloc" $ _calloc 1 (fromIntegral size) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9902d9ec95dfc3ddb3e8a703de6b000c3ac3871a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9902d9ec95dfc3ddb3e8a703de6b000c3ac3871a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 22:53:02 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 30 Oct 2020 18:53:02 -0400 Subject: [Git][ghc/ghc][master] Split HsConDecl{H98,GADT}Details Message-ID: <5f9c994e3f26f_8973fa3bbdd66cc1378830@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 22 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1476,9 +1476,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1495,7 +1495,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1626,27 +1626,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1726,15 +1734,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1102,9 +1102,22 @@ instance OutputableBndrId p => Outputable (ConDeclField (GhcPass p)) where ppr (ConDeclField _ fld_n fld_ty _) = ppr fld_n <+> dcolon <+> ppr fld_ty --- HsConDetails is used for patterns/expressions *and* for data type --- declarations --- | Haskell Constructor Details +-- | Describes the arguments to a data constructor. This is a common +-- representation for several constructor-related concepts, including: +-- +-- * The arguments in a Haskell98-style constructor declaration +-- (see 'HsConDeclH98Details' in "GHC.Hs.Decls"). +-- +-- * The arguments in constructor patterns in @case@/function definitions +-- (see 'HsConPatDetails' in "GHC.Hs.Pat"). +-- +-- * The left-hand side arguments in a pattern synonym binding +-- (see 'HsPatSynDetails' in "GHC.Hs.Binds"). +-- +-- One notable exception is the arguments in a GADT constructor, which uses +-- a separate data type entirely (see 'HsConDeclGADTDetails' in +-- "GHC.Hs.Decls"). This is because GADT constructors cannot be declared with +-- infix syntax, unlike the concepts above (#18844). data HsConDetails arg rec = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1259,29 +1259,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -885,7 +885,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -897,7 +897,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2589,49 +2589,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2640,16 +2642,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1321,6 +1321,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1532,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1543,7 +1547,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1557,13 +1563,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2330,7 +2330,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -611,7 +611,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -636,17 +636,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1618,7 +1618,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2181,7 +2181,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2198,15 +2198,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2214,9 +2211,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2224,7 +2221,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2239,7 +2236,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2250,27 +2247,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -775,7 +775,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1574,7 +1574,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1587,6 +1587,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1615,14 +1630,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1636,7 +1651,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3207,7 +3222,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3277,7 +3292,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3294,7 +3309,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3373,48 +3388,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3426,6 +3443,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -622,7 +622,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -631,9 +631,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -641,7 +641,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 87a9f86d1ad7de67ff011311905ecf76578b26e9 +Subproject commit 3cce1bdee8c61bb6daa089059e12435178f50770 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31fcb55f4ff8c06c5ab100a6817cae8b571295a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31fcb55f4ff8c06c5ab100a6817cae8b571295a9 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:23:51 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Fri, 30 Oct 2020 19:23:51 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Split HsConDecl{H98,GADT}Details Message-ID: <5f9ca0877950f_8973fa3bbf472041388824@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 109f3cfe by Ryan Scott at 2020-10-30T19:23:37-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - 904a038c by Sylvain Henry at 2020-10-30T19:23:42-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 67a26cdb by Sylvain Henry at 2020-10-30T19:23:42-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - 4c9c8ee8 by Ben Gamari at 2020-10-30T19:23:43-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - bba8aec7 by Ben Gamari at 2020-10-30T19:23:43-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 5b3972b5 by Sylvain Henry at 2020-10-30T19:23:45-04:00 Move loadDecl into IfaceToCore - - - - - 30 changed files: - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/TyThing.hs - docs/users_guide/9.2.1-notes.rst The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ac6f8806bb9524d2e7cd8f9518e8391c07e3d79...5b3972b563c8b871c424ad703daa4c4322b673a8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ac6f8806bb9524d2e7cd8f9518e8391c07e3d79...5b3972b563c8b871c424ad703daa4c4322b673a8 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:40:05 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 30 Oct 2020 19:40:05 -0400 Subject: [Git][ghc/ghc][wip/T16762] 3 commits: [skip ci] Fix typo in `callocBytes` haddock. Message-ID: <5f9ca455a3869_8973fa3d9aa52281393166@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T16762 at Glasgow Haskell Compiler / GHC Commits: 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - e9b2578f by Ryan Scott at 2020-10-30T19:38:31-04:00 Replace HsImplicitBndrs with HsOuterTyVarBndrs This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com> Co-authored-by: Richard Eisenberg <rae at richarde.dev> Co-authored-by: Zubin Duggal <zubin at cmi.ac.in> - - - - - 21 changed files: - compiler/GHC/Core/Coercion.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Extension.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Tc/Deriv.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors.hs - compiler/GHC/Tc/Gen/Bind.hs - compiler/GHC/Tc/Gen/Head.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19f717ba6414e3d15b3960f27619ae84b6a21fae...e9b2578fa17989f13ec6ba8fae0c35b2dac4d900 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/19f717ba6414e3d15b3960f27619ae84b6a21fae...e9b2578fa17989f13ec6ba8fae0c35b2dac4d900 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:49:35 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 19:49:35 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/angerman/ghc-9.0-runpath-backport Message-ID: <5f9ca68f3dfa7_8973fa31ac651cc1395832@gitlab.haskell.org.mail> Ben Gamari deleted branch wip/angerman/ghc-9.0-runpath-backport at Glasgow Haskell Compiler / GHC -- You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:49:38 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 19:49:38 -0400 Subject: [Git][ghc/ghc][ghc-9.0] [macOS] improved runpath handling Message-ID: <5f9ca692bd73_897f7a3ca81396023@gitlab.haskell.org.mail> Ben Gamari pushed to branch ghc-9.0 at Glasgow Haskell Compiler / GHC Commits: 7644d85c by Moritz Angermann at 2020-10-30T10:59:36-04:00 [macOS] improved runpath handling 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) (cherry picked from commit 89a753308deb2c7ed012e875e220b1d39e1798d8) Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 16 changed files: - aclocal.m4 - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools.hs - compiler/GHC/SysTools/Tasks.hs - configure.ac - docs/users_guide/phases.rst - hadrian/cfg/system.config.in - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Generate.hs - includes/ghc.mk - mk/config.mk.in - testsuite/tests/rts/all.T Changes: ===================================== aclocal.m4 ===================================== @@ -586,6 +586,18 @@ AC_DEFUN([FP_SETTINGS], else SettingsOptCommand="$OptCmd" fi + if test -z "$OtoolCmd" + then + SettingsOtoolCommand="otool" + else + SettingsOtoolCommand="$OtoolCmd" + fi + if test -z "$InstallNameToolCmd" + then + SettingsInstallNameToolCommand="install_name_tool" + else + SettingsInstallNameToolCommand="$InstallNameToolCmd" + fi SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2" SettingsCxxCompilerFlags="$CONF_CXX_OPTS_STAGE2" SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2" @@ -604,6 +616,8 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsMergeObjectsFlags) AC_SUBST(SettingsArCommand) AC_SUBST(SettingsRanlibCommand) + AC_SUBST(SettingsOtoolCommand) + AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) AC_SUBST(SettingsLibtoolCommand) ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -391,7 +391,56 @@ compileEmptyStub dflags hsc_env basename location mod_name = do -- --------------------------------------------------------------------------- -- Link - +-- +-- Note [Dynamic linking on macOS] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- +-- Since macOS Sierra (10.14), the dynamic system linker enforces +-- a limit on the Load Commands. Specifically the Load Command Size +-- Limit is at 32K (32768). The Load Commands contain the install +-- name, dependencies, runpaths, and a few other commands. We however +-- only have control over the install name, dependencies and runpaths. +-- +-- The install name is the name by which this library will be +-- referenced. This is such that we do not need to bake in the full +-- absolute location of the library, and can move the library around. +-- +-- The dependency commands contain the install names from of referenced +-- libraries. Thus if a libraries install name is @rpath/libHS...dylib, +-- that will end up as the dependency. +-- +-- Finally we have the runpaths, which informs the linker about the +-- directories to search for the referenced dependencies. +-- +-- The system linker can do recursive linking, however using only the +-- direct dependencies conflicts with ghc's ability to inline across +-- packages, and as such would end up with unresolved symbols. +-- +-- Thus we will pass the full dependency closure to the linker, and then +-- ask the linker to remove any unused dynamic libraries (-dead_strip_dylibs). +-- +-- We still need to add the relevant runpaths, for the dynamic linker to +-- lookup the referenced libraries though. The linker (ld64) does not +-- have any option to dead strip runpaths; which makes sense as runpaths +-- can be used for dependencies of dependencies as well. +-- +-- The solution we then take in GHC is to not pass any runpaths to the +-- linker at link time, but inject them after the linking. For this to +-- work we'll need to ask the linker to create enough space in the header +-- to add more runpaths after the linking (-headerpad 8000). +-- +-- After the library has been linked by $LD (usually ld64), we will use +-- otool to inspect the libraries left over after dead stripping, compute +-- the relevant runpaths, and inject them into the linked product using +-- the install_name_tool command. +-- +-- This strategy should produce the smallest possible set of load commands +-- while still retaining some form of relocatability via runpaths. +-- +-- The only way I can see to reduce the load command size further would be +-- by shortening the library names, or start putting libraries into the same +-- folders, such that one runpath would be sufficient for multiple/all +-- libraries. link :: GhcLink -- interactive or batch -> DynFlags -- dynamic flags -> Bool -- attempt linking in batch mode? @@ -1766,9 +1815,12 @@ linkBinary' staticLink dflags o_files dep_units = do rc_objs <- maybeCreateManifest dflags output_fn - let link = if staticLink - then GHC.SysTools.runLibtool - else GHC.SysTools.runLink + let link dflags args | staticLink = GHC.SysTools.runLibtool dflags args + | platformOS platform == OSDarwin + = GHC.SysTools.runLink dflags args >> GHC.SysTools.runInjectRPaths dflags pkg_lib_paths output_fn + | otherwise + = GHC.SysTools.runLink dflags args + link dflags ( map GHC.SysTools.Option verbFlags ++ [ GHC.SysTools.Option "-o" @@ -1835,7 +1887,13 @@ linkBinary' staticLink dflags o_files dep_units = do ++ pkg_link_opts ++ pkg_framework_opts ++ (if platformOS platform == OSDarwin - then [ "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the left over + -- libraries during runInjectRpaths phase. + -- + -- See Note [Dynamic linking on macOS]. + then [ "-Wl,-dead_strip_dylibs", "-Wl,-headerpad,8000" ] else []) )) ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -147,8 +147,8 @@ module GHC.Driver.Session ( versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, pgm_L, pgm_P, pgm_F, pgm_c, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, - pgm_windres, pgm_libtool, pgm_ar, pgm_ranlib, pgm_lo, pgm_lc, - pgm_lcc, pgm_i, + pgm_windres, pgm_libtool, pgm_ar, pgm_otool, pgm_install_name_tool, + pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, opt_P_signature, opt_windres, opt_lo, opt_lc, opt_lcc, @@ -950,6 +950,10 @@ pgm_lcc :: DynFlags -> (String,[Option]) pgm_lcc dflags = toolSettings_pgm_lcc $ toolSettings dflags pgm_ar :: DynFlags -> String pgm_ar dflags = toolSettings_pgm_ar $ toolSettings dflags +pgm_otool :: DynFlags -> String +pgm_otool dflags = toolSettings_pgm_otool $ toolSettings dflags +pgm_install_name_tool :: DynFlags -> String +pgm_install_name_tool dflags = toolSettings_pgm_install_name_tool $ toolSettings dflags pgm_ranlib :: DynFlags -> String pgm_ranlib dflags = toolSettings_pgm_ranlib $ toolSettings dflags pgm_lo :: DynFlags -> (String,[Option]) @@ -2393,6 +2397,10 @@ dynamic_flags_deps = [ $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_libtool = f } , make_ord_flag defFlag "pgmar" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ar = f } + , make_ord_flag defFlag "pgmotool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_otool = f} + , make_ord_flag defFlag "pgminstall_name_tool" + $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_install_name_tool = f} , make_ord_flag defFlag "pgmranlib" $ hasArg $ \f -> alterToolSettings $ \s -> s { toolSettings_pgm_ranlib = f } @@ -3903,7 +3911,6 @@ defaultFlags settings Opt_OmitYields, Opt_PrintBindContents, Opt_ProfCountEntries, - Opt_RPath, Opt_SharedImplib, Opt_SimplPreInlining, Opt_VersionMacros @@ -3914,6 +3921,8 @@ defaultFlags settings ++ default_PIC platform + ++ default_RPath platform + ++ concatMap (wayGeneralFlags platform) (defaultWays settings) ++ validHoleFitDefaults @@ -3954,6 +3963,29 @@ default_PIC platform = -- information. _ -> [] + +-- We usually want to use RPath, except on macOS (OSDarwin). On recent macOS +-- versions the number of load commands we can embed in a dynamic library is +-- restricted. Hence since b592bd98ff2 we rely on -dead_strip_dylib to only +-- link the needed dylibs instead of linking the full dependency closure. +-- +-- If we split the library linking into injecting -rpath and -l @rpath/... +-- components, we will reduce the number of libraries we link, however we will +-- still inject one -rpath entry for each library, independent of their use. +-- That is, we even inject -rpath values for libraries that we dead_strip in +-- the end. As such we can run afoul of the load command size limit simply +-- by polluting the load commands with RPATH entries. +-- +-- Thus, we disable Opt_RPath by default on OSDarwin. The savvy user can always +-- enable it with -use-rpath if they so wish. +-- +-- See Note [Dynamic linking on macOS] + +default_RPath :: Platform -> [GeneralFlag] +default_RPath platform | platformOS platform == OSDarwin = [] +default_RPath _ = [Opt_RPath] + + -- General flags that are switched on/off when other general flags are switched -- on impliedGFlags :: [(GeneralFlag, TurnOnFlag, GeneralFlag)] ===================================== compiler/GHC/Runtime/Linker.hs ===================================== @@ -927,20 +927,22 @@ dynLoadObjs hsc_env pls at PersistentLinkerState{..} objs = do ldInputs = concatMap (\l -> [ Option ("-l" ++ l) ]) (nub $ snd <$> temp_sos) - ++ concatMap (\lp -> [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp ]) + ++ concatMap (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) (nub $ fst <$> temp_sos) ++ concatMap - (\lp -> - [ Option ("-L" ++ lp) - , Option "-Xlinker" - , Option "-rpath" - , Option "-Xlinker" - , Option lp - ]) + (\lp -> Option ("-L" ++ lp) + : if gopt Opt_RPath dflags + then [ Option "-Xlinker" + , Option "-rpath" + , Option "-Xlinker" + , Option lp ] + else []) minus_big_ls -- See Note [-Xlinker -rpath vs -Wl,-rpath] ++ map (\l -> Option ("-l" ++ l)) minus_ls, ===================================== compiler/GHC/Settings.hs ===================================== @@ -36,6 +36,8 @@ module GHC.Settings , sPgm_windres , sPgm_libtool , sPgm_ar + , sPgm_otool + , sPgm_install_name_tool , sPgm_ranlib , sPgm_lo , sPgm_lc @@ -109,6 +111,8 @@ data ToolSettings = ToolSettings , toolSettings_pgm_windres :: String , toolSettings_pgm_libtool :: String , toolSettings_pgm_ar :: String + , toolSettings_pgm_otool :: String + , toolSettings_pgm_install_name_tool :: String , toolSettings_pgm_ranlib :: String , -- | LLVM: opt llvm optimiser toolSettings_pgm_lo :: (String, [Option]) @@ -222,6 +226,10 @@ sPgm_libtool :: Settings -> String sPgm_libtool = toolSettings_pgm_libtool . sToolSettings sPgm_ar :: Settings -> String sPgm_ar = toolSettings_pgm_ar . sToolSettings +sPgm_otool :: Settings -> String +sPgm_otool = toolSettings_pgm_otool . sToolSettings +sPgm_install_name_tool :: Settings -> String +sPgm_install_name_tool = toolSettings_pgm_install_name_tool . sToolSettings sPgm_ranlib :: Settings -> String sPgm_ranlib = toolSettings_pgm_ranlib . sToolSettings sPgm_lo :: Settings -> (String, [Option]) ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -116,6 +116,8 @@ initSettings top_dir = do windres_path <- getToolSetting "windres command" libtool_path <- getToolSetting "libtool command" ar_path <- getToolSetting "ar command" + otool_path <- getToolSetting "otool command" + install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" -- TODO this side-effect doesn't belong here. Reading and parsing the settings @@ -192,6 +194,8 @@ initSettings top_dir = do , toolSettings_pgm_windres = windres_path , toolSettings_pgm_libtool = libtool_path , toolSettings_pgm_ar = ar_path + , toolSettings_pgm_otool = otool_path + , toolSettings_pgm_install_name_tool = install_name_tool_path , toolSettings_pgm_ranlib = ranlib_path , toolSettings_pgm_lo = (lo_prog,[]) , toolSettings_pgm_lc = (lc_prog,[]) ===================================== compiler/GHC/SysTools.hs ===================================== @@ -254,7 +254,10 @@ linkDynLib dflags0 o_files dep_packages | ( osElfTarget (platformOS (targetPlatform dflags)) || osMachOTarget (platformOS (targetPlatform dflags)) ) && dynLibLoader dflags == SystemDependent && - WayDyn `Set.member` ways dflags + -- Only if we want dynamic libraries + WayDyn `Set.member` ways dflags && + -- Only use RPath if we explicitly asked for it + gopt Opt_RPath dflags = ["-L" ++ l, "-Xlinker", "-rpath", "-Xlinker", l] -- See Note [-Xlinker -rpath vs -Wl,-rpath] | otherwise = ["-L" ++ l] @@ -379,8 +382,15 @@ linkDynLib dflags0 o_files dep_packages ++ map Option pkg_lib_path_opts ++ map Option pkg_link_opts ++ map Option pkg_framework_opts - ++ [ Option "-Wl,-dead_strip_dylibs" ] + -- dead_strip_dylibs, will remove unused dylibs, and thus save + -- space in the load commands. The -headerpad is necessary so + -- that we can inject more @rpath's later for the leftover + -- libraries in the runInjectRpaths phase below. + -- + -- See Note [Dynamic linking on macOS] + ++ [ Option "-Wl,-dead_strip_dylibs", Option "-Wl,-headerpad,8000" ] ) + runInjectRPaths dflags pkg_lib_paths output_fn _ -> do ------------------------------------------------------------------- -- Making a DSO ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -28,6 +28,10 @@ import GHC.CmmToLlvm.Base (LlvmVersion, llvmVersionStr, supportedLlvmVersion, pa import GHC.SysTools.Process import GHC.SysTools.Info +import Control.Monad (join, forM, filterM) +import System.Directory (doesFileExist) +import System.FilePath (()) + {- ************************************************************************ * * @@ -237,6 +241,41 @@ figureLlvmVersion dflags = traceToolCommand dflags "llc" $ do return Nothing) +-- | On macOS we rely on the linkers @-dead_strip_dylibs@ flag to remove unused +-- libraries from the dynamic library. We do this to reduce the number of load +-- commands that end up in the dylib, and has been limited to 32K (32768) since +-- macOS Sierra (10.14). +-- +-- @-dead_strip_dylibs@ does not dead strip @-rpath@ entries, as such passing +-- @-l@ and @-rpath@ to the linker will result in the unnecesasry libraries not +-- being included in the load commands, however the @-rpath@ entries are all +-- forced to be included. This can lead to 100s of @-rpath@ entries being +-- included when only a handful of libraries end up being truely linked. +-- +-- Thus after building the library, we run a fixup phase where we inject the +-- @-rpath@ for each found library (in the given library search paths) into the +-- dynamic library through @-add_rpath at . +-- +-- See Note [Dynamic linking on macOS] +runInjectRPaths :: DynFlags -> [FilePath] -> FilePath -> IO () +runInjectRPaths dflags lib_paths dylib = do + info <- lines <$> askOtool dflags Nothing [Option "-L", Option dylib] + -- filter the output for only the libraries. And then drop the @rpath prefix. + let libs = fmap (drop 7) $ filter (isPrefixOf "@rpath") $ fmap (head.words) $ info + -- find any pre-existing LC_PATH items + info <- fmap words.lines <$> askOtool dflags Nothing [Option "-l", Option dylib] + let paths = concatMap f info + where f ("path":p:_) = [p] + f _ = [] + lib_paths' = [ p | p <- lib_paths, not (p `elem` paths) ] + -- only find those rpaths, that aren't already in the library. + rpaths <- nub.sort.join <$> forM libs (\f -> filterM (\l -> doesFileExist (l f)) lib_paths') + -- inject the rpaths + case rpaths of + [] -> return () + _ -> runInstallNameTool dflags $ map Option $ "-add_rpath":(intersperse "-add_rpath" rpaths) ++ [dylib] + + runLink :: DynFlags -> [Option] -> IO () runLink dflags args = traceToolCommand dflags "linker" $ do -- See Note [Run-time linker info] @@ -329,6 +368,17 @@ runAr dflags cwd args = traceToolCommand dflags "ar" $ do let ar = pgm_ar dflags runSomethingFiltered dflags id "Ar" ar args cwd Nothing +askOtool :: DynFlags -> Maybe FilePath -> [Option] -> IO String +askOtool dflags mb_cwd args = do + let otool = pgm_otool dflags + runSomethingWith dflags "otool" otool args $ \real_args -> + readCreateProcessWithExitCode' (proc otool real_args){ cwd = mb_cwd } + +runInstallNameTool :: DynFlags -> [Option] -> IO () +runInstallNameTool dflags args = do + let tool = pgm_install_name_tool dflags + runSomethingFiltered dflags id "Install Name Tool" tool args Nothing Nothing + runRanlib :: DynFlags -> [Option] -> IO () runRanlib dflags args = traceToolCommand dflags "ranlib" $ do let ranlib = pgm_ranlib dflags ===================================== configure.ac ===================================== @@ -696,6 +696,18 @@ else fi AC_SUBST([LibtoolCmd]) +dnl ** Which otool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([OTOOL], [otool]) +OtoolCmd="$OTOOL" +AC_SUBST(OtoolCmd) + +dnl ** Which install_name_tool to use on macOS +dnl -------------------------------------------------------------- +AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) +InstallNameToolCmd="$INSTALL_NAME_TOOL" +AC_SUBST(InstallNameToolCmd) + # Here is where we re-target which specific version of the LLVM # tools we are looking for. In the past, GHC supported a number of # versions of LLVM simultaneously, but that stopped working around @@ -1519,6 +1531,8 @@ echo "\ libtool : $LibtoolCmd objdump : $ObjdumpCmd ranlib : $RanlibCmd + otool : $OtoolCmd + install_name_tool : $InstallNameToolCmd windres : $WindresCmd dllwrap : $DllWrapCmd genlib : $GenlibCmd ===================================== docs/users_guide/phases.rst ===================================== @@ -95,6 +95,24 @@ given compilation phase: Use ⟨cmd⟩ as the pre-processor (with :ghc-flag:`-F` only). +.. ghc-flag:: -pgmotool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inspect mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inspect mach-o dynamic libraries and + executables to read the dynamic library dependencies. We will compute + the necessary ``runpath``s to embed for the dependencies based on the + result of the ``otool`` call. + +.. ghc-flag:: -pgminstall_name_tool ⟨cmd⟩ + :shortdesc: Use ⟨cmd⟩ as the program to inject ``runpath`` into mach-o dylibs on macOS + :type: dynamic + :category: phase-programs + + Use ⟨cmd⟩ as the program to inject ``runpath``s into mach-o dynamic + libraries and executables. As detected by the ``otool`` call. + .. ghc-flag:: -pgmwindres ⟨cmd⟩ :shortdesc: Use ⟨cmd⟩ as the program for embedding manifests on Windows. :type: dynamic ===================================== hadrian/cfg/system.config.in ===================================== @@ -149,6 +149,8 @@ settings-merge-objects-command = @SettingsMergeObjectsCommand@ settings-merge-objects-flags = @SettingsMergeObjectsFlags@ settings-ar-command = @SettingsArCommand@ settings-ranlib-command = @SettingsRanlibCommand@ +settings-otool-command = @SettingsOtoolCommand@ +settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ settings-libtool-command = @SettingsLibtoolCommand@ ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -114,6 +114,8 @@ data SettingsFileSetting | SettingsFileSetting_MergeObjectsFlags | SettingsFileSetting_ArCommand | SettingsFileSetting_RanlibCommand + | SettingsFileSetting_OtoolCommand + | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand | SettingsFileSetting_LibtoolCommand @@ -199,6 +201,8 @@ settingsFileSetting key = lookupValueOrError configFile $ case key of SettingsFileSetting_MergeObjectsFlags -> "settings-merge-objects-flags" SettingsFileSetting_ArCommand -> "settings-ar-command" SettingsFileSetting_RanlibCommand -> "settings-ranlib-command" + SettingsFileSetting_OtoolCommand -> "settings-otool-command" + SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" SettingsFileSetting_LibtoolCommand -> "settings-libtool-command" ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -298,6 +298,8 @@ generateSettings = do , ("ar flags", expr $ lookupValueOrError configFile "ar-args") , ("ar supports at file", expr $ yesNo <$> flag ArSupportsAtFile) , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) + , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) + , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) ===================================== includes/ghc.mk ===================================== @@ -229,6 +229,8 @@ $(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/. @echo ',("ar flags", "$(ArArgs)")' >> $@ @echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@ @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ + @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ + @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ ===================================== mk/config.mk.in ===================================== @@ -503,6 +503,8 @@ SettingsLdFlags = @SettingsLdFlags@ SettingsMergeObjectsCommand = @SettingsMergeObjectsCommand@ SettingsMergeObjectsFlags = @SettingsMergeObjectsFlags@ SettingsArCommand = @SettingsArCommand@ +SettingsOtoolCommand = @SettingsOtoolCommand@ +SettingsInstallNameToolCommand = @SettingsInstallNameToolCommand@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ ===================================== testsuite/tests/rts/all.T ===================================== @@ -406,7 +406,7 @@ test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp - test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', - [when(opsys('darwin') or opsys('mingw32'), expect_broken(17447)), + [when(opsys('mingw32'), expect_broken(17447)), extra_files(['T13676.hs'])], ghci_script, ['T13676.script']) test('InitEventLogging', View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7644d85ca21ca8af9cd81d64d6c88afc80e03eb5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7644d85ca21ca8af9cd81d64d6c88afc80e03eb5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:49:45 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 19:49:45 -0400 Subject: [Git][ghc/ghc][wip/T15808] 2 commits: rts/linker: Fix relocation overflow in PE linker Message-ID: <5f9ca699f40be_8973fa3b8e387bc1396217@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T15808 at Glasgow Haskell Compiler / GHC Commits: 0a435602 by Ben Gamari at 2020-10-30T19:49:37-04:00 rts/linker: Fix relocation overflow in PE linker Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808. - - - - - 59c459f2 by Ben Gamari at 2020-10-30T19:49:37-04:00 rts/linker: Try using m32 to allocate PE symbol extras - - - - - 3 changed files: - rts/Linker.c - rts/LinkerInternals.h - rts/linker/PEi386.c Changes: ===================================== rts/Linker.c ===================================== @@ -1351,7 +1351,7 @@ void freeObjectCode (ObjectCode *oc) ocDeinit_ELF(oc); #endif -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) m32_allocator_free(oc->rx_m32); m32_allocator_free(oc->rw_m32); #endif @@ -1422,7 +1422,7 @@ mkOc( pathchar *path, char *image, int imageSize, /* chain it onto the list of objects */ oc->next = NULL; -#if RTS_LINKER_USE_MMAP +#if defined(USE_M32) oc->rw_m32 = m32_allocator_new(false); oc->rx_m32 = m32_allocator_new(true); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -236,7 +236,7 @@ typedef struct _ObjectCode { require extra information.*/ StrHashTable *extraInfos; -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) /* The m32 allocators used for allocating small sections and symbol extras * during loading. We have two: one for (writeable) data and one for * (read-only/executable) code. */ @@ -336,6 +336,12 @@ resolveSymbolAddr (pathchar* buffer, int size, #define USE_CONTIGUOUS_MMAP 0 #endif +// We use the m32 allocator on Windows and Unix platforms using mmap +#if (RTS_LINKER_USE_MMAP == 1) || defined(PE_OBJFORMAT) +#define USE_M32 +#endif + + HsInt isAlreadyLoaded( pathchar *path ); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( pathchar *path, char *image, int imageSize, ===================================== rts/linker/PEi386.c ===================================== @@ -1294,7 +1294,7 @@ ocVerifyImage_PEi386 ( ObjectCode* oc ) = (PEi386_IMAGE_OFFSET + 2 * default_alignment + oc->info->secBytesTotal) & ~0x7; oc->info->secBytesTotal - = oc->info->trampoline + info->numberOfSymbols * sizeof(SymbolExtra); + = oc->info->trampoline; /* No further verification after this point; only debug printing. */ i = 0; @@ -1792,12 +1792,15 @@ ocAllocateExtras_PEi386 ( ObjectCode* oc ) if (!oc->info) return false; - const int mask = default_alignment - 1; - size_t origin = oc->info->trampoline; + COFF_HEADER_INFO *info = oc->info->ch_info; + size_t extras_size = info->numberOfSymbols * sizeof(SymbolExtra); + oc->symbol_extras - = (SymbolExtra*)((uintptr_t)(oc->info->image + origin + mask) & ~mask); + = (SymbolExtra*) m32_alloc(oc->rx_m32, extras_size, 8); + if (oc->symbol_extras == NULL) + return false; + oc->first_symbol_extra = 0; - COFF_HEADER_INFO *info = oc->info->ch_info; oc->n_symbol_extras = info->numberOfSymbols; return true; @@ -1952,13 +1955,15 @@ ocResolve_PEi386 ( ObjectCode* oc ) { uint64_t v; v = S + A; - if (v >> 32) { + // N.B. in the case of the sign-extended relocations we must ensure that v + // fits in a signed 32-bit value. See #15808. + if (((int64_t) v > (int64_t) INT32_MAX) || ((int64_t) v < (int64_t) INT32_MIN)) { copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol); /* And retry */ v = S + A; - if (v >> 32) { + if (((int64_t) v > (int64_t) INT32_MAX) || ((int64_t) v < (int64_t) INT32_MIN)) { barf("IMAGE_REL_AMD64_ADDR32[NB]: High bits are set in %zx for %s", v, (char *)symbol); } @@ -1970,14 +1975,14 @@ ocResolve_PEi386 ( ObjectCode* oc ) { intptr_t v; v = S + (int32_t)A - ((intptr_t)pP) - 4; - if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) { + if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { /* Make the trampoline then */ copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol); /* And retry */ v = S + (int32_t)A - ((intptr_t)pP) - 4; - if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) { + if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { barf("IMAGE_REL_AMD64_REL32: High bits are set in %zx for %s", v, (char *)symbol); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7547b5b63e362a3f165fa8980e35325b7322ada4...59c459f2e0f5d5ba948bb9ea03f54f8c42c0e93e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7547b5b63e362a3f165fa8980e35325b7322ada4...59c459f2e0f5d5ba948bb9ea03f54f8c42c0e93e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:52:27 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 19:52:27 -0400 Subject: [Git][ghc/ghc][wip/unloading] 4 commits: Fix and enable object unloading in GHCi Message-ID: <5f9ca73b464d9_8976c8b6981397218@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: c2ed5e81 by Ömer Sinan Ağacan at 2020-10-30T19:52:22-04:00 Fix and enable object unloading in GHCi Fixes #16525 See Note [Object unloading] in CheckUnload.c for details. - - - - - 75ae73fa by Ray Shih at 2020-10-30T19:52:22-04:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - a888e94b by GHC GitLab CI at 2020-10-30T19:52:22-04:00 rts: Introduce highMemDynamic - - - - - 708ea4cf by GHC GitLab CI at 2020-10-30T19:52:23-04:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - compiler/GHC/Runtime/Linker.hs - includes/rts/Linker.h - includes/rts/storage/GC.h - rts/CheckUnload.c - rts/CheckUnload.h - rts/Hash.c - rts/Hash.h - rts/Linker.c - rts/LinkerInternals.h - rts/RtsStartup.c - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/MachO.c - rts/linker/PEi386.c - rts/linker/elf_got.c - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GC.h - rts/sm/Storage.c - testsuite/tests/ghci/T16525a/T16525a.script - testsuite/tests/ghci/T16525a/T16525a.stdout - testsuite/tests/ghci/T16525a/all.T - + testsuite/tests/ghci/T16525b/A.hs - + testsuite/tests/ghci/T16525b/B.hs - + testsuite/tests/ghci/T16525b/T16525b.script - + testsuite/tests/ghci/T16525b/T16525b.stdout - + testsuite/tests/ghci/T16525b/all.T - testsuite/tests/rts/linker/Makefile - testsuite/tests/rts/linker/all.T - testsuite/tests/rts/linker/linker_error.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3cff938c3f97f7072a6e1c6d79c0ad644694878...708ea4cf8be9803fb100f20d44531f9be5f7a13f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e3cff938c3f97f7072a6e1c6d79c0ad644694878...708ea4cf8be9803fb100f20d44531f9be5f7a13f You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Fri Oct 30 23:59:21 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Fri, 30 Oct 2020 19:59:21 -0400 Subject: [Git][ghc/ghc][wip/T18389] 24 commits: Parser regression tests, close #12862 #12446 Message-ID: <5f9ca8d97c140_8973fa3b8241530140036@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC Commits: e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - b9fd0f0f by Simon Peyton Jones at 2020-10-30T19:58:30-04:00 Work in progress on #18359 Joint work between Richard, Simon, Ryan - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Type.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot - compiler/GHC/Core/TyCo/Ppr.hs - compiler/GHC/Core/TyCo/Rep.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55cf28534eaef254c16da050f5e63dc3ff6d7af...b9fd0f0f98706e4eda4657c014ed69e5a9afc57e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b55cf28534eaef254c16da050f5e63dc3ff6d7af...b9fd0f0f98706e4eda4657c014ed69e5a9afc57e You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 01:11:03 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Fri, 30 Oct 2020 21:11:03 -0400 Subject: [Git][ghc/ghc][wip/T18698] testsuite: Add performance test for #18698 Message-ID: <5f9cb9a731620_8973fa3bbe4bae414043ae@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18698 at Glasgow Haskell Compiler / GHC Commits: e81cb575 by Ben Gamari at 2020-10-31T01:10:53+00:00 testsuite: Add performance test for #18698 - - - - - 2 changed files: - + testsuite/tests/perf/compiler/T18698/T18698.hs - + testsuite/tests/perf/compiler/T18698/all.T Changes: ===================================== testsuite/tests/perf/compiler/T18698/T18698.hs ===================================== @@ -0,0 +1,85 @@ +{-# LANGUAGE StrictData #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE ScopedTypeVariables #-} + +module Blowup (Ps(..)) where + +import Data.Coerce +import Data.Semigroup (Semigroup(..), Last(..)) + +-- N.B. This was original Data.Semigroup.Option, which was deprecated +newtype Option a = Option (Maybe a) + +instance Semigroup a => Semigroup (Option a) where + (<>) = coerce ((<>) :: Maybe a -> Maybe a -> Maybe a) + stimes _ (Option Nothing) = Option Nothing + stimes n (Option (Just a)) = case compare n 0 of + LT -> error "stimes: Option, negative multiplier" + EQ -> Option Nothing + GT -> Option (Just (stimes n a)) + +-- | @since 4.9.0.0 +instance Semigroup a => Monoid (Option a) where + mempty = Option Nothing + +data Ps = Ps + { _p1 :: Maybe Double + , _p2 :: Maybe Double + , _p3 :: Maybe Double + , _p4 :: Maybe Double + , _p5 :: Maybe Double + , _p6 :: Maybe Double + , _p7 :: Maybe Double + , _p8 :: Maybe Double + , _p9 :: Maybe Double + , _p10 :: Maybe Double + , _p11 :: Maybe Double + , _p12 :: Maybe Double + , _p13 :: Maybe Double + , _p14 :: Maybe Double + , _p15 :: Maybe Double + , _p16 :: Maybe Double + , _p17 :: Maybe Double + , _p18 :: Maybe Double + , _p19 :: Maybe Double + , _p20 :: Maybe Double + , _pa :: Maybe (String, String) + } + +instance Semigroup Ps where + (<>) (Ps p_1 p_2 p_3 p_4 p_5 p_6 p_7 p_8 p_9 + p_10 p_11 p_12 p_13 p_14 p_15 p_16 p_17 p_18 p_19 p_20 + pa) + (Ps p_1' p_2' p_3' p_4' p_5' p_6' p_7' p_8' p_9' + p_10' p_11' p_12' p_13' p_14' p_15' p_16' p_17' p_18' p_19' p_20' + pa') + = Ps (f p_1 p_1') + (f p_2 p_2') + (f p_3 p_3') + (f p_4 p_4') + (f p_5 p_5') + (f p_6 p_6') + (f p_7 p_7') + (f p_8 p_8') + (f p_9 p_9') + (f p_10 p_10') + (f p_11 p_11') + (f p_12 p_12') + (f p_13 p_13') + (f p_14 p_14') + (f p_15 p_15') + (f p_16 p_16') + (f p_17 p_17') + (f p_18 p_18') + (f p_19 p_19') + (f p_20 p_20') + (f pa pa') + + where + f :: forall a. Maybe a -> Maybe a -> Maybe a +#if defined(COERCE) + f = coerce ((<>) :: Option (Last a) -> Option (Last a) -> Option (Last a)) +#else + f _ y@(Just _) = y + f x _ = x +#endif ===================================== testsuite/tests/perf/compiler/T18698/all.T ===================================== @@ -0,0 +1,15 @@ +test('T18698a', + [collect_compiler_residency(15), + collect_compiler_stats('bytes allocated', 1), + extra_files(['T18698.hs']) + ], + multimod_compile, + ['T18698', '-O2 -v0']) + +test('T18698b', + [collect_compiler_residency(15), + collect_compiler_stats('bytes allocated', 1), + extra_files(['T18698.hs']) + ], + multimod_compile, + ['T18698', '-O2 -v0 -DCOERCE']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81cb57536725e5f829754a6227bf07093449c11 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e81cb57536725e5f829754a6227bf07093449c11 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 05:13:38 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 01:13:38 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] 2 commits: Annotate hopefully "benign" race in freeGroup Message-ID: <5f9cf28293fba_7853fb660336db829323@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: 1050e8d8 by Ben Gamari at 2020-10-31T01:12:46-04:00 Annotate hopefully "benign" race in freeGroup - - - - - 098c1f93 by Ben Gamari at 2020-10-31T01:13:13-04:00 Strengthen ordering in releaseGCThreads - - - - - 2 changed files: - rts/sm/BlockAlloc.c - rts/sm/GC.c Changes: ===================================== rts/sm/BlockAlloc.c ===================================== @@ -856,6 +856,12 @@ freeGroup(bdescr *p) prev = p - 1; if (prev->blocks == 0) prev = prev->link; // find the head + // This is a bit hairy... we are looking at bd->free of a block that we + // do not own and yet have not synchronized with the thread that *does* + // own the block. We currently assume we won't see torn values and + // consequently this will work, although this is strictly speaking not + // guaranteed under the memory model. + TSAN_ANNOTATE_BENIGN_RACE(&prev->free, "freeGroup"); if (RELAXED_LOAD(&prev->free) == (P_)-1) { ln = log_2(prev->blocks); ===================================== rts/sm/GC.c ===================================== @@ -1416,10 +1416,10 @@ releaseGCThreads (Capability *cap USED_IF_THREADS, bool idle_cap[]) uint32_t i; for (i=0; i < n_threads; i++) { if (i == me || idle_cap[i]) continue; - if (RELAXED_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE) + if (SEQ_CST_LOAD(&gc_threads[i]->wakeup) != GC_THREAD_WAITING_TO_CONTINUE) barf("releaseGCThreads"); - RELAXED_STORE(&gc_threads[i]->wakeup, GC_THREAD_INACTIVE); + SEQ_CST_STORE(&gc_threads[i]->wakeup, GC_THREAD_INACTIVE); ACQUIRE_SPIN_LOCK(&gc_threads[i]->gc_spin); RELEASE_SPIN_LOCK(&gc_threads[i]->mut_spin); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8be6fdee5377d4fcd7eacd935b2644461c6e2bb...098c1f934c079cba390f4e51d83b744eaec12666 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b8be6fdee5377d4fcd7eacd935b2644461c6e2bb...098c1f934c079cba390f4e51d83b744eaec12666 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 06:54:04 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 02:54:04 -0400 Subject: [Git][ghc/ghc][master] Make typechecker equality consider visibility in ForAllTys Message-ID: <5f9d0a0cced84_785b7e2e5c365be@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - 14 changed files: - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/exts/type_applications.rst - + testsuite/tests/saks/should_fail/T18863a.hs - + testsuite/tests/saks/should_fail/T18863a.stderr - + testsuite/tests/saks/should_fail/T18863b.hs - + testsuite/tests/saks/should_fail/T18863b.stderr - testsuite/tests/saks/should_fail/all.T - + testsuite/tests/typecheck/should_compile/T15079.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -485,6 +485,12 @@ Another helpful principle with eqType is this: This principle also tells us that eqType must relate only types with the same kinds. +Besides eqType, another equality relation that upholds the (EQ) property above +is /typechecker equality/, which is implemented as +GHC.Tc.Utils.TcType.tcEqType. See +Note [Typechecker equality vs definitional equality] in GHC.Tc.Utils.TcType for +what the difference between eqType and tcEqType is. + Note [Respecting definitional equality] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note [Non-trivial definitional equality] introduces the property (EQ). ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -2236,7 +2236,7 @@ eqVarBndrs _ _ _= Nothing {- Note [nonDetCmpType nondeterminism] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nonDetCmpType is implemented in terms of nonDetCmpTypeX. nonDetCmpTypeX uses nonDetCmpTc which compares TyCons by their Unique value. Using Uniques for ordering leads to nondeterminism. We hit the same problem in the TyVarTy case, @@ -2926,7 +2926,7 @@ splitVisVarsOfTypes = foldMap splitVisVarsOfType ************************************************************************ Note [Kind Constraint and kind Type] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The kind Constraint is the kind of classes and other type constraints. The special thing about types of kind Constraint is that * They are displayed with double arrow: @@ -2945,6 +2945,18 @@ generates an axiom witnessing so on the left we have Constraint, and on the right we have Type. See #7451. +Because we treat Constraint/Type differently during and after type inference, +GHC has two notions of equality that differ in whether they equate +Constraint/Type or not: + +* GHC.Tc.Utils.TcType.tcEqType implements typechecker equality (see + Note [Typechecker equality vs definitional equality] in GHC.Tc.Utils.TcType), + which treats Constraint and Type as distinct. This is used during type + inference. See #11715 for issues that arise from this. +* GHC.Core.TyCo.Rep.eqType implements definitional equality (see + Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep), which treats + Constraint and Type as equal. This is used after type inference. + Bottom line: although 'Type' and 'Constraint' are distinct TyCons, with distinct uniques, they are treated as equal at all times except during type inference. ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1035,7 +1035,9 @@ can_eq_nc' _flat _rdr_env _envs ev eq_rel = canTyConApp ev eq_rel tc1 tys1 tc2 tys2 can_eq_nc' _flat _rdr_env _envs ev eq_rel - s1@(ForAllTy {}) _ s2@(ForAllTy {}) _ + s1@(ForAllTy (Bndr _ vis1) _) _ + s2@(ForAllTy (Bndr _ vis2) _) _ + | vis1 `sameVis` vis2 -- Note [ForAllTy and typechecker equality] = can_eq_nc_forall ev eq_rel s1 s2 -- See Note [Canonicalising type applications] about why we require flat types @@ -1071,6 +1073,63 @@ If we have an unsolved equality like that is not necessarily insoluble! Maybe 'a' will turn out to be a newtype. So we want to make it a potentially-soluble Irred not an insoluble one. Missing this point is what caused #15431 + +Note [ForAllTy and typechecker equality] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Should GHC type-check the following program (adapted from #15740)? + + {-# LANGUAGE PolyKinds, ... #-} + data D a + type family F :: forall k. k -> Type + type instance F = D + +Due to the way F is declared, any instance of F must have a right-hand side +whose kind is equal to `forall k. k -> Type`. The kind of D is +`forall {k}. k -> Type`, which is very close, but technically uses distinct +Core: + + ----------------------------------------------------------- + | Source Haskell | Core | + ----------------------------------------------------------- + | forall k. <...> | ForAllTy (Bndr k Specified) (<...>) | + | forall {k}. <...> | ForAllTy (Bndr k Inferred) (<...>) | + ----------------------------------------------------------- + +We could deem these kinds to be unequal, but that would imply rejecting +programs like the one above. Whether a kind variable binder ends up being +specified or inferred can be somewhat subtle, however, especially for kinds +that aren't explicitly written out in the source code (like in D above). +For now, we decide to not make the specified/inferred status of an invisible +type variable binder affect GHC's notion of typechecker equality +(see Note [Typechecker equality vs definitional equality] in +GHC.Tc.Utils.TcType). That is, we have the following: + + -------------------------------------------------- + | Type 1 | Type 2 | Equal? | + --------------------|----------------------------- + | forall k. <...> | forall k. <...> | Yes | + | | forall {k}. <...> | Yes | + | | forall k -> <...> | No | + -------------------------------------------------- + | forall {k}. <...> | forall k. <...> | Yes | + | | forall {k}. <...> | Yes | + | | forall k -> <...> | No | + -------------------------------------------------- + | forall k -> <...> | forall k. <...> | No | + | | forall {k}. <...> | No | + | | forall k -> <...> | Yes | + -------------------------------------------------- + +We implement this nuance by using the GHC.Types.Var.sameVis function in +GHC.Tc.Solver.Canonical.canEqNC and GHC.Tc.Utils.TcType.tcEqType, which +respect typechecker equality. sameVis puts both forms of invisible type +variable binders into the same equivalence class. + +Note that we do /not/ use sameVis in GHC.Core.Type.eqType, which implements +/definitional/ equality, a slighty more coarse-grained notion of equality +(see Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep) that does +not consider the ArgFlag of ForAllTys at all. That is, eqType would equate all +of forall k. <...>, forall {k}. <...>, and forall k -> <...>. -} --------------------------------- ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1506,9 +1506,8 @@ tcEqKind :: HasDebugCallStack => TcKind -> TcKind -> Bool tcEqKind = tcEqType tcEqType :: HasDebugCallStack => TcType -> TcType -> Bool --- tcEqType is a proper implements the same Note [Non-trivial definitional --- equality] (in GHC.Core.TyCo.Rep) as `eqType`, but Type.eqType believes (* == --- Constraint), and that is NOT what we want in the type checker! +-- ^ tcEqType implements typechecker equality, as described in +-- @Note [Typechecker equality vs definitional equality]@. tcEqType ty1 ty2 = tc_eq_type False False ki1 ki2 && tc_eq_type False False ty1 ty2 @@ -1557,7 +1556,9 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 go env (ForAllTy (Bndr tv1 vis1) ty1) (ForAllTy (Bndr tv2 vis2) ty2) - = vis1 == vis2 + = vis1 `sameVis` vis2 + -- See Note [ForAllTy and typechecker equality] in + -- GHC.Tc.Solver.Canonical for why we use `sameVis` here && (vis_only || go env (varType tv1) (varType tv2)) && go (rnBndr2 env tv1 tv2) ty1 ty2 @@ -1622,6 +1623,29 @@ tc_eq_type keep_syns vis_only orig_ty1 orig_ty2 get_args _ _ = False eqFunTy _ _ _ _ _ = False +{- Note [Typechecker equality vs definitional equality] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GHC has two notions of equality over Core types: + +* Definitional equality, as implemented by GHC.Core.Type.eqType. + See Note [Non-trivial definitional equality] in GHC.Core.TyCo.Rep. +* Typechecker equality, as implemented by tcEqType (in GHC.Tc.Utils.TcType). + GHC.Tc.Solver.Canonical.canEqNC also respects typechecker equality. + +Typechecker equality implies definitional equality: if two types are equal +according to typechecker equality, then they are also equal according to +definitional equality. The converse is not always true, as typechecker equality +is more finer-grained than definitional equality in two places: + +* Unlike definitional equality, which equates Type and Constraint, typechecker + treats them as distinct types. See Note [Kind Constraint and kind Type] in + GHC.Core.Type. +* Unlike definitional equality, which does not care about the ArgFlag of a + ForAllTy, typechecker equality treats Required type variable binders as + distinct from Invisible type variable binders. + See Note [ForAllTy and typechecker equality] in GHC.Tc.Solver.Canonical. +-} + {- ********************************************************************* * * Predicate types ===================================== compiler/GHC/Tc/Utils/Unify.hs ===================================== @@ -1321,7 +1321,7 @@ We expand synonyms during unification, but: This is particularly helpful when checking (* ~ *), because * is now a type synonym. -Note [Deferred Unification] +Note [Deferred unification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ We may encounter a unification ty1 ~ ty2 that cannot be performed syntactically, and yet its consistency is undetermined. Previously, there was no way to still ===================================== docs/users_guide/exts/poly_kinds.rst ===================================== @@ -769,24 +769,6 @@ In this redefinition, we give an explicit kind for ``(:~~:)``, deferring the cho of ``k2`` until after the first argument (``a``) has been given. With this declaration for ``(:~~:)``, the instance for ``HTestEquality`` is accepted. -Another difference between higher-rank kinds and types can be found in their -treatment of inferred and user-specified type variables. Consider the following -program: :: - - newtype Foo (f :: forall k. k -> Type) = MkFoo (f Int) - data Proxy a = Proxy - - foo :: Foo Proxy - foo = MkFoo Proxy - -The kind of ``Foo``'s parameter is ``forall k. k -> Type``, but the kind of -``Proxy`` is ``forall {k}. k -> Type``, where ``{k}`` denotes that the kind -variable ``k`` is to be inferred, not specified by the user. (See -:ref:`visible-type-application` for more discussion on the inferred-specified -distinction). GHC does not consider ``forall k. k -> Type`` and -``forall {k}. k -> Type`` to be equal at the kind level, and thus rejects -``Foo Proxy`` as ill-kinded. - The kind ``Type`` ----------------- ===================================== docs/users_guide/exts/type_applications.rst ===================================== @@ -246,8 +246,7 @@ The braces are *not* allowed in the following places: explicitly applied. Making them inferred (and thus not appliable) would be conflicting. -- In default type signatures for class methods, in SPECIALISE pragmas or in - instance declaration heads, e.g.:: +- In SPECIALISE pragmas or in instance declaration heads, e.g.:: instance forall {a}. Eq (Maybe a) where ... @@ -256,3 +255,22 @@ The braces are *not* allowed in the following places: could play a role. - On the left-hand sides of type declarations, such as classes, data types, etc. + +Note that while specified and inferred type variables have different properties +vis-à-vis visible type application, they do not otherwise affect GHC's notion +of equality over types. For example, given the following definitions: :: + + id1 :: forall a. a -> a + id1 x = x + + id2 :: forall {a}. a -> a + id2 x = x + + app1 :: (forall a. a -> a) -> b -> b + app1 g x = g x + + app2 :: (forall {a}. a -> a) -> b -> b + app2 g x = g x + +GHC will deem all of ``app1 id1``, ``app1 id2``, ``app2 id1``, and ``app2 id2`` +to be well typed. ===================================== testsuite/tests/saks/should_fail/T18863a.hs ===================================== @@ -0,0 +1,9 @@ +{-# Language PolyKinds #-} +{-# Language RankNTypes #-} +{-# Language StandaloneKindSignatures #-} +module T18863a where + +import Data.Kind + +type IDa :: forall i -> i -> Type +data IDa :: forall i. i -> Type ===================================== testsuite/tests/saks/should_fail/T18863a.stderr ===================================== @@ -0,0 +1,5 @@ + +T18863a.hs:9:1: error: + • Couldn't match expected kind: forall i. i -> * + with actual kind: forall i -> i -> * + • In the data type declaration for ‘IDa’ ===================================== testsuite/tests/saks/should_fail/T18863b.hs ===================================== @@ -0,0 +1,9 @@ +{-# Language PolyKinds #-} +{-# Language RankNTypes #-} +{-# Language StandaloneKindSignatures #-} +module T18863b where + +import Data.Kind + +type IDb :: forall i. i -> Type +data IDb :: forall i -> i -> Type ===================================== testsuite/tests/saks/should_fail/T18863b.stderr ===================================== @@ -0,0 +1,5 @@ + +T18863b.hs:9:1: error: + • Couldn't match expected kind: forall i -> i -> * + with actual kind: i -> * + • In the data type declaration for ‘IDb’ ===================================== testsuite/tests/saks/should_fail/all.T ===================================== @@ -31,3 +31,5 @@ test('T16725', normal, compile_fail, ['']) test('T16826', normal, compile_fail, ['']) test('T16756b', normal, compile_fail, ['']) test('T16758', normal, compile_fail, ['']) +test('T18863a', normal, compile_fail, ['']) +test('T18863b', normal, compile_fail, ['']) ===================================== testsuite/tests/typecheck/should_compile/T15079.hs ===================================== @@ -0,0 +1,64 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} +module T15079 where + +import Data.Kind +import qualified Data.Type.Equality as Eq +import Data.Void +import GHC.Exts (Any) + +infixl 4 :== +-- | Heterogeneous Leibnizian equality. +newtype (a :: j) :== (b :: k) + = HRefl { hsubst :: forall (c :: forall (i :: Type). i -> Type). c a -> c b } + +----- + +newtype Coerce a = Coerce { uncoerce :: Starify a } +type family Starify (a :: k) :: Type where + Starify (a :: Type) = a + Starify _ = Void + +coerce :: a :== b -> a -> b +coerce f = uncoerce . hsubst f . Coerce + +----- + +newtype Flay :: (forall (i :: Type). i -> i -> Type) + -> forall (j :: Type). j -> forall (k :: Type). k -> Type where + Flay :: forall (p :: forall (i :: Type). i -> i -> Type) + (j :: Type) (k :: Type) (a :: j) (b :: k). + { unflay :: p a (MassageKind j b) } -> Flay p a b + +type family MassageKind (j :: Type) (a :: k) :: j where + MassageKind j (a :: j) = a + MassageKind _ _ = Any + +fromLeibniz :: forall a b. a :== b -> a Eq.:~: b +fromLeibniz f = unflay $ hsubst f $ Flay Eq.Refl + +----- + +newtype Foo (f :: forall (a :: Type). a -> Type) = MkFoo (f Int) +data InferredProxy a = MkInferredProxy + +foo :: Foo InferredProxy +foo = MkFoo MkInferredProxy + +----- + +id1 :: forall a. a -> a +id1 x = x + +id2 :: forall {a}. a -> a +id2 x = x + +app1 :: (forall a. a -> a) -> b -> b +app1 g x = g x + +app2 :: (forall {a}. a -> a) -> b -> b +app2 g x = g x ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -627,6 +627,7 @@ test('SplitWD', normal, compile, ['']) # (2) Build the program twice: once with -dynamic, and then # with -prof using -osuf to set a different object file suffix. test('T14441', omit_ways(['profasm']), compile, ['']) +test('T15079', normal, compile, ['']) test('T15050', normal, compile, ['']) test('T14735', normal, compile, ['']) test('T15180', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57c3db9612463426e1724816fd3f98142fec0e31 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57c3db9612463426e1724816fd3f98142fec0e31 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 06:54:44 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 02:54:44 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Refactor numeric constant folding rules Message-ID: <5f9d0a342c649_7853fb642dd5418390b1@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - 5 changed files: - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Types/Literal.hs - + testsuite/tests/simplCore/should_run/NumConstantFolding.hs - + testsuite/tests/simplCore/should_run/NumConstantFolding.stdout - testsuite/tests/simplCore/should_run/all.T Changes: ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -1,8 +1,6 @@ {- (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 -\section[ConFold]{Constant Folder} - Conceptually, constant folding should be parameterized with the kind of target machine to get identical behaviour during compilation time and runtime. We cheat a little bit here... @@ -13,9 +11,18 @@ ToDo: -} {-# LANGUAGE CPP, RankNTypes, PatternSynonyms, ViewPatterns, RecordWildCards, - DeriveFunctor, LambdaCase, TypeApplications #-} + DeriveFunctor, LambdaCase, TypeApplications, MultiWayIf #-} + {-# OPTIONS_GHC -optc-DNON_POSIX_SOURCE -Wno-incomplete-uni-patterns #-} +#if __GLASGOW_HASKELL__ <= 808 +-- GHC 8.10 deprecates this flag, but GHC 8.8 needs it +-- The default iteration limit is a bit too low for the definitions +-- in this module. +{-# OPTIONS_GHC -fmax-pmcheck-iterations=20000000 #-} +#endif + +-- | Constant Folder module GHC.Core.Opt.ConstantFold ( primOpRules , builtinRules @@ -100,12 +107,12 @@ primOpRules nm = \case -- Int operations IntAddOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (+)) , identityPlatform zeroi - , numFoldingRules IntAddOp intPrimOps + , addFoldingRules IntAddOp intOps ] IntSubOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (-)) , rightIdentityPlatform zeroi , equalArgs >> retLit zeroi - , numFoldingRules IntSubOp intPrimOps + , subFoldingRules IntSubOp intOps ] IntAddCOp -> mkPrimOpRule nm 2 [ binaryLit (intOpC2 (+)) , identityCPlatform zeroi ] @@ -115,7 +122,7 @@ primOpRules nm = \case IntMulOp -> mkPrimOpRule nm 2 [ binaryLit (intOp2 (*)) , zeroElem zeroi , identityPlatform onei - , numFoldingRules IntMulOp intPrimOps + , mulFoldingRules IntMulOp intOps ] IntQuotOp -> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (intOp2 quot) , leftZero zeroi @@ -152,12 +159,12 @@ primOpRules nm = \case -- Word operations WordAddOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (+)) , identityPlatform zerow - , numFoldingRules WordAddOp wordPrimOps + , addFoldingRules WordAddOp wordOps ] WordSubOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (-)) , rightIdentityPlatform zerow , equalArgs >> retLit zerow - , numFoldingRules WordSubOp wordPrimOps + , subFoldingRules WordSubOp wordOps ] WordAddCOp -> mkPrimOpRule nm 2 [ binaryLit (wordOpC2 (+)) , identityCPlatform zerow ] @@ -166,7 +173,7 @@ primOpRules nm = \case , equalArgs >> retLitNoC zerow ] WordMulOp -> mkPrimOpRule nm 2 [ binaryLit (wordOp2 (*)) , identityPlatform onew - , numFoldingRules WordMulOp wordPrimOps + , mulFoldingRules WordMulOp wordOps ] WordQuotOp -> mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (wordOp2 quot) , rightIdentityPlatform onew ] @@ -1878,181 +1885,348 @@ match_smallIntegerTo _ _ _ _ _ = Nothing -- -------------------------------------------------------- --- | Rules to perform constant folding into nested expressions +-- Rules to perform constant folding into nested expressions -- --See Note [Constant folding through nested expressions] -numFoldingRules :: PrimOp -> (Platform -> PrimOps) -> RuleM CoreExpr -numFoldingRules op dict = do - env <- getEnv - if not (roNumConstantFolding env) - then mzero - else do - [e1,e2] <- getArgs - platform <- getPlatform - let PrimOps{..} = dict platform - case BinOpApp e1 op e2 of - -- R1) +/- simplification - x :++: (y :++: v) -> return $ mkL (x+y) `add` v - x :++: (L y :-: v) -> return $ mkL (x+y) `sub` v - x :++: (v :-: L y) -> return $ mkL (x-y) `add` v - L x :-: (y :++: v) -> return $ mkL (x-y) `sub` v - L x :-: (L y :-: v) -> return $ mkL (x-y) `add` v - L x :-: (v :-: L y) -> return $ mkL (x+y) `sub` v - - (y :++: v) :-: L x -> return $ mkL (y-x) `add` v - (L y :-: v) :-: L x -> return $ mkL (y-x) `sub` v - (v :-: L y) :-: L x -> return $ mkL (0-y-x) `add` v - - (x :++: w) :+: (y :++: v) -> return $ mkL (x+y) `add` (w `add` v) - (w :-: L x) :+: (L y :-: v) -> return $ mkL (y-x) `add` (w `sub` v) - (w :-: L x) :+: (v :-: L y) -> return $ mkL (0-x-y) `add` (w `add` v) - (L x :-: w) :+: (L y :-: v) -> return $ mkL (x+y) `sub` (w `add` v) - (L x :-: w) :+: (v :-: L y) -> return $ mkL (x-y) `add` (v `sub` w) - (w :-: L x) :+: (y :++: v) -> return $ mkL (y-x) `add` (w `add` v) - (L x :-: w) :+: (y :++: v) -> return $ mkL (x+y) `add` (v `sub` w) - (y :++: v) :+: (w :-: L x) -> return $ mkL (y-x) `add` (w `add` v) - (y :++: v) :+: (L x :-: w) -> return $ mkL (x+y) `add` (v `sub` w) - - (v :-: L y) :-: (w :-: L x) -> return $ mkL (x-y) `add` (v `sub` w) - (v :-: L y) :-: (L x :-: w) -> return $ mkL (0-x-y) `add` (v `add` w) - (L y :-: v) :-: (w :-: L x) -> return $ mkL (x+y) `sub` (v `add` w) - (L y :-: v) :-: (L x :-: w) -> return $ mkL (y-x) `add` (w `sub` v) - (x :++: w) :-: (y :++: v) -> return $ mkL (x-y) `add` (w `sub` v) - (w :-: L x) :-: (y :++: v) -> return $ mkL (0-y-x) `add` (w `sub` v) - (L x :-: w) :-: (y :++: v) -> return $ mkL (x-y) `sub` (v `add` w) - (y :++: v) :-: (w :-: L x) -> return $ mkL (y+x) `add` (v `sub` w) - (y :++: v) :-: (L x :-: w) -> return $ mkL (y-x) `add` (v `add` w) - - -- R2) * simplification - x :**: (y :**: v) -> return $ mkL (x*y) `mul` v - (x :**: w) :*: (y :**: v) -> return $ mkL (x*y) `mul` (w `mul` v) - - -- R3) * distribution over +/- - x :**: (y :++: v) -> return $ mkL (x*y) `add` (mkL x `mul` v) - x :**: (L y :-: v) -> return $ mkL (x*y) `sub` (mkL x `mul` v) - x :**: (v :-: L y) -> return $ (mkL x `mul` v) `sub` mkL (x*y) - - -- R4) Simple factorization - v :+: w - | w `cheapEqExpr` v -> return $ mkL 2 `mul` v - w :+: (y :**: v) - | w `cheapEqExpr` v -> return $ mkL (1+y) `mul` v - w :-: (y :**: v) - | w `cheapEqExpr` v -> return $ mkL (1-y) `mul` v - (y :**: v) :+: w - | w `cheapEqExpr` v -> return $ mkL (y+1) `mul` v - (y :**: v) :-: w - | w `cheapEqExpr` v -> return $ mkL (y-1) `mul` v - (x :**: w) :+: (y :**: v) - | w `cheapEqExpr` v -> return $ mkL (x+y) `mul` v - (x :**: w) :-: (y :**: v) - | w `cheapEqExpr` v -> return $ mkL (x-y) `mul` v - - -- R5) +/- propagation - w :+: (y :++: v) -> return $ mkL y `add` (w `add` v) - (y :++: v) :+: w -> return $ mkL y `add` (w `add` v) - w :-: (y :++: v) -> return $ (w `sub` v) `sub` mkL y - (y :++: v) :-: w -> return $ mkL y `add` (v `sub` w) - w :-: (L y :-: v) -> return $ (w `add` v) `sub` mkL y - (L y :-: v) :-: w -> return $ mkL y `sub` (w `add` v) - w :+: (L y :-: v) -> return $ mkL y `add` (w `sub` v) - w :+: (v :-: L y) -> return $ (w `add` v) `sub` mkL y - (L y :-: v) :+: w -> return $ mkL y `add` (w `sub` v) - (v :-: L y) :+: w -> return $ (w `add` v) `sub` mkL y - - _ -> mzero +addFoldingRules :: PrimOp -> NumOps -> RuleM CoreExpr +addFoldingRules op num_ops = do + ASSERT(op == numAdd num_ops) return () + env <- getEnv + guard (roNumConstantFolding env) + [arg1,arg2] <- getArgs + platform <- getPlatform + liftMaybe + -- commutativity for + is handled here + (addFoldingRules' platform arg1 arg2 num_ops + <|> addFoldingRules' platform arg2 arg1 num_ops) + +subFoldingRules :: PrimOp -> NumOps -> RuleM CoreExpr +subFoldingRules op num_ops = do + ASSERT(op == numSub num_ops) return () + env <- getEnv + guard (roNumConstantFolding env) + [arg1,arg2] <- getArgs + platform <- getPlatform + liftMaybe (subFoldingRules' platform arg1 arg2 num_ops) + +mulFoldingRules :: PrimOp -> NumOps -> RuleM CoreExpr +mulFoldingRules op num_ops = do + ASSERT(op == numMul num_ops) return () + env <- getEnv + guard (roNumConstantFolding env) + [arg1,arg2] <- getArgs + platform <- getPlatform + liftMaybe + -- commutativity for * is handled here + (mulFoldingRules' platform arg1 arg2 num_ops + <|> mulFoldingRules' platform arg2 arg1 num_ops) + + +addFoldingRules' :: Platform -> CoreExpr -> CoreExpr -> NumOps -> Maybe CoreExpr +addFoldingRules' platform arg1 arg2 num_ops = case (arg1, arg2) of + -- R1) +/- simplification + + -- l1 + (l2 + x) ==> (l1+l2) + x + (L l1, is_lit_add num_ops -> Just (l2,x)) + -> Just (mkL (l1+l2) `add` x) + + -- l1 + (l2 - x) ==> (l1+l2) - x + (L l1, is_sub num_ops -> Just (L l2,x)) + -> Just (mkL (l1+l2) `sub` x) + + -- l1 + (x - l2) ==> (l1-l2) + x + (L l1, is_sub num_ops -> Just (x,L l2)) + -> Just (mkL (l1-l2) `add` x) + + -- (l1 + x) + (l2 + y) ==> (l1+l2) + (x+y) + (is_lit_add num_ops -> Just (l1,x), is_lit_add num_ops -> Just (l2,y)) + -> Just (mkL (l1+l2) `add` (x `add` y)) + + -- (l1 + x) + (l2 - y) ==> (l1+l2) + (x-y) + (is_lit_add num_ops -> Just (l1,x), is_sub num_ops -> Just (L l2,y)) + -> Just (mkL (l1+l2) `add` (x `sub` y)) + + -- (l1 + x) + (y - l2) ==> (l1-l2) + (x+y) + (is_lit_add num_ops -> Just (l1,x), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (l1-l2) `add` (x `add` y)) + + -- (l1 - x) + (l2 - y) ==> (l1+l2) - (x+y) + (is_sub num_ops -> Just (L l1,x), is_sub num_ops -> Just (L l2,y)) + -> Just (mkL (l1+l2) `sub` (x `add` y)) + + -- (l1 - x) + (y - l2) ==> (l1-l2) + (y-x) + (is_sub num_ops -> Just (L l1,x), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (l1-l2) `add` (y `sub` x)) + + -- (x - l1) + (y - l2) ==> (0-l1-l2) + (x+y) + (is_sub num_ops -> Just (x,L l1), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (0-l1-l2) `add` (x `add` y)) + + -- R4) Simple factorization + + -- x + x ==> 2 * x + _ | Just l1 <- is_expr_mul num_ops arg1 arg2 + -> Just (mkL (l1+1) `mul` arg1) + + -- (l1 * x) + x ==> (l1+1) * x + _ | Just l1 <- is_expr_mul num_ops arg2 arg1 + -> Just (mkL (l1+1) `mul` arg2) + + -- (l1 * x) + (l2 * x) ==> (l1+l2) * x + (is_lit_mul num_ops -> Just (l1,x), is_expr_mul num_ops x -> Just l2) + -> Just (mkL (l1+l2) `mul` x) + + -- R5) +/- propagation: these transformations push literals outwards + -- with the hope that other rules can then be applied. + + -- In the following rules, x can't be a literal otherwise another + -- rule would have combined it with the other literal in arg2. So we + -- don't have to check this to avoid loops here. + + -- x + (l1 + y) ==> l1 + (x + y) + (_, is_lit_add num_ops -> Just (l1,y)) + -> Just (mkL l1 `add` (arg1 `add` y)) + + -- x + (l1 - y) ==> l1 + (x - y) + (_, is_sub num_ops -> Just (L l1,y)) + -> Just (mkL l1 `add` (arg1 `sub` y)) + + -- x + (y - l1) ==> (x + y) - l1 + (_, is_sub num_ops -> Just (y,L l1)) + -> Just ((arg1 `add` y) `sub` mkL l1) + + _ -> Nothing + where + mkL = Lit . mkNumLiteral platform num_ops + add x y = BinOpApp x (numAdd num_ops) y + sub x y = BinOpApp x (numSub num_ops) y + mul x y = BinOpApp x (numMul num_ops) y --- | Match the application of a binary primop -pattern BinOpApp :: Arg CoreBndr -> PrimOp -> Arg CoreBndr -> CoreExpr -pattern BinOpApp x op y = OpVal op `App` x `App` y +subFoldingRules' :: Platform -> CoreExpr -> CoreExpr -> NumOps -> Maybe CoreExpr +subFoldingRules' platform arg1 arg2 num_ops = case (arg1,arg2) of + -- R1) +/- simplification --- | Match a primop -pattern OpVal :: PrimOp -> Arg CoreBndr -pattern OpVal op <- Var (isPrimOpId_maybe -> Just op) where - OpVal op = Var (mkPrimOpId op) + -- l1 - (l2 + x) ==> (l1-l2) - x + (L l1, is_lit_add num_ops -> Just (l2,x)) + -> Just (mkL (l1-l2) `sub` x) + -- l1 - (l2 - x) ==> (l1-l2) + x + (L l1, is_sub num_ops -> Just (L l2,x)) + -> Just (mkL (l1-l2) `add` x) + -- l1 - (x - l2) ==> (l1+l2) - x + (L l1, is_sub num_ops -> Just (x, L l2)) + -> Just (mkL (l1+l2) `sub` x) --- | Match a literal -pattern L :: Integer -> Arg CoreBndr -pattern L l <- Lit (isLitValue_maybe -> Just l) + -- (l1 + x) - l2 ==> (l1-l2) + x + (is_lit_add num_ops -> Just (l1,x), L l2) + -> Just (mkL (l1-l2) `add` x) + + -- (l1 - x) - l2 ==> (l1-l2) - x + (is_sub num_ops -> Just (L l1,x), L l2) + -> Just (mkL (l1-l2) `sub` x) + + -- (x - l1) - l2 ==> x - (l1+l2) + (is_sub num_ops -> Just (x,L l1), L l2) + -> Just (x `sub` mkL (l1+l2)) + + + -- (l1 + x) - (l2 + y) ==> (l1-l2) + (x-y) + (is_lit_add num_ops -> Just (l1,x), is_lit_add num_ops -> Just (l2,y)) + -> Just (mkL (l1-l2) `add` (x `sub` y)) + + -- (l1 + x) - (l2 - y) ==> (l1-l2) + (x+y) + (is_lit_add num_ops -> Just (l1,x), is_sub num_ops -> Just (L l2,y)) + -> Just (mkL (l1-l2) `add` (x `add` y)) + + -- (l1 + x) - (y - l2) ==> (l1+l2) + (x-y) + (is_lit_add num_ops -> Just (l1,x), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (l1+l2) `add` (x `sub` y)) + + -- (l1 - x) - (l2 + y) ==> (l1-l2) - (x+y) + (is_sub num_ops -> Just (L l1,x), is_lit_add num_ops -> Just (l2,y)) + -> Just (mkL (l1-l2) `sub` (x `add` y)) + + -- (x - l1) - (l2 + y) ==> (0-l1-l2) + (x-y) + (is_sub num_ops -> Just (x,L l1), is_lit_add num_ops -> Just (l2,y)) + -> Just (mkL (0-l1-l2) `add` (x `sub` y)) + + -- (l1 - x) - (l2 - y) ==> (l1-l2) + (y-x) + (is_sub num_ops -> Just (L l1,x), is_sub num_ops -> Just (L l2,y)) + -> Just (mkL (l1-l2) `add` (y `sub` x)) + + -- (l1 - x) - (y - l2) ==> (l1+l2) - (x+y) + (is_sub num_ops -> Just (L l1,x), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (l1+l2) `sub` (x `add` y)) + + -- (x - l1) - (l2 - y) ==> (0-l1-l2) + (x+y) + (is_sub num_ops -> Just (x,L l1), is_sub num_ops -> Just (L l2,y)) + -> Just (mkL (0-l1-l2) `add` (x `add` y)) + + -- (x - l1) - (y - l2) ==> (l2-l1) + (x-y) + (is_sub num_ops -> Just (x,L l1), is_sub num_ops -> Just (y,L l2)) + -> Just (mkL (l2-l1) `add` (x `sub` y)) + + -- R4) Simple factorization --- | Match an addition -pattern (:+:) :: Arg CoreBndr -> Arg CoreBndr -> CoreExpr -pattern x :+: y <- BinOpApp x (isAddOp -> True) y + -- x - (l1 * x) ==> (1-l1) * x + _ | Just l1 <- is_expr_mul num_ops arg1 arg2 + -> Just (mkL (1-l1) `mul` arg1) --- | Match an addition with a literal (handle commutativity) -pattern (:++:) :: Integer -> Arg CoreBndr -> CoreExpr -pattern l :++: x <- (isAdd -> Just (l,x)) + -- (l1 * x) - x ==> (l1-1) * x + _ | Just l1 <- is_expr_mul num_ops arg2 arg1 + -> Just (mkL (l1-1) `mul` arg2) -isAdd :: CoreExpr -> Maybe (Integer,CoreExpr) -isAdd e = case e of - L l :+: x -> Just (l,x) - x :+: L l -> Just (l,x) - _ -> Nothing + -- (l1 * x) - (l2 * x) ==> (l1-l2) * x + (is_lit_mul num_ops -> Just (l1,x), is_expr_mul num_ops x -> Just l2) + -> Just (mkL (l1-l2) `mul` x) --- | Match a multiplication -pattern (:*:) :: Arg CoreBndr -> Arg CoreBndr -> CoreExpr -pattern x :*: y <- BinOpApp x (isMulOp -> True) y + -- R5) +/- propagation: these transformations push literals outwards + -- with the hope that other rules can then be applied. --- | Match a multiplication with a literal (handle commutativity) -pattern (:**:) :: Integer -> Arg CoreBndr -> CoreExpr -pattern l :**: x <- (isMul -> Just (l,x)) + -- In the following rules, x can't be a literal otherwise another + -- rule would have combined it with the other literal in arg2. So we + -- don't have to check this to avoid loops here. -isMul :: CoreExpr -> Maybe (Integer,CoreExpr) -isMul e = case e of - L l :*: x -> Just (l,x) - x :*: L l -> Just (l,x) - _ -> Nothing + -- x - (l1 + y) ==> (x - y) - l1 + (_, is_lit_add num_ops -> Just (l1,y)) + -> Just ((arg1 `sub` y) `sub` mkL l1) + -- (l1 + x) - y ==> l1 + (x - y) + (is_lit_add num_ops -> Just (l1,x), _) + -> Just (mkL l1 `add` (x `sub` arg2)) --- | Match a subtraction -pattern (:-:) :: Arg CoreBndr -> Arg CoreBndr -> CoreExpr -pattern x :-: y <- BinOpApp x (isSubOp -> True) y + -- x - (l1 - y) ==> (x + y) - l1 + (_, is_sub num_ops -> Just (L l1,y)) + -> Just ((arg1 `add` y) `sub` mkL l1) -isSubOp :: PrimOp -> Bool -isSubOp IntSubOp = True -isSubOp WordSubOp = True -isSubOp _ = False + -- x - (y - l1) ==> l1 + (x - y) + (_, is_sub num_ops -> Just (y,L l1)) + -> Just (mkL l1 `add` (arg1 `sub` y)) -isAddOp :: PrimOp -> Bool -isAddOp IntAddOp = True -isAddOp WordAddOp = True -isAddOp _ = False + -- (l1 - x) - y ==> l1 - (x + y) + (is_sub num_ops -> Just (L l1,x), _) + -> Just (mkL l1 `sub` (x `add` arg2)) -isMulOp :: PrimOp -> Bool -isMulOp IntMulOp = True -isMulOp WordMulOp = True -isMulOp _ = False + -- (x - l1) - y ==> (x - y) - l1 + (is_sub num_ops -> Just (x,L l1), _) + -> Just ((x `sub` arg2) `sub` mkL l1) + + _ -> Nothing + where + mkL = Lit . mkNumLiteral platform num_ops + add x y = BinOpApp x (numAdd num_ops) y + sub x y = BinOpApp x (numSub num_ops) y + mul x y = BinOpApp x (numMul num_ops) y + +mulFoldingRules' :: Platform -> CoreExpr -> CoreExpr -> NumOps -> Maybe CoreExpr +mulFoldingRules' platform arg1 arg2 num_ops = case (arg1,arg2) of + -- l1 * (l2 * x) ==> (l1*l2) * x + (L l1, is_lit_mul num_ops -> Just (l2,x)) + -> Just (mkL (l1*l2) `mul` x) + + -- l1 * (l2 + x) ==> (l1*l2) + (l1 * x) + (L l1, is_lit_add num_ops -> Just (l2,x)) + -> Just (mkL (l1*l2) `add` (arg1 `mul` x)) + + -- l1 * (l2 - x) ==> (l1*l2) - (l1 * x) + (L l1, is_sub num_ops -> Just (L l2,x)) + -> Just (mkL (l1*l2) `sub` (arg1 `mul` x)) + + -- l1 * (x - l2) ==> (l1 * x) - (l1*l2) + (L l1, is_sub num_ops -> Just (x, L l2)) + -> Just ((arg1 `mul` x) `sub` mkL (l1*l2)) + + -- (l1 * x) * (l2 * y) ==> (l1*l2) * (x * y) + (is_lit_mul num_ops -> Just (l1,x), is_lit_mul num_ops -> Just (l2,y)) + -> Just (mkL (l1*l2) `mul` (x `mul` y)) + + _ -> Nothing + where + mkL = Lit . mkNumLiteral platform num_ops + add x y = BinOpApp x (numAdd num_ops) y + sub x y = BinOpApp x (numSub num_ops) y + mul x y = BinOpApp x (numMul num_ops) y + +is_op :: PrimOp -> CoreExpr -> Maybe (Arg CoreBndr, Arg CoreBndr) +is_op op e = case e of + BinOpApp x op' y | op == op' -> Just (x,y) + _ -> Nothing + +is_add, is_sub, is_mul :: NumOps -> CoreExpr -> Maybe (Arg CoreBndr, Arg CoreBndr) +is_add num_ops = is_op (numAdd num_ops) +is_sub num_ops = is_op (numSub num_ops) +is_mul num_ops = is_op (numMul num_ops) + +-- match addition with a literal (handles commutativity) +is_lit_add :: NumOps -> CoreExpr -> Maybe (Integer, Arg CoreBndr) +is_lit_add num_ops e = case is_add num_ops e of + Just (L l, x ) -> Just (l,x) + Just (x , L l) -> Just (l,x) + _ -> Nothing + +-- match multiplication with a literal (handles commutativity) +is_lit_mul :: NumOps -> CoreExpr -> Maybe (Integer, Arg CoreBndr) +is_lit_mul num_ops e = case is_mul num_ops e of + Just (L l, x ) -> Just (l,x) + Just (x , L l) -> Just (l,x) + _ -> Nothing + +-- match given "x": return 1 +-- match "lit * x": return lit value (handles commutativity) +is_expr_mul :: NumOps -> Expr CoreBndr -> Expr CoreBndr -> Maybe Integer +is_expr_mul num_ops x e = if + | x `cheapEqExpr` e + -> Just 1 + | Just (k,x') <- is_lit_mul num_ops e + , x `cheapEqExpr` x' + -> return k + | otherwise + -> Nothing + + +-- | Match the application of a binary primop +pattern BinOpApp :: Arg CoreBndr -> PrimOp -> Arg CoreBndr -> CoreExpr +pattern BinOpApp x op y = OpVal op `App` x `App` y + +-- | Match a primop +pattern OpVal:: PrimOp -> Arg CoreBndr +pattern OpVal op <- Var (isPrimOpId_maybe -> Just op) where + OpVal op = Var (mkPrimOpId op) + +-- | Match a literal +pattern L :: Integer -> Arg CoreBndr +pattern L i <- Lit (LitNumber _ i) -- | Explicit "type-class"-like dictionary for numeric primops --- --- Depends on Platform because creating a literal value depends on Platform -data PrimOps = PrimOps - { add :: CoreExpr -> CoreExpr -> CoreExpr -- ^ Add two numbers - , sub :: CoreExpr -> CoreExpr -> CoreExpr -- ^ Sub two numbers - , mul :: CoreExpr -> CoreExpr -> CoreExpr -- ^ Multiply two numbers - , mkL :: Integer -> CoreExpr -- ^ Create a literal value +data NumOps = NumOps + { numAdd :: !PrimOp -- ^ Add two numbers + , numSub :: !PrimOp -- ^ Sub two numbers + , numMul :: !PrimOp -- ^ Multiply two numbers + , numLitType :: !LitNumType -- ^ Literal type } -intPrimOps :: Platform -> PrimOps -intPrimOps platform = PrimOps - { add = \x y -> BinOpApp x IntAddOp y - , sub = \x y -> BinOpApp x IntSubOp y - , mul = \x y -> BinOpApp x IntMulOp y - , mkL = intResult' platform - } +-- | Create a numeric literal +mkNumLiteral :: Platform -> NumOps -> Integer -> Literal +mkNumLiteral platform ops i = mkLitNumberWrap platform (numLitType ops) i -wordPrimOps :: Platform -> PrimOps -wordPrimOps platform = PrimOps - { add = \x y -> BinOpApp x WordAddOp y - , sub = \x y -> BinOpApp x WordSubOp y - , mul = \x y -> BinOpApp x WordMulOp y - , mkL = wordResult' platform +intOps :: NumOps +intOps = NumOps + { numAdd = IntAddOp + , numSub = IntSubOp + , numMul = IntMulOp + , numLitType = LitNumInt } +wordOps :: NumOps +wordOps = NumOps + { numAdd = WordAddOp + , numSub = WordSubOp + , numMul = WordMulOp + , numLitType = LitNumWord + } -------------------------------------------------------- -- Constant folding through case-expressions @@ -2082,14 +2256,14 @@ caseRules :: Platform caseRules platform (App (App (Var f) v) (Lit l)) -- v `op` x# | Just op <- isPrimOpId_maybe f - , Just x <- isLitValue_maybe l + , LitNumber _ x <- l , Just adjust_lit <- adjustDyadicRight op x = Just (v, tx_lit_con platform adjust_lit , \v -> (App (App (Var f) (Var v)) (Lit l))) caseRules platform (App (App (Var f) (Lit l)) v) -- x# `op` v | Just op <- isPrimOpId_maybe f - , Just x <- isLitValue_maybe l + , LitNumber _ x <- l , Just adjust_lit <- adjustDyadicLeft x op = Just (v, tx_lit_con platform adjust_lit , \v -> (App (App (Var f) (Lit l)) (Var v))) ===================================== compiler/GHC/Types/Literal.hs ===================================== @@ -36,7 +36,7 @@ module GHC.Types.Literal , inCharRange , isZeroLit , litFitsInChar - , litValue, isLitValue, isLitValue_maybe, mapLitValue + , litValue, mapLitValue -- ** Coercions , wordToIntLit, intToWordLit @@ -71,7 +71,6 @@ import Data.ByteString (ByteString) import Data.Int import Data.Word import Data.Char -import Data.Maybe ( isJust ) import Data.Data ( Data ) import Data.Proxy import Numeric ( fromRat ) @@ -462,11 +461,6 @@ mapLitValue _ f (LitChar c) = mkLitChar (fchar c) mapLitValue platform f (LitNumber nt i) = wrapLitNumber platform (LitNumber nt (f i)) mapLitValue _ _ l = pprPanic "mapLitValue" (ppr l) --- | Indicate if the `Literal` contains an 'Integer' value, e.g. 'Char', --- 'Int', 'Word', 'LitInteger' and 'LitNatural'. -isLitValue :: Literal -> Bool -isLitValue = isJust . isLitValue_maybe - {- Coercions ~~~~~~~~~ ===================================== testsuite/tests/simplCore/should_run/NumConstantFolding.hs ===================================== @@ -0,0 +1,109 @@ +{-# LANGUAGE MagicHash #-} + +import GHC.Exts +import Data.Word +import Data.Int + +(+&) = plusWord# +(-&) = minusWord# +(*&) = timesWord# + +{-# NOINLINE testsW #-} +-- NOINLINE otherwise basic constant folding rules (without +-- variables) are applied +testsW :: Word# -> Word# -> [Word] +testsW x y = fmap (\z -> fromIntegral (fromIntegral z :: Word32)) + -- narrowing to get the same results on both 64- and 32-bit arch + [ W# (43## +& (37## +& x)) + , W# (43## +& (37## -& x)) + , W# (43## +& (x -& 37##)) + , W# (43## -& (37## +& x)) + , W# (43## -& (37## -& x)) + , W# (43## -& (x -& 37##)) + , W# ((43## +& x) -& 37##) + , W# ((x +& 43##) -& 37##) + , W# ((43## -& x) -& 37##) + , W# ((x -& 43##) -& 37##) + + , W# ((x +& 43##) +& (y +& 37##)) + , W# ((x +& 43##) +& (y -& 37##)) + , W# ((x +& 43##) +& (37## -& y)) + , W# ((x -& 43##) +& (37## -& y)) + , W# ((x -& 43##) +& (y -& 37##)) + , W# ((43## -& x) +& (37## -& y)) + , W# ((43## -& x) +& (y -& 37##)) + ] + +{-# NOINLINE testsI #-} +testsI :: Int# -> Int# -> [Int] +testsI x y = fmap (\z -> fromIntegral (fromIntegral z :: Int32)) + [ I# (43# +# (37# +# x)) + , I# (43# +# (37# -# x)) + , I# (43# +# (x -# 37#)) + , I# (43# -# (37# +# x)) + , I# (43# -# (37# -# x)) + , I# (43# -# (x -# 37#)) + , I# ((43# +# x) -# 37#) + , I# ((x +# 43#) -# 37#) + , I# ((43# -# x) -# 37#) + , I# ((x -# 43#) -# 37#) + + , I# ((x +# 43#) +# (y +# 37#)) + , I# ((x +# 43#) +# (y -# 37#)) + , I# ((x +# 43#) +# (37# -# y)) + , I# ((x -# 43#) +# (37# -# y)) + , I# ((x -# 43#) +# (y -# 37#)) + , I# ((43# -# x) +# (37# -# y)) + , I# ((43# -# x) +# (y -# 37#)) + + , I# ((x +# 43#) -# (y +# 37#)) + , I# ((x +# 43#) -# (y -# 37#)) + , I# ((x +# 43#) -# (37# -# y)) + , I# ((x -# 43#) -# (y +# 37#)) + , I# ((43# -# x) -# (37# +# y)) + , I# ((x -# 43#) -# (y -# 37#)) + , I# ((x -# 43#) -# (37# -# y)) + , I# ((43# -# x) -# (y -# 37#)) + , I# ((43# -# x) -# (37# -# y)) + + , I# (43# *# (37# *# y)) + , I# (43# *# (y *# 37#)) + , I# ((43# *# x) *# (y *# 37#)) + + , I# (43# *# (37# +# y)) + , I# (43# *# (37# -# y)) + , I# (43# *# (y -# 37#)) + + , I# (x +# x) + , I# ((43# *# x) +# x) + , I# (x +# (43# *# x)) + , I# ((43# *# x) +# (37# *# x)) + , I# ((43# *# x) +# (x *# 37#)) + + , I# (x -# x) + , I# ((43# *# x) -# x) + , I# (x -# (43# *# x)) + , I# ((43# *# x) -# (37# *# x)) + , I# ((43# *# x) -# (x *# 37#)) + + , I# (x +# (37# +# y)) + , I# (x +# (y +# 37#)) + , I# (x +# (37# -# y)) + , I# (x +# (y -# 37#)) + , I# (x -# (37# +# y)) + , I# (x -# (y +# 37#)) + , I# (x -# (37# -# y)) + , I# (x -# (y -# 37#)) + , I# ((37# +# y) -# x) + , I# ((y +# 37#) -# x) + , I# ((37# -# y) -# x) + , I# ((y -# 37#) -# x) + + , I# (y *# y) + ] + + +main :: IO () +main = do + print (testsW 7## 13##) + print (testsI 7# 13#) ===================================== testsuite/tests/simplCore/should_run/NumConstantFolding.stdout ===================================== @@ -0,0 +1,2 @@ +[87,73,13,4294967295,13,73,13,13,4294967295,4294967223,100,26,74,4294967284,4294967236,60,12] +[87,73,13,-1,13,73,13,13,-1,-73,100,26,74,-12,-60,60,12,0,74,26,-86,-14,-12,-60,60,12,20683,20683,144781,2150,1032,-1032,14,308,308,560,560,0,294,-294,42,42,57,57,31,-17,-43,-43,-17,31,43,43,17,-31,169] ===================================== testsuite/tests/simplCore/should_run/all.T ===================================== @@ -93,3 +93,4 @@ test('T17151', [], multimod_compile_and_run, ['T17151', '']) test('T18012', normal, compile_and_run, ['']) test('T17744', normal, compile_and_run, ['']) test('T18638', normal, compile_and_run, ['']) +test('NumConstantFolding', normal, compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57c3db9612463426e1724816fd3f98142fec0e31...730ef38f467d67f4f664b2b4a5f4b236864e97b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/57c3db9612463426e1724816fd3f98142fec0e31...730ef38f467d67f4f664b2b4a5f4b236864e97b2 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 06:55:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 02:55:25 -0400 Subject: [Git][ghc/ghc][master] 2 commits: primops.txt.pp: Move ByteArray# primops to separate file Message-ID: <5f9d0a5dacf95_785f7a4cc0419a6@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 3 changed files: - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - + utils/genprimopcode/gen_bytearray_ops.py Changes: ===================================== compiler/GHC/Builtin/bytearray-ops.txt.pp ===================================== @@ -0,0 +1,551 @@ + +------------------------------------ +-- ByteArray# operations +------------------------------------ + + +-- Do not edit. This file is generated by utils/genprimopcode/gen_bytearray_ops.py. +-- To regenerate run, +-- +-- python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp + + +------------------------------------ +-- aligned index operations +------------------------------------ + +primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp + ByteArray# -> Int# -> Char# + {Read a 8-bit character; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp + ByteArray# -> Int# -> Char# + {Read a 32-bit character; offset in 4-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a word-sized integer; offset in machine words.} + with can_fail = True + +primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a word-sized unsigned integer; offset in machine words.} + with can_fail = True + +primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp + ByteArray# -> Int# -> Addr# + {Read a machine address; offset in machine words.} + with can_fail = True + +primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp + ByteArray# -> Int# -> Float# + {Read a single-precision floating-point value; offset in 4-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp + ByteArray# -> Int# -> Double# + {Read a double-precision floating-point value; offset in 8-byte words.} + with can_fail = True + +primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp + ByteArray# -> Int# -> StablePtr# a + {Read a {\tt StablePtr#} value; offset in machine words.} + with can_fail = True + +primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a 8-bit signed integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a 16-bit signed integer; offset in 2-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp + ByteArray# -> Int# -> INT32 + {Read a 32-bit signed integer; offset in 4-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp + ByteArray# -> Int# -> INT64 + {Read a 64-bit signed integer; offset in 8-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a 8-bit unsigned integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a 16-bit unsigned integer; offset in 2-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp + ByteArray# -> Int# -> WORD32 + {Read a 32-bit unsigned integer; offset in 4-byte words.} + with can_fail = True + +primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp + ByteArray# -> Int# -> WORD64 + {Read a 64-bit unsigned integer; offset in 8-byte words.} + with can_fail = True + + +------------------------------------ +-- unaligned index operations +------------------------------------ + +primop IndexByteArrayOp_Word8AsChar "indexWord8ArrayAsChar#" GenPrimOp + ByteArray# -> Int# -> Char# + {Read a 8-bit character; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWideChar "indexWord8ArrayAsWideChar#" GenPrimOp + ByteArray# -> Int# -> Char# + {Read a 32-bit character; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a word-sized integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a word-sized unsigned integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsAddr "indexWord8ArrayAsAddr#" GenPrimOp + ByteArray# -> Int# -> Addr# + {Read a machine address; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsFloat "indexWord8ArrayAsFloat#" GenPrimOp + ByteArray# -> Int# -> Float# + {Read a single-precision floating-point value; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsDouble "indexWord8ArrayAsDouble#" GenPrimOp + ByteArray# -> Int# -> Double# + {Read a double-precision floating-point value; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp + ByteArray# -> Int# -> StablePtr# a + {Read a {\tt StablePtr#} value; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp + ByteArray# -> Int# -> Int# + {Read a 16-bit signed integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp + ByteArray# -> Int# -> INT32 + {Read a 32-bit signed integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp + ByteArray# -> Int# -> INT64 + {Read a 64-bit signed integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp + ByteArray# -> Int# -> Word# + {Read a 16-bit unsigned integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp + ByteArray# -> Int# -> WORD32 + {Read a 32-bit unsigned integer; offset in bytes.} + with can_fail = True + +primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp + ByteArray# -> Int# -> WORD64 + {Read a 64-bit unsigned integer; offset in bytes.} + with can_fail = True + + +------------------------------------ +-- aligned read operations +------------------------------------ + +primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 8-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 32-bit character; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a word-sized integer; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a word-sized unsigned integer; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) + {Read a machine address; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) + {Read a single-precision floating-point value; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) + {Read a double-precision floating-point value; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) + {Read a {\tt StablePtr#} value; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 8-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 16-bit signed integer; offset in 2-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) + {Read a 32-bit signed integer; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + {Read a 64-bit signed integer; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 8-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 16-bit unsigned integer; offset in 2-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) + {Read a 32-bit unsigned integer; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + {Read a 64-bit unsigned integer; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + + +------------------------------------ +-- unaligned read operations +------------------------------------ + +primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 8-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) + {Read a 32-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a word-sized integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a word-sized unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) + {Read a machine address; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) + {Read a single-precision floating-point value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) + {Read a double-precision floating-point value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) + {Read a {\tt StablePtr#} value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) + {Read a 16-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) + {Read a 32-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) + {Read a 64-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) + {Read a 16-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) + {Read a 32-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) + {Read a 64-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + + +------------------------------------ +-- aligned write operations +------------------------------------ + +primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp + MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 8-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp + MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 32-bit character; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a word-sized integer; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a word-sized unsigned integer; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp + MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s + {Write a machine address; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp + MutableByteArray# s -> Int# -> Float# -> State# s -> State# s + {Write a single-precision floating-point value; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp + MutableByteArray# s -> Int# -> Double# -> State# s -> State# s + {Write a double-precision floating-point value; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp + MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s + {Write a {\tt StablePtr#} value; offset in machine words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 8-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 16-bit signed integer; offset in 2-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp + MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s + {Write a 32-bit signed integer; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp + MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + {Write a 64-bit signed integer; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 8-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 16-bit unsigned integer; offset in 2-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp + MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s + {Write a 32-bit unsigned integer; offset in 4-byte words.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp + MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + {Write a 64-bit unsigned integer; offset in 8-byte words.} + with has_side_effects = True + can_fail = True + + +------------------------------------ +-- unaligned write operations +------------------------------------ + +primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp + MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 8-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp + MutableByteArray# s -> Int# -> Char# -> State# s -> State# s + {Write a 32-bit character; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a word-sized integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a word-sized unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp + MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s + {Write a machine address; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp + MutableByteArray# s -> Int# -> Float# -> State# s -> State# s + {Write a single-precision floating-point value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp + MutableByteArray# s -> Int# -> Double# -> State# s -> State# s + {Write a double-precision floating-point value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp + MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s + {Write a {\tt StablePtr#} value; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp + MutableByteArray# s -> Int# -> Int# -> State# s -> State# s + {Write a 16-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp + MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s + {Write a 32-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp + MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s + {Write a 64-bit signed integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp + MutableByteArray# s -> Int# -> Word# -> State# s -> State# s + {Write a 16-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp + MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s + {Write a 32-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + +primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp + MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s + {Write a 64-bit unsigned integer; offset in bytes.} + with has_side_effects = True + can_fail = True + ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -1546,455 +1546,7 @@ primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp MutableByteArray# s -> State# s -> (# State# s, Int# #) {Return the number of elements in the array.} -primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp - ByteArray# -> Int# -> Char# - {Read 8-bit character; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp - ByteArray# -> Int# -> Char# - {Read 31-bit character; offset in 4-byte words.} - with can_fail = True - -primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp - ByteArray# -> Int# -> Int# - with can_fail = True - -primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp - ByteArray# -> Int# -> Word# - with can_fail = True - -primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp - ByteArray# -> Int# -> Addr# - with can_fail = True - -primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp - ByteArray# -> Int# -> Float# - with can_fail = True - -primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp - ByteArray# -> Int# -> Double# - with can_fail = True - -primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp - ByteArray# -> Int# -> StablePtr# a - with can_fail = True - -primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp - ByteArray# -> Int# -> Int# - {Read 8-bit integer; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp - ByteArray# -> Int# -> Int# - {Read 16-bit integer; offset in 16-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp - ByteArray# -> Int# -> INT32 - {Read 32-bit integer; offset in 32-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp - ByteArray# -> Int# -> INT64 - {Read 64-bit integer; offset in 64-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp - ByteArray# -> Int# -> Word# - {Read 8-bit word; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp - ByteArray# -> Int# -> Word# - {Read 16-bit word; offset in 16-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp - ByteArray# -> Int# -> WORD32 - {Read 32-bit word; offset in 32-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp - ByteArray# -> Int# -> WORD64 - {Read 64-bit word; offset in 64-bit words.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsChar "indexWord8ArrayAsChar#" GenPrimOp - ByteArray# -> Int# -> Char# - {Read 8-bit character; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsWideChar "indexWord8ArrayAsWideChar#" GenPrimOp - ByteArray# -> Int# -> Char# - {Read 31-bit character; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsAddr "indexWord8ArrayAsAddr#" GenPrimOp - ByteArray# -> Int# -> Addr# - {Read address; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsFloat "indexWord8ArrayAsFloat#" GenPrimOp - ByteArray# -> Int# -> Float# - {Read float; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsDouble "indexWord8ArrayAsDouble#" GenPrimOp - ByteArray# -> Int# -> Double# - {Read double; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp - ByteArray# -> Int# -> StablePtr# a - {Read stable pointer; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp - ByteArray# -> Int# -> Int# - {Read 16-bit int; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp - ByteArray# -> Int# -> INT32 - {Read 32-bit int; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp - ByteArray# -> Int# -> INT64 - {Read 64-bit int; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp - ByteArray# -> Int# -> Int# - {Read int; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp - ByteArray# -> Int# -> Word# - {Read 16-bit word; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp - ByteArray# -> Int# -> WORD32 - {Read 32-bit word; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp - ByteArray# -> Int# -> WORD64 - {Read 64-bit word; offset in bytes.} - with can_fail = True - -primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp - ByteArray# -> Int# -> Word# - {Read word; offset in bytes.} - with can_fail = True - -primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - {Read 8-bit character; offset in bytes.} - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - {Read 31-bit character; offset in 4-byte words.} - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - {Read integer; offset in machine words.} - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - {Read word; offset in machine words.} - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) - with has_side_effects = True - can_fail = True - -primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp - MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp - MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - {Write 8-bit character; offset in bytes.} - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp - MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - {Write 31-bit character; offset in 4-byte words.} - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp - MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp - MutableByteArray# s -> Int# -> Float# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp - MutableByteArray# s -> Int# -> Double# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp - MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp - MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s - with can_fail = True - has_side_effects = True - -primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp - MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp - MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp - MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp - MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp - MutableByteArray# s -> Int# -> Float# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp - MutableByteArray# s -> Int# -> Double# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp - MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp - MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp - MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp - MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp - MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp - MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s - with has_side_effects = True - can_fail = True - -primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp - MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True +#include "bytearray-ops.txt.pp" primop CompareByteArraysOp "compareByteArrays#" GenPrimOp ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int# ===================================== utils/genprimopcode/gen_bytearray_ops.py ===================================== @@ -0,0 +1,144 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from typing import Optional, NamedTuple +import textwrap + +class ElementType(NamedTuple): + name: str + rep_ty: str + desc: str + width: Optional[int] + +MACH_WORD = None + +element_types = [ + # (name, representation type, human description, width) + # + # width in bytes. + # width == None denotes machine word + + ElementType("Char", "Char#", "8-bit character", 1), + ElementType("WideChar", "Char#", "32-bit character", 4), + ElementType("Int", "Int#", "word-sized integer", MACH_WORD), + ElementType("Word", "Word#", "word-sized unsigned integer", MACH_WORD), + ElementType("Addr", "Addr#", "machine address", MACH_WORD), + ElementType("Float", "Float#", "single-precision floating-point value", 4), + ElementType("Double", "Double#", "double-precision floating-point value", 8), + ElementType("StablePtr", "StablePtr# a", "{\\tt StablePtr#} value", MACH_WORD), +] + +# TODO: Eventually when the sized integer primops use proper unboxed types we +# should rather do: +# +#for n in [8,16,32,64]: +# element_types += [ ElementType(f"Int{n}", f"Int{n}#", f"{n}-bit signed integer", n // 8) ] +# +#for n in [8,16,32,64]: +# element_types += [ ElementType(f"Word{n}", f"Word{n}#", f"{n}-bit unsigned integer", n // 8) ] + +element_types += [ + ElementType("Int8", "Int#", "8-bit signed integer", 1), + ElementType("Int16", "Int#", "16-bit signed integer", 2), + ElementType("Int32", "INT32", "32-bit signed integer", 4), + ElementType("Int64", "INT64", "64-bit signed integer", 8), + + ElementType("Word8", "Word#", "8-bit unsigned integer", 1), + ElementType("Word16", "Word#", "16-bit unsigned integer", 2), + ElementType("Word32", "WORD32", "32-bit unsigned integer", 4), + ElementType("Word64", "WORD64", "64-bit unsigned integer", 8), +] + +def pretty_offset(n: Optional[int]) -> str: + if n == MACH_WORD: + return 'machine words' + elif n == 1: + return 'bytes' + else: + return f'{n}-byte words' + +def print_block(template: str, **kwargs) -> None: + print(textwrap.dedent(template.format(**kwargs)).lstrip()) + +def header(s: str): + print('') + print_block(''' + ------------------------------------ + -- {s} + ------------------------------------ + ''', s=s) + + +header("ByteArray# operations") + +print(''' +-- Do not edit. This file is generated by utils/genprimopcode/gen_bytearray_ops.py. +-- To regenerate run, +-- +-- python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp +''') + +header('aligned index operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop IndexByteArrayOp_{name} "index{name}Array#" GenPrimOp + ByteArray# -> Int# -> {rep_ty} + {{Read a {desc}; offset in {offset}.}} + with can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned index operations') +for t in element_types: + if t.name in ['Int8', 'Word8']: continue + print_block(''' + primop IndexByteArrayOp_Word8As{name} "indexWord8ArrayAs{name}#" GenPrimOp + ByteArray# -> Int# -> {rep_ty} + {{Read a {desc}; offset in bytes.}} + with can_fail = True + ''', **t._asdict()) + +header('aligned read operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop ReadByteArrayOp_{name} "read{name}Array#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #) + {{Read a {desc}; offset in {offset}.}} + with has_side_effects = True + can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned read operations') +for t in element_types: + if t.name in ['Int8', 'Word8']: continue + print_block(''' + primop ReadByteArrayOp_Word8As{name} "readWord8ArrayAs{name}#" GenPrimOp + MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #) + {{Read a {desc}; offset in bytes.}} + with has_side_effects = True + can_fail = True + ''', **t._asdict()) + +header('aligned write operations') +for t in element_types: + offset = pretty_offset(t.width) + print_block(''' + primop WriteByteArrayOp_{name} "write{name}Array#" GenPrimOp + MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s + {{Write a {desc}; offset in {offset}.}} + with has_side_effects = True + can_fail = True + ''', offset = offset, **t._asdict()) + +header('unaligned write operations') +for t in element_types: + if t.name in ['Int8', 'Word8']: continue + print_block(''' + primop WriteByteArrayOp_Word8As{name} "writeWord8ArrayAs{name}#" GenPrimOp + MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s + {{Write a {desc}; offset in bytes.}} + with has_side_effects = True + can_fail = True + ''', **t._asdict()) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/730ef38f467d67f4f664b2b4a5f4b236864e97b2...b4278a41a18132a981b25c59b296cdf3ba970024 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/730ef38f467d67f4f664b2b4a5f4b236864e97b2...b4278a41a18132a981b25c59b296cdf3ba970024 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 06:55:58 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 02:55:58 -0400 Subject: [Git][ghc/ghc][master] Move loadDecl into IfaceToCore Message-ID: <5f9d0a7eba21b_785781559044422@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - 5 changed files: - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Types/TyThing.hs Changes: ===================================== compiler/GHC/Iface/Load.hs ===================================== @@ -2,13 +2,13 @@ (c) The University of Glasgow 2006 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 - -Loading interface files -} {-# LANGUAGE CPP, BangPatterns, RecordWildCards, NondecreasingIndentation #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} + +-- | Loading interface files module GHC.Iface.Load ( -- Importing one thing tcLookupImported_maybe, importDecl, @@ -23,7 +23,6 @@ module GHC.Iface.Load ( loadInterface, loadSysInterface, loadUserInterface, loadPluginInterface, findAndReadIface, readIface, writeIface, - loadDecls, -- Should move to GHC.IfaceToCore and be renamed initExternalPackageState, moduleFreeHolesPrecise, needWiredInHomeIface, loadWiredInHomeIface, @@ -37,7 +36,7 @@ module GHC.Iface.Load ( import GHC.Prelude import {-# SOURCE #-} GHC.IfaceToCore - ( tcIfaceDecl, tcIfaceRules, tcIfaceInst, tcIfaceFamInst + ( tcIfaceDecls, tcIfaceRules, tcIfaceInst, tcIfaceFamInst , tcIfaceAnnotations, tcIfaceCompleteMatches ) import GHC.Driver.Env @@ -48,7 +47,6 @@ import GHC.Driver.Hooks import GHC.Driver.Plugins import GHC.Iface.Syntax -import GHC.Iface.Env import GHC.Iface.Ext.Fields import GHC.Iface.Binary import GHC.Iface.Rename @@ -60,7 +58,6 @@ import GHC.Utils.Error import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic import GHC.Utils.Misc -import GHC.Utils.Fingerprint import GHC.Settings.Constants @@ -489,13 +486,13 @@ loadInterface doc_str mod from -- IfaceDecls, IfaceClsInst, IfaceFamInst, IfaceRules, -- out of the ModIface and put them into the big EPS pools - -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined + -- NB: *first* we do tcIfaceDecls, so that the provenance of all the locally-defined --- names is done correctly (notably, whether this is an .hi file or .hi-boot file). -- If we do loadExport first the wrong info gets into the cache (unless we -- explicitly tag each export which seems a bit of a bore) ; ignore_prags <- goptM Opt_IgnoreInterfacePragmas - ; new_eps_decls <- loadDecls ignore_prags (mi_decls iface) + ; new_eps_decls <- tcIfaceDecls ignore_prags (mi_decls iface) ; new_eps_insts <- mapM tcIfaceInst (mi_insts iface) ; new_eps_fam_insts <- mapM tcIfaceFamInst (mi_fam_insts iface) ; new_eps_rules <- tcIfaceRules ignore_prags (mi_rules iface) @@ -777,110 +774,6 @@ badSourceImport mod addDeclsToPTE :: PackageTypeEnv -> [(Name,TyThing)] -> PackageTypeEnv addDeclsToPTE pte things = extendNameEnvList pte things -loadDecls :: Bool - -> [(Fingerprint, IfaceDecl)] - -> IfL [(Name,TyThing)] -loadDecls ignore_prags ver_decls - = concatMapM (loadDecl ignore_prags) ver_decls - -loadDecl :: Bool -- Don't load pragmas into the decl pool - -> (Fingerprint, IfaceDecl) - -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the - -- TyThings are forkM'd thunks -loadDecl ignore_prags (_version, decl) - = do { -- Populate the name cache with final versions of all - -- the names associated with the decl - let main_name = ifName decl - - -- Typecheck the thing, lazily - -- NB. Firstly, the laziness is there in case we never need the - -- declaration (in one-shot mode), and secondly it is there so that - -- we don't look up the occurrence of a name before calling mk_new_bndr - -- on the binder. This is important because we must get the right name - -- which includes its nameParent. - - ; thing <- forkM doc $ do { bumpDeclStats main_name - ; tcIfaceDecl ignore_prags decl } - - -- Populate the type environment with the implicitTyThings too. - -- - -- Note [Tricky iface loop] - -- ~~~~~~~~~~~~~~~~~~~~~~~~ - -- Summary: The delicate point here is that 'mini-env' must be - -- buildable from 'thing' without demanding any of the things - -- 'forkM'd by tcIfaceDecl. - -- - -- In more detail: Consider the example - -- data T a = MkT { x :: T a } - -- The implicitTyThings of T are: [ , ] - -- (plus their workers, wrappers, coercions etc etc) - -- - -- We want to return an environment - -- [ "MkT" -> , "x" -> , ... ] - -- (where the "MkT" is the *Name* associated with MkT, etc.) - -- - -- We do this by mapping the implicit_names to the associated - -- TyThings. By the invariant on ifaceDeclImplicitBndrs and - -- implicitTyThings, we can use getOccName on the implicit - -- TyThings to make this association: each Name's OccName should - -- be the OccName of exactly one implicitTyThing. So the key is - -- to define a "mini-env" - -- - -- [ 'MkT' -> , 'x' -> , ... ] - -- where the 'MkT' here is the *OccName* associated with MkT. - -- - -- However, there is a subtlety: due to how type checking needs - -- to be staged, we can't poke on the forkM'd thunks inside the - -- implicitTyThings while building this mini-env. - -- If we poke these thunks too early, two problems could happen: - -- (1) When processing mutually recursive modules across - -- hs-boot boundaries, poking too early will do the - -- type-checking before the recursive knot has been tied, - -- so things will be type-checked in the wrong - -- environment, and necessary variables won't be in - -- scope. - -- - -- (2) Looking up one OccName in the mini_env will cause - -- others to be looked up, which might cause that - -- original one to be looked up again, and hence loop. - -- - -- The code below works because of the following invariant: - -- getOccName on a TyThing does not force the suspended type - -- checks in order to extract the name. For example, we don't - -- poke on the "T a" type of on the way to - -- extracting 's OccName. Of course, there is no - -- reason in principle why getting the OccName should force the - -- thunks, but this means we need to be careful in - -- implicitTyThings and its helper functions. - -- - -- All a bit too finely-balanced for my liking. - - -- This mini-env and lookup function mediates between the - --'Name's n and the map from 'OccName's to the implicit TyThings - ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing] - lookup n = case lookupOccEnv mini_env (getOccName n) of - Just thing -> thing - Nothing -> - pprPanic "loadDecl" (ppr main_name <+> ppr n $$ ppr (decl)) - - ; implicit_names <- mapM lookupIfaceTop (ifaceDeclImplicitBndrs decl) - --- ; traceIf (text "Loading decl for " <> ppr main_name $$ ppr implicit_names) - ; return $ (main_name, thing) : - -- uses the invariant that implicit_names and - -- implicitTyThings are bijective - [(n, lookup n) | n <- implicit_names] - } - where - doc = text "Declaration for" <+> ppr (ifName decl) - -bumpDeclStats :: Name -> IfL () -- Record that one more declaration has actually been used -bumpDeclStats name - = do { traceIf (text "Loading decl for" <+> ppr name) - ; updateEps_ (\eps -> let stats = eps_stats eps - in eps { eps_stats = stats { n_decls_out = n_decls_out stats + 1 } }) - } - {- ********************************************************* * * ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -469,7 +469,8 @@ ifaceDeclImplicitBndrs :: IfaceDecl -> [OccName] -- N.B. the set of names returned here *must* match the set of -- TyThings returned by GHC.Driver.Env.implicitTyThings, in the sense that -- TyThing.getOccName should define a bijection between the two lists. --- This invariant is used in GHC.Iface.Load.loadDecl (see note [Tricky iface loop]) +-- This invariant is used in GHC.IfaceToCore.tc_iface_decl_fingerprint (see note +-- [Tricky iface loop]) -- The order of the list does not matter. ifaceDeclImplicitBndrs (IfaceData {ifName = tc_name, ifCons = cons }) @@ -2017,13 +2018,13 @@ knot in the type checker. It saved ~1% of the total build time of GHC. When we read an interface file, we extend the PTE, a mapping of Names to TyThings, with the declarations we have read. The extension of the PTE is strict in the Names, but not in the TyThings themselves. -GHC.Iface.Load.loadDecl calculates the list of (Name, TyThing) bindings to -add to the PTE. For an IfaceId, there's just one binding to add; and +GHC.IfaceToCore.tcIfaceDecls calculates the list of (Name, TyThing) bindings +to add to the PTE. For an IfaceId, there's just one binding to add; and the ty, details, and idinfo fields of an IfaceId are used only in the TyThing. So by reading those fields lazily we may be able to save the work of ever having to deserialize them (into IfaceType, etc.). -For IfaceData and IfaceClass, loadDecl creates extra implicit bindings +For IfaceData and IfaceClass, tcIfaceDecls creates extra implicit bindings (the constructors and field selectors of the data declaration, or the methods of the class), whose Names depend on more than just the Name of the type constructor or class itself. So deserializing them lazily ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -16,7 +16,8 @@ module GHC.IfaceToCore ( importDecl, checkWiredInTyCon, tcHiBootIface, typecheckIface, typecheckIfacesForMerging, typecheckIfaceForInstantiate, - tcIfaceDecl, tcIfaceInst, tcIfaceFamInst, tcIfaceRules, + tcIfaceDecl, tcIfaceDecls, + tcIfaceInst, tcIfaceFamInst, tcIfaceRules, tcIfaceAnnotations, tcIfaceCompleteMatches, tcIfaceExpr, -- Desired by HERMIT (#7683) tcIfaceGlobal, @@ -185,7 +186,7 @@ typecheckIface iface -- Typecheck the decls. This is done lazily, so that the knot-tying -- within this single module works out right. It's the callers -- job to make sure the knot is tied. - ; names_w_things <- loadDecls ignore_prags (mi_decls iface) + ; names_w_things <- tcIfaceDecls ignore_prags (mi_decls iface) ; let type_env = mkNameEnv names_w_things -- Now do those rules, instances and annotations @@ -390,8 +391,8 @@ typecheckIfacesForMerging mod ifaces tc_env_var = :: [OccEnv IfaceDecl] decl_env = foldl' mergeIfaceDecls emptyOccEnv decl_envs :: OccEnv IfaceDecl - -- TODO: change loadDecls to accept w/o Fingerprint - names_w_things <- loadDecls ignore_prags (map (\x -> (fingerprint0, x)) + -- TODO: change tcIfaceDecls to accept w/o Fingerprint + names_w_things <- tcIfaceDecls ignore_prags (map (\x -> (fingerprint0, x)) (occEnvElts decl_env)) let global_type_env = mkNameEnv names_w_things writeMutVar tc_env_var global_type_env @@ -401,7 +402,7 @@ typecheckIfacesForMerging mod ifaces tc_env_var = -- See Note [Resolving never-exported Names] in GHC.IfaceToCore type_env <- fixM $ \type_env -> do setImplicitEnvM type_env $ do - decls <- loadDecls ignore_prags (mi_decls iface) + decls <- tcIfaceDecls ignore_prags (mi_decls iface) return (mkNameEnv decls) -- But note that we use this type_env to typecheck references to DFun -- in 'IfaceInst' @@ -441,7 +442,7 @@ typecheckIfaceForInstantiate nsubst iface = -- See Note [Resolving never-exported Names] in GHC.IfaceToCore type_env <- fixM $ \type_env -> do setImplicitEnvM type_env $ do - decls <- loadDecls ignore_prags (mi_decls iface) + decls <- tcIfaceDecls ignore_prags (mi_decls iface) return (mkNameEnv decls) -- See Note [rnIfaceNeverExported] setImplicitEnvM type_env $ do @@ -871,6 +872,110 @@ tc_iface_decl _ _ (IfacePatSyn{ ifName = name tc_pr (nm, b) = do { id <- forkM (ppr nm) (tcIfaceExtId nm) ; return (id, b) } +tcIfaceDecls :: Bool + -> [(Fingerprint, IfaceDecl)] + -> IfL [(Name,TyThing)] +tcIfaceDecls ignore_prags ver_decls + = concatMapM (tc_iface_decl_fingerprint ignore_prags) ver_decls + +tc_iface_decl_fingerprint :: Bool -- Don't load pragmas into the decl pool + -> (Fingerprint, IfaceDecl) + -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the + -- TyThings are forkM'd thunks +tc_iface_decl_fingerprint ignore_prags (_version, decl) + = do { -- Populate the name cache with final versions of all + -- the names associated with the decl + let main_name = ifName decl + + -- Typecheck the thing, lazily + -- NB. Firstly, the laziness is there in case we never need the + -- declaration (in one-shot mode), and secondly it is there so that + -- we don't look up the occurrence of a name before calling mk_new_bndr + -- on the binder. This is important because we must get the right name + -- which includes its nameParent. + + ; thing <- forkM doc $ do { bumpDeclStats main_name + ; tcIfaceDecl ignore_prags decl } + + -- Populate the type environment with the implicitTyThings too. + -- + -- Note [Tricky iface loop] + -- ~~~~~~~~~~~~~~~~~~~~~~~~ + -- Summary: The delicate point here is that 'mini-env' must be + -- buildable from 'thing' without demanding any of the things + -- 'forkM'd by tcIfaceDecl. + -- + -- In more detail: Consider the example + -- data T a = MkT { x :: T a } + -- The implicitTyThings of T are: [ , ] + -- (plus their workers, wrappers, coercions etc etc) + -- + -- We want to return an environment + -- [ "MkT" -> , "x" -> , ... ] + -- (where the "MkT" is the *Name* associated with MkT, etc.) + -- + -- We do this by mapping the implicit_names to the associated + -- TyThings. By the invariant on ifaceDeclImplicitBndrs and + -- implicitTyThings, we can use getOccName on the implicit + -- TyThings to make this association: each Name's OccName should + -- be the OccName of exactly one implicitTyThing. So the key is + -- to define a "mini-env" + -- + -- [ 'MkT' -> , 'x' -> , ... ] + -- where the 'MkT' here is the *OccName* associated with MkT. + -- + -- However, there is a subtlety: due to how type checking needs + -- to be staged, we can't poke on the forkM'd thunks inside the + -- implicitTyThings while building this mini-env. + -- If we poke these thunks too early, two problems could happen: + -- (1) When processing mutually recursive modules across + -- hs-boot boundaries, poking too early will do the + -- type-checking before the recursive knot has been tied, + -- so things will be type-checked in the wrong + -- environment, and necessary variables won't be in + -- scope. + -- + -- (2) Looking up one OccName in the mini_env will cause + -- others to be looked up, which might cause that + -- original one to be looked up again, and hence loop. + -- + -- The code below works because of the following invariant: + -- getOccName on a TyThing does not force the suspended type + -- checks in order to extract the name. For example, we don't + -- poke on the "T a" type of on the way to + -- extracting 's OccName. Of course, there is no + -- reason in principle why getting the OccName should force the + -- thunks, but this means we need to be careful in + -- implicitTyThings and its helper functions. + -- + -- All a bit too finely-balanced for my liking. + + -- This mini-env and lookup function mediates between the + --'Name's n and the map from 'OccName's to the implicit TyThings + ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing] + lookup n = case lookupOccEnv mini_env (getOccName n) of + Just thing -> thing + Nothing -> + pprPanic "tc_iface_decl_fingerprint" (ppr main_name <+> ppr n $$ ppr (decl)) + + ; implicit_names <- mapM lookupIfaceTop (ifaceDeclImplicitBndrs decl) + +-- ; traceIf (text "Loading decl for " <> ppr main_name $$ ppr implicit_names) + ; return $ (main_name, thing) : + -- uses the invariant that implicit_names and + -- implicitTyThings are bijective + [(n, lookup n) | n <- implicit_names] + } + where + doc = text "Declaration for" <+> ppr (ifName decl) + +bumpDeclStats :: Name -> IfL () -- Record that one more declaration has actually been used +bumpDeclStats name + = do { traceIf (text "Loading decl for" <+> ppr name) + ; updateEps_ (\eps -> let stats = eps_stats eps + in eps { eps_stats = stats { n_decls_out = n_decls_out stats + 1 } }) + } + tc_fd :: FunDep IfLclName -> IfL (FunDep TyVar) tc_fd (tvs1, tvs2) = do { tvs1' <- mapM tcIfaceTyVar tvs1 ; tvs2' <- mapM tcIfaceTyVar tvs2 ===================================== compiler/GHC/IfaceToCore.hs-boot ===================================== @@ -10,6 +10,8 @@ import GHC.Core.FamInstEnv ( FamInst ) import GHC.Core ( CoreRule ) import GHC.Types.CompleteMatch ( CompleteMatch ) import GHC.Types.Annotations ( Annotation ) +import GHC.Types.Name +import GHC.Fingerprint.Type tcIfaceDecl :: Bool -> IfaceDecl -> IfL TyThing tcIfaceRules :: Bool -> [IfaceRule] -> IfL [CoreRule] @@ -17,3 +19,4 @@ tcIfaceInst :: IfaceClsInst -> IfL ClsInst tcIfaceFamInst :: IfaceFamInst -> IfL FamInst tcIfaceAnnotations :: [IfaceAnnotation] -> IfL [Annotation] tcIfaceCompleteMatches :: [IfaceCompleteMatch] -> IfL [CompleteMatch] +tcIfaceDecls :: Bool -> [(Fingerprint, IfaceDecl)] -> IfL [(Name,TyThing)] ===================================== compiler/GHC/Types/TyThing.hs ===================================== @@ -138,7 +138,8 @@ Examples: -- N.B. the set of TyThings returned here *must* match the set of -- names returned by 'GHC.Iface.Load.ifaceDeclImplicitBndrs', in the sense that -- TyThing.getOccName should define a bijection between the two lists. --- This invariant is used in 'GHC.Iface.Load.loadDecl' (see note [Tricky iface loop]) +-- This invariant is used in 'GHC.IfaceToCore.tc_iface_decl_fingerprint' (see +-- note [Tricky iface loop]) -- The order of the list does not matter. implicitTyThings :: TyThing -> [TyThing] implicitTyThings (AnId _) = [] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08e6993a1b956e6edccdc1cecc7250b724bf79a0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08e6993a1b956e6edccdc1cecc7250b724bf79a0 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 07:26:53 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 03:26:53 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Make typechecker equality consider visibility in ForAllTys Message-ID: <5f9d11bdd9df1_785ee451d4494bf@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - 459a8534 by Tamar Christina at 2020-10-31T03:26:45-04:00 winio: Fix unused variables warnings - - - - - 926c9e35 by Andrzej Rybczak at 2020-10-31T03:26:47-04:00 Add testcase for #816 - - - - - 30 changed files: - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/TyThing.hs - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/exts/type_applications.rst - libraries/base/GHC/Event/Windows.hsc - rts/win32/AsyncWinIO.c - rts/win32/AsyncWinIO.h - + testsuite/tests/saks/should_fail/T18863a.hs - + testsuite/tests/saks/should_fail/T18863a.stderr - + testsuite/tests/saks/should_fail/T18863b.hs - + testsuite/tests/saks/should_fail/T18863b.stderr - testsuite/tests/saks/should_fail/all.T - + testsuite/tests/simplCore/should_run/NumConstantFolding.hs - + testsuite/tests/simplCore/should_run/NumConstantFolding.stdout - testsuite/tests/simplCore/should_run/all.T - + testsuite/tests/typecheck/should_compile/T15079.hs - + testsuite/tests/typecheck/should_compile/T816.hs - testsuite/tests/typecheck/should_compile/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b3972b563c8b871c424ad703daa4c4322b673a8...926c9e3595cc7d48400cecfb4482388b5dd8df4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5b3972b563c8b871c424ad703daa4c4322b673a8...926c9e3595cc7d48400cecfb4482388b5dd8df4a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 13:27:02 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 09:27:02 -0400 Subject: [Git][ghc/ghc][master] winio: Fix unused variables warnings Message-ID: <5f9d6626826cc_7853fb643d6398474719@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - 3 changed files: - libraries/base/GHC/Event/Windows.hsc - rts/win32/AsyncWinIO.c - rts/win32/AsyncWinIO.h Changes: ===================================== libraries/base/GHC/Event/Windows.hsc ===================================== @@ -289,8 +289,8 @@ foreign import ccall safe "registerIOCPHandle" registerIOCPHandle :: FFI.IOCP -> IO () foreign import ccall safe "registerAlertableWait" --- (bool has_timeout, DWORD mssec, uint64_t num_req, bool pending_service); - c_registerAlertableWait :: Bool -> DWORD -> Word64 -> Bool -> IO () +-- (bool has_timeout, DWORD mssec); + c_registerAlertableWait :: Bool -> DWORD -> IO () foreign import ccall safe "getOverlappedEntries" getOverlappedEntries :: Ptr DWORD -> IO (Ptr OVERLAPPED_ENTRY) @@ -674,12 +674,11 @@ withOverlappedEx mgr fname h offset startCB completionCB = do debugIO $ "-1.. " ++ show reqs1 ++ " requests queued after error." completionCB' (fromIntegral nerr) 0 when (not threadedIOMgr) $ - do num_remaining <- outstandingRequests - -- Run timeouts. This way if we canceled the last + do -- Run timeouts. This way if we canceled the last -- IO Request and have no timer events waiting we -- can go into an unbounded alertable wait. delay <- runExpiredTimeouts mgr - registerAlertableWait delay num_remaining True + registerAlertableWait delay return $ IOFailed Nothing let runner = do debugIO $ (dbgMsg ":: waiting ") ++ " | " ++ show lpol res <- readIOPort signal `catch` cancel @@ -1127,23 +1126,20 @@ processRemoteCompletion = do -- Process available completions _ <- processCompletion mngr n delay - num_left <- outstandingRequests - -- Update and potentially wake up IO Manager -- This call will unblock the non-threaded I/O manager. After this it is no -- longer safe to use `entries` nor `completed` as they can now be modified -- by the C thread. - registerAlertableWait delay num_left False + registerAlertableWait delay debugIO "processRemoteCompletion :: done ()" return () -registerAlertableWait :: Maybe Seconds -> Word64 -> Bool -> IO () -registerAlertableWait Nothing num_reqs pending_service = - c_registerAlertableWait False 0 num_reqs pending_service -registerAlertableWait (Just delay) num_reqs pending_service = +registerAlertableWait :: Maybe Seconds -> IO () +registerAlertableWait Nothing = + c_registerAlertableWait False 0 +registerAlertableWait (Just delay) = c_registerAlertableWait True (secondsToMilliSeconds delay) - num_reqs pending_service -- | Event loop for the Threaded I/O manager. The one for the non-threaded -- I/O manager is in AsyncWinIO.c in the rts. ===================================== rts/win32/AsyncWinIO.c ===================================== @@ -322,17 +322,10 @@ void completeSynchronousRequest (void) * MSSEC is the maximum amount of time in milliseconds that an alertable wait should be done for before the haskell side requested to be notified of progress. * NUM_REQ is the total overall number of outstanding I/O requests. - * pending_service indicates that there might be still a outstanding service - request queued and therefore we shouldn't unblock the runner quite yet. - - `pending_service` is needed in case we cancel an IO operation. We don't want this - to result in two processRemoteCompletion threads being queued. As this is both harder - to reason about and bad for performance. So we only reset outstanding_service_requests - if no service is pending. */ -void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, bool pending_service) +void registerAlertableWait (bool has_timeout, DWORD mssec) { ASSERT(completionPortHandle != INVALID_HANDLE_VALUE); AcquireSRWLockExclusive (&wio_runner_lock); ===================================== rts/win32/AsyncWinIO.h ===================================== @@ -18,7 +18,7 @@ extern bool startupAsyncWinIO(void); extern void shutdownAsyncWinIO(bool wait_threads); extern void awaitAsyncRequests(bool wait); extern void registerIOCPHandle (HANDLE port); -extern void registerAlertableWait (bool has_timeout, DWORD mssec, uint64_t num_req, bool service_pending); +extern void registerAlertableWait (bool has_timeout, DWORD mssec); extern OVERLAPPED_ENTRY* getOverlappedEntries (uint32_t *num); extern void completeSynchronousRequest (void); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb1f755c6fb77f140aee11fdc7b4da04dd5dcd02 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb1f755c6fb77f140aee11fdc7b4da04dd5dcd02 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 13:27:40 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 09:27:40 -0400 Subject: [Git][ghc/ghc][master] Add testcase for #816 Message-ID: <5f9d664c7031f_785101dc030789a3@gitlab.haskell.org.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - 2 changed files: - + testsuite/tests/typecheck/should_compile/T816.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== testsuite/tests/typecheck/should_compile/T816.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FunctionalDependencies #-} +{-# LANGUAGE UndecidableInstances #-} + +module T816 where + +class Foo x y | x -> y where + foo :: x -> y + +class Bar x y where + bar :: x -> y -> Int + +instance (Foo x y, Bar y z) => Bar x z where + bar x z = bar (foo x) z ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -266,6 +266,7 @@ test('FD3', normal, compile_fail, ['']) test('FD4', normal, compile, ['']) test('faxen', normal, compile, ['']) +test('T816', normal, compile, ['']) test('T1495', normal, compile, ['']) test('T2045', normal, compile, ['']) # Needs -fhpc test('T2478', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb368078204bceba51e3c80e387ce1d776762cfd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb368078204bceba51e3c80e387ce1d776762cfd You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 15:43:04 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 11:43:04 -0400 Subject: [Git][ghc/ghc][wip/tsan/all] More races in freeGroup Message-ID: <5f9d8608d1f29_785fac53b499954@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/tsan/all at Glasgow Haskell Compiler / GHC Commits: e3a7e8bd by Ben Gamari at 2020-10-31T11:42:53-04:00 More races in freeGroup - - - - - 1 changed file: - rts/sm/BlockAlloc.c Changes: ===================================== rts/sm/BlockAlloc.c ===================================== @@ -787,6 +787,26 @@ free_mega_group (bdescr *mg) } +/* Note [Data races in freeGroup] + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * freeGroup commits a rather serious concurrency sin in its block coalescence + * logic: When freeing a block it looks at bd->free of the previous/next block + * to see whether it is allocated. However, the free'ing thread likely does not + * own the previous/next block, nor do we make any attempt to synchronize with + * the thread that *does* own it; this makes this access a data race. + * + * The original design argued that this was correct because `bd->free` will + * only take a value of -1 when the block is free and thereby owned by the + * storage manager. However, this is nevertheless unsafe under the C11 data + * model, which guarantees no particular semantics for data races. + * + * We currently assume (and hope) we won't see torn values and consequently + * we will never see `bd->free == -1` for an allocated block which we do not + * own. However, this is all extremely dodgy. + * + * This is tracked as #18913. + */ + void freeGroup(bdescr *p) { @@ -834,6 +854,9 @@ freeGroup(bdescr *p) { bdescr *next; next = p + p->blocks; + + // See Note [Data races in freeGroup]. + TSAN_ANNOTATE_BENIGN_RACE(&next->free, "freeGroup"); if (next <= LAST_BDESCR(MBLOCK_ROUND_DOWN(p)) && RELAXED_LOAD(&next->free) == (P_)-1) { @@ -856,11 +879,7 @@ freeGroup(bdescr *p) prev = p - 1; if (prev->blocks == 0) prev = prev->link; // find the head - // This is a bit hairy... we are looking at bd->free of a block that we - // do not own and yet have not synchronized with the thread that *does* - // own the block. We currently assume we won't see torn values and - // consequently this will work, although this is strictly speaking not - // guaranteed under the memory model. + // See Note [Data races in freeGroup]. TSAN_ANNOTATE_BENIGN_RACE(&prev->free, "freeGroup"); if (RELAXED_LOAD(&prev->free) == (P_)-1) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3a7e8bd76a817d0a5cab10f5b098153624b7585 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3a7e8bd76a817d0a5cab10f5b098153624b7585 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 15:51:48 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 31 Oct 2020 11:51:48 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T18770 Message-ID: <5f9d88148cf02_785106694a4100721@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T18770 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T18770 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 16:00:15 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 31 Oct 2020 12:00:15 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T13795-T18828 Message-ID: <5f9d8a0f6e389_7853fb64290af641065b1@gitlab.haskell.org.mail> Ryan Scott pushed new branch wip/T13795-T18828 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T13795-T18828 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 16:24:11 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 12:24:11 -0400 Subject: [Git][ghc/ghc][wip/unloading] 4 commits: Fix and enable object unloading in GHCi Message-ID: <5f9d8fabca543_785102137d8110340@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: a7d73051 by Ömer Sinan Ağacan at 2020-10-31T12:22:44-04:00 Fix and enable object unloading in GHCi Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details. - - - - - 3f1db003 by Ray Shih at 2020-10-31T12:23:34-04:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - 933e7428 by GHC GitLab CI at 2020-10-31T12:23:34-04:00 rts: Introduce highMemDynamic - - - - - d99dc5bc by GHC GitLab CI at 2020-10-31T12:23:34-04:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - compiler/GHC/Runtime/Linker.hs - includes/rts/Linker.h - includes/rts/storage/GC.h - rts/CheckUnload.c - rts/CheckUnload.h - rts/Hash.c - rts/Hash.h - rts/Linker.c - rts/LinkerInternals.h - rts/RtsStartup.c - rts/linker/Elf.c - rts/linker/LoadArchive.c - rts/linker/MachO.c - rts/linker/PEi386.c - rts/linker/elf_got.c - rts/sm/Evac.c - rts/sm/GC.c - rts/sm/GC.h - rts/sm/Storage.c - testsuite/tests/ghci/T16525a/T16525a.script - testsuite/tests/ghci/T16525a/T16525a.stdout - testsuite/tests/ghci/T16525a/all.T - + testsuite/tests/ghci/T16525b/A.hs - + testsuite/tests/ghci/T16525b/B.hs - + testsuite/tests/ghci/T16525b/T16525b.script - + testsuite/tests/ghci/T16525b/T16525b.stdout - + testsuite/tests/ghci/T16525b/all.T - testsuite/tests/rts/linker/Makefile - testsuite/tests/rts/linker/all.T - testsuite/tests/rts/linker/linker_error.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/708ea4cf8be9803fb100f20d44531f9be5f7a13f...d99dc5bc1715e581fb552f4248b61f5793cd5bda -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/708ea4cf8be9803fb100f20d44531f9be5f7a13f...d99dc5bc1715e581fb552f4248b61f5793cd5bda You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 16:33:06 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 12:33:06 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/hadrian-runtest Message-ID: <5f9d91c275265_7853fb5e34b8bdc111584@gitlab.haskell.org.mail> Ben Gamari pushed new branch wip/hadrian-runtest at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/hadrian-runtest You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 16:36:06 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 12:36:06 -0400 Subject: [Git][ghc/ghc][wip/T15808] 4 commits: [skip ci] Fix typo in `callocBytes` haddock. Message-ID: <5f9d92763304b_785abe005011342b@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T15808 at Glasgow Haskell Compiler / GHC Commits: 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 2c66bc3a by Ben Gamari at 2020-10-31T12:35:18-04:00 rts/linker: Fix relocation overflow in PE linker Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808. - - - - - 47dbdc44 by Ben Gamari at 2020-10-31T12:35:18-04:00 rts/linker: Try using m32 to allocate PE symbol extras - - - - - 28 changed files: - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/ThToHs.hs - docs/users_guide/9.2.1-notes.rst - libraries/base/Foreign/Marshal/Alloc.hs - rts/Linker.c - rts/LinkerInternals.h - rts/linker/M32Alloc.c - rts/linker/M32Alloc.h - rts/linker/PEi386.c - testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - testsuite/tests/parser/should_compile/DumpRenamedAst.stderr - testsuite/tests/parser/should_compile/T15323.stderr - testsuite/tests/printer/T18791.stderr - utils/haddock Changes: ===================================== compiler/GHC/Hs/Decls.hs ===================================== @@ -74,8 +74,8 @@ module GHC.Hs.Decls ( CImportSpec(..), -- ** Data-constructor declarations ConDecl(..), LConDecl, - HsConDeclDetails, hsConDeclArgTys, hsConDeclTheta, - getConNames, getConArgs, + HsConDeclH98Details, HsConDeclGADTDetails(..), hsConDeclTheta, + getConNames, getRecConArgs_maybe, -- ** Document comments DocDecl(..), LDocDecl, docDeclDoc, -- ** Deprecations @@ -1476,9 +1476,9 @@ data ConDecl pass -- Whether or not there is an /explicit/ forall, we still -- need to capture the implicitly-bound type/kind variables - , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; never InfixCon - , con_res_ty :: LHsType pass -- ^ Result type + , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , con_res_ty :: LHsType pass -- ^ Result type , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1495,7 +1495,7 @@ data ConDecl pass -- False => con_ex_tvs is empty , con_ex_tvs :: [LHsTyVarBndr Specificity pass] -- ^ Existentials only , con_mb_cxt :: Maybe (LHsContext pass) -- ^ User-written context (if any) - , con_args :: HsConDeclDetails pass -- ^ Arguments; can be InfixCon + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. @@ -1626,27 +1626,35 @@ or contexts in two parts: quantification occurs after a visible argument type. -} --- | Haskell data Constructor Declaration Details -type HsConDeclDetails pass +-- | The arguments in a Haskell98-style data constructor. +type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) +-- | The arguments in a GADT constructor. Unlike Haskell98-style constructors, +-- GADT constructors cannot be declared with infix syntax. As a result, we do +-- not use 'HsConDetails' here, as 'InfixCon' would be an unrepresentable +-- state. (There is a notion of infix GADT constructors for the purposes of +-- derived Show instances—see Note [Infix GADT constructors] in +-- GHC.Tc.TyCl—but that is an orthogonal concern.) +data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + getConNames :: ConDecl GhcRn -> [Located Name] getConNames ConDeclH98 {con_name = name} = [name] getConNames ConDeclGADT {con_names = names} = names -getConArgs :: ConDecl GhcRn -> HsConDeclDetails GhcRn -getConArgs d = con_args d - -hsConDeclArgTys :: HsConDeclDetails (GhcPass p) -> [HsScaled (GhcPass p) (LBangType (GhcPass p))] -hsConDeclArgTys (PrefixCon tys) = tys -hsConDeclArgTys (InfixCon ty1 ty2) = [ty1,ty2] -hsConDeclArgTys (RecCon flds) = map (hsLinear . cd_fld_type . unLoc) (unLoc flds) - -- Remark: with the record syntax, constructors have all their argument - -- linear, despite the fact that projections do not make sense on linear - -- constructors. The design here is that the record projection themselves are - -- typed to take an unrestricted argument (that is the record itself is - -- unrestricted). By the transfer property, projections are then correct in - -- that all the non-projected fields have multiplicity Many, and can be dropped. +-- | Return @'Just' fields@ if a data constructor declaration uses record +-- syntax (i.e., 'RecCon'), where @fields@ are the field selectors. +-- Otherwise, return 'Nothing'. +getRecConArgs_maybe :: ConDecl GhcRn -> Maybe (Located [LConDeclField GhcRn]) +getRecConArgs_maybe (ConDeclH98{con_args = args}) = case args of + PrefixCon{} -> Nothing + RecCon flds -> Just flds + InfixCon{} -> Nothing +getRecConArgs_maybe (ConDeclGADT{con_g_args = args}) = case args of + PrefixConGADT{} -> Nothing + RecConGADT flds -> Just flds hsConDeclTheta :: Maybe (LHsContext (GhcPass p)) -> [LHsType (GhcPass p)] hsConDeclTheta Nothing = [] @@ -1726,15 +1734,14 @@ pprConDecl (ConDeclH98 { con_name = L _ con cxt = fromMaybe noLHsContext mcxt pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars - , con_mb_cxt = mcxt, con_args = args + , con_mb_cxt = mcxt, con_g_args = args , con_res_ty = res_ty, con_doc = doc }) = ppr_mbDoc doc <+> ppr_con_names cons <+> dcolon <+> (sep [pprHsForAll (mkHsForAllInvisTele qvars) cxt, ppr_arrow_chain (get_args args ++ [ppr res_ty]) ]) where - get_args (PrefixCon args) = map ppr args - get_args (RecCon fields) = [pprConDeclFields (unLoc fields)] - get_args (InfixCon {}) = pprPanic "pprConDecl:GADT" (ppr cons) + get_args (PrefixConGADT args) = map ppr args + get_args (RecConGADT fields) = [pprConDeclFields (unLoc fields)] cxt = fromMaybe noLHsContext mcxt ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -173,6 +173,11 @@ deriving instance Data (ConDecl GhcPs) deriving instance Data (ConDecl GhcRn) deriving instance Data (ConDecl GhcTc) +-- deriving instance DataIdLR p p => Data (HsConDeclGADTDetails p) +deriving instance Data (HsConDeclGADTDetails GhcPs) +deriving instance Data (HsConDeclGADTDetails GhcRn) +deriving instance Data (HsConDeclGADTDetails GhcTc) + -- deriving instance DataIdLR p p => Data (TyFamInstDecl p) deriving instance Data (TyFamInstDecl GhcPs) deriving instance Data (TyFamInstDecl GhcRn) ===================================== compiler/GHC/Hs/Type.hs ===================================== @@ -1102,9 +1102,22 @@ instance OutputableBndrId p => Outputable (ConDeclField (GhcPass p)) where ppr (ConDeclField _ fld_n fld_ty _) = ppr fld_n <+> dcolon <+> ppr fld_ty --- HsConDetails is used for patterns/expressions *and* for data type --- declarations --- | Haskell Constructor Details +-- | Describes the arguments to a data constructor. This is a common +-- representation for several constructor-related concepts, including: +-- +-- * The arguments in a Haskell98-style constructor declaration +-- (see 'HsConDeclH98Details' in "GHC.Hs.Decls"). +-- +-- * The arguments in constructor patterns in @case@/function definitions +-- (see 'HsConPatDetails' in "GHC.Hs.Pat"). +-- +-- * The left-hand side arguments in a pattern synonym binding +-- (see 'HsPatSynDetails' in "GHC.Hs.Binds"). +-- +-- One notable exception is the arguments in a GADT constructor, which uses +-- a separate data type entirely (see 'HsConDeclGADTDetails' in +-- "GHC.Hs.Decls"). This is because GADT constructors cannot be declared with +-- infix syntax, unlike the concepts above (#18844). data HsConDetails arg rec = PrefixCon [arg] -- C p1 p2 p3 | RecCon rec -- C { x = p1, y = p2 } ===================================== compiler/GHC/Hs/Utils.hs ===================================== @@ -1259,29 +1259,36 @@ hsConDeclsBinders cons in case unLoc r of -- remove only the first occurrence of any seen field in order to -- avoid circumventing detection of duplicate fields (#9156) - ConDeclGADT { con_names = names, con_args = args } + ConDeclGADT { con_names = names, con_g_args = args } -> (map (L loc . unLoc) names ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_gadt remSeen args (ns, fs) = go remSeen' rs ConDeclH98 { con_name = name, con_args = args } -> ([L loc (unLoc name)] ++ ns, flds ++ fs) where - (remSeen', flds) = get_flds remSeen args + (remSeen', flds) = get_flds_h98 remSeen args (ns, fs) = go remSeen' rs - get_flds :: Seen p -> HsConDeclDetails (GhcPass p) + get_flds_h98 :: Seen p -> HsConDeclH98Details (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_h98 remSeen (RecCon flds) = get_flds remSeen flds + get_flds_h98 remSeen _ = (remSeen, []) + + get_flds_gadt :: Seen p -> HsConDeclGADTDetails (GhcPass p) + -> (Seen p, [LFieldOcc (GhcPass p)]) + get_flds_gadt remSeen (RecConGADT flds) = get_flds remSeen flds + get_flds_gadt remSeen _ = (remSeen, []) + + get_flds :: Seen p -> Located [LConDeclField (GhcPass p)] -> (Seen p, [LFieldOcc (GhcPass p)]) - get_flds remSeen (RecCon flds) - = (remSeen', fld_names) + get_flds remSeen flds = (remSeen', fld_names) where fld_names = remSeen (concatMap (cd_fld_names . unLoc) (unLoc flds)) remSeen' = foldr (.) remSeen [deleteBy ((==) `on` unLoc . rdrNameFieldOcc . unLoc) v | v <- fld_names] - get_flds remSeen _ - = (remSeen, []) {- ===================================== compiler/GHC/HsToCore/Docs.hs ===================================== @@ -189,7 +189,7 @@ subordinates instMap decl = case decl of , conArgDocs c) | c <- cons, cname <- getConNames c ] fields = [ (extFieldOcc n, maybeToList $ fmap unLoc doc, M.empty) - | RecCon flds <- map getConArgs cons + | Just flds <- map getRecConArgs_maybe cons , (L _ (ConDeclField _ ns _ doc)) <- (unLoc flds) , (L _ n) <- ns ] derivs = [ (instName, [unLoc doc], M.empty) @@ -216,22 +216,30 @@ subordinates instMap decl = case decl of _ -> Nothing -- | Extract constructor argument docs from inside constructor decls. -conArgDocs :: ConDecl GhcRn -> Map Int (HsDocString) -conArgDocs con = case getConArgs con of - PrefixCon args -> go 0 (map (unLoc . hsScaledThing) args ++ ret) - InfixCon arg1 arg2 -> go 0 ([unLoc (hsScaledThing arg1), - unLoc (hsScaledThing arg2)] ++ ret) - RecCon _ -> go 1 ret +conArgDocs :: ConDecl GhcRn -> Map Int HsDocString +conArgDocs (ConDeclH98{con_args = args}) = + h98ConArgDocs args +conArgDocs (ConDeclGADT{con_g_args = args, con_res_ty = res_ty}) = + gadtConArgDocs args (unLoc res_ty) + +h98ConArgDocs :: HsConDeclH98Details GhcRn -> Map Int HsDocString +h98ConArgDocs con_args = case con_args of + PrefixCon args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args + InfixCon arg1 arg2 -> con_arg_docs 0 [ unLoc (hsScaledThing arg1) + , unLoc (hsScaledThing arg2) ] + RecCon _ -> M.empty + +gadtConArgDocs :: HsConDeclGADTDetails GhcRn -> HsType GhcRn -> Map Int HsDocString +gadtConArgDocs con_args res_ty = case con_args of + PrefixConGADT args -> con_arg_docs 0 $ map (unLoc . hsScaledThing) args ++ [res_ty] + RecConGADT _ -> con_arg_docs 1 [res_ty] + +con_arg_docs :: Int -> [HsType GhcRn] -> Map Int HsDocString +con_arg_docs n = M.fromList . catMaybes . zipWith f [n..] where - go n = M.fromList . catMaybes . zipWith f [n..] - where - f n (HsDocTy _ _ lds) = Just (n, unLoc lds) - f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) - f _ _ = Nothing - - ret = case con of - ConDeclGADT { con_res_ty = res_ty } -> [ unLoc res_ty ] - _ -> [] + f n (HsDocTy _ _ lds) = Just (n, unLoc lds) + f n (HsBangTy _ _ (L _ (HsDocTy _ _ lds))) = Just (n, unLoc lds) + f _ _ = Nothing isValD :: HsDecl a -> Bool isValD (ValD _ _) = True ===================================== compiler/GHC/HsToCore/Quote.hs ===================================== @@ -877,7 +877,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_forall = (L _ False) , con_mb_cxt = Nothing , con_args = args })) - = repDataCon con args + = repH98DataCon con args repC (L _ (ConDeclH98 { con_name = con , con_forall = L _ is_existential @@ -885,7 +885,7 @@ repC (L _ (ConDeclH98 { con_name = con , con_mb_cxt = mcxt , con_args = args })) = do { addHsTyVarBinds con_tvs $ \ ex_bndrs -> - do { c' <- repDataCon con args + do { c' <- repH98DataCon con args ; ctxt' <- repMbContext mcxt ; if not is_existential && isNothing mcxt then return c' @@ -897,7 +897,7 @@ repC (L _ (ConDeclGADT { con_g_ext = imp_tvs , con_names = cons , con_qvars = exp_tvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty })) | null imp_tvs && null exp_tvs -- No implicit or explicit variables , Nothing <- mcxt -- No context @@ -2589,49 +2589,51 @@ repImplicitParamBind (MkC n) (MkC e) = rep2 implicitParamBindDName [n, e] repCtxt :: Core [(M TH.Pred)] -> MetaM (Core (M TH.Cxt)) repCtxt (MkC tys) = rep2 cxtName [tys] -repDataCon :: Located Name - -> HsConDeclDetails GhcRn - -> MetaM (Core (M TH.Con)) -repDataCon con details +repH98DataCon :: Located Name + -> HsConDeclH98Details GhcRn + -> MetaM (Core (M TH.Con)) +repH98DataCon con details = do con' <- lookupLOcc con -- See Note [Binders and occurrences] - repConstr details Nothing [con'] + case details of + PrefixCon ps -> do + arg_tys <- repPrefixConArgs ps + rep2 normalCName [unC con', unC arg_tys] + InfixCon st1 st2 -> do + arg1 <- repBangTy (hsScaledThing st1) + arg2 <- repBangTy (hsScaledThing st2) + rep2 infixCName [unC arg1, unC con', unC arg2] + RecCon ips -> do + arg_vtys <- repRecConArgs ips + rep2 recCName [unC con', unC arg_vtys] repGadtDataCons :: [Located Name] - -> HsConDeclDetails GhcRn + -> HsConDeclGADTDetails GhcRn -> LHsType GhcRn -> MetaM (Core (M TH.Con)) repGadtDataCons cons details res_ty = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences] - repConstr details (Just res_ty) cons' - --- Invariant: --- * for plain H98 data constructors second argument is Nothing and third --- argument is a singleton list --- * for GADTs data constructors second argument is (Just return_type) and --- third argument is a non-empty list -repConstr :: HsConDeclDetails GhcRn - -> Maybe (LHsType GhcRn) - -> [Core TH.Name] - -> MetaM (Core (M TH.Con)) -repConstr (PrefixCon ps) Nothing [con] - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - rep2 normalCName [unC con, unC arg_tys] - -repConstr (PrefixCon ps) (Just res_ty) cons - = do arg_tys <- repListM bangTypeTyConName repBangTy (map hsScaledThing ps) - res_ty' <- repLTy res_ty - rep2 gadtCName [ unC (nonEmptyCoreList cons), unC arg_tys, unC res_ty'] - -repConstr (RecCon ips) resTy cons - = do args <- concatMapM rep_ip (unLoc ips) - arg_vtys <- coreListM varBangTypeTyConName args - case resTy of - Nothing -> rep2 recCName [unC (head cons), unC arg_vtys] - Just res_ty -> do + case details of + PrefixConGADT ps -> do + arg_tys <- repPrefixConArgs ps res_ty' <- repLTy res_ty - rep2 recGadtCName [unC (nonEmptyCoreList cons), unC arg_vtys, + rep2 gadtCName [ unC (nonEmptyCoreList cons'), unC arg_tys, unC res_ty'] + RecConGADT ips -> do + arg_vtys <- repRecConArgs ips + res_ty' <- repLTy res_ty + rep2 recGadtCName [unC (nonEmptyCoreList cons'), unC arg_vtys, unC res_ty'] +-- Desugar the arguments in a data constructor declared with prefix syntax. +repPrefixConArgs :: [HsScaled GhcRn (LHsType GhcRn)] + -> MetaM (Core [M TH.BangType]) +repPrefixConArgs ps = repListM bangTypeTyConName repBangTy (map hsScaledThing ps) + +-- Desugar the arguments in a data constructor declared with record syntax. +repRecConArgs :: Located [LConDeclField GhcRn] + -> MetaM (Core [M TH.VarBangType]) +repRecConArgs ips = do + args <- concatMapM rep_ip (unLoc ips) + coreListM varBangTypeTyConName args where rep_ip (L _ ip) = mapM (rep_one_ip (cd_fld_type ip)) (cd_fld_names ip) @@ -2640,16 +2642,6 @@ repConstr (RecCon ips) resTy cons ; MkC ty <- repBangTy t ; rep2 varBangTypeName [v,ty] } -repConstr (InfixCon st1 st2) Nothing [con] - = do arg1 <- repBangTy (hsScaledThing st1) - arg2 <- repBangTy (hsScaledThing st2) - rep2 infixCName [unC arg1, unC con, unC arg2] - -repConstr (InfixCon {}) (Just _) _ = - panic "repConstr: infix GADT constructor should be in a PrefixCon" -repConstr _ _ _ = - panic "repConstr: invariant violated" - ------------ Types ------------------- repTForall :: Core [(M (TH.TyVarBndr TH.Specificity))] -> Core (M TH.Cxt) -> Core (M TH.Type) ===================================== compiler/GHC/Iface/Ext/Ast.hs ===================================== @@ -1321,6 +1321,10 @@ instance (ToHie arg, ToHie rec) => ToHie (HsConDetails arg rec) where toHie (RecCon rec) = toHie rec toHie (InfixCon a b) = concatM [ toHie a, toHie b] +instance ToHie (HsConDeclGADTDetails GhcRn) where + toHie (PrefixConGADT args) = toHie args + toHie (RecConGADT rec) = toHie rec + instance HiePass p => ToHie (Located (HsCmdTop (GhcPass p))) where toHie (L span top) = concatM $ makeNode top span : case top of HsCmdTop _ cmd -> @@ -1532,7 +1536,7 @@ instance ToHie a => ToHie (HsScaled GhcRn a) where instance ToHie (Located (ConDecl GhcRn)) where toHie (L span decl) = concatM $ makeNode decl span : case decl of ConDeclGADT { con_names = names, con_qvars = exp_vars, con_g_ext = imp_vars - , con_mb_cxt = ctx, con_args = args, con_res_ty = typ } -> + , con_mb_cxt = ctx, con_g_args = args, con_res_ty = typ } -> [ toHie $ map (C (Decl ConDec $ getRealSpan span)) names , concatM $ [ bindingsOnly bindings , toHie $ tvScopes resScope NoScope exp_vars ] @@ -1543,7 +1547,9 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes argsScope tyScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope args + argsScope = case args of + PrefixConGADT xs -> scaled_args_scope xs + RecConGADT x -> mkLScope x tyScope = mkLScope typ resScope = ResolvedScopes [ctxScope, rhsScope] bindings = map (C $ TyVarBind (mkScope (loc exp_vars)) resScope) imp_vars @@ -1557,13 +1563,12 @@ instance ToHie (Located (ConDecl GhcRn)) where where rhsScope = combineScopes ctxScope argsScope ctxScope = maybe NoScope mkLScope ctx - argsScope = condecl_scope dets - where condecl_scope :: HsConDeclDetails (GhcPass p) -> Scope - condecl_scope args = case args of - PrefixCon xs -> foldr combineScopes NoScope $ map (mkLScope . hsScaledThing) xs - InfixCon a b -> combineScopes (mkLScope (hsScaledThing a)) - (mkLScope (hsScaledThing b)) - RecCon x -> mkLScope x + argsScope = case dets of + PrefixCon xs -> scaled_args_scope xs + InfixCon a b -> scaled_args_scope [a, b] + RecCon x -> mkLScope x + where scaled_args_scope :: [HsScaled GhcRn (LHsType GhcRn)] -> Scope + scaled_args_scope = foldr combineScopes NoScope . map (mkLScope . hsScaledThing) instance ToHie (Located [Located (ConDeclField GhcRn)]) where toHie (L span decls) = concatM $ ===================================== compiler/GHC/Parser.y ===================================== @@ -2330,7 +2330,7 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr Specificity GhcPs]) } : 'forall' tv_bndrs '.' { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) } | {- empty -} { noLoc ([], Nothing) } -constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) } +constr_stuff :: { Located (Located RdrName, HsConDeclH98Details GhcPs) } : infixtype {% fmap (mapLoc (\b -> (dataConBuilderCon b, dataConBuilderDetails b))) (runPV $1) } ===================================== compiler/GHC/Parser/PostProcess.hs ===================================== @@ -611,7 +611,7 @@ recordPatSynErr loc pat = addFatalError $ Error (ErrRecordSyntaxInPatSynDecl pat) [] loc mkConDeclH98 :: Located RdrName -> Maybe [LHsTyVarBndr Specificity GhcPs] - -> Maybe (LHsContext GhcPs) -> HsConDeclDetails GhcPs + -> Maybe (LHsContext GhcPs) -> HsConDeclH98Details GhcPs -> ConDecl GhcPs mkConDeclH98 name mb_forall mb_cxt args @@ -636,17 +636,17 @@ mkGadtDecl :: [Located RdrName] mkGadtDecl names ty = do let (args, res_ty, anns) | L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty - = (RecCon (L loc rf), res_ty, []) + = (RecConGADT (L loc rf), res_ty, []) | otherwise = let (arg_types, res_type, anns) = splitHsFunType body_ty - in (PrefixCon arg_types, res_type, anns) + in (PrefixConGADT arg_types, res_type, anns) pure ( ConDeclGADT { con_g_ext = noExtField , con_names = names , con_forall = L (getLoc ty) $ isJust mtvs , con_qvars = fromMaybe [] mtvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } , anns ) @@ -1618,7 +1618,7 @@ dataConBuilderCon :: DataConBuilder -> Located RdrName dataConBuilderCon (PrefixDataConBuilder _ dc) = dc dataConBuilderCon (InfixDataConBuilder _ dc _) = dc -dataConBuilderDetails :: DataConBuilder -> HsConDeclDetails GhcPs +dataConBuilderDetails :: DataConBuilder -> HsConDeclH98Details GhcPs -- Detect when the record syntax is used: -- data T = MkT { ... } ===================================== compiler/GHC/Parser/PostProcess/Haddock.hs ===================================== @@ -690,22 +690,21 @@ instance HasHaddock (Located (ConDecl GhcPs)) where addHaddock (L l_con_decl con_decl) = extendHdkA l_con_decl $ case con_decl of - ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_args, con_res_ty } -> do + ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_g_args, con_res_ty } -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. con_doc' <- discardHasInnerDocs $ getConDoc (getLoc (head con_names)) - con_args' <- - case con_args of - PrefixCon ts -> PrefixCon <$> addHaddock ts - RecCon (L l_rec flds) -> do + con_g_args' <- + case con_g_args of + PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts + RecConGADT (L l_rec flds) -> do -- discardHasInnerDocs is ok because we don't need this info for GADTs. flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds - pure $ RecCon (L l_rec flds') - InfixCon _ _ -> panic "ConDeclGADT InfixCon" + pure $ RecConGADT (L l_rec flds') con_res_ty' <- addHaddock con_res_ty pure $ L l_con_decl $ ConDeclGADT { con_g_ext, con_names, con_forall, con_qvars, con_mb_cxt, con_doc = con_doc', - con_args = con_args', + con_g_args = con_g_args', con_res_ty = con_res_ty' } ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } -> addConTrailingDoc (srcSpanEnd l_con_decl) $ ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -29,9 +29,9 @@ module GHC.Rename.HsType ( rnImplicitBndrs, bindSigTyVarsFV, bindHsQTyVars, FreeKiTyVars, extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars, - extractHsTysRdrTyVars, extractRdrKindSigVars, extractDataDefnKindVars, + extractHsTysRdrTyVars, extractRdrKindSigVars, + extractConDeclGADTDetailsTyVars, extractDataDefnKindVars, extractHsTvBndrs, extractHsTyArgRdrKiTyVars, - extractHsScaledTysRdrTyVars, forAllOrNothing, nubL ) where @@ -1747,9 +1747,6 @@ extractHsTyArgRdrKiTyVars args extractHsTyRdrTyVars :: LHsType GhcPs -> FreeKiTyVars extractHsTyRdrTyVars ty = extract_lty ty [] -extractHsScaledTysRdrTyVars :: [HsScaled GhcPs (LHsType GhcPs)] -> FreeKiTyVars -> FreeKiTyVars -extractHsScaledTysRdrTyVars args acc = foldr (\(HsScaled m ty) -> extract_lty ty . extract_hs_arrow m) acc args - -- | Extracts the free type/kind variables from the kind signature of a HsType. -- This is used to implicitly quantify over @k@ in @type T = Nothing :: Maybe k at . -- The left-to-right order of variables is preserved. @@ -1787,6 +1784,15 @@ extractRdrKindSigVars (L _ resultSig) = case resultSig of TyVarSig _ (L _ (KindedTyVar _ _ _ k)) -> extractHsTyRdrTyVars k _ -> [] +-- | Extracts free type and kind variables from an argument in a GADT +-- constructor, returning variable occurrences in left-to-right order. +-- See @Note [Ordering of implicit variables]@. +extractConDeclGADTDetailsTyVars :: + HsConDeclGADTDetails GhcPs -> FreeKiTyVars -> FreeKiTyVars +extractConDeclGADTDetailsTyVars con_args = case con_args of + PrefixConGADT args -> extract_scaled_ltys args + RecConGADT (L _ flds) -> extract_ltys $ map (cd_fld_type . unLoc) $ flds + -- | Get type/kind variables mentioned in the kind signature, preserving -- left-to-right order: -- @@ -1801,6 +1807,14 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig }) extract_lctxt :: LHsContext GhcPs -> FreeKiTyVars -> FreeKiTyVars extract_lctxt ctxt = extract_ltys (unLoc ctxt) +extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)] + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_ltys args acc = foldr extract_scaled_lty acc args + +extract_scaled_lty :: HsScaled GhcPs (LHsType GhcPs) + -> FreeKiTyVars -> FreeKiTyVars +extract_scaled_lty (HsScaled m ty) acc = extract_lty ty $ extract_hs_arrow m acc + extract_ltys :: [LHsType GhcPs] -> FreeKiTyVars -> FreeKiTyVars extract_ltys tys acc = foldr extract_lty acc tys ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2181,7 +2181,7 @@ rnConDecl decl@(ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs ; bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing ex_tvs $ \ new_ex_tvs -> do { (new_context, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc new_name) ctxt args + ; (new_args, fvs2) <- rnConDeclH98Details (unLoc new_name) ctxt args ; let all_fvs = fvs1 `plusFV` fvs2 ; traceRn "rnConDecl (ConDeclH98)" (ppr name <+> vcat [ text "ex_tvs:" <+> ppr ex_tvs @@ -2198,15 +2198,12 @@ rnConDecl decl@(ConDeclGADT { con_names = names , con_forall = forall@(L _ explicit_forall) , con_qvars = explicit_tkvs , con_mb_cxt = mcxt - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = mb_doc }) = do { mapM_ (addLocM checkConName) names ; new_names <- mapM lookupLocatedTopBndrRn names - ; let theta = hsConDeclTheta mcxt - arg_tys = hsConDeclArgTys args - -- We must ensure that we extract the free tkvs in left-to-right -- order of their appearance in the constructor type. -- That order governs the order the implicitly-quantified type @@ -2214,9 +2211,9 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- See #14808. ; implicit_bndrs <- forAllOrNothing explicit_forall $ extractHsTvBndrs explicit_tkvs - $ extractHsTysRdrTyVars theta - $ extractHsScaledTysRdrTyVars arg_tys - $ extractHsTysRdrTyVars [res_ty] [] + $ extractHsTysRdrTyVars (hsConDeclTheta mcxt) + $ extractConDeclGADTDetailsTyVars args + $ extractHsTyRdrTyVars res_ty ; let ctxt = ConDeclCtx new_names @@ -2224,7 +2221,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names bindLHsTyVarBndrs ctxt WarnUnusedForalls Nothing explicit_tkvs $ \ explicit_tkvs -> do { (new_cxt, fvs1) <- rnMbContext ctxt mcxt - ; (new_args, fvs2) <- rnConDeclDetails (unLoc (head new_names)) ctxt args + ; (new_args, fvs2) <- rnConDeclGADTDetails (unLoc (head new_names)) ctxt args ; (new_res_ty, fvs3) <- rnLHsType ctxt res_ty -- Ensure that there are no nested `forall`s or contexts, per @@ -2239,7 +2236,7 @@ rnConDecl decl@(ConDeclGADT { con_names = names (ppr names $$ ppr implicit_tkvs $$ ppr explicit_tkvs) ; return (decl { con_g_ext = implicit_tkvs, con_names = new_names , con_qvars = explicit_tkvs, con_mb_cxt = new_cxt - , con_args = new_args, con_res_ty = new_res_ty + , con_g_args = new_args, con_res_ty = new_res_ty , con_doc = mb_doc , con_forall = forall }, -- Remove when #18311 is fixed all_fvs) } } @@ -2250,27 +2247,45 @@ rnMbContext _ Nothing = return (Nothing, emptyFVs) rnMbContext doc (Just cxt) = do { (ctx',fvs) <- rnContext doc cxt ; return (Just ctx',fvs) } -rnConDeclDetails - :: Name +rnConDeclH98Details :: + Name -> HsDocContext - -> HsConDetails (HsScaled GhcPs (LHsType GhcPs)) (Located [LConDeclField GhcPs]) - -> RnM ((HsConDetails (HsScaled GhcRn (LHsType GhcRn))) (Located [LConDeclField GhcRn]), - FreeVars) -rnConDeclDetails _ doc (PrefixCon tys) + -> HsConDeclH98Details GhcPs + -> RnM (HsConDeclH98Details GhcRn, FreeVars) +rnConDeclH98Details _ doc (PrefixCon tys) = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys ; return (PrefixCon new_tys, fvs) } - -rnConDeclDetails _ doc (InfixCon ty1 ty2) +rnConDeclH98Details _ doc (InfixCon ty1 ty2) = do { (new_ty1, fvs1) <- rnScaledLHsType doc ty1 ; (new_ty2, fvs2) <- rnScaledLHsType doc ty2 ; return (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2) } +rnConDeclH98Details con doc (RecCon flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecCon new_flds, fvs) } -rnConDeclDetails con doc (RecCon (L l fields)) +rnConDeclGADTDetails :: + Name + -> HsDocContext + -> HsConDeclGADTDetails GhcPs + -> RnM (HsConDeclGADTDetails GhcRn, FreeVars) +rnConDeclGADTDetails _ doc (PrefixConGADT tys) + = do { (new_tys, fvs) <- mapFvRn (rnScaledLHsType doc) tys + ; return (PrefixConGADT new_tys, fvs) } +rnConDeclGADTDetails con doc (RecConGADT flds) + = do { (new_flds, fvs) <- rnRecConDeclFields con doc flds + ; return (RecConGADT new_flds, fvs) } + +rnRecConDeclFields :: + Name + -> HsDocContext + -> Located [LConDeclField GhcPs] + -> RnM (Located [LConDeclField GhcRn], FreeVars) +rnRecConDeclFields con doc (L l fields) = do { fls <- lookupConstructorFields con ; (new_fields, fvs) <- rnConDeclFields doc fls fields -- No need to check for duplicate fields -- since that is done by GHC.Rename.Names.extendGlobalRdrEnvRn - ; return (RecCon (L l new_fields), fvs) } + ; pure (L l new_fields, fvs) } ------------------------------------------------- ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -775,7 +775,7 @@ getLocalNonValBinders fixity_env = [( find_con_name rdr , concatMap find_con_decl_flds (unLoc cdflds) )] find_con_flds (L _ (ConDeclGADT { con_names = rdrs - , con_args = RecCon flds })) + , con_g_args = RecConGADT flds })) = [ ( find_con_name rdr , concatMap find_con_decl_flds (unLoc flds)) | L _ rdr <- rdrs ] ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -1574,7 +1574,7 @@ kcTyClDecl (FamDecl _ (FamilyDecl { fdInfo = fd_info })) fam_tc ------------------- --- Type check the types of the arguments to a data constructor. +-- Kind-check the types of the arguments to a data constructor. -- This includes doing kind unification if the type is a newtype. -- See Note [Implementation of UnliftedNewtypes] for why we need -- the first two arguments. @@ -1587,6 +1587,21 @@ kcConArgTys new_or_data res_kind arg_tys = do -- See Note [Implementation of UnliftedNewtypes], STEP 2 } +-- Kind-check the types of arguments to a Haskell98 data constructor. +kcConH98Args :: NewOrData -> Kind -> HsConDeclH98Details GhcRn -> TcM () +kcConH98Args new_or_data res_kind con_args = case con_args of + PrefixCon tys -> kcConArgTys new_or_data res_kind tys + InfixCon ty1 ty2 -> kcConArgTys new_or_data res_kind [ty1, ty2] + RecCon (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + +-- Kind-check the types of arguments to a GADT data constructor. +kcConGADTArgs :: NewOrData -> Kind -> HsConDeclGADTDetails GhcRn -> TcM () +kcConGADTArgs new_or_data res_kind con_args = case con_args of + PrefixConGADT tys -> kcConArgTys new_or_data res_kind tys + RecConGADT (L _ flds) -> kcConArgTys new_or_data res_kind $ + map (hsLinear . cd_fld_type . unLoc) flds + kcConDecls :: NewOrData -> Kind -- The result kind signature -> [LConDecl GhcRn] -- The data constructors @@ -1615,14 +1630,14 @@ kcConDecl new_or_data res_kind (ConDeclH98 discardResult $ bindExplicitTKBndrs_Tv ex_tvs $ do { _ <- tcHsMbContext ex_ctxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConH98Args new_or_data res_kind args -- We don't need to check the telescope here, -- because that's done in tcConDecl } kcConDecl new_or_data res_kind (ConDeclGADT { con_names = names, con_qvars = explicit_tkv_nms, con_mb_cxt = cxt - , con_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) + , con_g_args = args, con_res_ty = res_ty, con_g_ext = implicit_tkv_nms }) = -- Even though the GADT-style data constructor's type is closed, -- we must still kind-check the type, because that may influence -- the inferred kind of the /type/ constructor. Example: @@ -1636,7 +1651,7 @@ kcConDecl new_or_data res_kind (ConDeclGADT bindExplicitTKBndrs_Tv explicit_tkv_nms $ -- Why "_Tv"? See Note [Kind-checking for GADTs] do { _ <- tcHsMbContext cxt - ; kcConArgTys new_or_data res_kind (hsConDeclArgTys args) + ; kcConGADTArgs new_or_data res_kind args ; _ <- tcHsOpenType res_ty ; return () } @@ -3207,7 +3222,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs res_kind res_tmpl new_or_data bindExplicitTKBndrs_Skol explicit_tkv_nms $ do { ctxt <- tcHsMbContext hs_ctxt ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConH98Args exp_kind hs_args ; field_lbls <- lookupConstructorFields name ; let (arg_tys, stricts) = unzip btys ; return (ctxt, arg_tys, field_lbls, stricts) @@ -3277,7 +3292,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data (ConDeclGADT { con_g_ext = implicit_tkv_nms , con_names = names , con_qvars = explicit_tkv_nms - , con_mb_cxt = cxt, con_args = hs_args + , con_mb_cxt = cxt, con_g_args = hs_args , con_res_ty = hs_res_ty }) = addErrCtxt (dataConCtxtName names) $ do { traceTc "tcConDecl 1 gadt" (ppr names) @@ -3294,7 +3309,7 @@ tcConDecl rep_tycon tag_map tmpl_bndrs _res_kind res_tmpl new_or_data -- See Note [Datatype return kinds] ; let exp_kind = getArgExpKind new_or_data res_kind - ; btys <- tcConArgs exp_kind hs_args + ; btys <- tcConGADTArgs exp_kind hs_args ; let (arg_tys, stricts) = unzip btys ; field_lbls <- lookupConstructorFields name ; return (ctxt, arg_tys, res_ty, field_lbls, stricts) @@ -3373,48 +3388,50 @@ getArgExpKind NewType res_ki = TheKind res_ki getArgExpKind DataType _ = OpenKind tcConIsInfixH98 :: Name - -> HsConDetails a b + -> HsConDeclH98Details GhcRn -> TcM Bool tcConIsInfixH98 _ details = case details of - InfixCon {} -> return True - _ -> return False + InfixCon{} -> return True + RecCon{} -> return False + PrefixCon{} -> return False tcConIsInfixGADT :: Name - -> HsConDetails (HsScaled GhcRn (LHsType GhcRn)) r + -> HsConDeclGADTDetails GhcRn -> TcM Bool tcConIsInfixGADT con details = case details of - InfixCon {} -> return True - RecCon {} -> return False - PrefixCon arg_tys -- See Note [Infix GADT constructors] + RecConGADT{} -> return False + PrefixConGADT arg_tys -- See Note [Infix GADT constructors] | isSymOcc (getOccName con) , [_ty1,_ty2] <- map hsScaledThing arg_tys -> do { fix_env <- getFixityEnv ; return (con `elemNameEnv` fix_env) } | otherwise -> return False -tcConArgs :: ContextKind -- expected kind of arguments - -- always OpenKind for datatypes, but unlifted newtypes - -- might have a specific kind - -> HsConDeclDetails GhcRn - -> TcM [(Scaled TcType, HsSrcBang)] -tcConArgs exp_kind (PrefixCon btys) +tcConH98Args :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclH98Details GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConH98Args exp_kind (PrefixCon btys) = mapM (tcConArg exp_kind) btys -tcConArgs exp_kind (InfixCon bty1 bty2) +tcConH98Args exp_kind (InfixCon bty1 bty2) = do { bty1' <- tcConArg exp_kind bty1 ; bty2' <- tcConArg exp_kind bty2 ; return [bty1', bty2'] } -tcConArgs exp_kind (RecCon fields) +tcConH98Args exp_kind (RecCon fields) + = tcRecConDeclFields exp_kind fields + +tcConGADTArgs :: ContextKind -- expected kind of arguments + -- always OpenKind for datatypes, but unlifted newtypes + -- might have a specific kind + -> HsConDeclGADTDetails GhcRn + -> TcM [(Scaled TcType, HsSrcBang)] +tcConGADTArgs exp_kind (PrefixConGADT btys) = mapM (tcConArg exp_kind) btys - where - -- We need a one-to-one mapping from field_names to btys - combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) - (unLoc fields) - explode (ns,ty) = zip ns (repeat ty) - exploded = concatMap explode combined - (_,btys) = unzip exploded - +tcConGADTArgs exp_kind (RecConGADT fields) + = tcRecConDeclFields exp_kind fields tcConArg :: ContextKind -- expected kind for args; always OpenKind for datatypes, -- but might be an unlifted type with UnliftedNewtypes @@ -3426,6 +3443,19 @@ tcConArg exp_kind (HsScaled w bty) ; traceTc "tcConArg 2" (ppr bty) ; return (Scaled w' arg_ty, getBangStrictness bty) } +tcRecConDeclFields :: ContextKind + -> Located [LConDeclField GhcRn] + -> TcM [(Scaled TcType, HsSrcBang)] +tcRecConDeclFields exp_kind fields + = mapM (tcConArg exp_kind) btys + where + -- We need a one-to-one mapping from field_names to btys + combined = map (\(L _ f) -> (cd_fld_names f,hsLinear (cd_fld_type f))) + (unLoc fields) + explode (ns,ty) = zip ns (repeat ty) + exploded = concatMap explode combined + (_,btys) = unzip exploded + tcDataConMult :: HsArrow GhcRn -> TcM Mult tcDataConMult arr@(HsUnrestrictedArrow _) = do -- See Note [Function arrows in GADT constructors] ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -622,7 +622,7 @@ cvtConstr (GadtC c strtys ty) = do { c' <- mapM cNameL c ; args <- mapM cvt_arg strtys ; ty' <- cvtType ty - ; returnL $ mk_gadt_decl c' (PrefixCon $ map hsLinear args) ty'} + ; returnL $ mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'} cvtConstr (RecGadtC [] _varstrtys _ty) = failWith (text "RecGadtC must have at least one constructor name") @@ -631,9 +631,9 @@ cvtConstr (RecGadtC c varstrtys ty) = do { c' <- mapM cNameL c ; ty' <- cvtType ty ; rec_flds <- mapM cvt_id_arg varstrtys - ; returnL $ mk_gadt_decl c' (RecCon $ noLoc rec_flds) ty' } + ; returnL $ mk_gadt_decl c' (RecConGADT $ noLoc rec_flds) ty' } -mk_gadt_decl :: [Located RdrName] -> HsConDeclDetails GhcPs -> LHsType GhcPs +mk_gadt_decl :: [Located RdrName] -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs -> ConDecl GhcPs mk_gadt_decl names args res_ty = ConDeclGADT { con_g_ext = noExtField @@ -641,7 +641,7 @@ mk_gadt_decl names args res_ty , con_forall = noLoc False , con_qvars = [] , con_mb_cxt = Nothing - , con_args = args + , con_g_args = args , con_res_ty = res_ty , con_doc = Nothing } ===================================== docs/users_guide/9.2.1-notes.rst ===================================== @@ -43,14 +43,52 @@ Compiler - ``Void#`` is now a type synonym for the unboxed tuple ``(# #)``. Code using ``Void#`` now has to enable :extension:`UnboxedTuples`. +``ghc`` library +~~~~~~~~~~~~~ + +- The ``con_args`` field of ``ConDeclGADT`` has been renamed to ``con_g_args``. + This is because the type of ``con_g_args`` is now different from the type of + the ``con_args`` field in ``ConDeclH98``: :: + + data ConDecl pass + = ConDeclGADT + { ... + , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix + , ... + } + + | ConDeclH98 + { ... + , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix + , ... + } + + Where: :: + + -- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC + type HsConDeclH98Details pass + = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) + + -- Introduced in GHC 9.2 + data HsConDeclGADTDetails pass + = PrefixConGADT [HsScaled pass (LBangType pass)] + | RecConGADT (XRec pass [LConDeclField pass]) + + Unlike Haskell98-style constructors, GADT constructors cannot be declared + using infix syntax, which is why ``HsConDeclGADTDetails`` lacks an + ``InfixConGADT`` constructor. + + As a result of all this, the ``con_args`` field is now partial, so using + ``con_args`` as a top-level field selector is discouraged. + ``base`` library ~~~~~~~~~~~~~~~~ -- It's possible now to promote the ``Natural`` type: :: - +- It's possible now to promote the ``Natural`` type: :: + data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10 - + The separate kind ``Nat`` is removed and now it is just a type synonym for ``Natural``. As a consequence, one must enable ``TypeSynonymInstances`` in order to define instances for ``Nat``. ===================================== libraries/base/Foreign/Marshal/Alloc.hs ===================================== @@ -99,7 +99,7 @@ calloc = callocBytes (sizeOf (undefined :: a)) mallocBytes :: Int -> IO (Ptr a) mallocBytes size = failWhenNULL "malloc" (_malloc (fromIntegral size)) --- |Llike 'mallocBytes' but memory is filled with bytes of value zero. +-- |Like 'mallocBytes', but memory is filled with bytes of value zero. -- callocBytes :: Int -> IO (Ptr a) callocBytes size = failWhenNULL "calloc" $ _calloc 1 (fromIntegral size) ===================================== rts/Linker.c ===================================== @@ -1351,7 +1351,7 @@ void freeObjectCode (ObjectCode *oc) ocDeinit_ELF(oc); #endif -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) m32_allocator_free(oc->rx_m32); m32_allocator_free(oc->rw_m32); #endif @@ -1422,7 +1422,7 @@ mkOc( pathchar *path, char *image, int imageSize, /* chain it onto the list of objects */ oc->next = NULL; -#if RTS_LINKER_USE_MMAP +#if defined(USE_M32) oc->rw_m32 = m32_allocator_new(false); oc->rx_m32 = m32_allocator_new(true); #endif ===================================== rts/LinkerInternals.h ===================================== @@ -21,6 +21,36 @@ void printLoadedObjects(void); #include "BeginPrivate.h" +/************************************************* + * Various bits of configuration + *************************************************/ + +/* PowerPC and ARM have relative branch instructions with only 24 bit + * displacements and therefore need jump islands contiguous with each object + * code module. + */ +#if defined(powerpc_HOST_ARCH) +#define SHORT_REL_BRANCH 1 +#endif +#if defined(arm_HOST_ARCH) +#define SHORT_REL_BRANCH 1 +#endif + +#if (RTS_LINKER_USE_MMAP && defined(SHORT_REL_BRANCH) && defined(linux_HOST_OS)) +#define USE_CONTIGUOUS_MMAP 1 +#else +#define USE_CONTIGUOUS_MMAP 0 +#endif + +// We use the m32 allocator on Windows and Unix platforms using mmap +#if (RTS_LINKER_USE_MMAP == 1) || defined(PE_OBJFORMAT) || 1 +#define USE_M32 +#endif + +#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) +#define NEED_SYMBOL_EXTRAS 1 +#endif + typedef void SymbolAddr; typedef char SymbolName; @@ -135,10 +165,6 @@ typedef struct _Segment { int n_sections; } Segment; -#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) -#define NEED_SYMBOL_EXTRAS 1 -#endif - /* Jump Islands are sniplets of machine code required for relative * address relocations on the PowerPC, x86_64 and ARM. */ @@ -236,7 +262,7 @@ typedef struct _ObjectCode { require extra information.*/ StrHashTable *extraInfos; -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) /* The m32 allocators used for allocating small sections and symbol extras * during loading. We have two: one for (writeable) data and one for * (read-only/executable) code. */ @@ -315,27 +341,6 @@ pathchar* resolveSymbolAddr (pathchar* buffer, int size, SymbolAddr* symbol, uintptr_t* top); -/************************************************* - * Various bits of configuration - *************************************************/ - -/* PowerPC and ARM have relative branch instructions with only 24 bit - * displacements and therefore need jump islands contiguous with each object - * code module. - */ -#if defined(powerpc_HOST_ARCH) -#define SHORT_REL_BRANCH 1 -#endif -#if defined(arm_HOST_ARCH) -#define SHORT_REL_BRANCH 1 -#endif - -#if (RTS_LINKER_USE_MMAP && defined(SHORT_REL_BRANCH) && defined(linux_HOST_OS)) -#define USE_CONTIGUOUS_MMAP 1 -#else -#define USE_CONTIGUOUS_MMAP 0 -#endif - HsInt isAlreadyLoaded( pathchar *path ); HsInt loadOc( ObjectCode* oc ); ObjectCode* mkOc( pathchar *path, char *image, int imageSize, ===================================== rts/linker/M32Alloc.c ===================================== @@ -42,7 +42,7 @@ still check the call for syntax and correct function parameter types. */ -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) /* ===================================== rts/linker/M32Alloc.h ===================================== @@ -8,7 +8,7 @@ #pragma once -#if RTS_LINKER_USE_MMAP == 1 +#if defined(USE_M32) #include #include @@ -20,7 +20,7 @@ #include "BeginPrivate.h" -#if RTS_LINKER_USE_MMAP +#if defined(USE_M32) #define M32_NO_RETURN /* Nothing */ #else #define M32_NO_RETURN GNUC3_ATTRIBUTE(__noreturn__) ===================================== rts/linker/PEi386.c ===================================== @@ -1294,7 +1294,7 @@ ocVerifyImage_PEi386 ( ObjectCode* oc ) = (PEi386_IMAGE_OFFSET + 2 * default_alignment + oc->info->secBytesTotal) & ~0x7; oc->info->secBytesTotal - = oc->info->trampoline + info->numberOfSymbols * sizeof(SymbolExtra); + = oc->info->trampoline; /* No further verification after this point; only debug printing. */ i = 0; @@ -1792,12 +1792,15 @@ ocAllocateExtras_PEi386 ( ObjectCode* oc ) if (!oc->info) return false; - const int mask = default_alignment - 1; - size_t origin = oc->info->trampoline; + COFF_HEADER_INFO *info = oc->info->ch_info; + size_t extras_size = info->numberOfSymbols * sizeof(SymbolExtra); + oc->symbol_extras - = (SymbolExtra*)((uintptr_t)(oc->info->image + origin + mask) & ~mask); + = (SymbolExtra*) m32_alloc(oc->rx_m32, extras_size, 8); + if (oc->symbol_extras == NULL) + return false; + oc->first_symbol_extra = 0; - COFF_HEADER_INFO *info = oc->info->ch_info; oc->n_symbol_extras = info->numberOfSymbols; return true; @@ -1952,13 +1955,15 @@ ocResolve_PEi386 ( ObjectCode* oc ) { uint64_t v; v = S + A; - if (v >> 32) { + // N.B. in the case of the sign-extended relocations we must ensure that v + // fits in a signed 32-bit value. See #15808. + if (((int64_t) v > (int64_t) INT32_MAX) || ((int64_t) v < (int64_t) INT32_MIN)) { copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol); /* And retry */ v = S + A; - if (v >> 32) { + if (((int64_t) v > (int64_t) INT32_MAX) || ((int64_t) v < (int64_t) INT32_MIN)) { barf("IMAGE_REL_AMD64_ADDR32[NB]: High bits are set in %zx for %s", v, (char *)symbol); } @@ -1970,14 +1975,14 @@ ocResolve_PEi386 ( ObjectCode* oc ) { intptr_t v; v = S + (int32_t)A - ((intptr_t)pP) - 4; - if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) { + if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { /* Make the trampoline then */ copyName (getSymShortName (info, sym), oc, symbol, sizeof(symbol)-1); S = makeSymbolExtra_PEi386(oc, symIndex, S, (char *)symbol); /* And retry */ v = S + (int32_t)A - ((intptr_t)pP) - 4; - if ((v > (intptr_t) INT32_MAX) || (v < (intptr_t) INT32_MIN)) { + if ((v > (int64_t) INT32_MAX) || (v < (int64_t) INT32_MIN)) { barf("IMAGE_REL_AMD64_REL32: High bits are set in %zx for %s", v, (char *)symbol); } ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr ===================================== @@ -386,7 +386,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:25:13-18 } (HsAppTy @@ -522,7 +522,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:31:13-18 } (HsAppTy @@ -658,7 +658,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:37:13-18 } (HsAppTy @@ -794,7 +794,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:43:13-18 } (HsAppTy @@ -930,7 +930,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:49:13-18 } (HsAppTy @@ -1066,7 +1066,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544.hs:55:14-20 } (HsAppTy ===================================== testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT []) ({ T17544_kw.hs:16:18-20 } (HsTyVar @@ -83,7 +83,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/DumpRenamedAst.stderr ===================================== @@ -374,7 +374,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) ===================================== testsuite/tests/parser/should_compile/T15323.stderr ===================================== @@ -72,7 +72,7 @@ ({ T15323.hs:6:35 } (Unqual {OccName: v}))))))))])) - (PrefixCon + (PrefixConGADT []) ({ T15323.hs:6:41-54 } (HsAppTy ===================================== testsuite/tests/printer/T18791.stderr ===================================== @@ -39,7 +39,7 @@ (False)) [] (Nothing) - (PrefixCon + (PrefixConGADT [(HsScaled (HsUnrestrictedArrow (NormalSyntax)) @@ -61,4 +61,6 @@ ({ } [])))))] (Nothing) - (Nothing))) \ No newline at end of file + (Nothing))) + + ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 87a9f86d1ad7de67ff011311905ecf76578b26e9 +Subproject commit 3cce1bdee8c61bb6daa089059e12435178f50770 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59c459f2e0f5d5ba948bb9ea03f54f8c42c0e93e...47dbdc442e2ef49831da1434b3c79eeba5a7b254 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/59c459f2e0f5d5ba948bb9ea03f54f8c42c0e93e...47dbdc442e2ef49831da1434b3c79eeba5a7b254 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 17:34:59 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 13:34:59 -0400 Subject: [Git][ghc/ghc][wip/T15808] 9 commits: Make typechecker equality consider visibility in ForAllTys Message-ID: <5f9da043429bf_7853fb64247b4d012367a@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T15808 at Glasgow Haskell Compiler / GHC Commits: 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - 6d21ecee by Ben Gamari at 2020-10-31T13:34:45-04:00 rts/linker: Fix relocation overflow in PE linker Previously the overflow check for the IMAGE_REL_AMD64_ADDR32NB relocation failed to account for the signed nature of the value. Specifically, the overflow check was: uint64_t v; v = S + A; if (v >> 32) { ... } However, `v` ultimately needs to fit into 32-bits as a signed value. Consequently, values `v > 2^31` in fact overflow yet this is not caught by the existing overflow check. Here we rewrite the overflow check to rather ensure that `INT32_MIN <= v <= INT32_MAX`. There is now quite a bit of repetition between the `IMAGE_REL_AMD64_REL32` and `IMAGE_REL_AMD64_ADDR32` cases but I am leaving fixing this for future work. This bug was first noticed by @awson. Fixes #15808. - - - - - 30 changed files: - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/TyThing.hs - docs/users_guide/exts/poly_kinds.rst - docs/users_guide/exts/type_applications.rst - libraries/base/GHC/Event/Windows.hsc - rts/linker/PEi386.c - rts/win32/AsyncWinIO.c - rts/win32/AsyncWinIO.h - + testsuite/tests/saks/should_fail/T18863a.hs - + testsuite/tests/saks/should_fail/T18863a.stderr - + testsuite/tests/saks/should_fail/T18863b.hs - + testsuite/tests/saks/should_fail/T18863b.stderr - testsuite/tests/saks/should_fail/all.T - + testsuite/tests/simplCore/should_run/NumConstantFolding.hs - + testsuite/tests/simplCore/should_run/NumConstantFolding.stdout - testsuite/tests/simplCore/should_run/all.T - + testsuite/tests/typecheck/should_compile/T15079.hs - + testsuite/tests/typecheck/should_compile/T816.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47dbdc442e2ef49831da1434b3c79eeba5a7b254...6d21ecee535782f01dba9947a49e282afee25724 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47dbdc442e2ef49831da1434b3c79eeba5a7b254...6d21ecee535782f01dba9947a49e282afee25724 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 18:09:41 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 14:09:41 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 33 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f9da865eec64_7853fb642560d3c1348cb@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - 154a79fa by Sven Tennie at 2020-10-31T13:54:14-04:00 deriveConstants: Add hie.yaml - - - - - 8efcab85 by Sven Tennie at 2020-10-31T13:54:20-04:00 base: Generalize newStablePtrPrimMVar Make it polymorphic in the type of the MVar's value. - - - - - 648cd4ad by Sven Tennie at 2020-10-31T14:07:00-04:00 Introduce snapshotting of thread's own stack Introduce `StackSnapshot#` type and the `cloneMyStack#` primop, allowing the user to reify the state of the calling thread's stack for later inspection. The stack snapshot is offline/cold, i.e. it isn't evaluated any further. For technical details, please see note [Stack Cloning]. - - - - - 35b7999a by Sven Tennie at 2020-10-31T14:07:06-04:00 Introduce cloning of other threads' stacks Introduce `cloneThreadStack` function, allowing threads to request snapshots of other threads' stacks. For technical details, please see note [Stack Cloning]. - - - - - 5e88f509 by Sven Tennie at 2020-10-31T14:07:06-04:00 Introduce printing support for StackSnapshot#'s This refactors the RTS's existing Printer module to allow printing of StackSnapshot#'s. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1da7d7da23b62719346cf79695664de694cb8b3...5e88f5097f60b24330d4397afcb5aa5d996fbb0a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d1da7d7da23b62719346cf79695664de694cb8b3...5e88f5097f60b24330d4397afcb5aa5d996fbb0a You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 18:28:09 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 14:28:09 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 3 commits: Introduce snapshotting of thread's own stack Message-ID: <5f9dacb982f68_7853fb61c2f4d6c1375f8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: f2402e6d by Sven Tennie at 2020-10-31T14:27:34-04:00 Introduce snapshotting of thread's own stack Introduce `StackSnapshot#` type and the `cloneMyStack#` primop, allowing the user to reify the state of the calling thread's stack for later inspection. The stack snapshot is offline/cold, i.e. it isn't evaluated any further. For technical details, please see note [Stack Cloning]. - - - - - 415ca6c6 by Sven Tennie at 2020-10-31T14:27:38-04:00 Introduce cloning of other threads' stacks Introduce `cloneThreadStack` function, allowing threads to request snapshots of other threads' stacks. For technical details, please see note [Stack Cloning]. - - - - - 276e19f7 by Sven Tennie at 2020-10-31T14:27:38-04:00 Introduce printing support for StackSnapshot#'s This refactors the RTS's existing Printer module to allow printing of StackSnapshot#'s. - - - - - 26 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - + includes/rts/PrinterAPI.h - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Disassembler.c - rts/Disassembler.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneMyStack.hs - + testsuite/tests/rts/cloneStackLib.c - + testsuite/tests/rts/cloneThreadStack.hs - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1770,7 +1770,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, typeConKey, threadIdPrimTyConKey, bcoPrimTyConKey, ptrTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, - compactPrimTyConKey :: Unique + compactPrimTyConKey, stackSnapshotPrimTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -1801,6 +1801,7 @@ ptrTyConKey = mkPreludeTyConUnique 77 funPtrTyConKey = mkPreludeTyConUnique 78 tVarPrimTyConKey = mkPreludeTyConUnique 79 compactPrimTyConKey = mkPreludeTyConUnique 80 +stackSnapshotPrimTyConKey = mkPreludeTyConUnique 81 eitherTyConKey :: Unique eitherTyConKey = mkPreludeTyConUnique 84 ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -69,6 +69,7 @@ module GHC.Builtin.Types.Prim( bcoPrimTyCon, bcoPrimTy, weakPrimTyCon, mkWeakPrimTy, threadIdPrimTyCon, threadIdPrimTy, + stackSnapshotPrimTyCon, stackSnapshotPrimTy, int8PrimTyCon, int8PrimTy, int8PrimTyConName, word8PrimTyCon, word8PrimTy, word8PrimTyConName, @@ -189,6 +190,7 @@ exposedPrimTyCons , word16PrimTyCon , word32PrimTyCon , word64PrimTyCon + , stackSnapshotPrimTyCon , tYPETyCon , funTyCon @@ -211,7 +213,7 @@ mkBuiltInPrimTc fs unique tycon BuiltInSyntax -charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName :: Name +charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, stackSnapshotPrimTyConName :: Name charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon @@ -247,6 +249,7 @@ tVarPrimTyConName = mkPrimTc (fsLit "TVar#") tVarPrimTyConKey tVarPr stablePtrPrimTyConName = mkPrimTc (fsLit "StablePtr#") stablePtrPrimTyConKey stablePtrPrimTyCon stableNamePrimTyConName = mkPrimTc (fsLit "StableName#") stableNamePrimTyConKey stableNamePrimTyCon compactPrimTyConName = mkPrimTc (fsLit "Compact#") compactPrimTyConKey compactPrimTyCon +stackSnapshotPrimTyConName = mkPrimTc (fsLit "StackSnapshot#") stackSnapshotPrimTyConKey stackSnapshotPrimTyCon bcoPrimTyConName = mkPrimTc (fsLit "BCO") bcoPrimTyConKey bcoPrimTyCon weakPrimTyConName = mkPrimTc (fsLit "Weak#") weakPrimTyConKey weakPrimTyCon threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKey threadIdPrimTyCon @@ -1087,6 +1090,21 @@ compactPrimTyCon = pcPrimTyCon0 compactPrimTyConName UnliftedRep compactPrimTy :: Type compactPrimTy = mkTyConTy compactPrimTyCon +{- +************************************************************************ +* * + The @StackSnapshot#@ type +* * +************************************************************************ +-} + +stackSnapshotPrimTyCon :: TyCon +stackSnapshotPrimTyCon = pcPrimTyCon0 stackSnapshotPrimTyConName UnliftedRep + +stackSnapshotPrimTy :: Type +stackSnapshotPrimTy = mkTyConTy stackSnapshotPrimTyCon + + {- ************************************************************************ * * ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3151,6 +3151,16 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp has_side_effects = True out_of_line = True +primtype StackSnapshot# + +primop CloneMyStack "cloneMyStack#" GenPrimOp + State# RealWorld -> (# State# RealWorld, StackSnapshot# #) + { Clones the stack of the current Haskell thread. } + with + has_side_effects = True + out_of_line = True + + ------------------------------------------------------------------------ section "Safe coercions" ------------------------------------------------------------------------ ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1521,6 +1521,7 @@ emitPrimOp dflags primop = case primop of TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + CloneMyStack -> alwaysExternal where profile = targetProfile dflags ===================================== includes/rts/PrinterAPI.h ===================================== @@ -0,0 +1,3 @@ +#pragma once + +extern void printStack (StgStack* stack); ===================================== includes/rts/storage/Closures.h ===================================== @@ -431,6 +431,14 @@ typedef struct MessageBlackHole_ { StgClosure *bh; } MessageBlackHole; +typedef struct MessageCloneStack_ { + StgHeader header; + Message *link; + StgMVar *result; + StgTSO *tso; +} MessageCloneStack; + + /* ---------------------------------------------------------------------------- Compact Regions ------------------------------------------------------------------------- */ ===================================== includes/stg/MiscClosures.h ===================================== @@ -129,6 +129,7 @@ RTS_ENTRY(stg_STM_AWOKEN); RTS_ENTRY(stg_MSG_TRY_WAKEUP); RTS_ENTRY(stg_MSG_THROWTO); RTS_ENTRY(stg_MSG_BLACKHOLE); +RTS_ENTRY(stg_MSG_CLONE_STACK); RTS_ENTRY(stg_MSG_NULL); RTS_ENTRY(stg_MVAR_TSO_QUEUE); RTS_ENTRY(stg_catch); @@ -492,6 +493,7 @@ RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_cloneMyStackzh); /* Other misc stuff */ ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -0,0 +1,72 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes#-} + +-- | +-- This module exposes an interface for capturing the state of a thread's +-- execution stack for diagnostics purposes. +-- +-- @since 2.16.0.0 +module GHC.Stack.CloneStack ( + StackSnapshot(..), + cloneMyStack, + cloneThreadStack, + printStack + ) where + +import GHC.Prim (StackSnapshot#, cloneMyStack#, ThreadId#) +import Control.Concurrent.MVar +import GHC.Conc.Sync +import GHC.Stable +import GHC.IO (IO(..)) + +-- | A frozen snapshot of the state of an execution stack. +-- +-- @since 2.16.0.0 +data StackSnapshot = StackSnapshot !StackSnapshot# + +{- +Note [Stack Cloning] +~~~~~~~~~~~~~~~~~~~~ +"Cloning" a stack means that it's StgStack closure is copied including the +stack memory (stack[]). The stack pointer (sp) of the clone is adjusted to be +valid. +The clone is "offline"/"cold", i.e. it won't be evaluated any further. This is +useful for further analyses like stack unwinding or traversal. + +There are two different ways to clone a stack: +1. By the corresponding thread via a primop call (cloneMyStack#). +2. By sending a RTS message (Messages.c) with a MVar to the corresponding + thread and receiving the stack by taking it out of this MVar. +-} + +-- | Clone the stack of the executing thread +-- +-- @since 2.16.0.0 +cloneMyStack :: IO StackSnapshot +cloneMyStack = IO $ \s -> + case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) + +foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () + +-- | Clone the stack of a thread identified by its 'ThreadId' +-- +-- @since 2.16.0.0 +cloneThreadStack :: ThreadId -> IO StackSnapshot +cloneThreadStack (ThreadId tid#) = do + resultVar <- newEmptyMVar @StackSnapshot + ptr <- newStablePtrPrimMVar resultVar + -- Use the RTS's "message" mechanism to request that + -- the thread captures its stack, saving the result + -- into resultVar. + sendCloneStackMessage tid# ptr + freeStablePtr ptr + takeMVar resultVar + +foreign import ccall "PrinterAPI.h printStack" printStack_c :: StackSnapshot# -> IO () + +-- | Print the stack +printStack :: StackSnapshot -> IO () +printStack (StackSnapshot stack) = printStack_c stack ===================================== libraries/base/base.cabal ===================================== @@ -264,6 +264,7 @@ Library GHC.ResponseFile GHC.RTS.Flags GHC.ST + GHC.Stack.CloneStack GHC.StaticPtr GHC.STRef GHC.Show ===================================== rts/CloneStack.c ===================================== @@ -0,0 +1,84 @@ +/* --------------------------------------------------------------------------- + * + * (c) The GHC Team, 2001-2021 + * + * Stack snapshotting. + */ + +#include + +#include "Rts.h" +#include "rts/Messages.h" +#include "Messages.h" +#include "rts/storage/TSO.h" +#include "stg/Types.h" +#include "CloneStack.h" +#include "StablePtr.h" +#include "Threads.h" + +#if defined(DEBUG) +#include "sm/Sanity.h" +#endif + +StgStack* cloneStack(Capability* capability, const StgStack* stack){ + StgWord spOffset = stack->sp - stack->stack; + StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); + + StgStack* newStackClosure = (StgStack*) allocate(capability, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + + memcpy(newStackClosure, stack, closureSizeBytes); + + newStackClosure->sp = newStackClosure->stack + spOffset; + // The new stack is not on the mutable list; clear the dirty flag such that + // we don't claim that it is. + newStackClosure->dirty = 0; + +#if defined(DEBUG) + checkClosure((StgClosure*) newStackClosure); +#endif + + return newStackClosure; +} + +#if defined(THREADED_RTS) + +// ThreadId# in Haskell is a StgTSO* in RTS. +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + Capability *srcCapability = rts_unsafeGetMyCapability(); + + MessageCloneStack *msg; + msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); + msg->tso = tso; + msg->result = (StgMVar*)deRefStablePtr(mvar); + freeStablePtr(mvar); + SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); + // Ensure that writes constructing Message are committed before sending. + write_barrier(); + + sendMessage(srcCapability, tso->cap, (Message *)msg); +} + +void handleCloneStackMessage(MessageCloneStack *msg){ + StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); + + // Lift StackSnapshot# to StackSnapshot by applying it's constructor. + // This is necessary because performTryPutMVar() puts the closure onto the + // stack for evaluation and stacks can not be evaluated (entered). + HaskellObj result = rts_apply(msg->tso->cap, StackSnapshot_constructor_closure, (HaskellObj) newStackClosure); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, result); + + if(!putMVarWasSuccessful) { + barf("Can't put stack cloning result into MVar."); + } +} + +#else // !defined(THREADED_RTS) + +GNU_ATTRIBUTE(__noreturn__) +void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) { + barf("Sending CloneStackMessages is only available in threaded RTS!"); +} + +#endif // end !defined(THREADED_RTS) + ===================================== rts/CloneStack.h ===================================== @@ -0,0 +1,23 @@ +/* --------------------------------------------------------------------------- + * + * (c) The GHC Team, 2001-2021 + * + * Stack snapshotting. + */ + +#pragma once + +extern StgClosure DLL_IMPORT_DATA_VARNAME(base_GHCziStackziCloneStack_StackSnapshot_closure); +#define StackSnapshot_constructor_closure DLL_IMPORT_DATA_REF(base_GHCziStackziCloneStack_StackSnapshot_closure) + +StgStack* cloneStack(Capability* capability, StgStack* stack); + +#include "BeginPrivate.h" + +#if defined(THREADED_RTS) +void handleCloneStackMessage(MessageCloneStack *msg); +#endif + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); + +#include "EndPrivate.h" ===================================== rts/Disassembler.c ===================================== @@ -8,8 +8,6 @@ * $Date: 2004/09/03 15:28:19 $ * ---------------------------------------------------------------------------*/ -#if defined(DEBUG) - #include "PosixSource.h" #include "Rts.h" #include "RtsAPI.h" @@ -358,5 +356,3 @@ void disassemble( StgBCO *bco ) debugBelch("\n"); } - -#endif /* DEBUG */ ===================================== rts/Disassembler.h ===================================== @@ -8,9 +8,5 @@ #pragma once -#if defined(DEBUG) - RTS_PRIVATE int disInstr ( StgBCO *bco, int pc ); RTS_PRIVATE void disassemble( StgBCO *bco ); - -#endif ===================================== rts/Messages.c ===================================== @@ -14,6 +14,7 @@ #include "Threads.h" #include "RaiseAsync.h" #include "sm/Storage.h" +#include "CloneStack.h" /* ---------------------------------------------------------------------------- Send a message to another Capability @@ -32,7 +33,8 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg) i != &stg_MSG_BLACKHOLE_info && i != &stg_MSG_TRY_WAKEUP_info && i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked - i != &stg_WHITEHOLE_info) { + i != &stg_WHITEHOLE_info && + i != &stg_MSG_CLONE_STACK_info) { barf("sendMessage: %p", i); } } @@ -131,6 +133,10 @@ loop: #endif goto loop; } + else if(i == &stg_MSG_CLONE_STACK_info){ + MessageCloneStack *cloneStackMessage = (MessageCloneStack*) m; + handleCloneStackMessage(cloneStackMessage); + } else { barf("executeMessage: %p", i); ===================================== rts/PrimOps.cmm ===================================== @@ -2840,3 +2840,14 @@ stg_setThreadAllocationCounterzh ( I64 counter ) StgTSO_alloc_limit(CurrentTSO) = counter + TO_I64(offset); return (); } + +stg_cloneMyStackzh () { + W_ stgStack; + W_ clonedStack; + + stgStack = StgTSO_stackobj(CurrentTSO); + + ("ptr" clonedStack) = ccall cloneStack(MyCapability() "ptr", stgStack "ptr"); + + return (clonedStack); +} ===================================== rts/Printer.c ===================================== @@ -17,6 +17,7 @@ #include "sm/GCThread.h" #include "Hash.h" #include "Printer.h" +#include "rts/PrinterAPI.h" #include "RtsUtils.h" #if defined(PROFILING) @@ -25,9 +26,10 @@ #include +#include "Disassembler.h" + #if defined(DEBUG) -#include "Disassembler.h" #include "Apply.h" /* -------------------------------------------------------------------------- @@ -58,402 +60,337 @@ void printObj( StgClosure *obj ) printClosure(obj); } -STATIC_INLINE void -printStdObjHdr( const StgClosure *obj, char* tag ) +void +printMutableList(bdescr *bd) { - debugBelch("%s(",tag); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif -} + StgPtr p; -static void -printStdObjPayload( const StgClosure *obj ) -{ - StgWord i, j; - const StgInfoTable* info; + debugBelch("mutable list %p: ", bd); - info = get_itbl(obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); + for (; bd != NULL; bd = bd->link) { + for (p = bd->start; p < bd->free; p++) { + debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); + } } - debugBelch(")\n"); + debugBelch("\n"); } -static void -printThunkPayload( StgThunk *obj ) +void printTSO( StgTSO *tso ) { - StgWord i, j; - const StgInfoTable* info; - - info = get_itbl((StgClosure *)obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); - } - debugBelch(")\n"); + printStack( tso->stackobj ); } -static void -printThunkObject( StgThunk *obj, char* tag ) +void printStaticObjects( StgClosure *p ) { - printStdObjHdr( (StgClosure *)obj, tag ); - printThunkPayload( obj ); + while (p != END_OF_STATIC_OBJECT_LIST) { + p = UNTAG_STATIC_LIST_PTR(p); + printClosure(p); + + const StgInfoTable *info = get_itbl(p); + p = *STATIC_LINK(info, p); + } } -void -printClosure( const StgClosure *obj ) +void printWeakLists() { - debugBelch("%p: ", obj); - obj = UNTAG_CONST_CLOSURE(obj); - const StgInfoTable* info = get_itbl(obj); + debugBelch("======= WEAK LISTS =======\n"); - while (IS_FORWARDING_PTR(info)) { - obj = (StgClosure*)UN_FORWARDING_PTR(info); - debugBelch("(forwarding to %p) ", (void*)obj); - info = get_itbl(obj); + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + debugBelch("Capability %d:\n", cap_idx); + Capability *cap = capabilities[cap_idx]; + for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } } - switch ( info->type ) { - case INVALID_OBJECT: - barf("Invalid object"); - - case CONSTR: - case CONSTR_1_0: case CONSTR_0_1: - case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: - case CONSTR_NOCAF: - { - StgWord i, j; - const StgConInfoTable *con_info = get_con_itbl (obj); - - debugBelch("%s(", GET_CON_DESC(con_info)); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - if (i != 0) debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - if (i != 0 || j != 0) debugBelch(", "); - debugBelch("%p#", obj->payload[i+j]); - } - debugBelch(")\n"); - break; + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current weaks:\n", gen_idx); + for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); } + debugBelch("Generation %d old weaks:\n", gen_idx); + for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } + } - case FUN: - case FUN_1_0: case FUN_0_1: - case FUN_1_1: case FUN_0_2: case FUN_2_0: - case FUN_STATIC: - debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif - printStdObjPayload(obj); - break; - - case PRIM: - debugBelch("PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case MUT_PRIM: - debugBelch("MUT_PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case THUNK: - case THUNK_1_0: case THUNK_0_1: - case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: - case THUNK_STATIC: - /* ToDo: will this work for THUNK_STATIC too? */ -#if defined(PROFILING) - printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); -#else - printThunkObject((StgThunk *)obj,"THUNK"); -#endif - break; + debugBelch("=========================\n"); +} - case THUNK_SELECTOR: - printStdObjHdr(obj, "THUNK_SELECTOR"); - debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); - break; +void printLargeAndPinnedObjects() +{ + debugBelch("====== PINNED OBJECTS ======\n"); - case BCO: - disassemble( (StgBCO*)obj ); - break; + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + Capability *cap = capabilities[cap_idx]; - case AP: - { - StgAP* ap = (StgAP*)obj; - StgWord i; - debugBelch("AP("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->n_args; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Capability %d: Current pinned object block: %p\n", + cap_idx, (void*)cap->pinned_object_block); + for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { + debugBelch("%p\n", (void*)bd); } + } - case PAP: - { - StgPAP* pap = (StgPAP*)obj; - StgWord i; - debugBelch("PAP/%d(",(int)pap->arity); - printPtr((StgPtr)pap->fun); - for (i = 0; i < pap->n_args; ++i) { - debugBelch(", "); - printPtr((StgPtr)pap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("====== LARGE OBJECTS =======\n"); + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current large objects:\n", gen_idx); + for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } - case AP_STACK: - { - StgAP_STACK* ap = (StgAP_STACK*)obj; - StgWord i; - debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->size; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Generation %d scavenged large objects:\n", gen_idx); + for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } + } - case IND: - debugBelch("IND("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; - - case IND_STATIC: - debugBelch("IND_STATIC("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; + debugBelch("============================\n"); +} - case BLACKHOLE: - debugBelch("BLACKHOLE("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; +/* -------------------------------------------------------------------------- + * Address printing code + * + * Uses symbol table in (unstripped executable) + * ------------------------------------------------------------------------*/ - /* Cannot happen -- use default case. - case RET_BCO: - case RET_SMALL: - case RET_BIG: - case RET_FUN: - */ +/* -------------------------------------------------------------------------- + * Simple lookup table + * address -> function name + * ------------------------------------------------------------------------*/ - case UPDATE_FRAME: - { - StgUpdateFrame* u = (StgUpdateFrame*)obj; - debugBelch("%s(", info_update_frame(obj)); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->updatee); - debugBelch(")\n"); - break; - } +static HashTable * add_to_fname_table = NULL; - case CATCH_FRAME: - { - StgCatchFrame* u = (StgCatchFrame*)obj; - debugBelch("CATCH_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->handler); - debugBelch(")\n"); - break; - } - - case UNDERFLOW_FRAME: - { - StgUnderflowFrame* u = (StgUnderflowFrame*)obj; - debugBelch("UNDERFLOW_FRAME("); - printPtr((StgPtr)u->next_chunk); - debugBelch(")\n"); - break; - } - - case STOP_FRAME: - { - StgStopFrame* u = (StgStopFrame*)obj; - debugBelch("STOP_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(")\n"); - break; - } - - case ARR_WORDS: - { - StgWord i; - debugBelch("ARR_WORDS(\""); - for (i=0; ipayload[i]); - debugBelch("\")\n"); - break; - } - - case MUT_ARR_PTRS_CLEAN: - debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; - - case MUT_ARR_PTRS_DIRTY: - debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; +const char *lookupGHCName( void *addr ) +{ + if (add_to_fname_table == NULL) + return NULL; - case MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; + return lookupHashTable(add_to_fname_table, (StgWord)addr); +} - case SMALL_MUT_ARR_PTRS_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* -------------------------------------------------------------------------- + * Symbol table loading + * ------------------------------------------------------------------------*/ - case SMALL_MUT_ARR_PTRS_DIRTY: - debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Causing linking trouble on Win32 plats, so I'm + disabling this for now. +*/ +#if defined(USING_LIBBFD) +# define PACKAGE 1 +# define PACKAGE_VERSION 1 +/* Those PACKAGE_* defines are workarounds for bfd: + * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 + * ghc's build system filter PACKAGE_* values out specifically to avoid clashes + * with user's autoconf-based Cabal packages. + * It's a shame checks for unrelated fields instead of actually used + * macros. + */ +# include - case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Fairly ad-hoc piece of code that seems to filter out a lot of + * rubbish like the obj-splitting symbols + */ - case MVAR_CLEAN: - case MVAR_DIRTY: - { - StgMVar* mv = (StgMVar*)obj; +static bool isReal( flagword flags STG_UNUSED, const char *name ) +{ +#if 0 + /* ToDo: make this work on BFD */ + int tp = type & N_TYPE; + if (tp == N_TEXT || tp == N_DATA) { + return (name[0] == '_' && name[1] != '_'); + } else { + return false; + } +#else + if (*name == '\0' || + (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || + (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { + return false; + } + return true; +#endif +} - debugBelch("MVAR(head="); - if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->head); - } +extern void DEBUG_LoadSymbols( const char *name ) +{ + bfd* abfd; + char **matching; - debugBelch(", tail="); - if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->tail); - } + bfd_init(); + abfd = bfd_openr(name, "default"); + if (abfd == NULL) { + barf("can't open executable %s to get symbol table", name); + } + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { + barf("mismatch"); + } - debugBelch(", value="); - if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->value); - } - debugBelch(")\n"); + { + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long num_real_syms = 0; + long i; - break; - } + storage_needed = bfd_get_symtab_upper_bound (abfd); - case TVAR: - { - StgTVar* tv = (StgTVar*)obj; - debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); - break; + if (storage_needed < 0) { + barf("can't read symbol table"); } + symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - case MUT_VAR_CLEAN: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); - break; - } + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - case MUT_VAR_DIRTY: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); - break; + if (number_of_symbols < 0) { + barf("can't canonicalise symbol table"); } - case WEAK: - debugBelch("WEAK("); - debugBelch("key=%p value=%p finalizer=%p", - (StgPtr)(((StgWeak*)obj)->key), - (StgPtr)(((StgWeak*)obj)->value), - (StgPtr)(((StgWeak*)obj)->finalizer)); - debugBelch(")\n"); - /* ToDo: chase 'link' ? */ - break; - - case TSO: - debugBelch("TSO("); - debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); - debugBelch(")\n"); - break; - - case STACK: - debugBelch("STACK\n"); - break; - -#if 0 - /* Symptomatic of a problem elsewhere, have it fall-through & fail */ - case EVACUATED: - debugBelch("EVACUATED("); - printClosure((StgEvacuated*)obj->evacuee); - debugBelch(")\n"); - break; -#endif + if (add_to_fname_table == NULL) + add_to_fname_table = allocHashTable(); - case COMPACT_NFDATA: - debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", - (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); - break; + for( i = 0; i != number_of_symbols; ++i ) { + symbol_info info; + bfd_get_symbol_info(abfd,symbol_table[i],&info); + if (isReal(info.type, info.name)) { + insertHashTable(add_to_fname_table, + info.value, (void*)info.name); + num_real_syms += 1; + } + } - case TREC_CHUNK: - debugBelch("TREC_CHUNK\n"); - break; + IF_DEBUG(interpreter, + debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", + number_of_symbols, num_real_syms) + ); - default: - //barf("printClosure %d",get_itbl(obj)->type); - debugBelch("*** printClosure: unknown type %d ****\n", - (int)get_itbl(obj)->type ); - barf("printClosure %d",get_itbl(obj)->type); - return; + stgFree(symbol_table); } } -void -printMutableList(bdescr *bd) +#else /* USING_LIBBFD */ + +extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { - StgPtr p; + /* nothing, yet */ +} - debugBelch("mutable list %p: ", bd); +#endif /* USING_LIBBFD */ - for (; bd != NULL; bd = bd->link) { - for (p = bd->start; p < bd->free; p++) { - debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); - } - } - debugBelch("\n"); -} +void findPtr(P_ p, int); /* keep gcc -Wall happy */ -// If you know you have an UPDATE_FRAME, but want to know exactly which. -const char *info_update_frame(const StgClosure *closure) +int searched = 0; + +static int +findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) { - // Note: We intentionally don't take the info table pointer as - // an argument. As it will be confusing whether one should pass - // it pointing to the code or struct members when compiling with - // TABLES_NEXT_TO_CODE. + StgPtr q, r, end; + for (; bd; bd = bd->link) { + searched++; + for (q = bd->start; q < bd->free; q++) { + if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { + if (i < arr_size) { + for (r = bd->start; r < bd->free; r = end) { + // skip over zeroed-out slop + while (*r == 0) r++; + if (!LOOKS_LIKE_CLOSURE_PTR(r)) { + debugBelch("%p found at %p, no closure at %p\n", + p, q, r); + break; + } + end = r + closure_sizeW((StgClosure*)r); + if (q < end) { + debugBelch("%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + break; + } + } + if (r >= bd->free) { + debugBelch("%p found at %p, closure?", p, q); + } + } else { + return i; + } + } + } + } + return i; +} + +void +findPtr(P_ p, int follow) +{ + uint32_t g, n; + bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; + searched = 0; + +#if 0 + // We can't search the nursery, because we don't know which blocks contain + // valid data, because the bd->free pointers in the nursery are only reset + // just before a block is used. + for (n = 0; n < n_capabilities; n++) { + bd = nurseries[i].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + } +#endif + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + bd = generations[g].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + bd = generations[g].large_objects; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + for (n = 0; n < n_capabilities; n++) { + i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, + arr, arr_size, i); + i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, + arr, arr_size, i); + } + if (i >= arr_size) return; + } + if (follow && i == 1) { + debugBelch("-->\n"); + findPtr(arr[0], 1); + } +} + +const char *what_next_strs[] = { + [0] = "(unknown)", + [ThreadRunGHC] = "ThreadRunGHC", + [ThreadInterpret] = "ThreadInterpret", + [ThreadKilled] = "ThreadKilled", + [ThreadComplete] = "ThreadComplete" +}; + +#else /* DEBUG */ +void printPtr( StgPtr p ) +{ + debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); +} + +void printObj( StgClosure *obj ) +{ + debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); +} + + +#endif /* DEBUG */ + +// If you know you have an UPDATE_FRAME, but want to know exactly which. +const char *info_update_frame(const StgClosure *closure) +{ + // Note: We intentionally don't take the info table pointer as + // an argument. As it will be confusing whether one should pass + // it pointing to the code or struct members when compiling with + // TABLES_NEXT_TO_CODE. const StgInfoTable *info = closure->header.info; if (info == &stg_upd_frame_info) { return "NORMAL_UPDATE_FRAME"; @@ -467,501 +404,567 @@ const char *info_update_frame(const StgClosure *closure) } static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, - uint32_t size ) +printThunkPayload( StgThunk *obj ) { - uint32_t i; + StgWord i, j; + const StgInfoTable* info; - for(i = 0; i < size; i++, bitmap >>= 1 ) { - debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } + info = get_itbl((StgClosure *)obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); +} + +STATIC_INLINE void +printStdObjHdr( const StgClosure *obj, char* tag ) +{ + debugBelch("%s(",tag); + printPtr((StgPtr)obj->header.info); +#if defined(PROFILING) + debugBelch(", %s", obj->header.prof.ccs->cc->label); +#endif } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, - uint32_t size ) +printThunkObject( StgThunk *obj, char* tag ) { - StgWord bmp; - uint32_t i, j; + printStdObjHdr( (StgClosure *)obj, tag ); + printThunkPayload( obj ); +} - i = 0; - for (bmp=0; i < size; bmp++) { - StgWord bitmap = large_bitmap->bitmap[bmp]; - j = 0; - for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { - debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } - } +static void +printStdObjPayload( const StgClosure *obj ) +{ + StgWord i, j; + const StgInfoTable* info; + + info = get_itbl(obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); } void -printStackChunk( StgPtr sp, StgPtr spBottom ) +printClosure( const StgClosure *obj ) { - const StgInfoTable *info; + debugBelch("%p: ", obj); + obj = UNTAG_CONST_CLOSURE(obj); + const StgInfoTable* info = get_itbl(obj); - ASSERT(sp <= spBottom); - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { + while (IS_FORWARDING_PTR(info)) { + obj = (StgClosure*)UN_FORWARDING_PTR(info); + debugBelch("(forwarding to %p) ", (void*)obj); + info = get_itbl(obj); + } - info = get_itbl((StgClosure *)sp); + switch ( info->type ) { + case INVALID_OBJECT: + barf("Invalid object"); - switch (info->type) { + case CONSTR: + case CONSTR_1_0: case CONSTR_0_1: + case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: + case CONSTR_NOCAF: + { + StgWord i, j; + const StgConInfoTable *con_info = get_con_itbl (obj); - case UPDATE_FRAME: - case CATCH_FRAME: - case UNDERFLOW_FRAME: - case STOP_FRAME: - printClosure((StgClosure*)sp); - continue; + debugBelch("%s(", GET_CON_DESC(con_info)); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + if (i != 0) debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + if (i != 0 || j != 0) debugBelch(", "); + debugBelch("%p#", obj->payload[i+j]); + } + debugBelch(")\n"); + break; + } - case RET_SMALL: { - StgWord c = *sp; - if (c == (StgWord)&stg_ctoi_R1p_info) { - debugBelch("tstg_ctoi_ret_R1p_info\n" ); - } else if (c == (StgWord)&stg_ctoi_R1n_info) { - debugBelch("stg_ctoi_ret_R1n_info\n" ); - } else if (c == (StgWord)&stg_ctoi_F1_info) { - debugBelch("stg_ctoi_ret_F1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_D1_info) { - debugBelch("stg_ctoi_ret_D1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_V_info) { - debugBelch("stg_ctoi_ret_V_info\n" ); - } else if (c == (StgWord)&stg_ap_v_info) { - debugBelch("stg_ap_v_info\n" ); - } else if (c == (StgWord)&stg_ap_f_info) { - debugBelch("stg_ap_f_info\n" ); - } else if (c == (StgWord)&stg_ap_d_info) { - debugBelch("stg_ap_d_info\n" ); - } else if (c == (StgWord)&stg_ap_l_info) { - debugBelch("stg_ap_l_info\n" ); - } else if (c == (StgWord)&stg_ap_n_info) { - debugBelch("stg_ap_n_info\n" ); - } else if (c == (StgWord)&stg_ap_p_info) { - debugBelch("stg_ap_p_info\n" ); - } else if (c == (StgWord)&stg_ap_pp_info) { - debugBelch("stg_ap_pp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppp_info) { - debugBelch("stg_ap_ppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppp_info) { - debugBelch("stg_ap_pppp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppppp_info) { - debugBelch("stg_ap_ppppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppppp_info) { - debugBelch("stg_ap_pppppp_info\n" ); - } else if (c == (StgWord)&stg_ret_v_info) { - debugBelch("stg_ret_v_info\n" ); - } else if (c == (StgWord)&stg_ret_p_info) { - debugBelch("stg_ret_p_info\n" ); - } else if (c == (StgWord)&stg_ret_n_info) { - debugBelch("stg_ret_n_info\n" ); - } else if (c == (StgWord)&stg_ret_f_info) { - debugBelch("stg_ret_f_info\n" ); - } else if (c == (StgWord)&stg_ret_d_info) { - debugBelch("stg_ret_d_info\n" ); - } else if (c == (StgWord)&stg_ret_l_info) { - debugBelch("stg_ret_l_info\n" ); + case FUN: + case FUN_1_0: case FUN_0_1: + case FUN_1_1: case FUN_0_2: case FUN_2_0: + case FUN_STATIC: + debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); + printPtr((StgPtr)obj->header.info); #if defined(PROFILING) - } else if (c == (StgWord)&stg_restore_cccs_info) { - debugBelch("stg_restore_cccs_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; - } else if (c == (StgWord)&stg_restore_cccs_eval_info) { - debugBelch("stg_restore_cccs_eval_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; + debugBelch(", %s", obj->header.prof.ccs->cc->label); #endif - } else { - debugBelch("RET_SMALL (%p)\n", info); - } - StgWord bitmap = info->layout.bitmap; - printSmallBitmap(spBottom, sp+1, - BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); - continue; - } + printStdObjPayload(obj); + break; - case RET_BCO: { - StgBCO *bco; + case PRIM: + debugBelch("PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - bco = ((StgBCO *)sp[1]); + case MUT_PRIM: + debugBelch("MUT_PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - debugBelch("RET_BCO (%p)\n", sp); - printLargeBitmap(spBottom, sp+2, - BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); - continue; - } + case THUNK: + case THUNK_1_0: case THUNK_0_1: + case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: + case THUNK_STATIC: + /* ToDo: will this work for THUNK_STATIC too? */ +#if defined(PROFILING) + printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); +#else + printThunkObject((StgThunk *)obj,"THUNK"); +#endif + break; - case RET_BIG: - debugBelch("RET_BIG (%p)\n", sp); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); - printLargeBitmap(spBottom, - (StgPtr)((StgClosure *) sp)->payload, - bitmap, - bitmap->size); - continue; - case RET_FUN: + case THUNK_SELECTOR: + printStdObjHdr(obj, "THUNK_SELECTOR"); + debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); + break; + + case BCO: + disassemble( (StgBCO*)obj ); + break; + + case AP: { - const StgFunInfoTable *fun_info; - StgRetFun *ret_fun; + StgAP* ap = (StgAP*)obj; + StgWord i; + debugBelch("AP("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->n_args; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; + } - ret_fun = (StgRetFun *)sp; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); - debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); - switch (fun_info->f.fun_type) { - case ARG_GEN: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(fun_info->f.b.bitmap), - BITMAP_SIZE(fun_info->f.b.bitmap)); - break; - case ARG_GEN_BIG: - printLargeBitmap(spBottom, sp+2, - GET_FUN_LARGE_BITMAP(fun_info), - GET_FUN_LARGE_BITMAP(fun_info)->size); - break; - default: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), - BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); - break; + case PAP: + { + StgPAP* pap = (StgPAP*)obj; + StgWord i; + debugBelch("PAP/%d(",(int)pap->arity); + printPtr((StgPtr)pap->fun); + for (i = 0; i < pap->n_args; ++i) { + debugBelch(", "); + printPtr((StgPtr)pap->payload[i]); } - continue; + debugBelch(")\n"); + break; } - default: - debugBelch("unknown object %d\n", (int)info->type); - barf("printStackChunk"); + case AP_STACK: + { + StgAP_STACK* ap = (StgAP_STACK*)obj; + StgWord i; + debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->size; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; } - } -} -static void printStack( StgStack *stack ) -{ - printStackChunk( stack->sp, stack->stack + stack->stack_size ); -} + case IND: + debugBelch("IND("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printTSO( StgTSO *tso ) -{ - printStack( tso->stackobj ); -} + case IND_STATIC: + debugBelch("IND_STATIC("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printStaticObjects( StgClosure *p ) -{ - while (p != END_OF_STATIC_OBJECT_LIST) { - p = UNTAG_STATIC_LIST_PTR(p); - printClosure(p); + case BLACKHOLE: + debugBelch("BLACKHOLE("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; - const StgInfoTable *info = get_itbl(p); - p = *STATIC_LINK(info, p); - } -} + /* Cannot happen -- use default case. + case RET_BCO: + case RET_SMALL: + case RET_BIG: + case RET_FUN: + */ -void printWeakLists() -{ - debugBelch("======= WEAK LISTS =======\n"); + case UPDATE_FRAME: + { + StgUpdateFrame* u = (StgUpdateFrame*)obj; + debugBelch("%s(", info_update_frame(obj)); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->updatee); + debugBelch(")\n"); + break; + } - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - debugBelch("Capability %d:\n", cap_idx); - Capability *cap = capabilities[cap_idx]; - for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case CATCH_FRAME: + { + StgCatchFrame* u = (StgCatchFrame*)obj; + debugBelch("CATCH_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->handler); + debugBelch(")\n"); + break; } - } - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current weaks:\n", gen_idx); - for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case UNDERFLOW_FRAME: + { + StgUnderflowFrame* u = (StgUnderflowFrame*)obj; + debugBelch("UNDERFLOW_FRAME("); + printPtr((StgPtr)u->next_chunk); + debugBelch(")\n"); + break; } - debugBelch("Generation %d old weaks:\n", gen_idx); - for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + + case STOP_FRAME: + { + StgStopFrame* u = (StgStopFrame*)obj; + debugBelch("STOP_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(")\n"); + break; } - } - debugBelch("=========================\n"); -} + case ARR_WORDS: + { + StgWord i; + debugBelch("ARR_WORDS(\""); + for (i=0; ipayload[i]); + debugBelch("\")\n"); + break; + } -void printLargeAndPinnedObjects() -{ - debugBelch("====== PINNED OBJECTS ======\n"); + case MUT_ARR_PTRS_CLEAN: + debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - Capability *cap = capabilities[cap_idx]; + case MUT_ARR_PTRS_DIRTY: + debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Capability %d: Current pinned object block: %p\n", - cap_idx, (void*)cap->pinned_object_block); - for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { - debugBelch("%p\n", (void*)bd); - } - } + case MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("====== LARGE OBJECTS =======\n"); - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current large objects:\n", gen_idx); - for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } + case SMALL_MUT_ARR_PTRS_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Generation %d scavenged large objects:\n", gen_idx); - for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } - } + case SMALL_MUT_ARR_PTRS_DIRTY: + debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("============================\n"); -} + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; -/* -------------------------------------------------------------------------- - * Address printing code - * - * Uses symbol table in (unstripped executable) - * ------------------------------------------------------------------------*/ + case MVAR_CLEAN: + case MVAR_DIRTY: + { + StgMVar* mv = (StgMVar*)obj; -/* -------------------------------------------------------------------------- - * Simple lookup table - * address -> function name - * ------------------------------------------------------------------------*/ + debugBelch("MVAR(head="); + if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->head); + } -static HashTable * add_to_fname_table = NULL; + debugBelch(", tail="); + if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->tail); + } -const char *lookupGHCName( void *addr ) -{ - if (add_to_fname_table == NULL) - return NULL; + debugBelch(", value="); + if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->value); + } + debugBelch(")\n"); - return lookupHashTable(add_to_fname_table, (StgWord)addr); -} + break; + } -/* -------------------------------------------------------------------------- - * Symbol table loading - * ------------------------------------------------------------------------*/ + case TVAR: + { + StgTVar* tv = (StgTVar*)obj; + debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); + break; + } -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame checks for unrelated fields instead of actually used - * macros. - */ -# include + case MUT_VAR_CLEAN: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); + break; + } -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ + case MUT_VAR_DIRTY: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); + break; + } -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} + case WEAK: + debugBelch("WEAK("); + debugBelch("key=%p value=%p finalizer=%p", + (StgPtr)(((StgWeak*)obj)->key), + (StgPtr)(((StgWeak*)obj)->value), + (StgPtr)(((StgWeak*)obj)->finalizer)); + debugBelch(")\n"); + /* ToDo: chase 'link' ? */ + break; -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; + case TSO: + debugBelch("TSO("); + debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); + debugBelch(")\n"); + break; - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } + case STACK: + debugBelch("STACK\n"); + break; - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; +#if 0 + /* Symptomatic of a problem elsewhere, have it fall-through & fail */ + case EVACUATED: + debugBelch("EVACUATED("); + printClosure((StgEvacuated*)obj->evacuee); + debugBelch(")\n"); + break; +#endif - storage_needed = bfd_get_symtab_upper_bound (abfd); + case COMPACT_NFDATA: + debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", + (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); + break; - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); + case TREC_CHUNK: + debugBelch("TREC_CHUNK\n"); + break; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + default: + //barf("printClosure %d",get_itbl(obj)->type); + debugBelch("*** printClosure: unknown type %d ****\n", + (int)get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); + return; + } +} - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); +static void +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) +{ + uint32_t i; + + for(i = 0; i < size; i++, bitmap >>= 1 ) { + debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } + } +} - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); +static void +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) +{ + StgWord bmp; + uint32_t i, j; - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; + i = 0; + for (bmp=0; i < size; bmp++) { + StgWord bitmap = large_bitmap->bitmap[bmp]; + j = 0; + for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { + debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); } } -#else /* USING_LIBBFD */ - -extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) +void +printStackChunk( StgPtr sp, StgPtr spBottom ) { - /* nothing, yet */ -} + const StgInfoTable *info; -#endif /* USING_LIBBFD */ + ASSERT(sp <= spBottom); + for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { -void findPtr(P_ p, int); /* keep gcc -Wall happy */ + info = get_itbl((StgClosure *)sp); -int searched = 0; + switch (info->type) { -static int -findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) -{ - StgPtr q, r, end; - for (; bd; bd = bd->link) { - searched++; - for (q = bd->start; q < bd->free; q++) { - if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { - if (i < arr_size) { - for (r = bd->start; r < bd->free; r = end) { - // skip over zeroed-out slop - while (*r == 0) r++; - if (!LOOKS_LIKE_CLOSURE_PTR(r)) { - debugBelch("%p found at %p, no closure at %p\n", - p, q, r); - break; - } - end = r + closure_sizeW((StgClosure*)r); - if (q < end) { - debugBelch("%p = ", r); - printClosure((StgClosure *)r); - arr[i++] = r; - break; - } - } - if (r >= bd->free) { - debugBelch("%p found at %p, closure?", p, q); - } - } else { - return i; - } + case UPDATE_FRAME: + case CATCH_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + printClosure((StgClosure*)sp); + continue; + + case RET_SMALL: { + StgWord c = *sp; + if (c == (StgWord)&stg_ctoi_R1p_info) { + debugBelch("tstg_ctoi_ret_R1p_info\n" ); + } else if (c == (StgWord)&stg_ctoi_R1n_info) { + debugBelch("stg_ctoi_ret_R1n_info\n" ); + } else if (c == (StgWord)&stg_ctoi_F1_info) { + debugBelch("stg_ctoi_ret_F1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_D1_info) { + debugBelch("stg_ctoi_ret_D1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_V_info) { + debugBelch("stg_ctoi_ret_V_info\n" ); + } else if (c == (StgWord)&stg_ap_v_info) { + debugBelch("stg_ap_v_info\n" ); + } else if (c == (StgWord)&stg_ap_f_info) { + debugBelch("stg_ap_f_info\n" ); + } else if (c == (StgWord)&stg_ap_d_info) { + debugBelch("stg_ap_d_info\n" ); + } else if (c == (StgWord)&stg_ap_l_info) { + debugBelch("stg_ap_l_info\n" ); + } else if (c == (StgWord)&stg_ap_n_info) { + debugBelch("stg_ap_n_info\n" ); + } else if (c == (StgWord)&stg_ap_p_info) { + debugBelch("stg_ap_p_info\n" ); + } else if (c == (StgWord)&stg_ap_pp_info) { + debugBelch("stg_ap_pp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppp_info) { + debugBelch("stg_ap_ppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppp_info) { + debugBelch("stg_ap_pppp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppppp_info) { + debugBelch("stg_ap_ppppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppppp_info) { + debugBelch("stg_ap_pppppp_info\n" ); + } else if (c == (StgWord)&stg_ret_v_info) { + debugBelch("stg_ret_v_info\n" ); + } else if (c == (StgWord)&stg_ret_p_info) { + debugBelch("stg_ret_p_info\n" ); + } else if (c == (StgWord)&stg_ret_n_info) { + debugBelch("stg_ret_n_info\n" ); + } else if (c == (StgWord)&stg_ret_f_info) { + debugBelch("stg_ret_f_info\n" ); + } else if (c == (StgWord)&stg_ret_d_info) { + debugBelch("stg_ret_d_info\n" ); + } else if (c == (StgWord)&stg_ret_l_info) { + debugBelch("stg_ret_l_info\n" ); +#if defined(PROFILING) + } else if (c == (StgWord)&stg_restore_cccs_info) { + debugBelch("stg_restore_cccs_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; + } else if (c == (StgWord)&stg_restore_cccs_eval_info) { + debugBelch("stg_restore_cccs_eval_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; +#endif + } else { + debugBelch("RET_SMALL (%p)\n", info); } + StgWord bitmap = info->layout.bitmap; + printSmallBitmap(spBottom, sp+1, + BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); + continue; } - } - return i; -} -void -findPtr(P_ p, int follow) -{ - uint32_t g, n; - bdescr *bd; - const int arr_size = 1024; - StgPtr arr[arr_size]; - int i = 0; - searched = 0; + case RET_BCO: { + StgBCO *bco; -#if 0 - // We can't search the nursery, because we don't know which blocks contain - // valid data, because the bd->free pointers in the nursery are only reset - // just before a block is used. - for (n = 0; n < n_capabilities; n++) { - bd = nurseries[i].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - } -#endif + bco = ((StgBCO *)sp[1]); - for (g = 0; g < RtsFlags.GcFlags.generations; g++) { - bd = generations[g].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - bd = generations[g].large_objects; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - for (n = 0; n < n_capabilities; n++) { - i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, - arr, arr_size, i); - i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, - arr, arr_size, i); - } - if (i >= arr_size) return; - } - if (follow && i == 1) { - debugBelch("-->\n"); - findPtr(arr[0], 1); - } -} + debugBelch("RET_BCO (%p)\n", sp); + printLargeBitmap(spBottom, sp+2, + BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); + continue; + } -const char *what_next_strs[] = { - [0] = "(unknown)", - [ThreadRunGHC] = "ThreadRunGHC", - [ThreadInterpret] = "ThreadInterpret", - [ThreadKilled] = "ThreadKilled", - [ThreadComplete] = "ThreadComplete" -}; + case RET_BIG: + debugBelch("RET_BIG (%p)\n", sp); + StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + printLargeBitmap(spBottom, + (StgPtr)((StgClosure *) sp)->payload, + bitmap, + bitmap->size); + continue; + case RET_FUN: + { + const StgFunInfoTable *fun_info; + StgRetFun *ret_fun; -#else /* DEBUG */ -void printPtr( StgPtr p ) -{ - debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); + ret_fun = (StgRetFun *)sp; + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); + switch (fun_info->f.fun_type) { + case ARG_GEN: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(fun_info->f.b.bitmap), + BITMAP_SIZE(fun_info->f.b.bitmap)); + break; + case ARG_GEN_BIG: + printLargeBitmap(spBottom, sp+2, + GET_FUN_LARGE_BITMAP(fun_info), + GET_FUN_LARGE_BITMAP(fun_info)->size); + break; + default: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), + BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + break; + } + continue; + } + + default: + debugBelch("unknown object %d\n", (int)info->type); + barf("printStackChunk"); + } + } } -void printObj( StgClosure *obj ) +void printStack( StgStack *stack ) { - debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); + printStackChunk( stack->sp, stack->stack + stack->stack_size ); } -#endif /* DEBUG */ - /* ----------------------------------------------------------------------------- Closure types ===================================== rts/Printer.h ===================================== @@ -20,9 +20,10 @@ const char * info_type ( const StgClosure *closure ); const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); -#if defined(DEBUG) extern void printClosure ( const StgClosure *obj ); extern void printStackChunk ( StgPtr sp, StgPtr spLim ); + +#if defined(DEBUG) extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); extern void printStaticObjects ( StgClosure *obj ); ===================================== rts/RtsSymbols.c ===================================== @@ -12,6 +12,8 @@ #include "Rts.h" #include "TopHandler.h" #include "HsFFI.h" +#include "CloneStack.h" +#include "rts/PrinterAPI.h" #include "sm/Storage.h" #include "sm/NonMovingMark.h" @@ -979,6 +981,7 @@ SymI_HasProto(stg_traceBinaryEventzh) \ SymI_HasProto(stg_getThreadAllocationCounterzh) \ SymI_HasProto(stg_setThreadAllocationCounterzh) \ + SymI_HasProto(stg_cloneMyStackzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ @@ -998,6 +1001,8 @@ SymI_HasProto(cas) \ SymI_HasProto(_assertFail) \ SymI_HasProto(keepCAFs) \ + SymI_HasProto(sendCloneStackMessage) \ + SymI_HasProto(printStack) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/StgMiscClosures.cmm ===================================== @@ -573,6 +573,9 @@ INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") { foreign "C" barf("MSG_NULL object (%p) entered!", R1) never returns; } +INFO_TABLE_CONSTR(stg_MSG_CLONE_STACK,3,0,0,PRIM,"MSG_CLONE_STACK","MSG_CLONE_STACK") +{ foreign "C" barf("stg_MSG_CLONE_STACK object (%p) entered!", R1) never returns; } + /* ---------------------------------------------------------------------------- END_TSO_QUEUE ===================================== rts/package.conf.in ===================================== @@ -194,6 +194,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,_findPtr" #endif + , "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" #else "-Wl,-u,base_GHCziTopHandler_runIO_closure" , "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" @@ -308,6 +309,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,findPtr" #endif + , "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" #endif /* Pick up static libraries in preference over dynamic if in earlier search ===================================== rts/rts.cabal.in ===================================== @@ -286,6 +286,7 @@ library "-Wl,-u,_hs_atomicwrite8" "-Wl,-u,_hs_atomicwrite16" "-Wl,-u,_hs_atomicwrite32" + "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -367,6 +368,7 @@ library "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" + "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -410,6 +412,7 @@ library Arena.c Capability.c CheckUnload.c + CloneStack.c ClosureFlags.c Disassembler.c FileLock.c ===================================== testsuite/tests/rts/all.T ===================================== @@ -418,3 +418,7 @@ test('T17088', compile_and_run, ['-rtsopts -O2']) test('T15427', normal, compile_and_run, ['']) + +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c']) + +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack +import Foreign +import Foreign.C.Types (CUInt) + +foreign import ccall "expectClosureTypes" expectClosureTypes:: StackSnapshot# -> Ptr CUInt -> Int -> IO () + +main :: IO () +main = do + stackSnapshot <- cloneMyStack + + let (StackSnapshot stack) = stackSnapshot + let expectedClosureTypes = [34 -- CATCH_FRAME + ,36 -- STOP_FRAME + ] + withArray expectedClosureTypes (\ptr -> expectClosureTypes stack ptr (length expectedClosureTypes)) ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -0,0 +1,53 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "rts/Messages.h" + + +void expectStacksToBeEqual(StgStack *clonedStack, StgTSO *tso) { + StgStack *liveStack = tso->stackobj; + + if(liveStack->header.info != clonedStack->header.info){ + barf("info table pointer not equal! Expected same pointer address, but got %p and %p", liveStack->header.info, clonedStack->header.info); + } + + StgInfoTable *info = INFO_PTR_TO_STRUCT(liveStack->header.info); + + if (info->type != STACK) { + barf("Expected a closure of type STACK!"); + } + + if(liveStack->stack_size != clonedStack->stack_size){ + barf("Expected same stack_size!"); + } + + if(liveStack->dirty != clonedStack->dirty){ + barf("Expected same dirty flags!"); + } + + if(liveStack->marking != clonedStack->marking){ + barf("Expected same marking flags!"); + } + + for(StgWord i = liveStack->stack_size - 1; (liveStack->stack + i) >= liveStack->sp; i--){ + if(liveStack->stack[i] != clonedStack->stack[i]){ + barf("Expected stack word %lu to be equal on both stacks.", i); + } + } +} + +void expectClosureTypes(StgStack *stack, unsigned int types[], size_t typesSize){ + StgPtr sp = stack->sp; + StgPtr spBottom = stack->stack + stack->stack_size; + + for (StgWord i = 0; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp), i++) { + const StgInfoTable *info = get_itbl((StgClosure *)sp); + + if(i >= typesSize) { + barf("Stack size exceeds expectation!"); + } + + if(info->type != types[i]) { + barf("Wrong closure type on stack! Expected %u but got %u", types[i], info->type); + } + } +} ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -0,0 +1,46 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#, ThreadId#) +import GHC.Conc.Sync (ThreadId(..)) +import GHC.Stack.CloneStack +import Control.Concurrent +import GHC.Conc + +foreign import ccall "expectStacksToBeEqual" expectStacksToBeEqual:: StackSnapshot# -> ThreadId# -> IO () + +main :: IO () +main = do + mVarToBeBlockedOn <- newEmptyMVar + threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + + waitUntilBlocked threadId + + stackSnapshot <- cloneThreadStack threadId + + let (StackSnapshot stack) = stackSnapshot + let (ThreadId tid#) = threadId + expectStacksToBeEqual stack tid# + +immediatelyBlocking :: MVar Int -> IO () +immediatelyBlocking mVarToBeBlockedOn = do + takeMVar mVarToBeBlockedOn + return () + +waitUntilBlocked :: ThreadId -> IO () +waitUntilBlocked tid = do + blocked <- isBlocked tid + if blocked then + return () + else + do + threadDelay 100000 + waitUntilBlocked tid + +isBlocked:: ThreadId -> IO Bool +isBlocked = fmap isThreadStatusBlocked . threadStatus + +isThreadStatusBlocked :: ThreadStatus -> Bool +isThreadStatusBlocked (ThreadBlocked _) = True +isThreadStatusBlocked _ = False ===================================== utils/genprimopcode/Main.hs ===================================== @@ -878,6 +878,7 @@ ppType (TyApp (TyCon "ThreadId#") []) = "threadIdPrimTy" ppType (TyApp (TyCon "ForeignObj#") []) = "foreignObjPrimTy" ppType (TyApp (TyCon "BCO") []) = "bcoPrimTy" ppType (TyApp (TyCon "Compact#") []) = "compactPrimTy" +ppType (TyApp (TyCon "StackSnapshot#") []) = "stackSnapshotPrimTy" ppType (TyApp (TyCon "()") []) = "unitTy" -- unitTy is GHC.Builtin.Types's name for () ppType (TyVar "a") = "alphaTy" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e88f5097f60b24330d4397afcb5aa5d996fbb0a...276e19f7809f7ece2db516d990347555a3436f25 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5e88f5097f60b24330d4397afcb5aa5d996fbb0a...276e19f7809f7ece2db516d990347555a3436f25 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 19:04:46 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 15:04:46 -0400 Subject: [Git][ghc/ghc][wip/stack_cloning] 3 commits: Introduce snapshotting of thread's own stack Message-ID: <5f9db54e239c6_7853fb642d08cec1410a8@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/stack_cloning at Glasgow Haskell Compiler / GHC Commits: 36e3225f by Sven Tennie at 2020-10-31T15:02:37-04:00 Introduce snapshotting of thread's own stack Introduce `StackSnapshot#` type and the `cloneMyStack#` primop, allowing the user to reify the state of the calling thread's stack for later inspection. The stack snapshot is offline/cold, i.e. it isn't evaluated any further. For technical details, please see note [Stack Cloning]. - - - - - e54314f2 by Sven Tennie at 2020-10-31T15:02:49-04:00 Introduce cloning of other threads' stacks Introduce `cloneThreadStack` function, allowing threads to request snapshots of other threads' stacks. For technical details, please see note [Stack Cloning]. - - - - - 78c2c2f8 by Sven Tennie at 2020-10-31T15:02:53-04:00 Introduce printing support for StackSnapshot#'s This refactors the RTS's existing Printer module to allow printing of StackSnapshot#'s. - - - - - 26 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/StgToCmm/Prim.hs - + includes/rts/PrinterAPI.h - includes/rts/storage/Closures.h - includes/stg/MiscClosures.h - + libraries/base/GHC/Stack/CloneStack.hs - libraries/base/base.cabal - + rts/CloneStack.c - + rts/CloneStack.h - rts/Disassembler.c - rts/Disassembler.h - rts/Messages.c - rts/PrimOps.cmm - rts/Printer.c - rts/Printer.h - rts/RtsSymbols.c - rts/StgMiscClosures.cmm - rts/package.conf.in - rts/rts.cabal.in - testsuite/tests/rts/all.T - + testsuite/tests/rts/cloneMyStack.hs - + testsuite/tests/rts/cloneStackLib.c - + testsuite/tests/rts/cloneThreadStack.hs - utils/genprimopcode/Main.hs Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -1770,7 +1770,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, typeConKey, threadIdPrimTyConKey, bcoPrimTyConKey, ptrTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, - compactPrimTyConKey :: Unique + compactPrimTyConKey, stackSnapshotPrimTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -1801,6 +1801,7 @@ ptrTyConKey = mkPreludeTyConUnique 77 funPtrTyConKey = mkPreludeTyConUnique 78 tVarPrimTyConKey = mkPreludeTyConUnique 79 compactPrimTyConKey = mkPreludeTyConUnique 80 +stackSnapshotPrimTyConKey = mkPreludeTyConUnique 81 eitherTyConKey :: Unique eitherTyConKey = mkPreludeTyConUnique 84 ===================================== compiler/GHC/Builtin/Types/Prim.hs ===================================== @@ -69,6 +69,7 @@ module GHC.Builtin.Types.Prim( bcoPrimTyCon, bcoPrimTy, weakPrimTyCon, mkWeakPrimTy, threadIdPrimTyCon, threadIdPrimTy, + stackSnapshotPrimTyCon, stackSnapshotPrimTy, int8PrimTyCon, int8PrimTy, int8PrimTyConName, word8PrimTyCon, word8PrimTy, word8PrimTyConName, @@ -189,6 +190,7 @@ exposedPrimTyCons , word16PrimTyCon , word32PrimTyCon , word64PrimTyCon + , stackSnapshotPrimTyCon , tYPETyCon , funTyCon @@ -211,7 +213,7 @@ mkBuiltInPrimTc fs unique tycon BuiltInSyntax -charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName :: Name +charPrimTyConName, intPrimTyConName, int8PrimTyConName, int16PrimTyConName, int32PrimTyConName, int64PrimTyConName, wordPrimTyConName, word32PrimTyConName, word8PrimTyConName, word16PrimTyConName, word64PrimTyConName, addrPrimTyConName, floatPrimTyConName, doublePrimTyConName, statePrimTyConName, proxyPrimTyConName, realWorldTyConName, arrayPrimTyConName, arrayArrayPrimTyConName, smallArrayPrimTyConName, byteArrayPrimTyConName, mutableArrayPrimTyConName, mutableByteArrayPrimTyConName, mutableArrayArrayPrimTyConName, smallMutableArrayPrimTyConName, mutVarPrimTyConName, mVarPrimTyConName, ioPortPrimTyConName, tVarPrimTyConName, stablePtrPrimTyConName, stableNamePrimTyConName, compactPrimTyConName, bcoPrimTyConName, weakPrimTyConName, threadIdPrimTyConName, eqPrimTyConName, eqReprPrimTyConName, eqPhantPrimTyConName, stackSnapshotPrimTyConName :: Name charPrimTyConName = mkPrimTc (fsLit "Char#") charPrimTyConKey charPrimTyCon intPrimTyConName = mkPrimTc (fsLit "Int#") intPrimTyConKey intPrimTyCon int8PrimTyConName = mkPrimTc (fsLit "Int8#") int8PrimTyConKey int8PrimTyCon @@ -247,6 +249,7 @@ tVarPrimTyConName = mkPrimTc (fsLit "TVar#") tVarPrimTyConKey tVarPr stablePtrPrimTyConName = mkPrimTc (fsLit "StablePtr#") stablePtrPrimTyConKey stablePtrPrimTyCon stableNamePrimTyConName = mkPrimTc (fsLit "StableName#") stableNamePrimTyConKey stableNamePrimTyCon compactPrimTyConName = mkPrimTc (fsLit "Compact#") compactPrimTyConKey compactPrimTyCon +stackSnapshotPrimTyConName = mkPrimTc (fsLit "StackSnapshot#") stackSnapshotPrimTyConKey stackSnapshotPrimTyCon bcoPrimTyConName = mkPrimTc (fsLit "BCO") bcoPrimTyConKey bcoPrimTyCon weakPrimTyConName = mkPrimTc (fsLit "Weak#") weakPrimTyConKey weakPrimTyCon threadIdPrimTyConName = mkPrimTc (fsLit "ThreadId#") threadIdPrimTyConKey threadIdPrimTyCon @@ -1087,6 +1090,21 @@ compactPrimTyCon = pcPrimTyCon0 compactPrimTyConName UnliftedRep compactPrimTy :: Type compactPrimTy = mkTyConTy compactPrimTyCon +{- +************************************************************************ +* * + The @StackSnapshot#@ type +* * +************************************************************************ +-} + +stackSnapshotPrimTyCon :: TyCon +stackSnapshotPrimTyCon = pcPrimTyCon0 stackSnapshotPrimTyConName UnliftedRep + +stackSnapshotPrimTy :: Type +stackSnapshotPrimTy = mkTyConTy stackSnapshotPrimTyCon + + {- ************************************************************************ * * ===================================== compiler/GHC/Builtin/primops.txt.pp ===================================== @@ -3151,6 +3151,16 @@ primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp has_side_effects = True out_of_line = True +primtype StackSnapshot# + +primop CloneMyStack "cloneMyStack#" GenPrimOp + State# RealWorld -> (# State# RealWorld, StackSnapshot# #) + { Clones the stack of the current Haskell thread. } + with + has_side_effects = True + out_of_line = True + + ------------------------------------------------------------------------ section "Safe coercions" ------------------------------------------------------------------------ ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -1521,6 +1521,7 @@ emitPrimOp dflags primop = case primop of TraceEventBinaryOp -> alwaysExternal TraceMarkerOp -> alwaysExternal SetThreadAllocationCounter -> alwaysExternal + CloneMyStack -> alwaysExternal where profile = targetProfile dflags ===================================== includes/rts/PrinterAPI.h ===================================== @@ -0,0 +1,3 @@ +#pragma once + +extern void printStack (StgStack* stack); ===================================== includes/rts/storage/Closures.h ===================================== @@ -431,6 +431,14 @@ typedef struct MessageBlackHole_ { StgClosure *bh; } MessageBlackHole; +typedef struct MessageCloneStack_ { + StgHeader header; + Message *link; + StgMVar *result; + StgTSO *tso; +} MessageCloneStack; + + /* ---------------------------------------------------------------------------- Compact Regions ------------------------------------------------------------------------- */ ===================================== includes/stg/MiscClosures.h ===================================== @@ -129,6 +129,7 @@ RTS_ENTRY(stg_STM_AWOKEN); RTS_ENTRY(stg_MSG_TRY_WAKEUP); RTS_ENTRY(stg_MSG_THROWTO); RTS_ENTRY(stg_MSG_BLACKHOLE); +RTS_ENTRY(stg_MSG_CLONE_STACK); RTS_ENTRY(stg_MSG_NULL); RTS_ENTRY(stg_MVAR_TSO_QUEUE); RTS_ENTRY(stg_catch); @@ -492,6 +493,7 @@ RTS_FUN_DECL(stg_traceBinaryEventzh); RTS_FUN_DECL(stg_traceMarkerzh); RTS_FUN_DECL(stg_getThreadAllocationCounterzh); RTS_FUN_DECL(stg_setThreadAllocationCounterzh); +RTS_FUN_DECL(stg_cloneMyStackzh); /* Other misc stuff */ ===================================== libraries/base/GHC/Stack/CloneStack.hs ===================================== @@ -0,0 +1,76 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnliftedFFITypes#-} + +-- | +-- This module exposes an interface for capturing the state of a thread's +-- execution stack for diagnostics purposes. +-- +-- @since 2.16.0.0 +module GHC.Stack.CloneStack ( + StackSnapshot(..), + cloneMyStack, + cloneThreadStack, + printStack + ) where + +import GHC.Prim (StackSnapshot#, cloneMyStack#, ThreadId#) +import Control.Concurrent.MVar +import GHC.Conc.Sync +import GHC.Stable +import GHC.IO (IO(..)) + +-- | A frozen snapshot of the state of an execution stack. +-- +-- @since 2.16.0.0 +data StackSnapshot = StackSnapshot !StackSnapshot# + +{- +Note [Stack Cloning] +~~~~~~~~~~~~~~~~~~~~ +"Cloning" a stack means that it's StgStack closure is copied including the +stack memory (stack[]). The stack pointer (sp) of the clone is adjusted to be +valid. + +The clone is "offline"/"cold", i.e. it won't be evaluated any further. This is +useful for further analyses like stack unwinding or traversal. + +There are two different ways to clone a stack: +1. By the corresponding thread via a primop call (cloneMyStack#). +2. By sending a RTS message (Messages.c) with a MVar to the corresponding + thread and receiving the stack by taking it out of this MVar. + +A StackSnapshot# is really a pointer to an immutable StgStack closure with +the invariant that stack->sp points to a valid frame. +-} + +-- | Clone the stack of the executing thread +-- +-- @since 2.16.0.0 +cloneMyStack :: IO StackSnapshot +cloneMyStack = IO $ \s -> + case (cloneMyStack# s) of (# s1, stack #) -> (# s1, StackSnapshot stack #) + +foreign import ccall "sendCloneStackMessage" sendCloneStackMessage :: ThreadId# -> StablePtr PrimMVar -> IO () + +-- | Clone the stack of a thread identified by its 'ThreadId' +-- +-- @since 2.16.0.0 +cloneThreadStack :: ThreadId -> IO StackSnapshot +cloneThreadStack (ThreadId tid#) = do + resultVar <- newEmptyMVar @StackSnapshot + ptr <- newStablePtrPrimMVar resultVar + -- Use the RTS's "message" mechanism to request that + -- the thread captures its stack, saving the result + -- into resultVar. + sendCloneStackMessage tid# ptr + freeStablePtr ptr + takeMVar resultVar + +foreign import ccall "PrinterAPI.h printStack" printStack_c :: StackSnapshot# -> IO () + +-- | Print the stack +printStack :: StackSnapshot -> IO () +printStack (StackSnapshot stack) = printStack_c stack ===================================== libraries/base/base.cabal ===================================== @@ -264,6 +264,7 @@ Library GHC.ResponseFile GHC.RTS.Flags GHC.ST + GHC.Stack.CloneStack GHC.StaticPtr GHC.STRef GHC.Show ===================================== rts/CloneStack.c ===================================== @@ -0,0 +1,104 @@ +/* --------------------------------------------------------------------------- + * + * (c) The GHC Team, 2001-2021 + * + * Stack snapshotting. + */ + +#include + +#include "Rts.h" +#include "rts/Messages.h" +#include "Messages.h" +#include "rts/storage/TSO.h" +#include "stg/Types.h" +#include "CloneStack.h" +#include "StablePtr.h" +#include "Threads.h" + +#if defined(DEBUG) +#include "sm/Sanity.h" +#endif + +static StgStack* cloneStackChunk(Capability* capability, const StgStack* stack) +{ + StgWord spOffset = stack->sp - stack->stack; + StgWord closureSizeBytes = sizeof(StgStack) + (stack->stack_size * sizeof(StgWord)); + + StgStack* newStackClosure = (StgStack*) allocate(capability, ROUNDUP_BYTES_TO_WDS(closureSizeBytes)); + + memcpy(newStackClosure, stack, closureSizeBytes); + + newStackClosure->sp = newStackClosure->stack + spOffset; + // The new stack is not on the mutable list; clear the dirty flag such that + // we don't claim that it is. + newStackClosure->dirty = 0; + +#if defined(DEBUG) + checkClosure((StgClosure*) newStackClosure); +#endif + + return newStackClosure; +} + +StgStack* cloneStack(Capability* capability, const StgStack* stack) +{ + StgStack *top_stack = cloneStackChunk(capability, stack); + StgStack last_stack = top_stack; + while (true) { + // check whether the stack ends in an underflow frame + StgPtr top = last_stack->stack + last_stack->stack_size + StgUnderflowFrame *frame = ((StgUnderflowFrame *)top)[-1]; + if (frame->header.info == &stg_UNDERFLOW_FRAME_info) { + StgStack *s = cloneStackChunk(capability, frame->next_chunk); + frame->next_chunk = s; + last_stack = s; + } else { + break; + } + } + return top_stack; +} + +#if defined(THREADED_RTS) + +// ThreadId# in Haskell is a StgTSO* in RTS. +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar) { + Capability *srcCapability = rts_unsafeGetMyCapability(); + + MessageCloneStack *msg; + msg = (MessageCloneStack *)allocate(srcCapability, sizeofW(MessageCloneStack)); + msg->tso = tso; + msg->result = (StgMVar*)deRefStablePtr(mvar); + freeStablePtr(mvar); + SET_HDR(msg, &stg_MSG_CLONE_STACK_info, CCS_SYSTEM); + // Ensure that writes constructing Message are committed before sending. + write_barrier(); + + sendMessage(srcCapability, tso->cap, (Message *)msg); +} + +void handleCloneStackMessage(MessageCloneStack *msg){ + StgStack* newStackClosure = cloneStack(msg->tso->cap, msg->tso->stackobj); + + // Lift StackSnapshot# to StackSnapshot by applying it's constructor. + // This is necessary because performTryPutMVar() puts the closure onto the + // stack for evaluation and stacks can not be evaluated (entered). + HaskellObj result = rts_apply(msg->tso->cap, StackSnapshot_constructor_closure, (HaskellObj) newStackClosure); + + bool putMVarWasSuccessful = performTryPutMVar(msg->tso->cap, msg->result, result); + + if(!putMVarWasSuccessful) { + barf("Can't put stack cloning result into MVar."); + } +} + +#else // !defined(THREADED_RTS) + +GNU_ATTRIBUTE(__noreturn__) +void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) { + barf("Sending CloneStackMessages is only available in threaded RTS!"); +} + +#endif // end !defined(THREADED_RTS) + ===================================== rts/CloneStack.h ===================================== @@ -0,0 +1,23 @@ +/* --------------------------------------------------------------------------- + * + * (c) The GHC Team, 2001-2021 + * + * Stack snapshotting. + */ + +#pragma once + +extern StgClosure DLL_IMPORT_DATA_VARNAME(base_GHCziStackziCloneStack_StackSnapshot_closure); +#define StackSnapshot_constructor_closure DLL_IMPORT_DATA_REF(base_GHCziStackziCloneStack_StackSnapshot_closure) + +StgStack* cloneStack(Capability* capability, const StgStack* stack); + +#include "BeginPrivate.h" + +#if defined(THREADED_RTS) +void handleCloneStackMessage(MessageCloneStack *msg); +#endif + +void sendCloneStackMessage(StgTSO *tso, HsStablePtr mvar); + +#include "EndPrivate.h" ===================================== rts/Disassembler.c ===================================== @@ -8,8 +8,6 @@ * $Date: 2004/09/03 15:28:19 $ * ---------------------------------------------------------------------------*/ -#if defined(DEBUG) - #include "PosixSource.h" #include "Rts.h" #include "RtsAPI.h" @@ -358,5 +356,3 @@ void disassemble( StgBCO *bco ) debugBelch("\n"); } - -#endif /* DEBUG */ ===================================== rts/Disassembler.h ===================================== @@ -8,9 +8,5 @@ #pragma once -#if defined(DEBUG) - RTS_PRIVATE int disInstr ( StgBCO *bco, int pc ); RTS_PRIVATE void disassemble( StgBCO *bco ); - -#endif ===================================== rts/Messages.c ===================================== @@ -14,6 +14,7 @@ #include "Threads.h" #include "RaiseAsync.h" #include "sm/Storage.h" +#include "CloneStack.h" /* ---------------------------------------------------------------------------- Send a message to another Capability @@ -32,7 +33,8 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg) i != &stg_MSG_BLACKHOLE_info && i != &stg_MSG_TRY_WAKEUP_info && i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked - i != &stg_WHITEHOLE_info) { + i != &stg_WHITEHOLE_info && + i != &stg_MSG_CLONE_STACK_info) { barf("sendMessage: %p", i); } } @@ -131,6 +133,10 @@ loop: #endif goto loop; } + else if(i == &stg_MSG_CLONE_STACK_info){ + MessageCloneStack *cloneStackMessage = (MessageCloneStack*) m; + handleCloneStackMessage(cloneStackMessage); + } else { barf("executeMessage: %p", i); ===================================== rts/PrimOps.cmm ===================================== @@ -2840,3 +2840,14 @@ stg_setThreadAllocationCounterzh ( I64 counter ) StgTSO_alloc_limit(CurrentTSO) = counter + TO_I64(offset); return (); } + +stg_cloneMyStackzh () { + W_ stgStack; + W_ clonedStack; + + stgStack = StgTSO_stackobj(CurrentTSO); + + ("ptr" clonedStack) = ccall cloneStack(MyCapability() "ptr", stgStack "ptr"); + + return (clonedStack); +} ===================================== rts/Printer.c ===================================== @@ -17,6 +17,7 @@ #include "sm/GCThread.h" #include "Hash.h" #include "Printer.h" +#include "rts/PrinterAPI.h" #include "RtsUtils.h" #if defined(PROFILING) @@ -25,9 +26,10 @@ #include +#include "Disassembler.h" + #if defined(DEBUG) -#include "Disassembler.h" #include "Apply.h" /* -------------------------------------------------------------------------- @@ -58,402 +60,337 @@ void printObj( StgClosure *obj ) printClosure(obj); } -STATIC_INLINE void -printStdObjHdr( const StgClosure *obj, char* tag ) +void +printMutableList(bdescr *bd) { - debugBelch("%s(",tag); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif -} + StgPtr p; -static void -printStdObjPayload( const StgClosure *obj ) -{ - StgWord i, j; - const StgInfoTable* info; + debugBelch("mutable list %p: ", bd); - info = get_itbl(obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); + for (; bd != NULL; bd = bd->link) { + for (p = bd->start; p < bd->free; p++) { + debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); + } } - debugBelch(")\n"); + debugBelch("\n"); } -static void -printThunkPayload( StgThunk *obj ) +void printTSO( StgTSO *tso ) { - StgWord i, j; - const StgInfoTable* info; - - info = get_itbl((StgClosure *)obj); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - debugBelch(", %pd#",obj->payload[i+j]); - } - debugBelch(")\n"); + printStack( tso->stackobj ); } -static void -printThunkObject( StgThunk *obj, char* tag ) +void printStaticObjects( StgClosure *p ) { - printStdObjHdr( (StgClosure *)obj, tag ); - printThunkPayload( obj ); + while (p != END_OF_STATIC_OBJECT_LIST) { + p = UNTAG_STATIC_LIST_PTR(p); + printClosure(p); + + const StgInfoTable *info = get_itbl(p); + p = *STATIC_LINK(info, p); + } } -void -printClosure( const StgClosure *obj ) +void printWeakLists() { - debugBelch("%p: ", obj); - obj = UNTAG_CONST_CLOSURE(obj); - const StgInfoTable* info = get_itbl(obj); + debugBelch("======= WEAK LISTS =======\n"); - while (IS_FORWARDING_PTR(info)) { - obj = (StgClosure*)UN_FORWARDING_PTR(info); - debugBelch("(forwarding to %p) ", (void*)obj); - info = get_itbl(obj); + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + debugBelch("Capability %d:\n", cap_idx); + Capability *cap = capabilities[cap_idx]; + for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } } - switch ( info->type ) { - case INVALID_OBJECT: - barf("Invalid object"); - - case CONSTR: - case CONSTR_1_0: case CONSTR_0_1: - case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: - case CONSTR_NOCAF: - { - StgWord i, j; - const StgConInfoTable *con_info = get_con_itbl (obj); - - debugBelch("%s(", GET_CON_DESC(con_info)); - for (i = 0; i < info->layout.payload.ptrs; ++i) { - if (i != 0) debugBelch(", "); - printPtr((StgPtr)obj->payload[i]); - } - for (j = 0; j < info->layout.payload.nptrs; ++j) { - if (i != 0 || j != 0) debugBelch(", "); - debugBelch("%p#", obj->payload[i+j]); - } - debugBelch(")\n"); - break; + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current weaks:\n", gen_idx); + for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); } + debugBelch("Generation %d old weaks:\n", gen_idx); + for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { + printClosure((StgClosure*)weak); + } + } - case FUN: - case FUN_1_0: case FUN_0_1: - case FUN_1_1: case FUN_0_2: case FUN_2_0: - case FUN_STATIC: - debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); - printPtr((StgPtr)obj->header.info); -#if defined(PROFILING) - debugBelch(", %s", obj->header.prof.ccs->cc->label); -#endif - printStdObjPayload(obj); - break; - - case PRIM: - debugBelch("PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case MUT_PRIM: - debugBelch("MUT_PRIM("); - printPtr((StgPtr)obj->header.info); - printStdObjPayload(obj); - break; - - case THUNK: - case THUNK_1_0: case THUNK_0_1: - case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: - case THUNK_STATIC: - /* ToDo: will this work for THUNK_STATIC too? */ -#if defined(PROFILING) - printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); -#else - printThunkObject((StgThunk *)obj,"THUNK"); -#endif - break; + debugBelch("=========================\n"); +} - case THUNK_SELECTOR: - printStdObjHdr(obj, "THUNK_SELECTOR"); - debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); - break; +void printLargeAndPinnedObjects() +{ + debugBelch("====== PINNED OBJECTS ======\n"); - case BCO: - disassemble( (StgBCO*)obj ); - break; + for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { + Capability *cap = capabilities[cap_idx]; - case AP: - { - StgAP* ap = (StgAP*)obj; - StgWord i; - debugBelch("AP("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->n_args; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Capability %d: Current pinned object block: %p\n", + cap_idx, (void*)cap->pinned_object_block); + for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { + debugBelch("%p\n", (void*)bd); } + } - case PAP: - { - StgPAP* pap = (StgPAP*)obj; - StgWord i; - debugBelch("PAP/%d(",(int)pap->arity); - printPtr((StgPtr)pap->fun); - for (i = 0; i < pap->n_args; ++i) { - debugBelch(", "); - printPtr((StgPtr)pap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("====== LARGE OBJECTS =======\n"); + for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { + generation *gen = &generations[gen_idx]; + debugBelch("Generation %d current large objects:\n", gen_idx); + for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } - case AP_STACK: - { - StgAP_STACK* ap = (StgAP_STACK*)obj; - StgWord i; - debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); - for (i = 0; i < ap->size; ++i) { - debugBelch(", "); - printPtr((P_)ap->payload[i]); - } - debugBelch(")\n"); - break; + debugBelch("Generation %d scavenged large objects:\n", gen_idx); + for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { + debugBelch("%p: ", (void*)bd); + printClosure((StgClosure*)bd->start); } + } - case IND: - debugBelch("IND("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; - - case IND_STATIC: - debugBelch("IND_STATIC("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; + debugBelch("============================\n"); +} - case BLACKHOLE: - debugBelch("BLACKHOLE("); - printPtr((StgPtr)((StgInd*)obj)->indirectee); - debugBelch(")\n"); - break; +/* -------------------------------------------------------------------------- + * Address printing code + * + * Uses symbol table in (unstripped executable) + * ------------------------------------------------------------------------*/ - /* Cannot happen -- use default case. - case RET_BCO: - case RET_SMALL: - case RET_BIG: - case RET_FUN: - */ +/* -------------------------------------------------------------------------- + * Simple lookup table + * address -> function name + * ------------------------------------------------------------------------*/ - case UPDATE_FRAME: - { - StgUpdateFrame* u = (StgUpdateFrame*)obj; - debugBelch("%s(", info_update_frame(obj)); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->updatee); - debugBelch(")\n"); - break; - } +static HashTable * add_to_fname_table = NULL; - case CATCH_FRAME: - { - StgCatchFrame* u = (StgCatchFrame*)obj; - debugBelch("CATCH_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(","); - printPtr((StgPtr)u->handler); - debugBelch(")\n"); - break; - } - - case UNDERFLOW_FRAME: - { - StgUnderflowFrame* u = (StgUnderflowFrame*)obj; - debugBelch("UNDERFLOW_FRAME("); - printPtr((StgPtr)u->next_chunk); - debugBelch(")\n"); - break; - } - - case STOP_FRAME: - { - StgStopFrame* u = (StgStopFrame*)obj; - debugBelch("STOP_FRAME("); - printPtr((StgPtr)GET_INFO((StgClosure *)u)); - debugBelch(")\n"); - break; - } - - case ARR_WORDS: - { - StgWord i; - debugBelch("ARR_WORDS(\""); - for (i=0; ipayload[i]); - debugBelch("\")\n"); - break; - } - - case MUT_ARR_PTRS_CLEAN: - debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; - - case MUT_ARR_PTRS_DIRTY: - debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; +const char *lookupGHCName( void *addr ) +{ + if (add_to_fname_table == NULL) + return NULL; - case MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); - break; + return lookupHashTable(add_to_fname_table, (StgWord)addr); +} - case SMALL_MUT_ARR_PTRS_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* -------------------------------------------------------------------------- + * Symbol table loading + * ------------------------------------------------------------------------*/ - case SMALL_MUT_ARR_PTRS_DIRTY: - debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Causing linking trouble on Win32 plats, so I'm + disabling this for now. +*/ +#if defined(USING_LIBBFD) +# define PACKAGE 1 +# define PACKAGE_VERSION 1 +/* Those PACKAGE_* defines are workarounds for bfd: + * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 + * ghc's build system filter PACKAGE_* values out specifically to avoid clashes + * with user's autoconf-based Cabal packages. + * It's a shame checks for unrelated fields instead of actually used + * macros. + */ +# include - case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: - debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", - (W_)((StgSmallMutArrPtrs *)obj)->ptrs); - break; +/* Fairly ad-hoc piece of code that seems to filter out a lot of + * rubbish like the obj-splitting symbols + */ - case MVAR_CLEAN: - case MVAR_DIRTY: - { - StgMVar* mv = (StgMVar*)obj; +static bool isReal( flagword flags STG_UNUSED, const char *name ) +{ +#if 0 + /* ToDo: make this work on BFD */ + int tp = type & N_TYPE; + if (tp == N_TEXT || tp == N_DATA) { + return (name[0] == '_' && name[1] != '_'); + } else { + return false; + } +#else + if (*name == '\0' || + (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || + (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { + return false; + } + return true; +#endif +} - debugBelch("MVAR(head="); - if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->head); - } +extern void DEBUG_LoadSymbols( const char *name ) +{ + bfd* abfd; + char **matching; - debugBelch(", tail="); - if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->tail); - } + bfd_init(); + abfd = bfd_openr(name, "default"); + if (abfd == NULL) { + barf("can't open executable %s to get symbol table", name); + } + if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { + barf("mismatch"); + } - debugBelch(", value="); - if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { - debugBelch("END_TSO_QUEUE"); - } else { - debugBelch("%p", mv->value); - } - debugBelch(")\n"); + { + long storage_needed; + asymbol **symbol_table; + long number_of_symbols; + long num_real_syms = 0; + long i; - break; - } + storage_needed = bfd_get_symtab_upper_bound (abfd); - case TVAR: - { - StgTVar* tv = (StgTVar*)obj; - debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); - break; + if (storage_needed < 0) { + barf("can't read symbol table"); } + symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - case MUT_VAR_CLEAN: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); - break; - } + number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - case MUT_VAR_DIRTY: - { - StgMutVar* mv = (StgMutVar*)obj; - debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); - break; + if (number_of_symbols < 0) { + barf("can't canonicalise symbol table"); } - case WEAK: - debugBelch("WEAK("); - debugBelch("key=%p value=%p finalizer=%p", - (StgPtr)(((StgWeak*)obj)->key), - (StgPtr)(((StgWeak*)obj)->value), - (StgPtr)(((StgWeak*)obj)->finalizer)); - debugBelch(")\n"); - /* ToDo: chase 'link' ? */ - break; - - case TSO: - debugBelch("TSO("); - debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); - debugBelch(")\n"); - break; - - case STACK: - debugBelch("STACK\n"); - break; - -#if 0 - /* Symptomatic of a problem elsewhere, have it fall-through & fail */ - case EVACUATED: - debugBelch("EVACUATED("); - printClosure((StgEvacuated*)obj->evacuee); - debugBelch(")\n"); - break; -#endif + if (add_to_fname_table == NULL) + add_to_fname_table = allocHashTable(); - case COMPACT_NFDATA: - debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", - (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); - break; + for( i = 0; i != number_of_symbols; ++i ) { + symbol_info info; + bfd_get_symbol_info(abfd,symbol_table[i],&info); + if (isReal(info.type, info.name)) { + insertHashTable(add_to_fname_table, + info.value, (void*)info.name); + num_real_syms += 1; + } + } - case TREC_CHUNK: - debugBelch("TREC_CHUNK\n"); - break; + IF_DEBUG(interpreter, + debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", + number_of_symbols, num_real_syms) + ); - default: - //barf("printClosure %d",get_itbl(obj)->type); - debugBelch("*** printClosure: unknown type %d ****\n", - (int)get_itbl(obj)->type ); - barf("printClosure %d",get_itbl(obj)->type); - return; + stgFree(symbol_table); } } -void -printMutableList(bdescr *bd) +#else /* USING_LIBBFD */ + +extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { - StgPtr p; + /* nothing, yet */ +} - debugBelch("mutable list %p: ", bd); +#endif /* USING_LIBBFD */ - for (; bd != NULL; bd = bd->link) { - for (p = bd->start; p < bd->free; p++) { - debugBelch("%p (%s), ", (void *)*p, info_type((StgClosure *)*p)); - } - } - debugBelch("\n"); -} +void findPtr(P_ p, int); /* keep gcc -Wall happy */ -// If you know you have an UPDATE_FRAME, but want to know exactly which. -const char *info_update_frame(const StgClosure *closure) +int searched = 0; + +static int +findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) { - // Note: We intentionally don't take the info table pointer as - // an argument. As it will be confusing whether one should pass - // it pointing to the code or struct members when compiling with - // TABLES_NEXT_TO_CODE. + StgPtr q, r, end; + for (; bd; bd = bd->link) { + searched++; + for (q = bd->start; q < bd->free; q++) { + if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { + if (i < arr_size) { + for (r = bd->start; r < bd->free; r = end) { + // skip over zeroed-out slop + while (*r == 0) r++; + if (!LOOKS_LIKE_CLOSURE_PTR(r)) { + debugBelch("%p found at %p, no closure at %p\n", + p, q, r); + break; + } + end = r + closure_sizeW((StgClosure*)r); + if (q < end) { + debugBelch("%p = ", r); + printClosure((StgClosure *)r); + arr[i++] = r; + break; + } + } + if (r >= bd->free) { + debugBelch("%p found at %p, closure?", p, q); + } + } else { + return i; + } + } + } + } + return i; +} + +void +findPtr(P_ p, int follow) +{ + uint32_t g, n; + bdescr *bd; + const int arr_size = 1024; + StgPtr arr[arr_size]; + int i = 0; + searched = 0; + +#if 0 + // We can't search the nursery, because we don't know which blocks contain + // valid data, because the bd->free pointers in the nursery are only reset + // just before a block is used. + for (n = 0; n < n_capabilities; n++) { + bd = nurseries[i].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + } +#endif + + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + bd = generations[g].blocks; + i = findPtrBlocks(p,bd,arr,arr_size,i); + bd = generations[g].large_objects; + i = findPtrBlocks(p,bd,arr,arr_size,i); + if (i >= arr_size) return; + for (n = 0; n < n_capabilities; n++) { + i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, + arr, arr_size, i); + i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, + arr, arr_size, i); + } + if (i >= arr_size) return; + } + if (follow && i == 1) { + debugBelch("-->\n"); + findPtr(arr[0], 1); + } +} + +const char *what_next_strs[] = { + [0] = "(unknown)", + [ThreadRunGHC] = "ThreadRunGHC", + [ThreadInterpret] = "ThreadInterpret", + [ThreadKilled] = "ThreadKilled", + [ThreadComplete] = "ThreadComplete" +}; + +#else /* DEBUG */ +void printPtr( StgPtr p ) +{ + debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); +} + +void printObj( StgClosure *obj ) +{ + debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); +} + + +#endif /* DEBUG */ + +// If you know you have an UPDATE_FRAME, but want to know exactly which. +const char *info_update_frame(const StgClosure *closure) +{ + // Note: We intentionally don't take the info table pointer as + // an argument. As it will be confusing whether one should pass + // it pointing to the code or struct members when compiling with + // TABLES_NEXT_TO_CODE. const StgInfoTable *info = closure->header.info; if (info == &stg_upd_frame_info) { return "NORMAL_UPDATE_FRAME"; @@ -467,501 +404,567 @@ const char *info_update_frame(const StgClosure *closure) } static void -printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, - uint32_t size ) +printThunkPayload( StgThunk *obj ) { - uint32_t i; + StgWord i, j; + const StgInfoTable* info; - for(i = 0; i < size; i++, bitmap >>= 1 ) { - debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } + info = get_itbl((StgClosure *)obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); +} + +STATIC_INLINE void +printStdObjHdr( const StgClosure *obj, char* tag ) +{ + debugBelch("%s(",tag); + printPtr((StgPtr)obj->header.info); +#if defined(PROFILING) + debugBelch(", %s", obj->header.prof.ccs->cc->label); +#endif } static void -printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, - uint32_t size ) +printThunkObject( StgThunk *obj, char* tag ) { - StgWord bmp; - uint32_t i, j; + printStdObjHdr( (StgClosure *)obj, tag ); + printThunkPayload( obj ); +} - i = 0; - for (bmp=0; i < size; bmp++) { - StgWord bitmap = large_bitmap->bitmap[bmp]; - j = 0; - for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { - debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); - if ((bitmap & 1) == 0) { - printPtr((P_)payload[i]); - debugBelch(" -- "); - printObj((StgClosure*) payload[i]); - } else { - debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); - } - } +static void +printStdObjPayload( const StgClosure *obj ) +{ + StgWord i, j; + const StgInfoTable* info; + + info = get_itbl(obj); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + debugBelch(", %pd#",obj->payload[i+j]); } + debugBelch(")\n"); } void -printStackChunk( StgPtr sp, StgPtr spBottom ) +printClosure( const StgClosure *obj ) { - const StgInfoTable *info; + debugBelch("%p: ", obj); + obj = UNTAG_CONST_CLOSURE(obj); + const StgInfoTable* info = get_itbl(obj); - ASSERT(sp <= spBottom); - for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { + while (IS_FORWARDING_PTR(info)) { + obj = (StgClosure*)UN_FORWARDING_PTR(info); + debugBelch("(forwarding to %p) ", (void*)obj); + info = get_itbl(obj); + } - info = get_itbl((StgClosure *)sp); + switch ( info->type ) { + case INVALID_OBJECT: + barf("Invalid object"); - switch (info->type) { + case CONSTR: + case CONSTR_1_0: case CONSTR_0_1: + case CONSTR_1_1: case CONSTR_0_2: case CONSTR_2_0: + case CONSTR_NOCAF: + { + StgWord i, j; + const StgConInfoTable *con_info = get_con_itbl (obj); - case UPDATE_FRAME: - case CATCH_FRAME: - case UNDERFLOW_FRAME: - case STOP_FRAME: - printClosure((StgClosure*)sp); - continue; + debugBelch("%s(", GET_CON_DESC(con_info)); + for (i = 0; i < info->layout.payload.ptrs; ++i) { + if (i != 0) debugBelch(", "); + printPtr((StgPtr)obj->payload[i]); + } + for (j = 0; j < info->layout.payload.nptrs; ++j) { + if (i != 0 || j != 0) debugBelch(", "); + debugBelch("%p#", obj->payload[i+j]); + } + debugBelch(")\n"); + break; + } - case RET_SMALL: { - StgWord c = *sp; - if (c == (StgWord)&stg_ctoi_R1p_info) { - debugBelch("tstg_ctoi_ret_R1p_info\n" ); - } else if (c == (StgWord)&stg_ctoi_R1n_info) { - debugBelch("stg_ctoi_ret_R1n_info\n" ); - } else if (c == (StgWord)&stg_ctoi_F1_info) { - debugBelch("stg_ctoi_ret_F1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_D1_info) { - debugBelch("stg_ctoi_ret_D1_info\n" ); - } else if (c == (StgWord)&stg_ctoi_V_info) { - debugBelch("stg_ctoi_ret_V_info\n" ); - } else if (c == (StgWord)&stg_ap_v_info) { - debugBelch("stg_ap_v_info\n" ); - } else if (c == (StgWord)&stg_ap_f_info) { - debugBelch("stg_ap_f_info\n" ); - } else if (c == (StgWord)&stg_ap_d_info) { - debugBelch("stg_ap_d_info\n" ); - } else if (c == (StgWord)&stg_ap_l_info) { - debugBelch("stg_ap_l_info\n" ); - } else if (c == (StgWord)&stg_ap_n_info) { - debugBelch("stg_ap_n_info\n" ); - } else if (c == (StgWord)&stg_ap_p_info) { - debugBelch("stg_ap_p_info\n" ); - } else if (c == (StgWord)&stg_ap_pp_info) { - debugBelch("stg_ap_pp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppp_info) { - debugBelch("stg_ap_ppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppp_info) { - debugBelch("stg_ap_pppp_info\n" ); - } else if (c == (StgWord)&stg_ap_ppppp_info) { - debugBelch("stg_ap_ppppp_info\n" ); - } else if (c == (StgWord)&stg_ap_pppppp_info) { - debugBelch("stg_ap_pppppp_info\n" ); - } else if (c == (StgWord)&stg_ret_v_info) { - debugBelch("stg_ret_v_info\n" ); - } else if (c == (StgWord)&stg_ret_p_info) { - debugBelch("stg_ret_p_info\n" ); - } else if (c == (StgWord)&stg_ret_n_info) { - debugBelch("stg_ret_n_info\n" ); - } else if (c == (StgWord)&stg_ret_f_info) { - debugBelch("stg_ret_f_info\n" ); - } else if (c == (StgWord)&stg_ret_d_info) { - debugBelch("stg_ret_d_info\n" ); - } else if (c == (StgWord)&stg_ret_l_info) { - debugBelch("stg_ret_l_info\n" ); + case FUN: + case FUN_1_0: case FUN_0_1: + case FUN_1_1: case FUN_0_2: case FUN_2_0: + case FUN_STATIC: + debugBelch("FUN/%d(",(int)itbl_to_fun_itbl(info)->f.arity); + printPtr((StgPtr)obj->header.info); #if defined(PROFILING) - } else if (c == (StgWord)&stg_restore_cccs_info) { - debugBelch("stg_restore_cccs_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; - } else if (c == (StgWord)&stg_restore_cccs_eval_info) { - debugBelch("stg_restore_cccs_eval_info\n" ); - fprintCCS(stderr, (CostCentreStack*)sp[1]); - debugBelch("\n" ); - continue; + debugBelch(", %s", obj->header.prof.ccs->cc->label); #endif - } else { - debugBelch("RET_SMALL (%p)\n", info); - } - StgWord bitmap = info->layout.bitmap; - printSmallBitmap(spBottom, sp+1, - BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); - continue; - } + printStdObjPayload(obj); + break; - case RET_BCO: { - StgBCO *bco; + case PRIM: + debugBelch("PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - bco = ((StgBCO *)sp[1]); + case MUT_PRIM: + debugBelch("MUT_PRIM("); + printPtr((StgPtr)obj->header.info); + printStdObjPayload(obj); + break; - debugBelch("RET_BCO (%p)\n", sp); - printLargeBitmap(spBottom, sp+2, - BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); - continue; - } + case THUNK: + case THUNK_1_0: case THUNK_0_1: + case THUNK_1_1: case THUNK_0_2: case THUNK_2_0: + case THUNK_STATIC: + /* ToDo: will this work for THUNK_STATIC too? */ +#if defined(PROFILING) + printThunkObject((StgThunk *)obj,GET_PROF_DESC(info)); +#else + printThunkObject((StgThunk *)obj,"THUNK"); +#endif + break; - case RET_BIG: - debugBelch("RET_BIG (%p)\n", sp); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); - printLargeBitmap(spBottom, - (StgPtr)((StgClosure *) sp)->payload, - bitmap, - bitmap->size); - continue; - case RET_FUN: + case THUNK_SELECTOR: + printStdObjHdr(obj, "THUNK_SELECTOR"); + debugBelch(", %p)\n", ((StgSelector *)obj)->selectee); + break; + + case BCO: + disassemble( (StgBCO*)obj ); + break; + + case AP: { - const StgFunInfoTable *fun_info; - StgRetFun *ret_fun; + StgAP* ap = (StgAP*)obj; + StgWord i; + debugBelch("AP("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->n_args; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; + } - ret_fun = (StgRetFun *)sp; - fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); - debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); - switch (fun_info->f.fun_type) { - case ARG_GEN: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(fun_info->f.b.bitmap), - BITMAP_SIZE(fun_info->f.b.bitmap)); - break; - case ARG_GEN_BIG: - printLargeBitmap(spBottom, sp+2, - GET_FUN_LARGE_BITMAP(fun_info), - GET_FUN_LARGE_BITMAP(fun_info)->size); - break; - default: - printSmallBitmap(spBottom, sp+2, - BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), - BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); - break; + case PAP: + { + StgPAP* pap = (StgPAP*)obj; + StgWord i; + debugBelch("PAP/%d(",(int)pap->arity); + printPtr((StgPtr)pap->fun); + for (i = 0; i < pap->n_args; ++i) { + debugBelch(", "); + printPtr((StgPtr)pap->payload[i]); } - continue; + debugBelch(")\n"); + break; } - default: - debugBelch("unknown object %d\n", (int)info->type); - barf("printStackChunk"); + case AP_STACK: + { + StgAP_STACK* ap = (StgAP_STACK*)obj; + StgWord i; + debugBelch("AP_STACK("); printPtr((StgPtr)ap->fun); + for (i = 0; i < ap->size; ++i) { + debugBelch(", "); + printPtr((P_)ap->payload[i]); + } + debugBelch(")\n"); + break; } - } -} -static void printStack( StgStack *stack ) -{ - printStackChunk( stack->sp, stack->stack + stack->stack_size ); -} + case IND: + debugBelch("IND("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printTSO( StgTSO *tso ) -{ - printStack( tso->stackobj ); -} + case IND_STATIC: + debugBelch("IND_STATIC("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; -void printStaticObjects( StgClosure *p ) -{ - while (p != END_OF_STATIC_OBJECT_LIST) { - p = UNTAG_STATIC_LIST_PTR(p); - printClosure(p); + case BLACKHOLE: + debugBelch("BLACKHOLE("); + printPtr((StgPtr)((StgInd*)obj)->indirectee); + debugBelch(")\n"); + break; - const StgInfoTable *info = get_itbl(p); - p = *STATIC_LINK(info, p); - } -} + /* Cannot happen -- use default case. + case RET_BCO: + case RET_SMALL: + case RET_BIG: + case RET_FUN: + */ -void printWeakLists() -{ - debugBelch("======= WEAK LISTS =======\n"); + case UPDATE_FRAME: + { + StgUpdateFrame* u = (StgUpdateFrame*)obj; + debugBelch("%s(", info_update_frame(obj)); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->updatee); + debugBelch(")\n"); + break; + } - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - debugBelch("Capability %d:\n", cap_idx); - Capability *cap = capabilities[cap_idx]; - for (StgWeak *weak = cap->weak_ptr_list_hd; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case CATCH_FRAME: + { + StgCatchFrame* u = (StgCatchFrame*)obj; + debugBelch("CATCH_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(","); + printPtr((StgPtr)u->handler); + debugBelch(")\n"); + break; } - } - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current weaks:\n", gen_idx); - for (StgWeak *weak = gen->weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + case UNDERFLOW_FRAME: + { + StgUnderflowFrame* u = (StgUnderflowFrame*)obj; + debugBelch("UNDERFLOW_FRAME("); + printPtr((StgPtr)u->next_chunk); + debugBelch(")\n"); + break; } - debugBelch("Generation %d old weaks:\n", gen_idx); - for (StgWeak *weak = gen->old_weak_ptr_list; weak; weak = weak->link) { - printClosure((StgClosure*)weak); + + case STOP_FRAME: + { + StgStopFrame* u = (StgStopFrame*)obj; + debugBelch("STOP_FRAME("); + printPtr((StgPtr)GET_INFO((StgClosure *)u)); + debugBelch(")\n"); + break; } - } - debugBelch("=========================\n"); -} + case ARR_WORDS: + { + StgWord i; + debugBelch("ARR_WORDS(\""); + for (i=0; ipayload[i]); + debugBelch("\")\n"); + break; + } -void printLargeAndPinnedObjects() -{ - debugBelch("====== PINNED OBJECTS ======\n"); + case MUT_ARR_PTRS_CLEAN: + debugBelch("MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - for (uint32_t cap_idx = 0; cap_idx < n_capabilities; ++cap_idx) { - Capability *cap = capabilities[cap_idx]; + case MUT_ARR_PTRS_DIRTY: + debugBelch("MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Capability %d: Current pinned object block: %p\n", - cap_idx, (void*)cap->pinned_object_block); - for (bdescr *bd = cap->pinned_object_blocks; bd; bd = bd->link) { - debugBelch("%p\n", (void*)bd); - } - } + case MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", (W_)((StgMutArrPtrs *)obj)->ptrs); + break; - debugBelch("====== LARGE OBJECTS =======\n"); - for (uint32_t gen_idx = 0; gen_idx <= oldest_gen->no; ++gen_idx) { - generation *gen = &generations[gen_idx]; - debugBelch("Generation %d current large objects:\n", gen_idx); - for (bdescr *bd = gen->large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } + case SMALL_MUT_ARR_PTRS_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("Generation %d scavenged large objects:\n", gen_idx); - for (bdescr *bd = gen->scavenged_large_objects; bd; bd = bd->link) { - debugBelch("%p: ", (void*)bd); - printClosure((StgClosure*)bd->start); - } - } + case SMALL_MUT_ARR_PTRS_DIRTY: + debugBelch("SMALL_MUT_ARR_PTRS_DIRTY(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; - debugBelch("============================\n"); -} + case SMALL_MUT_ARR_PTRS_FROZEN_CLEAN: + debugBelch("SMALL_MUT_ARR_PTRS_FROZEN_CLEAN(size=%" FMT_Word ")\n", + (W_)((StgSmallMutArrPtrs *)obj)->ptrs); + break; -/* -------------------------------------------------------------------------- - * Address printing code - * - * Uses symbol table in (unstripped executable) - * ------------------------------------------------------------------------*/ + case MVAR_CLEAN: + case MVAR_DIRTY: + { + StgMVar* mv = (StgMVar*)obj; -/* -------------------------------------------------------------------------- - * Simple lookup table - * address -> function name - * ------------------------------------------------------------------------*/ + debugBelch("MVAR(head="); + if ((StgClosure*)mv->head == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->head); + } -static HashTable * add_to_fname_table = NULL; + debugBelch(", tail="); + if ((StgClosure*)mv->tail == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->tail); + } -const char *lookupGHCName( void *addr ) -{ - if (add_to_fname_table == NULL) - return NULL; + debugBelch(", value="); + if ((StgClosure*)mv->value == &stg_END_TSO_QUEUE_closure) { + debugBelch("END_TSO_QUEUE"); + } else { + debugBelch("%p", mv->value); + } + debugBelch(")\n"); - return lookupHashTable(add_to_fname_table, (StgWord)addr); -} + break; + } -/* -------------------------------------------------------------------------- - * Symbol table loading - * ------------------------------------------------------------------------*/ + case TVAR: + { + StgTVar* tv = (StgTVar*)obj; + debugBelch("TVAR(value=%p, wq=%p, num_updates=%" FMT_Word ")\n", tv->current_value, tv->first_watch_queue_entry, tv->num_updates); + break; + } -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame checks for unrelated fields instead of actually used - * macros. - */ -# include + case MUT_VAR_CLEAN: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_CLEAN(var=%p)\n", mv->var); + break; + } -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ + case MUT_VAR_DIRTY: + { + StgMutVar* mv = (StgMutVar*)obj; + debugBelch("MUT_VAR_DIRTY(var=%p)\n", mv->var); + break; + } -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} + case WEAK: + debugBelch("WEAK("); + debugBelch("key=%p value=%p finalizer=%p", + (StgPtr)(((StgWeak*)obj)->key), + (StgPtr)(((StgWeak*)obj)->value), + (StgPtr)(((StgWeak*)obj)->finalizer)); + debugBelch(")\n"); + /* ToDo: chase 'link' ? */ + break; -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; + case TSO: + debugBelch("TSO("); + debugBelch("%lu (%p)",(unsigned long)(((StgTSO*)obj)->id), (StgTSO*)obj); + debugBelch(")\n"); + break; - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } + case STACK: + debugBelch("STACK\n"); + break; - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; +#if 0 + /* Symptomatic of a problem elsewhere, have it fall-through & fail */ + case EVACUATED: + debugBelch("EVACUATED("); + printClosure((StgEvacuated*)obj->evacuee); + debugBelch(")\n"); + break; +#endif - storage_needed = bfd_get_symtab_upper_bound (abfd); + case COMPACT_NFDATA: + debugBelch("COMPACT_NFDATA(size=%" FMT_Word ")\n", + (W_)((StgCompactNFData *)obj)->totalW * (W_)sizeof(W_)); + break; - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); + case TREC_CHUNK: + debugBelch("TREC_CHUNK\n"); + break; - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); + default: + //barf("printClosure %d",get_itbl(obj)->type); + debugBelch("*** printClosure: unknown type %d ****\n", + (int)get_itbl(obj)->type ); + barf("printClosure %d",get_itbl(obj)->type); + return; + } +} - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); +static void +printSmallBitmap( StgPtr spBottom, StgPtr payload, StgWord bitmap, + uint32_t size ) +{ + uint32_t i; + + for(i = 0; i < size; i++, bitmap >>= 1 ) { + debugBelch(" stk[%ld] (%p) = ", (long)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } + } +} - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); +static void +printLargeBitmap( StgPtr spBottom, StgPtr payload, StgLargeBitmap* large_bitmap, + uint32_t size ) +{ + StgWord bmp; + uint32_t i, j; - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; + i = 0; + for (bmp=0; i < size; bmp++) { + StgWord bitmap = large_bitmap->bitmap[bmp]; + j = 0; + for(; i < size && j < BITS_IN(W_); j++, i++, bitmap >>= 1 ) { + debugBelch(" stk[%" FMT_Word "] (%p) = ", (W_)(spBottom-(payload+i)), payload+i); + if ((bitmap & 1) == 0) { + printPtr((P_)payload[i]); + debugBelch(" -- "); + printObj((StgClosure*) payload[i]); + } else { + debugBelch("Word# %" FMT_Word "\n", (W_)payload[i]); } } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); } } -#else /* USING_LIBBFD */ - -extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) +void +printStackChunk( StgPtr sp, StgPtr spBottom ) { - /* nothing, yet */ -} + const StgInfoTable *info; -#endif /* USING_LIBBFD */ + ASSERT(sp <= spBottom); + for (; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp)) { -void findPtr(P_ p, int); /* keep gcc -Wall happy */ + info = get_itbl((StgClosure *)sp); -int searched = 0; + switch (info->type) { -static int -findPtrBlocks (StgPtr p, bdescr *bd, StgPtr arr[], int arr_size, int i) -{ - StgPtr q, r, end; - for (; bd; bd = bd->link) { - searched++; - for (q = bd->start; q < bd->free; q++) { - if (UNTAG_CONST_CLOSURE((StgClosure*)*q) == (const StgClosure *)p) { - if (i < arr_size) { - for (r = bd->start; r < bd->free; r = end) { - // skip over zeroed-out slop - while (*r == 0) r++; - if (!LOOKS_LIKE_CLOSURE_PTR(r)) { - debugBelch("%p found at %p, no closure at %p\n", - p, q, r); - break; - } - end = r + closure_sizeW((StgClosure*)r); - if (q < end) { - debugBelch("%p = ", r); - printClosure((StgClosure *)r); - arr[i++] = r; - break; - } - } - if (r >= bd->free) { - debugBelch("%p found at %p, closure?", p, q); - } - } else { - return i; - } + case UPDATE_FRAME: + case CATCH_FRAME: + case UNDERFLOW_FRAME: + case STOP_FRAME: + printClosure((StgClosure*)sp); + continue; + + case RET_SMALL: { + StgWord c = *sp; + if (c == (StgWord)&stg_ctoi_R1p_info) { + debugBelch("tstg_ctoi_ret_R1p_info\n" ); + } else if (c == (StgWord)&stg_ctoi_R1n_info) { + debugBelch("stg_ctoi_ret_R1n_info\n" ); + } else if (c == (StgWord)&stg_ctoi_F1_info) { + debugBelch("stg_ctoi_ret_F1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_D1_info) { + debugBelch("stg_ctoi_ret_D1_info\n" ); + } else if (c == (StgWord)&stg_ctoi_V_info) { + debugBelch("stg_ctoi_ret_V_info\n" ); + } else if (c == (StgWord)&stg_ap_v_info) { + debugBelch("stg_ap_v_info\n" ); + } else if (c == (StgWord)&stg_ap_f_info) { + debugBelch("stg_ap_f_info\n" ); + } else if (c == (StgWord)&stg_ap_d_info) { + debugBelch("stg_ap_d_info\n" ); + } else if (c == (StgWord)&stg_ap_l_info) { + debugBelch("stg_ap_l_info\n" ); + } else if (c == (StgWord)&stg_ap_n_info) { + debugBelch("stg_ap_n_info\n" ); + } else if (c == (StgWord)&stg_ap_p_info) { + debugBelch("stg_ap_p_info\n" ); + } else if (c == (StgWord)&stg_ap_pp_info) { + debugBelch("stg_ap_pp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppp_info) { + debugBelch("stg_ap_ppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppp_info) { + debugBelch("stg_ap_pppp_info\n" ); + } else if (c == (StgWord)&stg_ap_ppppp_info) { + debugBelch("stg_ap_ppppp_info\n" ); + } else if (c == (StgWord)&stg_ap_pppppp_info) { + debugBelch("stg_ap_pppppp_info\n" ); + } else if (c == (StgWord)&stg_ret_v_info) { + debugBelch("stg_ret_v_info\n" ); + } else if (c == (StgWord)&stg_ret_p_info) { + debugBelch("stg_ret_p_info\n" ); + } else if (c == (StgWord)&stg_ret_n_info) { + debugBelch("stg_ret_n_info\n" ); + } else if (c == (StgWord)&stg_ret_f_info) { + debugBelch("stg_ret_f_info\n" ); + } else if (c == (StgWord)&stg_ret_d_info) { + debugBelch("stg_ret_d_info\n" ); + } else if (c == (StgWord)&stg_ret_l_info) { + debugBelch("stg_ret_l_info\n" ); +#if defined(PROFILING) + } else if (c == (StgWord)&stg_restore_cccs_info) { + debugBelch("stg_restore_cccs_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; + } else if (c == (StgWord)&stg_restore_cccs_eval_info) { + debugBelch("stg_restore_cccs_eval_info\n" ); + fprintCCS(stderr, (CostCentreStack*)sp[1]); + debugBelch("\n" ); + continue; +#endif + } else { + debugBelch("RET_SMALL (%p)\n", info); } + StgWord bitmap = info->layout.bitmap; + printSmallBitmap(spBottom, sp+1, + BITMAP_BITS(bitmap), BITMAP_SIZE(bitmap)); + continue; } - } - return i; -} -void -findPtr(P_ p, int follow) -{ - uint32_t g, n; - bdescr *bd; - const int arr_size = 1024; - StgPtr arr[arr_size]; - int i = 0; - searched = 0; + case RET_BCO: { + StgBCO *bco; -#if 0 - // We can't search the nursery, because we don't know which blocks contain - // valid data, because the bd->free pointers in the nursery are only reset - // just before a block is used. - for (n = 0; n < n_capabilities; n++) { - bd = nurseries[i].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - } -#endif + bco = ((StgBCO *)sp[1]); - for (g = 0; g < RtsFlags.GcFlags.generations; g++) { - bd = generations[g].blocks; - i = findPtrBlocks(p,bd,arr,arr_size,i); - bd = generations[g].large_objects; - i = findPtrBlocks(p,bd,arr,arr_size,i); - if (i >= arr_size) return; - for (n = 0; n < n_capabilities; n++) { - i = findPtrBlocks(p, gc_threads[n]->gens[g].part_list, - arr, arr_size, i); - i = findPtrBlocks(p, gc_threads[n]->gens[g].todo_bd, - arr, arr_size, i); - } - if (i >= arr_size) return; - } - if (follow && i == 1) { - debugBelch("-->\n"); - findPtr(arr[0], 1); - } -} + debugBelch("RET_BCO (%p)\n", sp); + printLargeBitmap(spBottom, sp+2, + BCO_BITMAP(bco), BCO_BITMAP_SIZE(bco)); + continue; + } -const char *what_next_strs[] = { - [0] = "(unknown)", - [ThreadRunGHC] = "ThreadRunGHC", - [ThreadInterpret] = "ThreadInterpret", - [ThreadKilled] = "ThreadKilled", - [ThreadComplete] = "ThreadComplete" -}; + case RET_BIG: + debugBelch("RET_BIG (%p)\n", sp); + StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + printLargeBitmap(spBottom, + (StgPtr)((StgClosure *) sp)->payload, + bitmap, + bitmap->size); + continue; + case RET_FUN: + { + const StgFunInfoTable *fun_info; + StgRetFun *ret_fun; -#else /* DEBUG */ -void printPtr( StgPtr p ) -{ - debugBelch("ptr 0x%p (enable -DDEBUG for more info) " , p ); + ret_fun = (StgRetFun *)sp; + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + debugBelch("RET_FUN (%p) (type=%d)\n", ret_fun->fun, (int)fun_info->f.fun_type); + switch (fun_info->f.fun_type) { + case ARG_GEN: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(fun_info->f.b.bitmap), + BITMAP_SIZE(fun_info->f.b.bitmap)); + break; + case ARG_GEN_BIG: + printLargeBitmap(spBottom, sp+2, + GET_FUN_LARGE_BITMAP(fun_info), + GET_FUN_LARGE_BITMAP(fun_info)->size); + break; + default: + printSmallBitmap(spBottom, sp+2, + BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]), + BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + break; + } + continue; + } + + default: + debugBelch("unknown object %d\n", (int)info->type); + barf("printStackChunk"); + } + } } -void printObj( StgClosure *obj ) +void printStack( StgStack *stack ) { - debugBelch("obj 0x%p (enable -DDEBUG for more info) " , obj ); + printStackChunk( stack->sp, stack->stack + stack->stack_size ); } -#endif /* DEBUG */ - /* ----------------------------------------------------------------------------- Closure types ===================================== rts/Printer.h ===================================== @@ -20,9 +20,10 @@ const char * info_type ( const StgClosure *closure ); const char * info_type_by_ip ( const StgInfoTable *ip ); const char * info_update_frame ( const StgClosure *closure ); -#if defined(DEBUG) extern void printClosure ( const StgClosure *obj ); extern void printStackChunk ( StgPtr sp, StgPtr spLim ); + +#if defined(DEBUG) extern void printTSO ( StgTSO *tso ); extern void printMutableList( bdescr *bd ); extern void printStaticObjects ( StgClosure *obj ); ===================================== rts/RtsSymbols.c ===================================== @@ -12,6 +12,8 @@ #include "Rts.h" #include "TopHandler.h" #include "HsFFI.h" +#include "CloneStack.h" +#include "rts/PrinterAPI.h" #include "sm/Storage.h" #include "sm/NonMovingMark.h" @@ -979,6 +981,7 @@ SymI_HasProto(stg_traceBinaryEventzh) \ SymI_HasProto(stg_getThreadAllocationCounterzh) \ SymI_HasProto(stg_setThreadAllocationCounterzh) \ + SymI_HasProto(stg_cloneMyStackzh) \ SymI_HasProto(getMonotonicNSec) \ SymI_HasProto(lockFile) \ SymI_HasProto(unlockFile) \ @@ -998,6 +1001,8 @@ SymI_HasProto(cas) \ SymI_HasProto(_assertFail) \ SymI_HasProto(keepCAFs) \ + SymI_HasProto(sendCloneStackMessage) \ + SymI_HasProto(printStack) \ RTS_USER_SIGNALS_SYMBOLS \ RTS_INTCHAR_SYMBOLS ===================================== rts/StgMiscClosures.cmm ===================================== @@ -573,6 +573,9 @@ INFO_TABLE_CONSTR(stg_MSG_BLACKHOLE,3,0,0,PRIM,"MSG_BLACKHOLE","MSG_BLACKHOLE") INFO_TABLE_CONSTR(stg_MSG_NULL,1,0,0,PRIM,"MSG_NULL","MSG_NULL") { foreign "C" barf("MSG_NULL object (%p) entered!", R1) never returns; } +INFO_TABLE_CONSTR(stg_MSG_CLONE_STACK,3,0,0,PRIM,"MSG_CLONE_STACK","MSG_CLONE_STACK") +{ foreign "C" barf("stg_MSG_CLONE_STACK object (%p) entered!", R1) never returns; } + /* ---------------------------------------------------------------------------- END_TSO_QUEUE ===================================== rts/package.conf.in ===================================== @@ -194,6 +194,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,_findPtr" #endif + , "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" #else "-Wl,-u,base_GHCziTopHandler_runIO_closure" , "-Wl,-u,base_GHCziTopHandler_runNonIO_closure" @@ -308,6 +309,7 @@ ld-options: * so we need to force it to be included in the binary. */ , "-Wl,-u,findPtr" #endif + , "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" #endif /* Pick up static libraries in preference over dynamic if in earlier search ===================================== rts/rts.cabal.in ===================================== @@ -286,6 +286,7 @@ library "-Wl,-u,_hs_atomicwrite8" "-Wl,-u,_hs_atomicwrite16" "-Wl,-u,_hs_atomicwrite32" + "-Wl,-u,_base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -367,6 +368,7 @@ library "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" + "-Wl,-u,base_GHCziStackziCloneStack_StackSnapshot_closure" if flag(find-ptr) -- This symbol is useful in gdb, but not referred to anywhere, @@ -410,6 +412,7 @@ library Arena.c Capability.c CheckUnload.c + CloneStack.c ClosureFlags.c Disassembler.c FileLock.c ===================================== testsuite/tests/rts/all.T ===================================== @@ -418,3 +418,7 @@ test('T17088', compile_and_run, ['-rtsopts -O2']) test('T15427', normal, compile_and_run, ['']) + +test('cloneMyStack', [extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c']) + +test('cloneThreadStack', [only_ways(['threaded1']), extra_ways(['threaded1']), extra_files(['cloneStackLib.c'])], compile_and_run, ['cloneStackLib.c -threaded']) ===================================== testsuite/tests/rts/cloneMyStack.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#) +import GHC.Stack.CloneStack +import Foreign +import Foreign.C.Types (CUInt) + +foreign import ccall "expectClosureTypes" expectClosureTypes:: StackSnapshot# -> Ptr CUInt -> Int -> IO () + +main :: IO () +main = do + stackSnapshot <- cloneMyStack + + let (StackSnapshot stack) = stackSnapshot + let expectedClosureTypes = [34 -- CATCH_FRAME + ,36 -- STOP_FRAME + ] + withArray expectedClosureTypes (\ptr -> expectClosureTypes stack ptr (length expectedClosureTypes)) ===================================== testsuite/tests/rts/cloneStackLib.c ===================================== @@ -0,0 +1,53 @@ +#include "Rts.h" +#include "RtsAPI.h" +#include "rts/Messages.h" + + +void expectStacksToBeEqual(StgStack *clonedStack, StgTSO *tso) { + StgStack *liveStack = tso->stackobj; + + if(liveStack->header.info != clonedStack->header.info){ + barf("info table pointer not equal! Expected same pointer address, but got %p and %p", liveStack->header.info, clonedStack->header.info); + } + + StgInfoTable *info = INFO_PTR_TO_STRUCT(liveStack->header.info); + + if (info->type != STACK) { + barf("Expected a closure of type STACK!"); + } + + if(liveStack->stack_size != clonedStack->stack_size){ + barf("Expected same stack_size!"); + } + + if(liveStack->dirty != clonedStack->dirty){ + barf("Expected same dirty flags!"); + } + + if(liveStack->marking != clonedStack->marking){ + barf("Expected same marking flags!"); + } + + for(StgWord i = liveStack->stack_size - 1; (liveStack->stack + i) >= liveStack->sp; i--){ + if(liveStack->stack[i] != clonedStack->stack[i]){ + barf("Expected stack word %lu to be equal on both stacks.", i); + } + } +} + +void expectClosureTypes(StgStack *stack, unsigned int types[], size_t typesSize){ + StgPtr sp = stack->sp; + StgPtr spBottom = stack->stack + stack->stack_size; + + for (StgWord i = 0; sp < spBottom; sp += stack_frame_sizeW((StgClosure *)sp), i++) { + const StgInfoTable *info = get_itbl((StgClosure *)sp); + + if(i >= typesSize) { + barf("Stack size exceeds expectation!"); + } + + if(info->type != types[i]) { + barf("Wrong closure type on stack! Expected %u but got %u", types[i], info->type); + } + } +} ===================================== testsuite/tests/rts/cloneThreadStack.hs ===================================== @@ -0,0 +1,46 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnliftedFFITypes #-} + +import GHC.Prim (StackSnapshot#, ThreadId#) +import GHC.Conc.Sync (ThreadId(..)) +import GHC.Stack.CloneStack +import Control.Concurrent +import GHC.Conc + +foreign import ccall "expectStacksToBeEqual" expectStacksToBeEqual:: StackSnapshot# -> ThreadId# -> IO () + +main :: IO () +main = do + mVarToBeBlockedOn <- newEmptyMVar + threadId <- forkIO $ immediatelyBlocking mVarToBeBlockedOn + + waitUntilBlocked threadId + + stackSnapshot <- cloneThreadStack threadId + + let (StackSnapshot stack) = stackSnapshot + let (ThreadId tid#) = threadId + expectStacksToBeEqual stack tid# + +immediatelyBlocking :: MVar Int -> IO () +immediatelyBlocking mVarToBeBlockedOn = do + takeMVar mVarToBeBlockedOn + return () + +waitUntilBlocked :: ThreadId -> IO () +waitUntilBlocked tid = do + blocked <- isBlocked tid + if blocked then + return () + else + do + threadDelay 100000 + waitUntilBlocked tid + +isBlocked:: ThreadId -> IO Bool +isBlocked = fmap isThreadStatusBlocked . threadStatus + +isThreadStatusBlocked :: ThreadStatus -> Bool +isThreadStatusBlocked (ThreadBlocked _) = True +isThreadStatusBlocked _ = False ===================================== utils/genprimopcode/Main.hs ===================================== @@ -878,6 +878,7 @@ ppType (TyApp (TyCon "ThreadId#") []) = "threadIdPrimTy" ppType (TyApp (TyCon "ForeignObj#") []) = "foreignObjPrimTy" ppType (TyApp (TyCon "BCO") []) = "bcoPrimTy" ppType (TyApp (TyCon "Compact#") []) = "compactPrimTy" +ppType (TyApp (TyCon "StackSnapshot#") []) = "stackSnapshotPrimTy" ppType (TyApp (TyCon "()") []) = "unitTy" -- unitTy is GHC.Builtin.Types's name for () ppType (TyVar "a") = "alphaTy" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/276e19f7809f7ece2db516d990347555a3436f25...78c2c2f85fbe2f47442a6820d809b2a68c0af772 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/276e19f7809f7ece2db516d990347555a3436f25...78c2c2f85fbe2f47442a6820d809b2a68c0af772 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 19:16:02 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 15:16:02 -0400 Subject: [Git][ghc/ghc][wip/T18854] 29 commits: Fix `instance Bounded a => Bounded (Down a)` (#18716) Message-ID: <5f9db7f2d75e5_785f4903e0143849@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18854 at Glasgow Haskell Compiler / GHC Commits: 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - 7230b904 by Ben Gamari at 2020-10-31T15:15:52-04:00 Document that ccall convention doesn't support varargs We do not support foreign "C" imports of varargs functions. While this works on amd64, in general the platform's calling convention may need more type information that our Cmm representation can currently provide. For instance, this is the case with Darwin's AArch64 calling convention. Document this fact in the users guide and fix T5423 which makes use of a disallowed foreign import. Closes #18854. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Utils.hs - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Asm.hs - compiler/GHC/ByteCode/InfoTable.hs - compiler/GHC/ByteCode/Linker.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Axiom.hs - − compiler/GHC/Core/ConLike.hs-boot - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/FloatIn.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - − compiler/GHC/Core/PatSyn.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae63b16a7fa87f58ad0644be4a98266fe9bbbeae...7230b90458b5793e68c29362041017cc05a91241 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ae63b16a7fa87f58ad0644be4a98266fe9bbbeae...7230b90458b5793e68c29362041017cc05a91241 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 19:20:29 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 15:20:29 -0400 Subject: [Git][ghc/ghc][wip/local-symbols-2] Enable -fexpose-all-symbols when debug level >=2 Message-ID: <5f9db8fdc6c15_7853fb5f2084f84147122@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/local-symbols-2 at Glasgow Haskell Compiler / GHC Commits: e3071f56 by Ben Gamari at 2020-10-31T15:20:18-04:00 Enable -fexpose-all-symbols when debug level >=2 - - - - - 3 changed files: - compiler/GHC/Driver/Session.hs - docs/users_guide/debug-info.rst - docs/users_guide/phases.rst Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -4392,7 +4392,13 @@ setVerbosity :: Maybe Int -> DynP () setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 }) setDebugLevel :: Maybe Int -> DynP () -setDebugLevel mb_n = upd (\dfs -> dfs{ debugLevel = mb_n `orElse` 2 }) +setDebugLevel mb_n = + upd (\dfs -> exposeSyms $ dfs{ debugLevel = n }) + where + n = mb_n `orElse` 2 + exposeSyms + | n > 2 = setGeneralFlag' Opt_ExposeInternalSymbols + | otherwise = id data PkgDbRef = GlobalPkgDb ===================================== docs/users_guide/debug-info.rst ===================================== @@ -14,6 +14,7 @@ useable by most UNIX debugging tools. :category: debugging :since: 7.10, numeric levels since 8.0 + :implies: :ghc-flag:`-fexpose-internal-symbols` when ⟨n⟩ >= 2. Emit debug information in object code. Currently only DWARF debug information is supported on x86-64 and i386. Currently debug levels 0 ===================================== docs/users_guide/phases.rst ===================================== @@ -728,10 +728,11 @@ Options affecting code generation Request that GHC emits verbose symbol tables which include local symbols for module-internal functions. These can be useful for tools like :ref:`perf ` but increase object file sizes. + This is implied by :ghc-flag:`-g2 <-g>` and above. - :ghc-flag:`-fno-expose-internal-symbols` suppresses all non-global symbol - table entries, resulting in smaller object file sizes at the expense of - debuggability. + :ghc-flag:`-fno-expose-internal-symbols <-fexpose-internal-symbols>` + suppresses all non-global symbol table entries, resulting in smaller object + file sizes at the expense of debuggability. .. _options-linker: View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3071f569b9383d58e966929f784278fe38f6eed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3071f569b9383d58e966929f784278fe38f6eed You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 19:30:25 2020 From: gitlab at gitlab.haskell.org (Marge Bot) Date: Sat, 31 Oct 2020 15:30:25 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: winio: Fix unused variables warnings Message-ID: <5f9dbb51d834e_7853fb61c9eb4cc1521e3@gitlab.haskell.org.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - e2c59a51 by Ben Gamari at 2020-10-31T15:30:16-04:00 testsuite: Add performance test for #18698 - - - - - fe686293 by Hécate at 2020-10-31T15:30:19-04:00 Add the proper HLint rules and remove redundant keywords from compiler - - - - - 30 changed files: - compiler/.hlint.yaml - compiler/GHC/Cmm/Graph.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/ProcPoint.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/CFG/Dominators.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs - compiler/GHC/CmmToAsm/SPARC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/Exitify.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/StaticArgs.hs - compiler/GHC/Core/TyCon/Env.hs - compiler/GHC/Core/TyCon/RecWalk.hs - compiler/GHC/Core/TyCon/Set.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/StringBuffer.hs - compiler/GHC/Driver/Backpack.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/926c9e3595cc7d48400cecfb4482388b5dd8df4a...fe686293c201f0b214a9dc8a94534d08fdbbdcf5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/926c9e3595cc7d48400cecfb4482388b5dd8df4a...fe686293c201f0b214a9dc8a94534d08fdbbdcf5 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 20:02:28 2020 From: gitlab at gitlab.haskell.org (Ryan Scott) Date: Sat, 31 Oct 2020 16:02:28 -0400 Subject: [Git][ghc/ghc][wip/T18770] Display results of GHC.Core.Lint.lint* functions consistently Message-ID: <5f9dc2d45bc56_7853fb5f391d65415343b@gitlab.haskell.org.mail> Ryan Scott pushed to branch wip/T18770 at Glasgow Haskell Compiler / GHC Commits: 13d53c37 by Ryan Scott at 2020-10-31T16:01:26-04:00 Display results of GHC.Core.Lint.lint* functions consistently Previously, the functions in `GHC.Core.Lint` used a patchwork of different ways to display Core Lint errors: * `lintPassResult` (which is the source of most Core Lint errors) renders Core Lint errors with a distinctive banner (e.g., `*** Core Lint errors : in result of ... ***`) that sets them apart from ordinary GHC error messages. * `lintAxioms`, in contrast, uses a completely different code path that displays Core Lint errors in a rather confusing manner. For example, the program in #18770 would give these results: ``` Bug.hs:1:1: error: Bug.hs:12:1: warning: Non-*-like kind when *-like expected: RuntimeRep when checking the body of forall: 'TupleRep '[r] In the coercion axiom Bug.N:T :: []. Bug.T ~_R Any Substitution: [TCvSubst In scope: InScope {r} Type env: [axl :-> r] Co env: []] | 1 | {-# LANGUAGE DataKinds #-} | ^ ``` * Further digging reveals that `GHC.IfaceToCore` displays Core Lint errors for iface unfoldings as though they were a GHC panic. See, for example, this excerpt from #17723: ``` ghc: panic! (the 'impossible' happened) (GHC version 8.8.2 for x86_64-unknown-linux): Iface Lint failure In interface for Lib ... ``` This patch makes all of these code paths display Core Lint errors and warnings consistently. I decided to adopt the conventions that `lintPassResult` currently uses, as they appear to have been around the longest (and look the best, in my subjective opinion). We now use the `displayLintResult` function for all three scenarios mentioned above. For example, here is what the Core Lint error for the program in #18770 looks like after this patch: ``` [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) *** Core Lint errors : in result of TcGblEnv axioms *** Bug.hs:12:1: warning: Non-*-like kind when *-like expected: RuntimeRep when checking the body of forall: 'TupleRep '[r_axn] In the coercion axiom N:T :: []. T ~_R Any Substitution: [TCvSubst In scope: InScope {r_axn} Type env: [axn :-> r_axn] Co env: []] *** Offending Program *** axiom N:T :: T = Any -- Defined at Bug.hs:12:1 *** End of Offense *** <no location info>: error: Compilation had errors ``` Fixes #18770. - - - - - 6 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/Types.hs - testsuite/tests/callarity/unittest/CallArity1.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -19,8 +19,8 @@ module GHC.Core.Lint ( -- ** Debug output endPass, endPassIO, - dumpPassResult, - GHC.Core.Lint.dumpIfSet, + displayLintResults, dumpPassResult, + dumpIfSet, ) where #include "HsVersions.h" @@ -51,7 +51,6 @@ import GHC.Types.Name.Env import GHC.Types.Id import GHC.Types.Id.Info import GHC.Core.Ppr -import GHC.Utils.Error import GHC.Core.Coercion import GHC.Types.SrcLoc import GHC.Core.Type as Type @@ -66,7 +65,8 @@ import GHC.Core.TyCon as TyCon import GHC.Core.Coercion.Axiom import GHC.Core.Unify import GHC.Types.Basic -import GHC.Utils.Error as Err +import GHC.Utils.Error hiding ( dumpIfSet ) +import qualified GHC.Utils.Error as Err import GHC.Data.List.SetOps import GHC.Builtin.Names import GHC.Utils.Outputable as Outputable @@ -373,33 +373,38 @@ lintPassResult hsc_env pass binds | not (gopt Opt_DoCoreLinting dflags) = return () | otherwise - = do { let (warns, errs) = lintCoreBindings dflags pass (interactiveInScope hsc_env) binds + = do { let warns_and_errs = lintCoreBindings dflags pass (interactiveInScope hsc_env) binds ; Err.showPass dflags ("Core Linted result of " ++ showPpr dflags pass) - ; displayLintResults dflags pass warns errs binds } + ; displayLintResults dflags (showLintWarnings pass) (ppr pass) + (pprCoreBindings binds) warns_and_errs } where dflags = hsc_dflags hsc_env -displayLintResults :: DynFlags -> CoreToDo - -> Bag Err.MsgDoc -> Bag Err.MsgDoc -> CoreProgram +displayLintResults :: DynFlags + -> Bool -- ^ If 'True', display linter warnings. + -- If 'False', ignore linter warnings. + -> SDoc -- ^ The source of the linted program + -> SDoc -- ^ The linted program, pretty-printed + -> WarnsAndErrs -> IO () -displayLintResults dflags pass warns errs binds +displayLintResults dflags display_warnings pp_what pp_pgm (warns, errs) | not (isEmptyBag errs) = do { putLogMsg dflags NoReason Err.SevDump noSrcSpan $ withPprStyle defaultDumpStyle - (vcat [ lint_banner "errors" (ppr pass), Err.pprMessageBag errs + (vcat [ lint_banner "errors" pp_what, Err.pprMessageBag errs , text "*** Offending Program ***" - , pprCoreBindings binds + , pp_pgm , text "*** End of Offense ***" ]) ; Err.ghcExit dflags 1 } | not (isEmptyBag warns) , not (hasNoDebugOutput dflags) - , showLintWarnings pass + , display_warnings -- If the Core linter encounters an error, output to stderr instead of -- stdout (#13342) = putLogMsg dflags NoReason Err.SevInfo noSrcSpan $ withPprStyle defaultDumpStyle - (lint_banner "warnings" (ppr pass) $$ Err.pprMessageBag (mapBag ($$ blankLine) warns)) + (lint_banner "warnings" pp_what $$ Err.pprMessageBag (mapBag ($$ blankLine) warns)) | otherwise = return () where @@ -415,29 +420,18 @@ showLintWarnings :: CoreToDo -> Bool showLintWarnings (CoreDoSimplify _ (SimplMode { sm_phase = InitialPhase })) = False showLintWarnings _ = True -lintInteractiveExpr :: String -> HscEnv -> CoreExpr -> IO () +lintInteractiveExpr :: SDoc -- ^ The source of the linted expression + -> HscEnv -> CoreExpr -> IO () lintInteractiveExpr what hsc_env expr | not (gopt Opt_DoCoreLinting dflags) = return () | Just err <- lintExpr dflags (interactiveInScope hsc_env) expr - = do { display_lint_err err - ; Err.ghcExit dflags 1 } + = displayLintResults dflags False what (pprCoreExpr expr) (emptyBag, err) | otherwise = return () where dflags = hsc_dflags hsc_env - display_lint_err err - = do { putLogMsg dflags NoReason Err.SevDump - noSrcSpan - $ withPprStyle defaultDumpStyle - (vcat [ lint_banner "errors" (text what) - , err - , text "*** Offending Program ***" - , pprCoreExpr expr - , text "*** End of Offense ***" ]) - ; Err.ghcExit dflags 1 } - interactiveInScope :: HscEnv -> [Var] -- In GHCi we may lint expressions, or bindings arising from 'deriving' -- clauses, that mention variables bound in the interactive context. @@ -466,7 +460,7 @@ interactiveInScope hsc_env -- where t is a RuntimeUnk (see TcType) -- | Type-check a 'CoreProgram'. See Note [Core Lint guarantee]. -lintCoreBindings :: DynFlags -> CoreToDo -> [Var] -> CoreProgram -> (Bag MsgDoc, Bag MsgDoc) +lintCoreBindings :: DynFlags -> CoreToDo -> [Var] -> CoreProgram -> WarnsAndErrs -- Returns (warnings, errors) -- If you edit this function, you may need to update the GHC formalism -- See Note [GHC Formalism] @@ -542,16 +536,16 @@ hence the `TopLevelFlag` on `tcPragExpr` in GHC.IfaceToCore. -} -lintUnfolding :: Bool -- True <=> is a compulsory unfolding +lintUnfolding :: Bool -- True <=> is a compulsory unfolding -> DynFlags -> SrcLoc - -> VarSet -- Treat these as in scope + -> VarSet -- Treat these as in scope -> CoreExpr - -> Maybe MsgDoc -- Nothing => OK + -> Maybe (Bag MsgDoc) -- Nothing => OK lintUnfolding is_compulsory dflags locn var_set expr | isEmptyBag errs = Nothing - | otherwise = Just (pprMessageBag errs) + | otherwise = Just errs where vars = nonDetEltsUniqSet var_set (_warns, errs) = initL dflags (defaultLintFlags dflags) vars $ @@ -565,11 +559,11 @@ lintUnfolding is_compulsory dflags locn var_set expr lintExpr :: DynFlags -> [Var] -- Treat these as in scope -> CoreExpr - -> Maybe MsgDoc -- Nothing => OK + -> Maybe (Bag MsgDoc) -- Nothing => OK lintExpr dflags vars expr | isEmptyBag errs = Nothing - | otherwise = Just (pprMessageBag errs) + | otherwise = Just errs where (_warns, errs) = initL dflags (defaultLintFlags dflags) vars linter linter = addLoc TopLevelBindings $ @@ -2328,13 +2322,15 @@ lintCoercion (HoleCo h) -} lintAxioms :: DynFlags + -> SDoc -- ^ The source of the linted axioms -> [CoAxiom Branched] - -> WarnsAndErrs -lintAxioms dflags axioms - = initL dflags (defaultLintFlags dflags) [] $ - do { mapM_ lint_axiom axioms - ; let axiom_groups = groupWith coAxiomTyCon axioms - ; mapM_ lint_axiom_group axiom_groups } + -> IO () +lintAxioms dflags what axioms = + displayLintResults dflags True what (vcat $ map pprCoAxiom axioms) $ + initL dflags (defaultLintFlags dflags) [] $ + do { mapM_ lint_axiom axioms + ; let axiom_groups = groupWith coAxiomTyCon axioms + ; mapM_ lint_axiom_group axiom_groups } lint_axiom :: CoAxiom Branched -> LintM () lint_axiom ax@(CoAxiom { co_ax_tc = tc, co_ax_branches = branches ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -1715,7 +1715,7 @@ hscParsedStmt hsc_env stmt = runInteractiveHsc hsc_env $ do -- Desugar it ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr - liftIO (lintInteractiveExpr "desugar expression" hsc_env ds_expr) + liftIO (lintInteractiveExpr (text "desugar expression") hsc_env ds_expr) handleWarnings -- Then code-gen, and link it @@ -1958,7 +1958,7 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr ; prepd_expr <- corePrepExpr hsc_env tidy_expr {- Lint if necessary -} - ; lintInteractiveExpr "hscCompileExpr" hsc_env prepd_expr + ; lintInteractiveExpr (text "hscCompileExpr") hsc_env prepd_expr {- Convert to BCOs -} ; bcos <- coreExprToBCOs hsc_env ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -62,6 +62,7 @@ import GHC.Core.TyCon import GHC.Core.ConLike import GHC.Core.DataCon import GHC.Core.Opt.OccurAnal ( occurAnalyseExpr ) +import GHC.Core.Ppr import GHC.Unit.External import GHC.Unit.Module @@ -73,6 +74,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +import GHC.Data.Bag import GHC.Data.Maybe import GHC.Data.FastString import GHC.Data.List.SetOps @@ -1199,13 +1201,11 @@ tcIfaceRule (IfaceRule {ifRuleName = name, ifActivation = act, ifRuleBndrs = bnd bndrs' ++ exprsFreeIdsList args') ; case lintExpr dflags in_scope rhs' of - Nothing -> return () - Just fail_msg -> do { mod <- getIfModule - ; pprPanic "Iface Lint failure" - (vcat [ text "In interface for" <+> ppr mod - , hang doc 2 fail_msg - , ppr name <+> equals <+> ppr rhs' - , text "Iface expr =" <+> ppr rhs ]) } } + Nothing -> return () + Just errs -> liftIO $ + displayLintResults dflags False doc + (pprCoreExpr rhs') + (emptyBag, errs) } ; return (bndrs', args', rhs') } ; let mb_tcs = map ifTopFreeName args ; this_mod <- getIfModule @@ -1725,13 +1725,10 @@ tcPragExpr is_compulsory toplvl name expr in_scope <- get_in_scope dflags <- getDynFlags case lintUnfolding is_compulsory dflags noSrcLoc in_scope core_expr' of - Nothing -> return () - Just fail_msg -> do { mod <- getIfModule - ; pprPanic "Iface Lint failure" - (vcat [ text "In interface for" <+> ppr mod - , hang doc 2 fail_msg - , ppr name <+> equals <+> ppr core_expr' - , text "Iface expr =" <+> ppr expr ]) } + Nothing -> return () + Just errs -> liftIO $ + displayLintResults dflags False doc + (pprCoreExpr core_expr') (emptyBag, errs) return core_expr' where doc = ppWhen is_compulsory (text "Compulsory") <+> ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -296,11 +296,7 @@ tcRnModuleTcRnM hsc_env mod_sum tcRnSrcDecls explicit_mod_hdr local_decls export_ies ; whenM (goptM Opt_DoCoreLinting) $ - do { let (warns, errs) = lintGblEnv (hsc_dflags hsc_env) tcg_env - ; mapBagM_ (addWarn NoReason) warns - ; mapBagM_ addErr errs - ; failIfErrsM } -- if we have a lint error, we're only - -- going to get in deeper trouble by proceeding + lintGblEnv (hsc_dflags hsc_env) tcg_env ; setGblEnv tcg_env $ do { -- Process the export list ===================================== compiler/GHC/Tc/Types.hs ===================================== @@ -1712,7 +1712,8 @@ getRoleAnnots bndrs role_env -- | Check the 'TcGblEnv' for consistency. Currently, only checks -- axioms, but should check other aspects, too. -lintGblEnv :: DynFlags -> TcGblEnv -> (Bag SDoc, Bag SDoc) -lintGblEnv dflags tcg_env = lintAxioms dflags axioms +lintGblEnv :: DynFlags -> TcGblEnv -> TcM () +lintGblEnv dflags tcg_env = + liftIO $ lintAxioms dflags (text "TcGblEnv axioms") axioms where axioms = typeEnvCoAxioms (tcg_type_env tcg_env) ===================================== testsuite/tests/callarity/unittest/CallArity1.hs ===================================== @@ -172,7 +172,7 @@ main = do dflags <- getSessionDynFlags liftIO $ forM_ exprs $ \(n,e) -> do case lintExpr dflags [f,scrutf,scruta] e of - Just msg -> putMsg dflags (msg $$ text "in" <+> text n) + Just errs -> putMsg dflags (pprMessageBag errs $$ text "in" <+> text n) Nothing -> return () putMsg dflags (text n Outputable.<> char ':') -- liftIO $ putMsg dflags (ppr e) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13d53c37b1f33b1ca3e6a18289215e861a1a2601 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/13d53c37b1f33b1ca3e6a18289215e861a1a2601 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 23:32:01 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 19:32:01 -0400 Subject: [Git][ghc/ghc][wip/unloading] 14 commits: [skip ci] Fix typo in `callocBytes` haddock. Message-ID: <5f9df3f1a0ff6_7853fb5dd3b76081693b2@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/unloading at Glasgow Haskell Compiler / GHC Commits: 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - baccb8b2 by Ömer Sinan Ağacan at 2020-10-31T19:31:55-04:00 Fix and enable object unloading in GHCi Fixes #16525 by tracking dependencies between object file symbols and marking symbol liveness during garbage collection See Note [Object unloading] in CheckUnload.c for details. - - - - - 8325c84c by Ray Shih at 2020-10-31T19:31:55-04:00 Add loadNativeObj and unloadNativeObj (This change is originally written by niteria) This adds two functions: * `loadNativeObj` * `unloadNativeObj` and implements them for Linux. They are useful if you want to load a shared object with Haskell code using the system linker and have GHC call dlclose() after the code is no longer referenced from the heap. Using the system linker allows you to load the shared object above outside the low-mem region. It also loads the DWARF sections in a way that `perf` understands. `dl_iterate_phdr` is what makes this implementation Linux specific. - - - - - 5e1d1056 by GHC GitLab CI at 2020-10-31T19:31:55-04:00 rts: Introduce highMemDynamic - - - - - e686c380 by GHC GitLab CI at 2020-10-31T19:31:55-04:00 Introduce test for dynamic library unloading This uses the highMemDynamic flag introduced earlier to verify that dynamic objects are properly unloaded. - - - - - 30 changed files: - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Runtime/Linker.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/TyThing.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d99dc5bc1715e581fb552f4248b61f5793cd5bda...e686c380d92cf2e57847f4e6d1bc80f38575bf98 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d99dc5bc1715e581fb552f4248b61f5793cd5bda...e686c380d92cf2e57847f4e6d1bc80f38575bf98 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 23:51:57 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 19:51:57 -0400 Subject: [Git][ghc/ghc][wip/restrict-pages] 757 commits: Switch from HscSource to IsBootInterface for module lookup in GhcMake Message-ID: <5f9df89d8c113_7853fb6439fb5e41724dd@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/restrict-pages at Glasgow Haskell Compiler / GHC Commits: 809caedf by John Ericson at 2020-06-23T22:47:37-04:00 Switch from HscSource to IsBootInterface for module lookup in GhcMake We look up modules by their name, and not their contents. There is no way to separately reference a signature vs regular module; you get what you get. Only boot files can be referenced indepenently with `import {-# SOURCE #-}`. - - - - - 7750bd45 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Cmm: introduce SAVE_REGS/RESTORE_REGS We don't want to save both Fn and Dn register sets on x86-64 as they are aliased to the same arch register (XMMn). Moreover, when SAVE_STGREGS was used in conjunction with `jump foo [*]` which makes a set of Cmm registers alive so that they cover all arch registers used to pass parameter, we could have Fn, Dn and XMMn alive at the same time. It made the LLVM code generator choke (see #17920). Now `SAVE_REGS/RESTORE_REGS` and `jump foo [*]` use the same set of registers. - - - - - 2636794d by Sylvain Henry at 2020-06-23T22:48:18-04:00 CmmToC: don't add extern decl to parsed Cmm data Previously, if a .cmm file *not in the RTS* contained something like: ```cmm section "rodata" { msg : bits8[] "Test\n"; } ``` It would get compiled by CmmToC into: ```c ERW_(msg); const char msg[] = "Test\012"; ``` and fail with: ``` /tmp/ghc32129_0/ghc_4.hc:5:12: error: error: conflicting types for \u2018msg\u2019 const char msg[] = "Test\012"; ^~~ In file included from /tmp/ghc32129_0/ghc_4.hc:3:0: error: /tmp/ghc32129_0/ghc_4.hc:4:6: error: note: previous declaration of \u2018msg\u2019 was here ERW_(msg); ^ /builds/hsyl20/ghc/_build/install/lib/ghc-8.11.0.20200605/lib/../lib/x86_64-linux-ghc-8.11.0.20200605/rts-1.0/include/Stg.h:253:46: error: note: in definition of macro \u2018ERW_\u2019 #define ERW_(X) extern StgWordArray (X) ^ ``` See the rationale for this on https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/backends/ppr-c#prototypes Now we don't generate these extern declarations (ERW_, etc.) for top-level data. It shouldn't change anything for the RTS (the only place we use .cmm files) as it is already special cased in `GHC.Cmm.CLabel.needsCDecl`. And hand-written Cmm can use explicit extern declarations when needed. Note that it allows `cgrun069` test to pass with CmmToC (cf #15467). - - - - - 5f6a0665 by Sylvain Henry at 2020-06-23T22:48:18-04:00 LLVM: refactor and comment register padding code (#17920) - - - - - cad62ef1 by Sylvain Henry at 2020-06-23T22:48:18-04:00 Add tests for #17920 Metric Decrease: T12150 T12234 - - - - - a2a9006b by Xavier Denis at 2020-06-23T22:48:56-04:00 Fix issue #18262 by zonking constraints after solving Zonk residual constraints in checkForExistence to reveal user type errors. Previously when `:instances` was used with instances that have TypeError constraints the result would look something like: instance [safe] s0 => Err 'A -- Defined at ../Bug2.hs:8:10 whereas after zonking, `:instances` now sees the `TypeError` and properly eliminates the constraint from the results. - - - - - 181516bc by Simon Peyton Jones at 2020-06-23T22:49:33-04:00 Fix a buglet in Simplify.simplCast This bug, revealed by #18347, is just a missing update to sc_hole_ty in simplCast. I'd missed a code path when I made the recentchanges in commit 6d49d5be904c0c01788fa7aae1b112d5b4dfaf1c Author: Simon Peyton Jones <simonpj at microsoft.com> Date: Thu May 21 12:53:35 2020 +0100 Implement cast worker/wrapper properly The fix is very easy. Two other minor changes * Tidy up in SimpleOpt.simple_opt_expr. In fact I think this is an outright bug, introduced in the fix to #18112: we were simplifying the same coercion twice *with the same substitution*, which is just wrong. It'd be a hard bug to trigger, so I just fixed it; less code too. * Better debug printing of ApplyToVal - - - - - 625a7f54 by Simon Peyton Jones at 2020-06-23T22:50:11-04:00 Two small tweaks to Coercion.simplifyArgsWorker These tweaks affect the inner loop of simplifyArgsWorker, which in turn is called from the flattener in Flatten.hs. This is a key perf bottleneck to T9872{a,b,c,d}. These two small changes have a modest but useful benefit. No change in functionality whatsoever. Relates to #18354 - - - - - b5768cce by Sylvain Henry at 2020-06-23T22:50:49-04:00 Don't use timesInt2# with GHC < 8.11 (fix #18358) - - - - - 7ad4085c by Sylvain Henry at 2020-06-23T22:51:27-04:00 Fix invalid printf format - - - - - a1f34d37 by Krzysztof Gogolewski at 2020-06-23T22:52:09-04:00 Add missing entry to freeNamesItem (#18369) - - - - - 03a708ba by Andreas Klebinger at 2020-06-25T03:54:37-04:00 Enable large address space optimization on windows. Starting with Win 8.1/Server 2012 windows no longer preallocates page tables for reserverd memory eagerly, which prevented us from using this approach in the past. We also try to allocate the heap high in the memory space. Hopefully this makes it easier to allocate things in the low 4GB of memory that need to be there. Like jump islands for the linker. - - - - - 7e6d3d09 by Roland Senn at 2020-06-25T03:54:38-04:00 In `:break ident` allow out of scope and nested identifiers (Fix #3000) This patch fixes the bug and implements the feature request of #3000. 1. If `Module` is a real module name and `identifier` a name of a top-level function in `Module` then `:break Module.identifer` works also for an `identifier` that is out of scope. 2. Extend the syntax for `:break identifier` to: :break [ModQual.]topLevelIdent[.nestedIdent]...[.nestedIdent] `ModQual` is optional and is either the effective name of a module or the local alias of a qualified import statement. `topLevelIdent` is the name of a top level function in the module referenced by `ModQual`. `nestedIdent` is optional and the name of a function nested in a let or where clause inside the previously mentioned function `nestedIdent` or `topLevelIdent`. If `ModQual` is a module name, then `topLevelIdent` can be any top level identifier in this module. If `ModQual` is missing or a local alias of a qualified import, then `topLevelIdent` must be in scope. Breakpoints can be set on arbitrarily deeply nested functions, but the whole chain of nested function names must be specified. 3. To support the new functionality rewrite the code to tab complete `:break`. - - - - - 30e42652 by Ben Gamari at 2020-06-25T03:54:39-04:00 make: Respect XELATEX variable Previously we simply ignored the XELATEX variable when building PDF documentation. - - - - - 4acc2934 by Ben Gamari at 2020-06-25T03:54:39-04:00 hadrian/make: Detect makeindex Previously we would simply assume that makeindex was available. Now we correctly detect it in `configure` and respect this conclusion in hadrian and make. - - - - - 0d61f866 by Simon Peyton Jones at 2020-06-25T03:54:40-04:00 Expunge GhcTcId GHC.Hs.Extension had type GhcPs = GhcPass 'Parsed type GhcRn = GhcPass 'Renamed type GhcTc = GhcPass 'Typechecked type GhcTcId = GhcTc The last of these, GhcTcId, is a vestige of the past. This patch expunges it from GHC. - - - - - 8ddbed4a by Adam Wespiser at 2020-06-25T03:54:40-04:00 add examples to Data.Traversable - - - - - 284001d0 by Oleg Grenrus at 2020-06-25T03:54:42-04:00 Export readBinIface_ - - - - - 90f43872 by Zubin Duggal at 2020-06-25T03:54:43-04:00 Export everything from HsToCore. This lets us reuse these functions in haddock, avoiding synchronization bugs. Also fixed some divergences with haddock in that file Updates haddock submodule - - - - - c7dd6da7 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part1) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Hs.* - GHC.Core.* - GHC.Stg.* - GHC.Cmm.* - GHC.Types.* - GHC.Data.* - GHC.Builtin.* - GHC.Parser.* - GHC.Driver.* - GHC top - - - - - 1eb997a8 by Takenobu Tani at 2020-06-25T03:54:44-04:00 Clean up haddock hyperlinks of GHC.* (part2) This updates haddock comments only. This patch focuses to update for hyperlinks in GHC API's haddock comments, because broken links especially discourage newcomers. This includes the following hierarchies: - GHC.Iface.* - GHC.Llvm.* - GHC.Rename.* - GHC.Tc.* - GHC.HsToCore.* - GHC.StgToCmm.* - GHC.CmmToAsm.* - GHC.Runtime.* - GHC.Unit.* - GHC.Utils.* - GHC.SysTools.* - - - - - 67a86b4d by Oleg Grenrus at 2020-06-25T03:54:46-04:00 Add MonadZip and MonadFix instances for Complex These instances are taken from https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html They are the unique possible, so let they be in `base`. - - - - - c50ef26e by Artem Pelenitsyn at 2020-06-25T03:54:47-04:00 test suite: add reproducer for #17516 - - - - - fe281b27 by Roland Senn at 2020-06-25T03:54:48-04:00 Enable maxBound checks for OverloadedLists (Fixes #18172) Consider the Literal `[256] :: [Data.Word.Word8]` When the `OverloadedLists` extension is not active, then the `ol_ext` field in the `OverLitTc` record that is passed to the function `getIntegralLit` contains the type `Word8`. This is a simple type, and we can use its type constructor immediately for the `warnAboutOverflowedLiterals` function. When the `OverloadedLists` extension is active, then the `ol_ext` field contains the type family `Item [Word8]`. The function `nomaliseType` is used to convert it to the needed type `Word8`. - - - - - a788d4d1 by Ben Gamari at 2020-06-25T03:54:52-04:00 rts/Hash: Simplify freeing of HashListChunks While looking at #18348 I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing. Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation. Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug. - - - - - d3c2d59b by Sylvain Henry at 2020-06-25T03:54:55-04:00 RTS: avoid overflow on 32-bit arch (#18375) We're now correctly computing allocated bytes on 32-bit arch, so we get huge increases. Metric Increase: haddock.Cabal haddock.base haddock.compiler space_leak_001 - - - - - a3d69dc6 by Sebastian Graf at 2020-06-25T23:06:18-04:00 GHC.Core.Unify: Make UM actions one-shot by default This MR makes the UM monad in GHC.Core.Unify into a one-shot monad. See the long Note [The one-shot state monad trick]. See also #18202 and !3309, which applies this to all Reader/State-like monads in GHC for compile-time perf improvements. The pattern used here enables something similar to the state-hack, but is applicable to user-defined monads, not just `IO`. Metric Decrease 'runtime/bytes allocated' (test_env='i386-linux-deb9'): haddock.Cabal - - - - - 9ee58f8d by Matthias Pall Gissurarson at 2020-06-26T17:12:45+00:00 Implement the proposed -XQualifiedDo extension Co-authored-by: Facundo Domínguez <facundo.dominguez at tweag.io> QualifiedDo is implemented using the same placeholders for operation names in the AST that were devised for RebindableSyntax. Whenever the renamer checks which names to use for do syntax, it first checks if the do block is qualified (e.g. M.do { stmts }), in which case it searches for qualified names in the module M. This allows users to write {-# LANGUAGE QualifiedDo #-} import qualified SomeModule as M f x = M.do -- desugars to: y <- M.return x -- M.return x M.>>= \y -> M.return y -- M.return y M.>> M.return y -- M.return y See Note [QualifiedDo] and the users' guide for more details. Issue #18214 Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst Since we change the constructors `ITdo` and `ITmdo` to carry the new module name, we need to bump the haddock submodule to account or the new shape of these constructors. - - - - - ce987865 by Ryan Scott at 2020-06-27T11:55:21-04:00 Revamp the treatment of auxiliary bindings for derived instances This started as a simple fix for #18321 that organically grew into a much more sweeping refactor of how auxiliary bindings for derived instances are handled. I have rewritten `Note [Auxiliary binders]` in `GHC.Tc.Deriv.Generate` to explain all of the moving parts, but the highlights are: * Previously, the OccName of each auxiliary binding would be given a suffix containing a hash of its package name, module name, and parent data type to avoid name clashes. This was needlessly complicated, so we take the more direct approach of generating `Exact` `RdrName`s for each auxiliary binding with the same `OccName`, but using an underlying `System` `Name` with a fresh `Unique` for each binding. Unlike hashes, allocating new `Unique`s does not require any cleverness and avoid name clashes all the same... * ...speaking of which, in order to convince the renamer that multiple auxiliary bindings with the same `OccName` (but different `Unique`s) are kosher, we now use `rnLocalValBindsLHS` instead of `rnTopBindsLHS` to rename auxiliary bindings. Again, see `Note [Auxiliary binders]` for the full story. * I have removed the `DerivHsBind` constructor for `DerivStuff`—which was only used for `Data.Data`-related auxiliary bindings—and refactored `gen_Data_binds` to use `DerivAuxBind` instead. This brings the treatment of `Data.Data`-related auxiliary bindings in line with every other form of auxiliary binding. Fixes #18321. - - - - - a403eb91 by Sylvain Henry at 2020-06-27T11:55:59-04:00 ghc-bignum: fix division by zero (#18359) - - - - - 1b3d13b6 by Sylvain Henry at 2020-06-27T11:55:59-04:00 Fix ghc-bignum exceptions We must ensure that exceptions are not simplified. Previously we used: case raiseDivZero of _ -> 0## -- dummyValue But it was wrong because the evaluation of `raiseDivZero` was removed and the dummy value was directly returned. See new Note [ghc-bignum exceptions]. I've also removed the exception triggering primops which were fragile. We don't need them to be primops, we can have them exported by ghc-prim. I've also added a test for #18359 which triggered this patch. - - - - - a74ec37c by Simon Peyton Jones at 2020-06-27T11:56:34-04:00 Better loop detection in findTypeShape Andreas pointed out, in !3466, that my fix for #18304 was not quite right. This patch fixes it properly, by having just one RecTcChecker rather than (implicitly) two nested ones, in findTypeShape. - - - - - a04020b8 by Sylvain Henry at 2020-06-27T11:57:11-04:00 DynFlags: don't store buildTag `DynFlags.buildTag` was a field created from the set of Ways in `DynFlags.ways`. It had to be kept in sync with `DynFlags.ways` which was fragile. We want to avoid global state like this (#17957). Moreover in #14335 we also want to support loading units with different ways: target units would still use `DynFlags.ways` but plugins would use `GHC.Driver.Ways.hostFullWays`. To avoid having to deal both with build tag and with ways, we recompute the buildTag on-the-fly (should be pretty cheap) and we remove `DynFlags.buildTag` field. - - - - - 0e83efa2 by Krzysztof Gogolewski at 2020-06-27T11:57:49-04:00 Don't generalize when typechecking a tuple section The code is simpler and cleaner. - - - - - d8ba9e6f by Peter Trommler at 2020-06-28T09:19:11-04:00 RTS: Refactor Haskell-C glue for PPC 64-bit Make sure the stack is 16 byte aligned even when reserved stack bytes are not a multiple of 16 bytes. Avoid saving r2 (TOC). On ELF v1 the function descriptor of StgReturn has the same TOC as StgRun, on ELF v2 the TOC is recomputed in the function prologue. Use the ABI provided functions to save clobbered GPRs and FPRs. Improve comments. Describe what the stack looks like and how it relates to the respective ABIs. - - - - - 42f797b0 by Ryan Scott at 2020-06-28T09:19:46-04:00 Use NHsCoreTy to embed types into GND-generated code `GeneralizedNewtypeDeriving` is in the unique situation where it must produce an `LHsType GhcPs` from a Core `Type`. Historically, this was done with the `typeToLHsType` function, which walked over the entire `Type` and attempted to construct an `LHsType` with the same overall structure. `typeToLHsType` is quite complicated, however, and has been the subject of numerous bugs over the years (e.g., #14579). Luckily, there is an easier way to accomplish the same thing: the `XHsType` constructor of `HsType`. `XHsType` bundles an `NHsCoreTy`, which allows embedding a Core `Type` directly into an `HsType`, avoiding the need to laboriously convert from one to another (as `typeToLHsType` did). Moreover, renaming and typechecking an `XHsType` is simple, since one doesn't need to do anything to a Core `Type`... ...well, almost. For the reasons described in `Note [Typechecking NHsCoreTys]` in `GHC.Tc.Gen.HsType`, we must apply a substitution that we build from the local `tcl_env` type environment. But that's a relatively modest price to pay. Now that `GeneralizedNewtypeDeriving` uses `NHsCoreTy`, the `typeToLHsType` function no longer has any uses in GHC, so this patch rips it out. Some additional tweaks to `hsTypeNeedsParens` were necessary to make the new `-ddump-deriv` output correctly parenthesized, but other than that, this patch is quite straightforward. This is a mostly internal refactoring, although it is likely that `GeneralizedNewtypeDeriving`-generated code will now need fewer language extensions in certain situations than it did before. - - - - - 68530b1c by Jan Hrček at 2020-06-28T09:20:22-04:00 Fix duplicated words and typos in comments and user guide - - - - - 15b79bef by Ryan Scott at 2020-06-28T09:20:57-04:00 Add integer-gmp's ghc.mk and GNUmakefile to .gitignore - - - - - bfa5698b by Simon Peyton Jones at 2020-06-28T09:21:32-04:00 Fix a typo in Lint This simple error in GHC.Core.Litn.lintJoinLams meant that Lint reported bogus errors. Fixes #18399 - - - - - 71006532 by Ryan Scott at 2020-06-30T07:10:42-04:00 Reject nested foralls/contexts in instance types more consistently GHC is very wishy-washy about rejecting instance declarations with nested `forall`s or contexts that are surrounded by outermost parentheses. This can even lead to some strange interactions with `ScopedTypeVariables`, as demonstrated in #18240. This patch makes GHC more consistently reject instance types with nested `forall`s/contexts so as to prevent these strange interactions. On the implementation side, this patch tweaks `splitLHsInstDeclTy` and `getLHsInstDeclHead` to not look through parentheses, which can be semantically significant. I've added a `Note [No nested foralls or contexts in instance types]` in `GHC.Hs.Type` to explain why. This also introduces a `no_nested_foralls_contexts_err` function in `GHC.Rename.HsType` to catch nested `forall`s/contexts in instance types. This function is now used in `rnClsInstDecl` (for ordinary instance declarations) and `rnSrcDerivDecl` (for standalone `deriving` declarations), the latter of which fixes #18271. On the documentation side, this adds a new "Formal syntax for instance declaration types" section to the GHC User's Guide that presents a BNF-style grammar for what is and isn't allowed in instance types. Fixes #18240. Fixes #18271. - - - - - bccf3351 by Sylvain Henry at 2020-06-30T07:10:46-04:00 Add ghc-bignum to 8.12 release notes - - - - - 81704a6f by David Eichmann at 2020-06-30T07:10:48-04:00 Update ssh keys in CI performance metrics upload script - - - - - 85310fb8 by Joshua Price at 2020-06-30T07:10:49-04:00 Add missing Ix instances for tuples of size 6 through 15 (#16643) - - - - - cbb6b62f by Vladislav Zavialov at 2020-07-01T15:41:38-04:00 Implement -XLexicalNegation (GHC Proposal #229) This patch introduces a new extension, -XLexicalNegation, which detects whether the minus sign stands for negation or subtraction using the whitespace-based rules described in GHC Proposal #229. Updates haddock submodule. - - - - - fb5a0d01 by Martin Handley at 2020-07-01T15:42:14-04:00 #17169: Clarify Fixed's Enum instance. - - - - - b316804d by Simon Peyton Jones at 2020-07-01T15:42:49-04:00 Improve debug tracing for substitution This patch improves debug tracing a bit (#18395) * Remove the ancient SDoc argument to substitution, replacing it with a HasDebugCallStack constraint. The latter does the same job (indicate the call site) but much better. * Add HasDebugCallStack to simpleOptExpr, exprIsConApp_maybe I needed this to help nail the lookupIdSubst panic in #18326, #17784 - - - - - 5c9fabb8 by Hécate at 2020-07-01T15:43:25-04:00 Add most common return values for `os` and `arch` - - - - - 76d8cc74 by Ryan Scott at 2020-07-01T15:44:01-04:00 Desugar quoted uses of DerivingVia and expression type signatures properly The way that `GHC.HsToCore.Quote` desugared quoted `via` types (e.g., `deriving via forall a. [a] instance Eq a => Eq (List a)`) and explicit type annotations in signatures (e.g., `f = id @a :: forall a. a -> a`) was completely wrong, as it did not implement the scoping guidelines laid out in `Note [Scoped type variables in bindings]`. This is easily fixed. While I was in town, I did some minor cleanup of related Notes: * `Note [Scoped type variables in bindings]` and `Note [Scoped type variables in class and instance declarations]` say very nearly the same thing. I decided to just consolidate the two Notes into `Note [Scoped type variables in quotes]`. * `Note [Don't quantify implicit type variables in quotes]` is somewhat outdated, as it predates GHC 8.10, where the `forall`-or-nothing rule requires kind variables to be explicitly quantified in the presence of an explicit `forall`. As a result, the running example in that Note doesn't even compile. I have changed the example to something simpler that illustrates the same point that the original Note was making. Fixes #18388. - - - - - 44d6a335 by Andreas Klebinger at 2020-07-02T02:54:54-04:00 T16012: Be verbose on failure. - - - - - f9853330 by Ryan Scott at 2020-07-02T02:55:29-04:00 Bump ghc-prim version to 0.7.0 Fixes #18279. Bumps the `text` submodule. - - - - - 23e4e047 by Sylvain Henry at 2020-07-02T10:46:31-04:00 Hadrian: fix PowerPC64le support (#17601) [ci skip] - - - - - 3cdd8d69 by Sylvain Henry at 2020-07-02T10:47:08-04:00 NCG: correctly handle addresses with huge offsets (#15570) Before this patch we could generate addresses of this form: movzbl cP0_str+-9223372036854775808,%eax The linker can't handle them because the offset is too large: ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647] With this patch we detect those cases and generate: movq $-9223372036854775808,%rax addq $cP0_str,%rax movzbl (%rax),%eax I've also refactored `getAmode` a little bit to make it easier to understand and to trace. - - - - - 4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00 No need for CURSES_INCLUDE_DIRS This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88 - - - - - f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00 Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function SCC profiling was enabled in a convoluted way: if WayProf was enabled, Opt_SccProfilingOn general flag was set (in `GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in various places. There is no need to go via general flags, so this patch defines a `sccProfilingEnabled :: DynFlags -> Bool` helper function that just checks whether WayProf is enabled. - - - - - 8cc7274b by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Only allocate the Censuses that we need When not LDV profiling there is no reason to allocate 32 Censuses; one will do. This is a very small memory footprint optimisation, but it comes for free. - - - - - b835112c by Ben Gamari at 2020-07-03T02:49:27-04:00 rts/ProfHeap: Free old allocations when reinitialising Censuses Previously when not LDV profiling we would repeatedly reinitialise `censuses[0]` with `initEra`. This failed to free the `Arena` and `HashTable` from the old census, resulting in a memory leak. Fixes #18348. - - - - - 34be6523 by Valery Tolstov at 2020-07-03T02:50:03-04:00 Mention flags that are not enabled by -Wall (#18372) * Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst) * Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8 - - - - - edc8d22b by Sylvain Henry at 2020-07-03T02:50:40-04:00 LLVM: support R9 and R10 registers d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10 vanilla registers but didn't update LLVM backend to support them. This patch fixes it. - - - - - 4bf18646 by Simon Peyton Jones at 2020-07-03T08:37:42+01:00 Improve handling of data type return kinds Following a long conversation with Richard, this patch tidies up the handling of return kinds for data/newtype declarations (vanilla, family, and instance). I have substantially edited the Notes in TyCl, so they would bear careful reading. Fixes #18300, #18357 In GHC.Tc.Instance.Family.newFamInst we were checking some Lint-like properties with ASSSERT. Instead Richard and I have added a proper linter for axioms, and called it from lintGblEnv, which in turn is called in tcRnModuleTcRnM New tests (T18300, T18357) cause an ASSERT failure in HEAD. - - - - - 41d26492 by Sylvain Henry at 2020-07-03T17:33:59-04:00 DynFlags: avoid the use of sdocWithDynFlags in GHC.Core.Rules (#17957) - - - - - 7aa6ef11 by Hécate at 2020-07-03T17:34:36-04:00 Add the __GHC_FULL_VERSION__ CPP macro to expose the full GHC version - - - - - e61d5395 by Chaitanya Koparkar at 2020-07-07T13:55:59-04:00 ghc-prim: Turn some comments into haddocks [ci skip] - - - - - 37743f91 by John Ericson at 2020-07-07T13:56:00-04:00 Support `timesInt2#` in LLVM backend - - - - - 46397e53 by John Ericson at 2020-07-07T13:56:00-04:00 `genericIntMul2Op`: Call `genericWordMul2Op` directly This unblocks a refactor, and removes partiality. It might be a PowerPC regression but that should be fixable. - - - - - 8a1c0584 by John Ericson at 2020-07-07T13:56:00-04:00 Simplify `PrimopCmmEmit` Follow @simonpj's suggestion of pushing the "into regs" logic into `emitPrimOp`. With the previous commit getting rid of the recursion in `genericIntMul2Op`, this is now an easy refactor. - - - - - 6607f203 by John Ericson at 2020-07-07T13:56:00-04:00 `opAllDone` -> `opIntoRegs` The old name was and terrible and became worse after the previous commit's refactor moved non-trivial funcationlity into its body. - - - - - fdcc53ba by Sylvain Henry at 2020-07-07T13:56:00-04:00 Optimise genericIntMul2Op We shouldn't directly call 'genericWordMul2Op' in genericIntMul2Op because a target may provide a faster primop for 'WordMul2Op': we'd better use it! - - - - - 686e7225 by Moritz Angermann at 2020-07-07T13:56:01-04:00 [linker/rtsSymbols] More linker symbols Mostly symbols needed for aarch64/armv7l and in combination with musl, where we have to rely on loading *all* objects/archives - __stack_chk_* only when not DYNAMIC - - - - - 3f60b94d by Moritz Angermann at 2020-07-07T13:56:01-04:00 better if guards. - - - - - 7abffced by Moritz Angermann at 2020-07-07T13:56:01-04:00 Fix (1) - - - - - cdfeb3f2 by Moritz Angermann at 2020-07-07T13:56:01-04:00 AArch32 symbols only on aarch32. - - - - - f496c955 by Adam Sandberg Ericsson at 2020-07-07T13:56:02-04:00 add -flink-rts flag to link the rts when linking a shared or static library #18072 By default we don't link the RTS when linking shared libraries because in the most usual mode a shared library is an intermediary product, for example a Haskell library, that will be linked into some executable in the end. So we wish to defer the RTS flavour to link to the final link. However sometimes the final product is the shared library, for example when writing a plugin for some other system, so we do wish the shared library to link the RTS. For consistency we also make -staticlib honor this flag and its inversion. -staticlib currently implies -flink-shared. - - - - - c59faf67 by Stefan Schulze Frielinghaus at 2020-07-07T13:56:04-04:00 hadrian: link check-ppr against debugging RTS if ghcDebugged - - - - - 0effc57d by Adam Sandberg Ericsson at 2020-07-07T13:56:05-04:00 rts linker: teach the linker about GLIBC's special handling of *stat, mknod and atexit functions #7072 - - - - - 96153433 by Adam Sandberg Ericsson at 2020-07-07T13:56:06-04:00 hadrian: make hadrian/ghci use the bootstrap compiler from configure #18190 - - - - - 4d24f886 by Adam Sandberg Ericsson at 2020-07-07T13:56:07-04:00 hadrian: ignore cabal configure verbosity related flags #18131 - - - - - 7332bbff by Ben Gamari at 2020-07-07T13:56:08-04:00 testsuite: Widen T12234 acceptance window to 2% Previously it wasn't uncommon to see +/-1% fluctuations in compiler allocations on this test. - - - - - 180b6313 by Gabor Greif at 2020-07-07T13:56:08-04:00 When running libtool, report it as such - - - - - d3bd6897 by Sylvain Henry at 2020-07-07T13:56:11-04:00 BigNum: rename BigNat types Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this. - - - - - 929d26db by Sylvain Henry at 2020-07-07T13:56:12-04:00 Bignum: don't build ghc-bignum with stage0 Noticed by @Ericson2314 - - - - - d25b6851 by Sylvain Henry at 2020-07-07T13:56:12-04:00 Hadrian: ghc-gmp.h shouldn't be a compiler dependency - - - - - 0ddae2ba by Sylvain Henry at 2020-07-07T13:56:14-04:00 DynFlags: factor out pprUnitId from "Outputable UnitId" instance - - - - - 204f3f5d by Krzysztof Gogolewski at 2020-07-07T13:56:18-04:00 Remove unused function pprHsForAllExtra (#18423) The function `pprHsForAllExtra` was called only on `Nothing` since 2015 (1e041b7382b6aa). - - - - - 3033e0e4 by Adam Sandberg Ericsson at 2020-07-08T20:36:49-04:00 hadrian: add flag to skip rebuilding dependency information #17636 - - - - - b7de4b96 by Stefan Schulze Frielinghaus at 2020-07-09T09:49:22-04:00 Fix GHCi :print on big-endian platforms On big-endian platforms executing import GHC.Exts data Foo = Foo Float# deriving Show foo = Foo 42.0# foo :print foo results in an arithmetic overflow exception which is caused by function index where moveBytes equals word_size - (r + item_size_b) * 8 Here we have a mixture of units. Both, word_size and item_size_b have unit bytes whereas r has unit bits. On 64-bit platforms moveBytes equals then 8 - (0 + 4) * 8 which results in a negative and therefore invalid second parameter for a shiftL operation. In order to make things more clear the expression (word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes is equivalent to (word `shiftR` moveBytes) .&. mask On big-endian platforms the shift must be a left shift instead of a right shift. For symmetry reasons not a mask is used but two shifts in order to zero out bits. Thus the fixed version equals case endian of BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits Fixes #16548 and #14455 - - - - - 3656dff8 by Sylvain Henry at 2020-07-09T09:50:01-04:00 LLVM: fix MO_S_Mul2 support (#18434) The value indicating if the carry is useful wasn't taken into account. - - - - - d9f09506 by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Define multiShotIO and use it in mkSplitUniqueSupply This patch is part of the ongoing eta-expansion saga; see #18238. It implements a neat trick (suggested by Sebastian Graf) that allows the programmer to disable the default one-shot behaviour of IO (the "state hack"). The trick is to use a new multiShotIO function; see Note [multiShotIO]. For now, multiShotIO is defined here in Unique.Supply; but it should ultimately be moved to the IO library. The change is necessary to get good code for GHC's unique supply; see Note [Optimising the unique supply]. However it makes no difference to GHC as-is. Rather, it makes a difference when a subsequent commit Improve eta-expansion using ArityType lands. - - - - - bce695cc by Simon Peyton Jones at 2020-07-10T10:33:44-04:00 Make arityType deal with join points As Note [Eta-expansion and join points] describes, this patch makes arityType deal correctly with join points. What was there before was not wrong, but yielded lower arities than it could. Fixes #18328 In base GHC this makes no difference to nofib. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- n-body -0.1% -0.1% -1.2% -1.1% 0.0% -------------------------------------------------------------------------------- Min -0.1% -0.1% -55.0% -56.5% 0.0% Max -0.0% 0.0% +16.1% +13.4% 0.0% Geometric Mean -0.0% -0.0% -30.1% -31.0% -0.0% But it starts to make real difference when we land the change to the way mkDupableAlts handles StrictArg, in fixing #13253 and friends. I think this is because we then get more non-inlined join points. - - - - - 2b7c71cb by Simon Peyton Jones at 2020-07-11T12:17:02-04:00 Improve eta-expansion using ArityType As #18355 shows, we were failing to preserve one-shot info when eta-expanding. It's rather easy to fix, by using ArityType more, rather than just Arity. This patch is important to suport the one-shot monad trick; see #18202. But the extra tracking of one-shot-ness requires the patch Define multiShotIO and use it in mkSplitUniqueSupply If that patch is missing, ths patch makes things worse in GHC.Types.Uniq.Supply. With it, however, we see these improvements T3064 compiler bytes allocated -2.2% T3294 compiler bytes allocated -1.3% T12707 compiler bytes allocated -1.3% T13056 compiler bytes allocated -2.2% Metric Decrease: T3064 T3294 T12707 T13056 - - - - - de139cc4 by Artem Pelenitsyn at 2020-07-12T02:53:20-04:00 add reproducer for #15630 - - - - - c4de6a7a by Andreas Klebinger at 2020-07-12T02:53:55-04:00 Give Uniq[D]FM a phantom type for its key. This fixes #17667 and should help to avoid such issues going forward. The changes are mostly mechanical in nature. With two notable exceptions. * The register allocator. The register allocator references registers by distinct uniques. However they come from the types of VirtualReg, Reg or Unique in various places. As a result we sometimes cast the key type of the map and use functions which operate on the now typed map but take a raw Unique as actual key. The logic itself has not changed it just becomes obvious where we do so now. * <Type>Env Modules. As an example a ClassEnv is currently queried using the types `Class`, `Name`, and `TyCon`. This is safe since for a distinct class value all these expressions give the same unique. getUnique cls getUnique (classTyCon cls) getUnique (className cls) getUnique (tcName $ classTyCon cls) This is for the most part contained within the modules defining the interface. However it requires us to play dirty when we are given a `Name` to lookup in a `UniqFM Class a` map. But again the logic did not change and it's for the most part hidden behind the Env Module. Some of these cases could be avoided by refactoring but this is left for future work. We also bump the haddock submodule as it uses UniqFM. - - - - - c2cfdfde by Aaron Allen at 2020-07-13T09:00:33-04:00 Warn about empty Char enumerations (#18402) Currently the "Enumeration is empty" warning (-Wempty-enumerations) only fires for numeric literals. This patch adds support for `Char` literals so that enumerating an empty list of `Char`s will also trigger the warning. - - - - - c3ac87ec by Stefan Schulze Frielinghaus at 2020-07-13T09:01:10-04:00 hadrian: build check-ppr dynamic if GHC is build dynamic Fixes #18361 - - - - - 9ad072b4 by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Use dumpStyle when printing inlinings This just makes debug-printing consistent, and more informative. - - - - - e78c4efb by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Comments only - - - - - 7ccb760b by Simon Peyton Jones at 2020-07-13T14:52:49-04:00 Reduce result discount in conSize Ticket #18282 showed that the result discount given by conSize was massively too large. This patch reduces that discount to a constant 10, which just balances the cost of the constructor application itself. Note [Constructor size and result discount] elaborates, as does the ticket #18282. Reducing result discount reduces inlining, which affects perf. I found that I could increase the unfoldingUseThrehold from 80 to 90 in compensation; in combination with the result discount change I get these overall nofib numbers: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- boyer -0.2% +5.4% -3.2% -3.4% 0.0% cichelli -0.1% +5.9% -11.2% -11.7% 0.0% compress2 -0.2% +9.6% -6.0% -6.8% 0.0% cryptarithm2 -0.1% -3.9% -6.0% -5.7% 0.0% gamteb -0.2% +2.6% -13.8% -14.4% 0.0% genfft -0.1% -1.6% -29.5% -29.9% 0.0% gg -0.0% -2.2% -17.2% -17.8% -20.0% life -0.1% -2.2% -62.3% -63.4% 0.0% mate +0.0% +1.4% -5.1% -5.1% -14.3% parser -0.2% -2.1% +7.4% +6.7% 0.0% primetest -0.2% -12.8% -14.3% -14.2% 0.0% puzzle -0.2% +2.1% -10.0% -10.4% 0.0% rsa -0.2% -11.7% -3.7% -3.8% 0.0% simple -0.2% +2.8% -36.7% -38.3% -2.2% wheel-sieve2 -0.1% -19.2% -48.8% -49.2% -42.9% -------------------------------------------------------------------------------- Min -0.4% -19.2% -62.3% -63.4% -42.9% Max +0.3% +9.6% +7.4% +11.0% +16.7% Geometric Mean -0.1% -0.3% -17.6% -18.0% -0.7% I'm ok with these numbers, remembering that this change removes an *exponential* increase in code size in some in-the-wild cases. I investigated compress2. The difference is entirely caused by this function no longer inlining WriteRoutines.$woutputCodes = \ (w :: [CodeEvent]) -> let result_s1Sr = case WriteRoutines.outputCodes_$s$woutput w 0# 0# 8# 9# of (# ww1, ww2 #) -> (ww1, ww2) in (# case result_s1Sr of (x, _) -> map @Int @Char WriteRoutines.outputCodes1 x , case result_s1Sr of { (_, y) -> y } #) It was right on the cusp before, driven by the excessive result discount. Too bad! Happily, the compiler/perf tests show a number of improvements: T12227 compiler bytes-alloc -6.6% T12545 compiler bytes-alloc -4.7% T13056 compiler bytes-alloc -3.3% T15263 runtime bytes-alloc -13.1% T17499 runtime bytes-alloc -14.3% T3294 compiler bytes-alloc -1.1% T5030 compiler bytes-alloc -11.7% T9872a compiler bytes-alloc -2.0% T9872b compiler bytes-alloc -1.2% T9872c compiler bytes-alloc -1.5% Metric Decrease: T12227 T12545 T13056 T15263 T17499 T3294 T5030 T9872a T9872b T9872c - - - - - 7f0b671e by Ben Gamari at 2020-07-13T14:52:49-04:00 testsuite: Widen acceptance threshold on T5837 This test is positively tiny and consequently the bytes allocated measurement will be relatively noisy. Consequently I have seen this fail spuriously quite often. - - - - - 118e1c3d by Alp Mestanogullari at 2020-07-14T21:30:52-04:00 compiler: re-engineer the treatment of rebindable if Executing on the plan described in #17582, this patch changes the way if expressions are handled in the compiler in the presence of rebindable syntax. We get rid of the SyntaxExpr field of HsIf and instead, when rebindable syntax is on, we rewrite the HsIf node to the appropriate sequence of applications of the local `ifThenElse` function. In order to be able to report good error messages, with expressions as they were written by the user (and not as desugared by the renamer), we make use of TTG extensions to extend GhcRn expression ASTs with an `HsExpansion` construct, which keeps track of a source (GhcPs) expression and the desugared (GhcRn) expression that it gives rise to. This way, we can typecheck the latter while reporting the former in error messages. In order to discard the error context lines that arise from typechecking the desugared expressions (because they talk about expressions that the user has not written), we carefully give a special treatment to the nodes fabricated by this new renaming-time transformation when typechecking them. See Note [Rebindable syntax and HsExpansion] for more details. The note also includes a recipe to apply the same treatment to other rebindable constructs. Tests 'rebindable11' and 'rebindable12' have been added to make sure we report identical error messages as before this patch under various circumstances. We also now disable rebindable syntax when processing untyped TH quotes, as per the discussion in #18102 and document the interaction of rebindable syntax and Template Haskell, both in Note [Template Haskell quotes and Rebindable Syntax] and in the user guide, adding a test to make sure that we do not regress in that regard. - - - - - 64c774b0 by Andreas Klebinger at 2020-07-14T21:31:27-04:00 Explain why keeping DynFlags in AnalEnv saves allocation. - - - - - 254245d0 by Ben Gamari at 2020-07-14T21:32:03-04:00 docs/users-guide: Update default -funfolding-use-threshold value This was changed in 3d2991f8 but I neglected to update the documentation. Fixes #18419. - - - - - 4c259f86 by Andreas Klebinger at 2020-07-14T21:32:41-04:00 Escape backslashes in json profiling reports properly. I also took the liberty to do away the fixed buffer size for escaping. Using a fixed size here can only lead to issues down the line. Fixes #18438. - - - - - 23797224 by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 .gitlab: re-enable integer-simple substitute (BIGNUM_BACKEND) Recently build system migrated from INTEGER_LIBRARY to BIGNUM_BACKEND. But gitlab CI was never updated. Let's enable BIGNUM_BACKEND=native. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - e0db878a by Sergei Trofimovich at 2020-07-14T21:33:19-04:00 ghc-bignum: bring in sync .hs-boot files with module declarations Before this change `BIGNUM_BACKEND=native` build was failing as: ``` libraries/ghc-bignum/src/GHC/Num/BigNat/Native.hs:708:16: error: * Variable not in scope: naturalFromBigNat# :: WordArray# -> t * Perhaps you meant one of these: `naturalFromBigNat' (imported from GHC.Num.Natural), `naturalToBigNat' (imported from GHC.Num.Natural) | 708 | m' = naturalFromBigNat# m | ``` This happens because `.hs-boot` files are slightly out of date. This change brings in data and function types in sync. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - c9f65c36 by Stefan Schulze Frielinghaus at 2020-07-14T21:33:57-04:00 rts/Disassembler.c: Use FMT_HexWord for printing values in hex format - - - - - 58ae62eb by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 macOS: Load frameworks without stating them first. macOS Big Sur makes the following change to how frameworks are shipped with the OS: > New in macOS Big Sur 11 beta, the system ships with a built-in > dynamic linker cache of all system-provided libraries. As part of > this change, copies of dynamic libraries are no longer present on > the filesystem. Code that attempts to check for dynamic library > presence by looking for a file at a path or enumerating a directory > will fail. Instead, check for library presence by attempting to > dlopen() the path, which will correctly check for the library in the > cache. (62986286) https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes/ Therefore, the previous method of checking whether a library exists before attempting to load it makes GHC.Runtime.Linker.loadFramework fail to find frameworks installed at /System/Library/Frameworks. GHC.Runtime.Linker.loadFramework now opportunistically loads the framework libraries without checking for their existence first, failing only if all attempts to load a given framework from any of the various possible locations fail. - - - - - cdc4a6b0 by Matthias Andreas Benkard at 2020-07-14T21:34:35-04:00 loadFramework: Output the errors collected in all loading attempts. With the recent change away from first finding and then loading a framework, loadFramework had no way of communicating the real reason why loadDLL failed if it was any reason other than the framework missing from the file system. It now collects all loading attempt errors into a list and concatenates them into a string to return to the caller. - - - - - 51dbfa52 by Ben Gamari at 2020-07-15T04:05:34-04:00 StgToCmm: Use CmmRegOff smart constructor Previously we would generate expressions of the form `CmmRegOff BaseReg 0`. This should do no harm (and really should be handled by the NCG anyways) but it's better to just generate a plain `CmmReg`. - - - - - ae11bdfd by Ben Gamari at 2020-07-15T04:06:08-04:00 testsuite: Add regression test for #17744 Test due to @monoidal. - - - - - 0e3c277a by Ben Gamari at 2020-07-15T16:41:01-04:00 Bump Cabal submodule Updates a variety of tests as Cabal is now more strict about Cabal file form. - - - - - ceed994a by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Drop Windows Vista support, require Windows 7 - - - - - 00a23bfd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Update Windows FileSystem wrapper utilities. - - - - - 459e1c5f by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Use SlimReaderLocks and ConditonalVariables provided by the OS instead of emulated ones - - - - - 763088fc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Small linker comment and ifdef cleanups - - - - - 1a228ff9 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Flush event logs eagerly. - - - - - e9e04dda by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Refactor Buffer structures to be able to track async operations - - - - - 356dc3fe by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Implement new Console API - - - - - 90e69f77 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add IOPort synchronization primitive - - - - - 71245fcc by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add new io-manager cmdline options - - - - - d548a3b3 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Init Windows console Codepage to UTF-8. - - - - - 58ef6366 by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add unsafeSplat to GHC.Event.Array - - - - - d660725e by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Add size and iterate to GHC.Event.IntTable. - - - - - 050da6dd by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Switch Testsuite to test winio by default - - - - - 4bf542bf by Tamar Christina at 2020-07-15T16:41:01-04:00 winio: Multiple refactorings and support changes. - - - - - 4489af6b by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core threaded I/O manager - - - - - 64d8f2fe by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: core non-threaded I/O manager - - - - - 8da15a09 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix a scheduler bug with the threaded-runtime. - - - - - 84ea3d14 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Relaxing some constraints in io-manager. - - - - - ccf0d107 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Fix issues with non-threaded I/O manager after split. - - - - - b492fe6e by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Remove some barf statements that are a bit strict. - - - - - 01423fd2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Expand comments describing non-threaded loop - - - - - 4b69004f by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: fix FileSize unstat-able handles - - - - - 9b384270 by Tamar Christina at 2020-07-15T16:41:02-04:00 winio: Implement new tempfile routines for winio - - - - - f1e0be82 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix input truncation when reading from handle. This was caused by not upholding the read buffer invariant that bufR == bufL == 0 for empty read buffers. - - - - - e176b625 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix output truncation for writes larger than buffer size - - - - - a831ce0e by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Rewrite bufWrite. I think it's far easier to follow the code now. It's also correct now as I had still missed a spot where we didn't update the offset. - - - - - 6aefdf62 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix offset set by bufReadEmpty. bufReadEmpty returns the bytes read *including* content that was already buffered, But for calculating the offset we only care about the number of bytes read into the new buffer. - - - - - 750ebaee by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Clean up code surrounding IOPort primitives. According to phyx these should only be read and written once per object. Not neccesarily in that order. To strengthen that guarantee the primitives will now throw an exception if we violate this invariant. As a consequence we can eliminate some code from their primops. In particular code dealing with multiple queued readers/writers now simply checks the invariant and throws an exception if it was violated. That is in contrast to mvars which will do things like wake up all readers, queue multi writers etc. - - - - - ffd31db9 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix multi threaded threadDelay and a few other small changes. Multithreaded threadDelay suffered from a race condition based on the ioManagerStatus. Since the status isn't needed for WIO I removed it completely. This resulted in a light refactoring, as consequence we will always wake up the IO manager using interruptSystemManager, which uses `postQueuedCompletionStatus` internally. I also added a few comments which hopefully makes the code easier to dive into for the next person diving in. - - - - - 6ec26df2 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 wionio: Make IO subsystem check a no-op on non-windows platforms. - - - - - 29bcd936 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Set handle offset when opening files in Append mode. Otherwise we would truncate the file. - - - - - 55c29700 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Remove debug event log trace - - - - - 9acb9f40 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix sqrt and openFile009 test cases - - - - - 57017cb7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Allow hp2ps to build with -DDEBUG - - - - - b8cd9995 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update output of T9681 since we now actually run it. - - - - - 10af5b14 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: A few more improvements to the IOPort primitives. - - - - - 39afc4a7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix expected tempfiles output. Tempfiles now works properly on windows, as such we can delete the win32 specific output. - - - - - 99db46e0 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Assign thread labels to IOManager threads. - - - - - be6af732 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Properly check for the tso of an incall to be zero. - - - - - e2c6dac7 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark FD instances as unsupported under WINIO. - - - - - fd02ceed by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Fix threadDelay maxBound invocations. Instead of letting the ns timer overflow now clamp it at (maxBound :: Word64) ns. That still gives a few hundred years. - - - - - bc79f9f1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comments/cleanup an import in base - - - - - 1d197f4b by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Mark outstanding_service_requests volatile. As far as I know C(99) gives no guarantees for code like bool condition; ... while(condition) sleep(); that condition will be updated if it's changed by another thread. So we are explicit here and mark it as volatile, this will force a reload from memory on each iteration. - - - - - dc438186 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Make last_event a local variable - - - - - 2fc957c5 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add comment about thread safety of processCompletion. - - - - - 4c026b6c by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: nonthreaded: Create io processing threads in main thread. We now set a flag in the IO thread. The scheduler when looking for work will check the flag and create/queue threads accordingly. We used to create these in the IO thread. This improved performance but caused frequent segfaults. Thread creation/allocation is only safe to do if nothing currently accesses the storeagemanager. However without locks in the non-threaded runtime this can't be guaranteed. This shouldn't change performance all too much. In the past we had: * IO: Create/Queue thread. * Scheduler: Runs a few times. Eventually picks up IO processing thread. Now it's: * IO: Set flag to queue thread. * Scheduler: Pick up flag, if set create/queue thread. Eventually picks up IO processing thread. - - - - - f47c7208 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Add an exported isHeapAlloced function to the RTS - - - - - cc5d7bb1 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Queue IO processing threads at the front of the queue. This will unblock the IO thread sooner hopefully leading to higher throughput in some situations. - - - - - e7630115 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: ThreadDelay001: Use higher resolution timer. - - - - - 451b5f96 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Update T9681 output, disable T4808 on windows. T4808 tests functionality of the FD interface which won't be supported under WINIO. T9681 just has it's expected output tweaked. - - - - - dd06f930 by Andreas Klebinger at 2020-07-15T16:41:02-04:00 winio: Wake io manager once per registerTimeout. Which is implicitly done in editTimeouts, so need to wake it up twice. - - - - - e87d0bf9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update placeholder comment with actual function name. - - - - - fc9025db by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Always lock win32 event queue - - - - - c24c9a1f by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Display thread labels when tracing scheduler events. - - - - - 06542b03 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Refactor non-threaded runner thread and scheduler interface. Only use a single communication point (registerAlertableWait) to inform the C side aobut both timeouts to use as well as outstanding requests. Also queue a haskell processing thread after each return from alertable waits. This way there is no risk of us missing a timer event. - - - - - 256299b1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove outstanding_requests from runner. We used a variable to keep track of situations where we got entries from the IO port, but all of them had already been canceled. While we can avoid some work that way this case seems quite rare. So we give up on tracking this and instead always assume at least one of the returned entries is valid. If that's not the case no harm is done, we just perform some additional work. But it makes the runner easier to reason about. In particular we don't need to care if another thread modifies oustanding_requests after we return from waiting on the IO Port. - - - - - 3ebd8ad9 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Various fixes related to rebase and testdriver - - - - - 6be6bcba by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: Fix rebase artifacts - - - - - 2c649dc3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename unsafeSplat to unsafeCopyFromBuffer - - - - - a18b73f3 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove unused size/iterate operations from IntTable - - - - - 16bab48e by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Detect running IO Backend via peeking at RtsConfig - - - - - 8b8405a0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update temp path so GCC etc can handle it. Also fix PIPE support, clean up error casting, fix memory leaks - - - - - 2092bc54 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Minor comments/renamings - - - - - a5b5b6c0 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Checking if an error code indicates completion is now a function. - - - - - 362176fd by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Small refactor in withOverlappedEx - - - - - 32e20597 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: A few comments and commented out dbxIO - - - - - a4bfc1d9 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't drop buffer offset in byteView/cwcharView - - - - - b3ad2a54 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: revert BHandle changes. - - - - - 3dcd87e2 by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Fix imports - - - - - 5a371890 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: update ghc-cabal to handle new Cabal submodule bump - - - - - d07ebe0d by Ben Gamari at 2020-07-15T16:41:03-04:00 winio: Only compile sources on Windows - - - - - dcb42393 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Actually return Nothing on EOF for non-blocking read - - - - - 895a3beb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate logic in encodeMultiByte[Raw]IO. - - - - - e06e6734 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Deduplicate openFile logic - - - - - b59430c0 by Tamar Christina at 2020-07-15T16:41:03-04:00 winio: fix -werror issue in encoding file - - - - - f8d39a51 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Don't mention windows specific functions when building on Linux. - - - - - 6a533d2a by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add a note about file locking in the RTS. - - - - - cf37ce34 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Add version to @since annotation - - - - - 0fafa2eb by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename GHC.Conc.IOCP -> GHC.Conc.WinIO - - - - - 1854fc23 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Expand GHC.Conc.POSIX description It now explains users may not use these functions when using the old IO manager. - - - - - fcc7ba41 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Fix potential spaceleak in __createUUIDTempFileErrNo - - - - - 6b3fd9fa by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant -Wno-missing-signatures pragmas - - - - - 916fc861 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Make it explicit that we only create one IO manager - - - - - f260a721 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Note why we don't use blocking waits. - - - - - aa0a4bbf by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove commented out pragma - - - - - d679b544 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Remove redundant buffer write in Handle/Text.hs:bufReadEmpty - - - - - d3f94368 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Rename SmartHandles to StdHandles - - - - - bd6b8ec1 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: add comment stating failure behaviour for getUniqueFileInfo. - - - - - 12846b85 by Andreas Klebinger at 2020-07-15T16:41:03-04:00 winio: Update IOPort haddocks. - - - - - 9f39fb14 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Add a note cross reference - - - - - 62dd5a73 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Name Haskell/OS I/O Manager explicitly in Note - - - - - fa807828 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Expand BlockedOnIOCompletion description. - - - - - f0880a1d by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove historical todos - - - - - 8e58e714 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Update note, remove debugging pragma. - - - - - aa4d84d5 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: flushCharReadBuffer shouldn't need to adjust offsets. - - - - - e580893a by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Remove obsolete comment about cond. variables - - - - - d54e9d79 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix initial linux validate build - - - - - 3cd4de46 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix ThreadDelay001 CPP - - - - - c88b1b9f by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix openFile009 merge conflict leftover - - - - - 849e8889 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept T9681 output. GHC now reports String instead of [Char]. - - - - - e7701818 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix cabal006 after upgrading cabal submodule Demand cabal 2.0 syntax instead of >= 1.20 as required by newer cabal versions. - - - - - a44f0373 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Fix stderr output for ghci/linking/dyn tests. We used to filter rtsopts, i opted to instead just accept the warning of it having no effect. This works both for -rtsopts, as well as -with-rtsopts which winio adds. - - - - - 515d9896 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T15261b stdout for --io-manager flag. - - - - - 949aaacc by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Adjust T5435_dyn_asm stderr The warning about rtsopts having no consequences is expected. So accept new stderr. - - - - - 7d424e1e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Also accept T7037 stderr - - - - - 1f009768 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal04 by filtering rts args - - - - - 981a9f2e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix cabal01 by accepting expected stderr - - - - - b7b0464e by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix safePkg01 by accepting expected stderr - - - - - 32734b29 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix T5435_dyn_gcc by accepting expected stderr - - - - - acc5cebf by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: fix tempfiles test on linux - - - - - c577b789 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for T3807 - - - - - c108c527 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload - - - - - 2b0b9a08 by Andreas Klebinger at 2020-07-15T16:41:04-04:00 winio: Accept accepted stderr for linker_unload_multiple_objs - - - - - 67afb03c by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify wording on conditional variables. - - - - - 3bd41572 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: clarify comment on cooked mode. - - - - - ded58a03 by Tamar Christina at 2020-07-15T16:41:04-04:00 winio: update lockfile signature and remove mistaken symbol in rts. - - - - - 2143c492 by Ben Gamari at 2020-07-15T16:41:04-04:00 testsuite: Add winio and winio_threaded ways Reverts many of the testsuite changes - - - - - c0979cc5 by Ben Gamari at 2020-07-16T10:56:54-04:00 Merge remote-tracking branch 'origin/wip/winio' - - - - - 750a1595 by Ben Gamari at 2020-07-18T07:26:41-04:00 rts: Add --copying-gc flag to reverse effect of --nonmoving-gc Fixes #18281. - - - - - 6ba6a881 by Hécate at 2020-07-18T07:26:42-04:00 Implement `fullCompilerVersion` Follow-up of https://gitlab.haskell.org/ghc/ghc/-/issues/18403 This MR adds `fullCompilerVersion`, a function that shares the same backend as the `--numeric-version` GHC flag, exposing a full, three-digit version datatype. - - - - - e6cf27df by Hécate at 2020-07-18T07:26:43-04:00 Add a Lint hadrian rule and an .hlint.yaml file in base/ - - - - - bcb177dd by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Allow multiple case branches to have a higher rank type As #18412 points out, it should be OK for multiple case alternatives to have a higher rank type, provided they are all the same. This patch implements that change. It sweeps away GHC.Tc.Gen.Match.tauifyMultipleBranches, and friends, replacing it with an enhanced version of fillInferResult. The basic change to fillInferResult is to permit the case in which another case alternative has already filled in the result; and in that case simply unify. It's very simple actually. See the new Note [fillInferResult] in TcMType Other refactoring: - Move all the InferResult code to one place, in GHC.Tc.Utils.TcMType (previously some of it was in Unify) - Move tcInstType and friends from TcMType to Instantiate, where it more properly belongs. (TCMType was getting very long.) - - - - - e5525a51 by Simon Peyton Jones at 2020-07-18T07:26:43-04:00 Improve typechecking of NPlusK patterns This patch (due to Richard Eisenberg) improves documentation of the wrapper returned by tcSubMult (see Note [Wrapper returned from tcSubMult] in GHC.Tc.Utils.Unify). And, more substantially, it cleans up the multiplicity handling in the typechecking of NPlusKPat - - - - - 12f90352 by Krzysztof Gogolewski at 2020-07-18T07:26:45-04:00 Remove {-# CORE #-} pragma (part of #18048) This pragma has no effect since 2011. It was introduced for External Core, which no longer exists. Updates haddock submodule. - - - - - e504c913 by Simon Peyton Jones at 2020-07-18T07:26:45-04:00 Refactor the simplification of join binders This MR (for #18449) refactors the Simplifier's treatment of join-point binders. Specifically, it puts together, into GHC.Core.Opt.Simplify.Env.adjustJoinPointType two currently-separate ways in which we adjust the type of a join point. As the comment says: -- (adjustJoinPointType mult new_res_ty join_id) does two things: -- -- 1. Set the return type of the join_id to new_res_ty -- See Note [Return type for join points] -- -- 2. Adjust the multiplicity of arrows in join_id's type, as -- directed by 'mult'. See Note [Scaling join point arguments] I think this actually fixes a latent bug, by ensuring that the seIdSubst and seInScope have the right multiplicity on the type of join points. I did some tidying up while I was at it. No more setJoinResTy, or modifyJoinResTy: instead it's done locally in Simplify.Env.adjustJoinPointType - - - - - 49b265f0 by Chaitanya Koparkar at 2020-07-18T07:26:46-04:00 Fix minor typos in a Core.hs note - - - - - 8d59aed6 by Stefan Schulze Frielinghaus at 2020-07-18T07:26:47-04:00 GHCi: Fix isLittleEndian - - - - - c26e81d1 by Ben Gamari at 2020-07-18T07:26:47-04:00 testsuite: Mark ghci tests as fragile under unreg compiler In particular I have seen T16012 fail repeatedly under the unregisterised compiler. - - - - - 868e4523 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "AArch32 symbols only on aarch32." This reverts commit cdfeb3f24f76e8fd30452016676e56fbc827789a. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - c915ba84 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "Fix (1)" This reverts commit 7abffced01f5680efafe44f6be2733eab321b039. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 777c452a by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "better if guards." This reverts commit 3f60b94de1f460ca3f689152860b108a19ce193e. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 0dd40552 by Moritz Angermann at 2020-07-20T04:30:38-04:00 Revert "[linker/rtsSymbols] More linker symbols" This reverts commit 686e72253aed3880268dd6858eadd8c320f09e97. Signed-off-by: Moritz Angermann <moritz.angermann at gmail.com> - - - - - 30caeee7 by Sylvain Henry at 2020-07-21T06:39:33-04:00 DynFlags: remove use of sdocWithDynFlags from GHC.Stg.* (#17957) * add StgPprOpts datatype * remove Outputable instances for types that need `StgPprOpts` to be pretty-printed and explicitly call type specific ppr functions * add default `panicStgPprOpts` for panic messages (when it's not convenient to thread StgPprOpts or DynFlags down to the ppr function call) - - - - - 863c544c by Mark at 2020-07-21T06:39:34-04:00 Fix a typo in existential_quantification.rst - - - - - 05910be1 by Krzysztof Gogolewski at 2020-07-21T14:47:07-04:00 Add release notes entry for #17816 [skip ci] - - - - - a6257192 by Matthew Pickering at 2020-07-21T14:47:19-04:00 Use a newtype `Code` for the return type of typed quotations (Proposal #195) There are three problems with the current API: 1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition of two type constructors. Doing so in your program involves making your own newtype and doing a lot of wrapping/unwrapping. For example, if I want to create a language which I can either run immediately or generate code from I could write the following with the new API. :: class Lang r where _int :: Int -> r Int _if :: r Bool -> r a -> r a -> r a instance Lang Identity where _int = Identity _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f) instance Quote m => Lang (Code m) where _int = liftTyped _if cb ct cf = [|| if $$cb then $$ct else $$cf ||] 2. When doing code generation it is common to want to store code fragments in a map. When doing typed code generation, these code fragments contain a type index so it is desirable to store them in one of the parameterised map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from ``parameterized-utils``. :: compiler :: Env -> AST a -> Code Q a data AST a where ... data Ident a = ... type Env = MapF Ident (Code Q) newtype Code m a = Code (m (TExp a)) In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``. Using one of these map types currently requires creating your own newtype and constantly wrapping every quotation and unwrapping it when using a splice. Achievable, but it creates even more syntactic noise than normal metaprogramming. 3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is easier. This is a weak reason but one everyone can surely agree with. Updates text submodule. - - - - - 58235d46 by Ben Gamari at 2020-07-21T14:47:28-04:00 users-guide: Fix :rts-flag:`--copying-gc` documentation It was missing a newline. - - - - - 19e80b9a by Vladislav Zavialov at 2020-07-21T14:50:01-04:00 Accumulate Haddock comments in P (#17544, #17561, #8944) Haddock comments are, first and foremost, comments. It's very annoying to incorporate them into the grammar. We can take advantage of an important property: adding a Haddock comment does not change the parse tree in any way other than wrapping some nodes in HsDocTy and the like (and if it does, that's a bug). This patch implements the following: * Accumulate Haddock comments with their locations in the P monad. This is handled in the lexer. * After parsing, do a pass over the AST to associate Haddock comments with AST nodes using location info. * Report the leftover comments to the user as a warning (-Winvalid-haddock). - - - - - 4c719460 by David Binder at 2020-07-22T20:17:35-04:00 Fix dead link to haskell prime discussion - - - - - f2f817e4 by BinderDavid at 2020-07-22T20:17:35-04:00 Replace broken links to old haskell-prime site by working links to gitlab instance. [skip ci] - - - - - 0bf8980e by Daniel Gröber at 2020-07-22T20:18:11-04:00 Remove length field from FastString - - - - - 1010c33b by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use ShortByteString for FastString There are multiple reasons we want this: - Fewer allocations: ByteString has 3 fields, ShortByteString just has one. - ByteString memory is pinned: - This can cause fragmentation issues (see for example #13110) but also - makes using FastStrings in compact regions impossible. Metric Decrease: T5837 T12150 T12234 T12425 - - - - - 8336ba78 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Pass specialised utf8DecodeChar# to utf8DecodeLazy# for performance Currently we're passing a indexWord8OffAddr# type function to utf8DecodeLazy# which then passes it on to utf8DecodeChar#. By passing one of utf8DecodeCharAddr# or utf8DecodeCharByteArray# instead we benefit from the inlining and specialization already done for those. - - - - - 7484a9a4 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Add comment about tricky ForeignPtr lifetime - - - - - 5536ed28 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Use IO constructor instead of `stToIO . ST` - - - - - 5b8902e3 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Remove redundant use of withForeignPtr - - - - - 5976a161 by Daniel Gröber at 2020-07-22T20:18:11-04:00 Encoding: Reformat utf8EncodeShortByteString to be more consistent - - - - - 9ddf1614 by Daniel Gröber at 2020-07-22T20:18:11-04:00 FastString: Reintroduce character count cache Metric Increase: ManyConstructors Metric Decrease: T4029 - - - - - e9491668 by Ben Gamari at 2020-07-22T20:18:46-04:00 get-win32-tarballs: Fix detection of missing tarballs This fixes the error message given by configure when the user attempts to configure without first download the win32 tarballs. - - - - - 9f3ff8fd by Andreas Klebinger at 2020-07-22T20:19:22-04:00 Enable BangPatterns, ScopedTypeVariables for ghc and hadrian by default. This is only for their respective codebases. - - - - - 0f17b930 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused "ncg" flag This flag has been removed in 066b369de2c6f7da03c88206288dca29ab061b31 in 2011. - - - - - bab4ec8f by Sylvain Henry at 2020-07-22T20:19:59-04:00 Don't panic if the NCG isn't built (it is always built) - - - - - 8ea33edb by Sylvain Henry at 2020-07-22T20:19:59-04:00 Remove unused sGhcWithNativeCodeGen - - - - - e079bb72 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Correctly test active backend Previously we used a platform settings to detect if the native code generator was used. This was wrong. We need to use the `DynFlags.hscTarget` field instead. - - - - - 735f9d6b by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace ghcWithNativeCodeGen with a proper Backend datatype * Represent backends with a `Backend` datatype in GHC.Driver.Backend * Don't detect the default backend to use for the target platform at compile time in Hadrian/make but at runtime. It makes "Settings" simpler and it is a step toward making GHC multi-target. * The latter change also fixes hadrian which has not been updated to take into account that the NCG now supports AIX and PPC64 (cf df26b95559fd467abc0a3a4151127c95cb5011b9 and d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984) * Also we don't treat iOS specifically anymore (cf cb4878ffd18a3c70f98bdbb413cd3c4d1f054e1f) - - - - - f7cc4313 by Sylvain Henry at 2020-07-22T20:19:59-04:00 Replace HscTarget with Backend They both have the same role and Backend name is more explicit. Metric Decrease: T3064 Update Haddock submodule - - - - - 15ce1804 by Andreas Klebinger at 2020-07-22T20:20:34-04:00 Deprecate -fdmd-tx-dict-sel. It's behaviour is now unconditionally enabled as it's slightly beneficial. There are almost no benchmarks which benefit from disabling it, so it's not worth the keep this configurable. This fixes #18429. - - - - - ff1b7710 by Sylvain Henry at 2020-07-22T20:21:11-04:00 Add test for #18064 It has been fixed by 0effc57d48ace6b719a9f4cbeac67c95ad55010b - - - - - cfa89149 by Krzysztof Gogolewski at 2020-07-22T20:21:48-04:00 Define type Void# = (# #) (#18441) There's one backwards compatibility issue: GHC.Prim no longer exports Void#, we now manually re-export it from GHC.Exts. - - - - - 02f40b0d by Sebastian Graf at 2020-07-22T20:22:23-04:00 Add regression test for #18478 !3392 backported !2993 to GHC 8.10.2 which most probably is responsible for fixing #18478, which triggered a pattern match checker performance regression in GHC 8.10.1 as first observed in #17977. - - - - - 7f44df1e by Sylvain Henry at 2020-07-22T20:23:00-04:00 Minor refactoring of Unit display * for consistency, try to always use UnitPprInfo to display units to users * remove some uses of `unitPackageIdString` as it doesn't show the component name and it uses String - - - - - dff1cb3d by Moritz Angermann at 2020-07-23T07:55:29-04:00 [linker] Fix out of range relocations. mmap may return address all over the place. mmap_next will ensure we get the next free page after the requested address. This is especially important for linking on aarch64, where the memory model with PIC admits relocations in the +-4GB range, and as such we can't work with arbitrary object locations in memory. Of note: we map the rts into process space, so any mapped objects must not be ouside of the 4GB from the processes address space. - - - - - cdd0ff16 by Tamar Christina at 2020-07-24T18:12:23-04:00 winio: restore console cp on exit - - - - - c1f4f81d by Tamar Christina at 2020-07-24T18:13:00-04:00 winio: change memory allocation strategy and fix double free errors. - - - - - ba205046 by Simon Peyton Jones at 2020-07-24T18:13:35-04:00 Care with occCheckExpand in kind of occurrences Issue #18451 showed that we could get an infinite type, through over-use of occCheckExpand in the kind of an /occurrence/ of a type variable. See Note [Occurrence checking: look inside kinds] in GHC.Core.Type This patch fixes the problem by making occCheckExpand less eager to expand synonyms in kinds. It also improves pretty printing of kinds, by *not* suppressing the kind on a tyvar-binder like (a :: Const Type b) where type Const p q = p. Even though the kind of 'a' is Type, we don't want to suppress the kind ascription. Example: the error message for polykinds/T18451{a,b}. See GHC.Core.TyCo.Ppr Note [Suppressing * kinds]. - - - - - 02133353 by Zubin Duggal at 2020-07-25T00:44:30-04:00 Simplify XRec definition Change `Located X` usage to `XRec pass X` This increases the scope of the LPat experiment to almost all of GHC. Introduce UnXRec and MapXRec classes Fixes #17587 and #18408 Updates haddock submodule Co-authored-by: Philipp Krüger <philipp.krueger1 at gmail.com> - - - - - e443846b by Sylvain Henry at 2020-07-25T00:45:07-04:00 DynFlags: store printer in TraceBinIfaceReading We don't need to pass the whole DynFlags, just pass the logging function, if any. - - - - - 15b2b44f by Sylvain Henry at 2020-07-25T00:45:08-04:00 Rename GHC.Driver.Ways into GHC.Platform.Ways - - - - - 342a01af by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add GHC.Platform.Profile - - - - - 6333d739 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Put PlatformConstants into Platform - - - - - 9dfeca6c by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove platform constant wrappers Platform constant wrappers took a DynFlags parameter, hence implicitly used the target platform constants. We removed them to allow support for several platforms at once (#14335) and to avoid having to pass the full DynFlags to every function (#17957). Metric Decrease: T4801 - - - - - 73145d57 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Remove dead code in utils/derivConstants - - - - - 7721b923 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Move GHC.Platform into the compiler Previously it was in ghc-boot so that ghc-pkg could use it. However it wasn't necessary because ghc-pkg only uses a subset of it: reading target arch and OS from the settings file. This is now done via GHC.Platform.ArchOS (was called PlatformMini before). - - - - - 459afeb5 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Fix build systems - - - - - 9e2930c3 by Sylvain Henry at 2020-07-25T00:45:08-04:00 Bump CountParserDeps - - - - - 6e2db34b by Sylvain Henry at 2020-07-25T00:45:08-04:00 Add accessors to ArchOS - - - - - fc0f6fbc by Stefan Schulze Frielinghaus at 2020-07-25T00:45:45-04:00 Require SMP support in order to build a threaded stage1 Fixes 18266 - - - - - a7c4439a by Matthias Andreas Benkard at 2020-07-26T13:23:24-04:00 Document loadFramework changes. (#18446) Adds commentary on the rationale for the changes made in merge request !3689. - - - - - da7269a4 by Ben Gamari at 2020-07-26T13:23:59-04:00 rts/win32: Exit with EXIT_HEAPOVERFLOW if memory commit fails Since switching to the two-step allocator, the `outofmem` test fails via `osCommitMemory` failing to commit. However, this was previously exiting with `EXIT_FAILURE`, rather than `EXIT_HEAPOVERFLOW`. I think the latter is a more reasonable exit code for this case and matches the behavior on POSIX platforms. - - - - - f153a1d0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Update win32 output for parseTree - - - - - e91672f0 by Ben Gamari at 2020-07-26T13:23:59-04:00 testsuite: Normalise WinIO error message differences Previously the old Windows IO manager threw different errors than WinIO. We now canonicalise these to the WinIO errors. - - - - - 9cbfe086 by Ben Gamari at 2020-07-26T13:23:59-04:00 gitlab-ci: Kill ssh-agent after pushing test metrics Otherwise the Windows builds hang forever waiting for the process to terminate. - - - - - 8236925f by Tamar Christina at 2020-07-26T13:24:35-04:00 winio: remove dead argument to stg_newIOPortzh - - - - - ce0a1d67 by Tamar Christina at 2020-07-26T13:25:11-04:00 winio: fix detection of tty terminals - - - - - 52685cf7 by Tamar Christina at 2020-07-26T13:25:48-04:00 winio: update codeowners - - - - - aee45d9e by Vladislav Zavialov at 2020-07-27T07:06:56-04:00 Improve NegativeLiterals (#18022, GHC Proposal #344) Before this patch, NegativeLiterals used to parse x-1 as x (-1). This may not be what the user expects, and now it is fixed: x-1 is parsed as (-) x 1. We achieve this by the following requirement: * When lexing a negative literal, it must not be preceded by a 'closing token'. This also applies to unboxed literals, e.g. -1#. See GHC Proposal #229 for the definition of a closing token. A nice consequence of this change is that -XNegativeLiterals becomes a subset of -XLexicalNegation. In other words, enabling both of those extensions has the same effect as enabling -XLexicalNegation alone. - - - - - 667ab69e by leiftw at 2020-07-27T07:07:32-04:00 fix typo referring to non-existent `-ohidir` flag, should be `-hidir` I think - - - - - 6ff89c17 by Vladislav Zavialov at 2020-07-27T07:08:07-04:00 Refactor the parser a little * Create a dedicated production for type operators * Create a dedicated type for the UNPACK pragma * Remove an outdated part of Note [Parsing data constructors is hard] - - - - - aa054d32 by Ben Gamari at 2020-07-27T20:09:07-04:00 Drop 32-bit Windows support As noted in #18487, we have reached the end of this road. - - - - - 6da73bbf by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Add minimal test for #12492 - - - - - 47680cb7 by Michalis Pardalos at 2020-07-27T20:09:44-04:00 Use allocate, not ALLOC_PRIM_P for unpackClosure# ALLOC_PRIM_P fails for large closures, by directly using allocate we can handle closures which are larger than the block size. Fixes #12492 - - - - - 3d345c96 by Simon Peyton Jones at 2020-07-27T20:10:19-04:00 Eta-expand the Simplifier monad This patch eta-expands the Simplifier's monad, using the method explained in GHC.Core.Unify Note [The one-shot state monad trick]. It's part of the exta-expansion programme in #18202. It's a tiny patch, but is worth a 1-2% reduction in bytes-allocated by the compiler. Here's the list, based on the compiler-performance tests in perf/compiler: Reduction in bytes allocated T10858(normal) -0.7% T12425(optasm) -1.3% T13056(optasm) -1.8% T14683(normal) -1.1% T15164(normal) -1.3% T15630(normal) -1.4% T17516(normal) -2.3% T18282(normal) -1.6% T18304(normal) -0.8% T1969(normal) -0.6% T4801(normal) -0.8% T5321FD(normal) -0.7% T5321Fun(normal) -0.5% T5642(normal) -0.9% T6048(optasm) -1.1% T9020(optasm) -2.7% T9233(normal) -0.7% T9675(optasm) -0.5% T9961(normal) -2.9% WWRec(normal) -1.2% Metric Decrease: T12425 T9020 T9961 - - - - - 57aca6bb by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Ensure that Hadrian jobs don't download artifacts Previously the Hadrian jobs had the default dependencies, meaning that they would download artifacts from all jobs of earlier stages. This is unneccessary. - - - - - 0a815cea by Ben Gamari at 2020-07-27T20:10:54-04:00 gitlab-ci: Bump bootstrap compiler to 8.8.4 Hopefully this will make the Windows jobs a bit more reliable. - - - - - 0bd60059 by Simon Peyton Jones at 2020-07-28T02:01:49-04:00 This patch addresses the exponential blow-up in the simplifier. Specifically: #13253 exponential inlining #10421 ditto #18140 strict constructors #18282 another nested-function call case This patch makes one really significant changes: change the way that mkDupableCont handles StrictArg. The details are explained in GHC.Core.Opt.Simplify Note [Duplicating StrictArg]. Specific changes * In mkDupableCont, when making auxiliary bindings for the other arguments of a call, add extra plumbing so that we don't forget the demand on them. Otherwise we haev to wait for another round of strictness analysis. But actually all the info is to hand. This change affects: - Make the strictness list in ArgInfo be [Demand] instead of [Bool], and rename it to ai_dmds. - Add as_dmd to ValArg - Simplify.makeTrivial takes a Demand - mkDupableContWithDmds takes a [Demand] There are a number of other small changes 1. For Ids that are used at most once in each branch of a case, make the occurrence analyser record the total number of syntactic occurrences. Previously we recorded just OneBranch or MultipleBranches. I thought this was going to be useful, but I ended up barely using it; see Note [Note [Suppress exponential blowup] in GHC.Core.Opt.Simplify.Utils Actual changes: * See the occ_n_br field of OneOcc. * postInlineUnconditionally 2. I found a small perf buglet in SetLevels; see the new function GHC.Core.Opt.SetLevels.hasFreeJoin 3. Remove the sc_cci field of StrictArg. I found I could get its information from the sc_fun field instead. Less to get wrong! 4. In ArgInfo, arrange that ai_dmds and ai_discs have a simpler invariant: they line up with the value arguments beyond ai_args This allowed a bit of nice refactoring; see isStrictArgInfo, lazyArgcontext, strictArgContext There is virtually no difference in nofib. (The runtime numbers are bogus -- I tried a few manually.) Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft +0.0% -2.0% -48.3% -49.4% 0.0% multiplier +0.0% -2.2% -50.3% -50.9% 0.0% -------------------------------------------------------------------------------- Min -0.4% -2.2% -59.2% -60.4% 0.0% Max +0.0% +0.1% +3.3% +4.9% 0.0% Geometric Mean +0.0% -0.0% -33.2% -34.3% -0.0% Test T18282 is an existing example of these deeply-nested strict calls. We get a big decrease in compile time (-85%) because so much less inlining takes place. Metric Decrease: T18282 - - - - - 6ee07b49 by Sylvain Henry at 2020-07-28T02:02:27-04:00 Bignum: add support for negative shifts (fix #18499) shiftR/shiftL support negative arguments despite Haskell 2010 report saying otherwise. We explicitly test for negative values which is bad (it gets in the way of constant folding, etc.). Anyway, for consistency we fix Bits instancesof Integer/Natural. - - - - - f305bbfd by Peter Trommler at 2020-07-28T02:03:02-04:00 config: Fix Haskell platform constructor w/ params Fixes #18505 - - - - - 318bb17c by Oleg Grenrus at 2020-07-28T20:54:13-04:00 Fix typo in haddock Spotted by `vilpan` on `#haskell` - - - - - 39c89862 by Sergei Trofimovich at 2020-07-28T20:54:50-04:00 ghc/mk: don't build gmp packages for BIGNUM_BACKEND=native Before this change make-based `BIGNUM_BACKEND=native` build was failing as: ``` x86_64-pc-linux-gnu-gcc: error: libraries/ghc-bignum/gmp/objs/*.o: No such file or directory ``` This happens because ghc.mk was pulling in gmp-dependent ghc-bignum library unconditionally. The change avoid building ghc-bignum. Bug: https://gitlab.haskell.org/ghc/ghc/-/issues/18437 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - b9a880fc by Felix Wiemuth at 2020-07-29T15:06:35-04:00 Fix typo - - - - - c59064b0 by Brandon Chinn at 2020-07-29T15:07:11-04:00 Add regression test for #16341 - - - - - a61411ca by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass dit_rep_tc_args to dsm_stock_gen_fn - - - - - a26498da by Brandon Chinn at 2020-07-29T15:07:11-04:00 Pass tc_args to gen_fn - - - - - 44b11bad by Brandon Chinn at 2020-07-29T15:07:11-04:00 Filter out unreachable constructors when deriving stock instances (#16431) - - - - - bbc51916 by Simon Peyton Jones at 2020-07-29T15:07:47-04:00 Kill off sc_mult and as_mult fields They are readily derivable from other fields, so this is more efficient, and less error prone. Fixes #18494 - - - - - e3db4b4c by Peter Trommler at 2020-07-29T15:08:22-04:00 configure: Fix build system on ARM - - - - - 96c31ea1 by Sylvain Henry at 2020-07-29T15:09:02-04:00 Fix bug in Natural multiplication (fix #18509) A bug was lingering in Natural multiplication (inverting two limbs) despite QuickCheck tests used during the development leading to wrong results (independently of the selected backend). - - - - - e1dc3d7b by Krzysztof Gogolewski at 2020-07-29T15:09:39-04:00 Fix validation errors (#18510) Test T2632 is a stage1 test that failed because of the Q => Quote change. The remaining tests did not use quotation and failed when the path contained a space. - - - - - 6c68a842 by John Ericson at 2020-07-30T07:11:02-04:00 For `-fkeep-going` do not duplicate dependency edge code We now compute the deps for `-fkeep-going` the same way that the original graph calculates them, so the edges are correct. Upsweep really ought to take the graph rather than a topological sort so we are never recalculating anything, but at least things are recaluclated consistently now. - - - - - 502de556 by cgibbard at 2020-07-30T07:11:02-04:00 Add haddock comment for unfilteredEdges and move the note about drop_hs_boot_nodes into it. - - - - - 01c948eb by Ryan Scott at 2020-07-30T07:11:37-04:00 Clean up the inferred type variable restriction This patch primarily: * Documents `checkInferredVars` (previously called `check_inferred_vars`) more carefully. This is the function which throws an error message if a user quantifies an inferred type variable in a place where specificity cannot be observed. See `Note [Unobservably inferred type variables]` in `GHC.Rename.HsType`. Note that I now invoke `checkInferredVars` _alongside_ `rnHsSigType`, `rnHsWcSigType`, etc. rather than doing so _inside_ of these functions. This results in slightly more call sites for `checkInferredVars`, but it makes it much easier to enumerate the spots where the inferred type variable restriction comes into effect. * Removes the inferred type variable restriction for default method type signatures, per the discussion in #18432. As a result, this patch fixes #18432. Along the way, I performed some various cleanup: * I moved `no_nested_foralls_contexts_err` into `GHC.Rename.Utils` (under the new name `noNestedForallsContextsErr`), since it now needs to be invoked from multiple modules. I also added a helper function `addNoNestedForallsContextsErr` that throws the error message after producing it, as this is a common idiom. * In order to ensure that users cannot sneak inferred type variables into `SPECIALISE instance` pragmas by way of nested `forall`s, I now invoke `addNoNestedForallsContextsErr` when renaming `SPECIALISE instance` pragmas, much like when we rename normal instance declarations. (This probably should have originally been done as a part of the fix for #18240, but this task was somehow overlooked.) As a result, this patch fixes #18455 as a side effect. - - - - - d47324ce by Ryan Scott at 2020-07-30T07:12:16-04:00 Don't mark closed type family equations as occurrences Previously, `rnFamInstEqn` would mark the name of the type/data family used in an equation as an occurrence, regardless of what sort of family it is. Most of the time, this is the correct thing to do. The exception is closed type families, whose equations constitute its definition and therefore should not be marked as occurrences. Overzealously counting the equations of a closed type family as occurrences can cause certain warnings to not be emitted, as observed in #18470. See `Note [Type family equations and occurrences]` in `GHC.Rename.Module` for the full story. This fixes #18470 with a little bit of extra-casing in `rnFamInstEqn`. To accomplish this, I added an extra `ClosedTyFamInfo` field to the `NonAssocTyFamEqn` constructor of `AssocTyFamInfo` and refactored the relevant call sites accordingly so that this information is propagated to `rnFamInstEqn`. While I was in town, I moved `wrongTyFamName`, which checks that the name of a closed type family matches the name in an equation for that family, from the renamer to the typechecker to avoid the need for an `ASSERT`. As an added bonus, this lets us simplify the details of `ClosedTyFamInfo` a bit. - - - - - ebe2cf45 by Simon Peyton Jones at 2020-07-30T07:12:52-04:00 Remove an incorrect WARN in extendLocalRdrEnv I noticed this warning going off, and discovered that it's really fine. This small patch removes the warning, and docments what is going on. - - - - - 9f71f697 by Simon Peyton Jones at 2020-07-30T07:13:27-04:00 Add two bangs to improve perf of flattening This tiny patch improves the compile time of flatten-heavy programs by 1-2%, by adding two bangs. Addresses (somewhat) #18502 This reduces allocation by T9872b -1.1% T9872d -3.3% T5321Fun -0.2% T5631 -0.2% T5837 +0.1% T6048 +0.1% Metric Decrease: T9872b T9872d - - - - - 7c274cd5 by Sylvain Henry at 2020-07-30T22:54:48-04:00 Fix minimal imports dump for boot files (fix #18497) - - - - - 175cb5b4 by Sylvain Henry at 2020-07-30T22:55:25-04:00 DynFlags: don't use sdocWithDynFlags in datacon ppr We don't need to use `sdocWithDynFlags` to know whether we should display linear types for datacon types, we already have `sdocLinearTypes` field in `SDocContext`. Moreover we want to remove `sdocWithDynFlags` (#10143, #17957)). - - - - - 380638a3 by Sylvain Henry at 2020-07-30T22:56:03-04:00 Bignum: fix powMod for gmp backend (#18515) Also reenable integerPowMod test which had never been reenabled by mistake. - - - - - 56a7c193 by Sylvain Henry at 2020-07-31T19:32:09+02:00 Refactor CLabel pretty-printing Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove (#10143, #17957). It uses it to query the backend and the platform. This patch exposes Clabel ppr functions specialised for each backend so that backend code can directly use them. - - - - - 3b15dc3c by Sylvain Henry at 2020-07-31T19:32:09+02:00 DynFlags: don't use sdocWithDynFlags in GHC.CmmToAsm.Dwarf.Types - - - - - e30fed6c by Vladislav Zavialov at 2020-08-01T04:23:04-04:00 Test case for #17652 The issue was fixed by 19e80b9af252eee760dc047765a9930ef00067ec - - - - - 22641742 by Ryan Scott at 2020-08-02T16:44:11-04:00 Remove ConDeclGADTPrefixPs This removes the `ConDeclGADTPrefixPs` per the discussion in #18517. Most of this patch simply removes code, although the code in the `rnConDecl` case for `ConDeclGADTPrefixPs` had to be moved around a bit: * The nested `forall`s check now lives in the `rnConDecl` case for `ConDeclGADT`. * The `LinearTypes`-specific code that used to live in the `rnConDecl` case for `ConDeclGADTPrefixPs` now lives in `GHC.Parser.PostProcess.mkGadtDecl`, which is now monadic so that it can check if `-XLinearTypes` is enabled. Fixes #18157. - - - - - f2d1accf by Leon Schoorl at 2020-08-02T16:44:47-04:00 Fix GHC_STAGE definition generated by make Fixes #18070 GHC_STAGE is the stage of the compiler we're building, it should be 1,2(,3?). But make was generating 0 and 1. Hadrian does this correctly using a similar `+ 1`: https://gitlab.haskell.org/ghc/ghc/-/blob/eb8115a8c4cbc842b66798480fefc7ab64d31931/hadrian/src/Rules/Generate.hs#L245 - - - - - 947206f4 by Niklas Hambüchen at 2020-08-03T07:52:33+02:00 hadrian: Fix running stage0/bin/ghc with wrong package DB. Fixes #17468. In the invocation of `cabal configure`, `--ghc-pkg-option=--global-package-db` was already given correctly to tell `stage0/bin/ghc-pkg` that it should use the package DB in `stage1/`. However, `ghc` needs to be given this information as well, not only `ghc-pkg`! Until now that was not the case; the package DB in `stage0` was given to `ghc` instead. This was wrong, because there is no binary compatibility guarantee that says that the `stage0` DB's `package.cache` (which is written by the stage0 == system-provided ghc-pkg) can be deserialised by the `ghc-pkg` from the source code tree. As a result, when trying to add fields to `InstalledPackageInfo` that get serialised into / deserialised from the `package.cache`, errors like _build/stage0/lib/package.conf.d/package.cache: GHC.PackageDb.readPackageDb: inappropriate type (Not a valid Unicode code point!) would appear. This was because the `stage0/bin/ghc would try to deserialise the newly added fields from `_build/stage0/lib/package.conf.d/package.cache`, but they were not in there because the system `ghc-pkg` doesn't know about them and thus didn't write them there. It would try to do that because any GHC by default tries to read the global package db in `../lib/package.conf.d/package.cache`. For `stage0/bin/ghc` that *can never work* as explained above, so we must disable this default via `-no-global-package-db` and give it the correct package DB explicitly. This is the same problem as #16534, and the same fix as in MR !780 (but in another context; that one was for developers trying out the `stage0/bin/ghc` == `_build/ghc-stage1` interactively, while this fix is for a `cabal configure` invocation). I also noticed that the fix for #16534 forgot to pass `-no-global-package-db`, and have fixed that in this commit as well. It only worked until now because nobody tried to add a new ghc-pkg `.conf` field since the introduction of Hadrian. - - - - - ef2ae81a by Alex Biehl at 2020-08-03T07:52:33+02:00 Hardcode RTS includes to cope with unregistered builds - - - - - d613ed76 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add backward compat integer-gmp functions Also enhance bigNatCheck# and isValidNatural test - - - - - 3f2f7718 by Sylvain Henry at 2020-08-05T03:59:27-04:00 Bignum: add more BigNat compat functions in integer-gmp - - - - - 5e12cd17 by Krzysztof Gogolewski at 2020-08-05T04:00:04-04:00 Rename Core.Opt.Driver -> Core.Opt.Pipeline Closes #18504. - - - - - 2bff2f87 by Ben Gamari at 2020-08-05T04:00:39-04:00 Revert "iserv: Don't pass --export-dynamic on FreeBSD" This reverts commit 2290eb02cf95e9cfffcb15fc9c593d5ef79c75d9. - - - - - 53ce0db5 by Ben Gamari at 2020-08-05T04:00:39-04:00 Refactor handling of object merging Previously to merge a set of object files we would invoke the linker as usual, adding -r to the command-line. However, this can result in non-sensical command-lines which causes lld to balk (#17962). To avoid this we introduce a new tool setting into GHC, -pgmlm, which is the linker which we use to merge object files. - - - - - eb7013c3 by Hécate at 2020-08-05T04:01:15-04:00 Remove all the unnecessary LANGUAGE pragmas - - - - - fbcb886d by Ryan Scott at 2020-08-05T04:01:51-04:00 Make CodeQ and TExpQ levity polymorphic The patch is quite straightforward. The only tricky part is that `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`). Since `CodeQ` has yet to appear in any released version of `template-haskell`, I didn't bother mentioning the change to `CodeQ` in the `template-haskell` release notes. Fixes #18521. - - - - - 686e06c5 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Grammar for types and data/newtype constructors Before this patch, we parsed types into a reversed sequence of operators and operands. For example, (F x y + G a b * X) would be parsed as [X, *, b, a, G, +, y, x, F], using a simple grammar: tyapps : tyapp | tyapps tyapp tyapp : atype | PREFIX_AT atype | tyop | unpackedness Then we used a hand-written state machine to assemble this either into a type, using 'mergeOps', or into a constructor, using 'mergeDataCon'. This is due to a syntactic ambiguity: data T1 a = MkT1 a data T2 a = Ord a => MkT2 a In T1, what follows after the = sign is a data/newtype constructor declaration. However, in T2, what follows is a type (of kind Constraint). We don't know which of the two we are parsing until we encounter =>, and we cannot check for => without unlimited lookahead. This poses a few issues when it comes to e.g. infix operators: data I1 = Int :+ Bool :+ Char -- bad data I2 = Int :+ Bool :+ Char => MkI2 -- fine By this issue alone we are forced into parsing into an intermediate representation and doing a separate validation pass. However, should that intermediate representation be as low-level as a flat sequence of operators and operands? Before GHC Proposal #229, the answer was Yes, due to some particularly nasty corner cases: data T = ! A :+ ! B -- used to be fine, hard to parse data T = ! A :+ ! B => MkT -- bad However, now the answer is No, as this corner case is gone: data T = ! A :+ ! B -- bad data T = ! A :+ ! B => MkT -- bad This means we can write a proper grammar for types, overloading it in the DisambECP style, see Note [Ambiguous syntactic categories]. With this patch, we introduce a new class, DisambTD. Just like DisambECP is used to disambiguate between expressions, commands, and patterns, DisambTD is used to disambiguate between types and data/newtype constructors. This way, we get a proper, declarative grammar for constructors and types: infixtype : ftype | ftype tyop infixtype | unpackedness infixtype ftype : atype | tyop | ftype tyarg | ftype PREFIX_AT tyarg tyarg : atype | unpackedness atype And having a grammar for types means we are a step closer to using a single grammar for types and expressions. - - - - - 6770e199 by Vladislav Zavialov at 2020-08-06T13:34:05-04:00 Clean up the story around runPV/runECP_P/runECP_PV This patch started as a small documentation change, an attempt to make Note [Parser-Validator] and Note [Ambiguous syntactic categories] more clear and up-to-date. But it turned out that runECP_P/runECP_PV are weakly motivated, and it's easier to remove them than to find a good rationale/explanation for their existence. As the result, there's a bit of refactoring in addition to a documentation update. - - - - - 826d07db by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix debug_ppr_ty ForAllTy (#18522) Before this change, GHC would pretty-print forall k. forall a -> () as forall @k a. () which isn't even valid Haskell. - - - - - 0ddb4384 by Vladislav Zavialov at 2020-08-06T13:34:06-04:00 Fix visible forall in ppr_ty (#18522) Before this patch, this type: T :: forall k -> (k ~ k) => forall j -> k -> j -> Type was printed incorrectly as: T :: forall k j -> (k ~ k) => k -> j -> Type - - - - - d2a43225 by Richard Eisenberg at 2020-08-06T13:34:06-04:00 Fail eagerly on a lev-poly datacon arg Close #18534. See commentary in the patch. - - - - - 63348155 by Sylvain Henry at 2020-08-06T13:34:08-04:00 Use a type alias for Ways - - - - - 9570c212 by Takenobu Tani at 2020-08-06T19:46:46-04:00 users-guide: Rename 8.12 to 9.0 GHC 8.12.1 has been renamed to GHC 9.0.1. See also: https://mail.haskell.org/pipermail/ghc-devs/2020-July/019083.html [skip ci] - - - - - 3907ee01 by Cale Gibbard at 2020-08-07T08:34:46-04:00 A fix to an error message in monad comprehensions, and a move of dsHandleMonadicFailure as suggested by comments on !2330. - - - - - fa9bb70a by Cale Gibbard at 2020-08-07T08:34:46-04:00 Add some tests for fail messages in do-expressions and monad-comprehensions. - - - - - 5f036063 by Ben Gamari at 2020-08-07T08:35:21-04:00 cmm: Clean up Notes a bit - - - - - 6402c124 by Ben Gamari at 2020-08-07T08:35:21-04:00 CmmLint: Check foreign call argument register invariant As mentioned in Note [Register parameter passing] the arguments of foreign calls cannot refer to caller-saved registers. - - - - - 15b36de0 by Ben Gamari at 2020-08-07T08:35:21-04:00 nativeGen: One approach to fix #18527 Previously the code generator could produce corrupt C call sequences due to register overlap between MachOp lowerings and the platform's calling convention. We fix this using a hack described in Note [Evaluate C-call arguments before placing in destination registers]. - - - - - 3847ae0c by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Add test for #18527 - - - - - dd51d53b by Ben Gamari at 2020-08-07T08:35:21-04:00 testsuite: Fix prog001 Previously it failed as the `ghc` package was not visible. - - - - - e4f1b73a by Alan Zimmerman at 2020-08-07T23:58:10-04:00 ApiAnnotations; tweaks for ghc-exactprint update Remove unused ApiAnns, add one for linear arrow. Include API Annotations for trailing comma in export list. - - - - - 8a665db6 by Ben Gamari at 2020-08-07T23:58:45-04:00 configure: Fix double-negation in ld merge-objects check We want to only run the check if ld is gold. Fixes the fix to #17962. - - - - - a11c9678 by Adam Sandberg Ericsson at 2020-08-09T11:32:25+02:00 hadrian: depend on boot compiler version #18001 - - - - - c8873b52 by Alan Zimmerman at 2020-08-09T21:17:54-04:00 Api Annotations : Adjust SrcSpans for prefix bang (!). And prefix ~ (cherry picked from commit 8dbee2c578b1f642d45561be3f416119863e01eb) - - - - - 77398b67 by Sylvain Henry at 2020-08-09T21:18:34-04:00 Avoid allocations in `splitAtList` (#18535) As suspected by @simonpj in #18535, avoiding allocations in `GHC.Utils.Misc.splitAtList` when there are no leftover arguments is beneficial for performance: On CI validate-x86_64-linux-deb9-hadrian: T12227 -7% T12545 -12.3% T5030 -10% T9872a -2% T9872b -2.1% T9872c -2.5% Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c - - - - - 8ba41a0f by Felix Yan at 2020-08-10T20:23:29-04:00 Correct a typo in ghc.mk - - - - - 1c469264 by Felix Yan at 2020-08-10T20:23:29-04:00 Add a closing parenthesis too - - - - - acf537f9 by Sylvain Henry at 2020-08-10T20:24:09-04:00 Make splitAtList strict in its arguments Also fix its slightly wrong comment Metric Decrease: T5030 T12227 T12545 - - - - - ab4d1589 by Ben Gamari at 2020-08-11T22:18:03-04:00 typecheck: Drop SPECIALISE pragmas when there is no unfolding Previously the desugarer would instead fall over when it realized that there was no unfolding for an imported function with a SPECIALISE pragma. We now rather drop the SPECIALISE pragma and throw a warning. Fixes #18118. - - - - - 0ac8c0a5 by Ben Gamari at 2020-08-11T22:18:03-04:00 testsuite: Add test for #18118 - - - - - c43078d7 by Sven Tennie at 2020-08-11T22:18:38-04:00 Add hie.yaml to ghc-heap This enables IDE support by haskell-language-server for ghc-heap. - - - - - f1088b3f by Ben Gamari at 2020-08-11T22:19:15-04:00 testsuite: Specify metrics collected by T17516 Previously it collected everything, including "max bytes used". This is problematic since the test makes no attempt to control for deviations in GC timing, resulting in high variability. Fix this by only collecting "bytes allocated". - - - - - accbc242 by Sylvain Henry at 2020-08-12T03:50:12-04:00 DynFlags: disentangle Outputable - put panic related functions into GHC.Utils.Panic - put trace related functions using DynFlags in GHC.Driver.Ppr One step closer making Outputable fully independent of DynFlags. Bump haddock submodule - - - - - db6dd810 by Ben Gamari at 2020-08-12T03:50:48-04:00 testsuite: Increase tolerance of T16916 T16916 (testing #16916) has been slightly fragile in CI due to its reliance on CPU times. While it's hard to see how to eliminate the time-dependence entirely, we can nevertheless make it more tolerant. Fixes #16966. - - - - - bee43aca by Sylvain Henry at 2020-08-12T20:52:50-04:00 Rewrite and move the monad-state hack note The note has been rewritten by @simonpj in !3851 [skip ci] - - - - - 25fdf25e by Alan Zimmerman at 2020-08-12T20:53:26-04:00 ApiAnnotations: Fix parser for new GHC 9.0 features - - - - - 7831fe05 by Ben Gamari at 2020-08-13T03:44:17-04:00 parser: Suggest ImportQualifiedPost in prepositive import warning As suggested in #18545. - - - - - 55dec4dc by Sebastian Graf at 2020-08-13T03:44:52-04:00 PmCheck: Better long-distance info for where bindings (#18533) Where bindings can see evidence from the pattern match of the `GRHSs` they belong to, but not from anything in any of the guards (which belong to one of possibly many RHSs). Before this patch, we did *not* consider said evidence, causing #18533, where the lack of considering type information from a case pattern match leads to failure to resolve the vanilla COMPLETE set of a data type. Making available that information required a medium amount of refactoring so that `checkMatches` can return a `[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each `GRHSs` of the match group. The first component of the pair is the covered set of the pattern, the second component is one covered set per RHS. Fixes #18533. Regression test case: T18533 - - - - - cf97889a by Hécate at 2020-08-13T03:45:29-04:00 Re-add BangPatterns to CodePage.hs - - - - - ffc0d578 by Sylvain Henry at 2020-08-13T09:49:56-04:00 Add HomeUnit type Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule - - - - - 8a51b2ab by Sylvain Henry at 2020-08-13T21:09:15-04:00 Make IOEnv monad one-shot (#18202) On CI (x86_64-linux-deb9-hadrian, compile_time/bytes_allocated): T10421 -1.8% (threshold: +/- 1%) T10421a -1.7% (threshold: +/- 1%) T12150 -4.9% (threshold: +/- 2%) T12227 -1.6 (threshold: +/- 1%) T12425 -1.5% (threshold: +/- 1%) T12545 -3.8% (threshold: +/- 1%) T12707 -3.0% (threshold: +/- 1%) T13035 -3.0% (threshold: +/- 1%) T14683 -10.3% (threshold: +/- 2%) T3064 -6.9% (threshold: +/- 2%) T4801 -4.3% (threshold: +/- 2%) T5030 -2.6% (threshold: +/- 2%) T5321FD -3.6% (threshold: +/- 2%) T5321Fun -4.6% (threshold: +/- 2%) T5631 -19.7% (threshold: +/- 2%) T5642 -13.0% (threshold: +/- 2%) T783 -2.7 (threshold: +/- 2%) T9020 -11.1 (threshold: +/- 2%) T9961 -3.4% (threshold: +/- 2%) T1969 (compile_time/bytes_allocated) -2.2% (threshold: +/-1%) T1969 (compile_time/max_bytes_used) +24.4% (threshold: +/-20%) Additionally on other CIs: haddock.Cabal -10.0% (threshold: +/- 5%) haddock.compiler -9.5% (threshold: +/- 5%) haddock.base (max bytes used) +24.6% (threshold: +/- 15%) T10370 (max bytes used, i386) +18.4% (threshold: +/- 15%) Metric Decrease: T10421 T10421a T12150 T12227 T12425 T12545 T12707 T13035 T14683 T3064 T4801 T5030 T5321FD T5321Fun T5631 T5642 T783 T9020 T9961 haddock.Cabal haddock.compiler Metric Decrease 'compile_time/bytes allocated': T1969 Metric Increase 'compile_time/max_bytes_used': T1969 T10370 haddock.base - - - - - 9f66fdf6 by Ben Gamari at 2020-08-14T15:50:34-04:00 testsuite: Drop --io-manager flag from testsuite configuration This is no longer necessary as there are now dedicated testsuite ways which run tests with WinIO. - - - - - 55fd1dc5 by Ben Gamari at 2020-08-14T15:51:10-04:00 llvm-targets: Add i686 targets Addresses #18422. - - - - - f4cc57fa by Ben Gamari at 2020-08-18T15:38:55-04:00 Allow unsaturated runRW# applications Previously we had a very aggressive Core Lint check which caught unsaturated applications of runRW#. However, there is nothing wrong with such applications and they may naturally arise in desugared Core. For instance, the desugared Core of Data.Primitive.Array.runArray# from the `primitive` package contains: case ($) (runRW# @_ @_) (\s -> ...) of ... In this case it's almost certain that ($) will be inlined, turning the application into a saturated application. However, even if this weren't the case there isn't a problem: CorePrep (after deleting an unnecessary case) can simply generate code in its usual way, resulting in a call to the Haskell definition of runRW#. Fixes #18291. - - - - - 3ac6ae7c by Ben Gamari at 2020-08-18T15:38:55-04:00 testsuite: Add test for #18291 - - - - - a87a0b49 by Eli Schwartz at 2020-08-18T15:39:30-04:00 install: do not install sphinx doctrees These files are 100% not needed at install time, and they contain unreproducible info. See https://reproducible-builds.org/ for why this matters. - - - - - 194b25ee by Ben Gamari at 2020-08-18T15:40:05-04:00 testsuite: Allow baseline commit to be set explicitly - - - - - fdcf7645 by Ben Gamari at 2020-08-18T15:40:05-04:00 gitlab-ci: Use MR base commit as performance baseline - - - - - 9ad5cab3 by Fendor at 2020-08-18T15:40:42-04:00 Expose UnitInfoMap as it is part of the public API - - - - - aa4b744d by Ben Gamari at 2020-08-18T22:11:36-04:00 testsuite: Only run llvm ways if llc is available As noted in #18560, we previously would always run the LLVM ways since `configure` would set `SettingsLlcCommand` to something non-null when it otherwise couldn't find the `llc` executable. Now we rather probe for the existence of the `llc` executable in the testsuite driver. Fixes #18560. - - - - - 0c5ed5c7 by Sylvain Henry at 2020-08-18T22:12:13-04:00 DynFlags: refactor GHC.CmmToAsm (#17957, #10143) This patch removes the use of `sdocWithDynFlags` from GHC.CmmToAsm.*.Ppr To do that I've had to make some refactoring: * X86' and PPC's `Instr` are no longer `Outputable` as they require a `Platform` argument * `Instruction` class now exposes `pprInstr :: Platform -> instr -> SDoc` * as a consequence, I've refactored some modules to avoid .hs-boot files * added (derived) functor instances for some datatypes parametric in the instruction type. It's useful for pretty-printing as we just have to map `pprInstr` before pretty-printing the container datatype. - - - - - 731c8d3b by nineonine at 2020-08-19T18:47:39-04:00 Implement -Wredundant-bang-patterns (#17340) Add new flag '-Wredundant-bang-patterns' that enables checks for "dead" bangs. Dead bangs are the ones that under no circumstances can force a thunk that wasn't already forced. Dead bangs are a form of redundant bangs. The new check is performed in Pattern-Match Coverage Checker along with other checks (namely, redundant and inaccessible RHSs). Given f :: Bool -> Int f True = 1 f !x = 2 we can detect dead bang patterns by checking whether @x ~ ⊥@ is satisfiable where the PmBang appears in 'checkGrdTree'. If not, then clearly the bang is dead. Such a dead bang is then indicated in the annotated pattern-match tree by a 'RedundantSrcBang' wrapping. In 'redundantAndInaccessibles', we collect all dead bangs to warn about. Note that we don't want to warn for a dead bang that appears on a redundant clause. That is because in that case, we recommend to delete the clause wholly, including its leading pattern match. Dead bang patterns are redundant. But there are bang patterns which are redundant that aren't dead, for example f !() = 0 the bang still forces the match variable, before we attempt to match on (). But it is redundant with the forcing done by the () match. We currently don't detect redundant bangs that aren't dead. - - - - - eb9bdaef by Simon Peyton Jones at 2020-08-19T18:48:14-04:00 Add right-to-left rule for pattern bindings 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 - - - - - 293c7fba by Sylvain Henry at 2020-08-21T09:36:38-04:00 Put CFG weights into their own module (#17957) It avoids having to query DynFlags to get them - - - - - 50eb4460 by Sylvain Henry at 2020-08-21T09:36:38-04:00 Don't use DynFlags in CmmToAsm.BlockLayout (#17957) - - - - - 659eb31b by Sylvain Henry at 2020-08-21T09:36:38-04:00 NCG: Dwarf configuration * remove references to DynFlags in GHC.CmmToAsm.Dwarf * add specific Dwarf options in NCGConfig instead of directly querying the debug level - - - - - 2d8ca917 by Sylvain Henry at 2020-08-21T09:37:15-04:00 Fix -ddump-stg flag -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. - - - - - fddddbf4 by Vladislav Zavialov at 2020-08-21T09:37:49-04:00 Import qualified Prelude in Cmm/Parser.y 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. - - - - - 989c1c27 by Ben Gamari at 2020-08-21T11:27:53-04:00 gitlab-ci: Test master branch as well While these builds are strictly speaking redundant (since every commit is tested by @marge-bot before making it into `master`), they are nevertheless useful as they are displayed in the branch's commit list in GitLab's web interface. Fixes #18595. - - - - - e67ae884 by Aditya Gupta at 2020-08-22T03:29:00-04:00 mkUnique refactoring (#18362) Move uniqFromMask from Unique.Supply to Unique. Move the the functions that call mkUnique from Unique to Builtin.Uniques - - - - - 03cfcfd4 by Wander Hillen at 2020-08-22T03:29:36-04:00 Add ubuntu 20.04 jobs for nightly and release - - - - - 3f501545 by Craig Ferguson at 2020-08-22T03:30:13-04:00 Utils: clarify docs slightly The previous comment implies `nTimes n f` is either `f^{n+1}` or `f^{2^n}` (when in fact it's `f^n`). - - - - - 8b865092 by Krzysztof Gogolewski at 2020-08-23T14:12:53+02:00 Do not print synonyms in :i (->), :i Type (#18594) This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'. - - - - - d8f61182 by Krzysztof Gogolewski at 2020-08-23T14:12:56+02:00 Move pprTyTcApp' inside pprTyTcApp No semantic change - - - - - 364258e0 by Krzysztof Gogolewski at 2020-08-24T00:32:31-04:00 Fix types in silly shifts (#18589) Patch written by Simon. I have only added a testcase. - - - - - b1eb38a0 by Sylvain Henry at 2020-08-24T00:33:13-04:00 Perf: make SDoc monad one-shot (#18202) 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 - - - - - a77b9ec2 by Krzysztof Gogolewski at 2020-08-24T10:04:20-04:00 Add a test for #18397 The bug was fixed by !3421. - - - - - 05550a5a by Sylvain Henry at 2020-08-24T10:04:59-04:00 Avoid roundtrip through SDoc As found by @monoidal on https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3885#note_295126 - - - - - 0a1ecc5f by Ben Gamari at 2020-08-25T07:37:05-04:00 SysTools.Process: Handle exceptions in readCreateProcessWithExitCode' 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. - - - - - db8793ad by Richard Eisenberg at 2020-08-25T07:37:40-04:00 Use tcView, not coreView, in the pure unifier. Addresses a lingering point within #11715. - - - - - fb77207a by Simon Peyton Jones at 2020-08-25T07:38:16-04:00 Use LIdP rather than (XRec p (IdP p)) 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. - - - - - 8426a136 by Krzysztof Gogolewski at 2020-08-25T07:38:54-04:00 Add a test for #18585 - - - - - 2d635a50 by Takenobu Tani at 2020-08-26T04:50:21-04:00 linters: Make CPP linter skip image files This patch adds an exclusion rule for `docs/users_guide/images`, to avoid lint errors of PDF files. - - - - - b7d98cb2 by Takenobu Tani at 2020-08-26T04:50:21-04:00 users-guide: Color the logo on the front page of the PDF This patch updates the logo with a recent color scheme. This affects only the PDF version of the user's guide. See also: * https://mail.haskell.org/pipermail/ghc-devs/2020-August/019139.html * https://gitlab.haskell.org/ghc/ghc/-/wikis/logo - - - - - 0b17fa18 by Sylvain Henry at 2020-08-26T04:50:58-04:00 Refactor UnitId pretty-printing 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. - - - - - dc476a50 by Sylvain Henry at 2020-08-26T04:51:35-04:00 Bignum: fix BigNat subtraction (#18604) There was a confusion between the boolean expected by withNewWordArrayTrimedMaybe and the boolean returned by subtracting functions. - - - - - fcb10b6c by Peter Trommler at 2020-08-26T10:42:30-04:00 PPC and X86: Portable printing of IEEE floats 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. - - - - - 770100e0 by Krzysztof Gogolewski at 2020-08-26T10:43:13-04:00 primops: Remove Monadic and Dyadic categories 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. - - - - - 01ff8c89 by Aditya Gupta at 2020-08-27T14:19:26-04:00 Consolidate imports in getMinimalImports (#18264) - - - - - bacccb73 by Ryan Scott at 2020-08-27T14:20:01-04:00 Make {hsExpr,hsType,pat}NeedsParens aware of boxed 1-tuples `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. - - - - - c6f50cea by Krzysztof Gogolewski at 2020-08-28T02:22:36-04:00 Add missing primop documentation (#18454) - 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. - - - - - f065b6b0 by Tamar Christina at 2020-08-28T02:23:13-04:00 Fix use distro toolchian - - - - - 4517a382 by Tamar Christina at 2020-08-28T02:23:13-04:00 document how build system find toolchains on Windows - - - - - 329f7cb9 by Ben Gamari at 2020-08-31T22:59:14-04:00 base: Better error message on invalid getSystemTimerManager call Previously we would produce a rather unhelpful pattern match failure error in the case where the user called `getSystemTimerManager` in a program which isn't built with `-threaded`. This understandably confused the user in #15616. Fixes #15616. - - - - - f6d70a8f by Roland Senn at 2020-08-31T22:59:50-04:00 Add tests for #15617. Avoid a similar regression in the future. - - - - - e5969fd0 by Roland Senn at 2020-08-31T23:00:27-04:00 Add additional tests for #18172 (Followup MR 3543) There was still one active discussion [thread](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3543#note_284325) when MR !3543 got merged. This MR adds the requested tests exercising the changes in `compiler/GHC/HsToCore/Match/Literal.hs:warnAboutEmptyEnumerations` and its sub-functions. - - - - - fe18b482 by Ben Gamari at 2020-08-31T23:01:02-04:00 Bump Win32 and process submodules - - - - - 2da93308 by Sylvain Henry at 2020-08-31T23:01:39-04:00 Hadrian: fix slow-validate flavour (#18586) - - - - - 85e13008 by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Update dominator code with fixes from the dom-lt package. Two bugs turned out in the package that have been fixed since. This MR includes this fixes in the GHC port of the code. - - - - - dffb38fa by Andreas Klebinger at 2020-08-31T23:02:15-04:00 Dominators.hs: Use unix line endings - - - - - 6189cc04 by Moritz Angermann at 2020-08-31T23:02:50-04:00 [fixup 3433] move debugBelch into IF_DEBUG(linker) The commit in dff1cb3d9c111808fec60190747272b973547c52 incorrectly left the `debugBelch` function without a comment or IF_DEBUG(linker,) decoration. This rectifies it. Needs at least a 8.10 backport, as it was backported in 6471cc6aff80d5deebbdb1bf7b677b31ed2af3d5 - - - - - bcb68a3f by Sylvain Henry at 2020-08-31T23:03:27-04:00 Don't store HomeUnit in UnitConfig Allow the creation of a UnitConfig (hence of a UnitState) without having a HomeUnit. It's required for #14335. - - - - - 0a372387 by Sylvain Henry at 2020-08-31T23:04:04-04:00 Fix documentation and fix "check" bignum backend (#18604) - - - - - eb85f125 by Moritz Angermann at 2020-08-31T23:04:39-04:00 Set the dynamic-system-linker flag to Manual This flag should be user controllable, hence Manual: True. - - - - - 380ef845 by Sven Tennie at 2020-08-31T23:05:14-04:00 Ignore more files Ignore files from "new style" cabal builds (dist-newstyle folders) and from clangd (C language server). - - - - - 74a7fbff by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.0 and earlier (#18620) This patch adds the upper bound of a happy version for ghc-9.0 and earlier. Currently, we can't use happy-1.20.0 for ghc-9.0. See #18620. - - - - - a4473f02 by Takenobu Tani at 2020-08-31T23:05:51-04:00 Limit upper version of Happy for ghc-9.2 (#18620) This patch adds the upper bound of a happy version for ghc-9.2. Currently, We can use happy-1.19 or happy-1.20 for ghc-9.2. See #18620. - - - - - a8a2568b by Sylvain Henry at 2020-08-31T23:06:28-04:00 Bignum: add BigNat compat functions (#18613) - - - - - 884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00 Fix FastString lexicographic ordering (fix #18562) - - - - - 4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00 Remove "Ord FastString" instance 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 - - - - - b4edcde7 by Ben Gamari at 2020-09-01T14:53:42-04:00 testsuite: Add broken test for #18302 - - - - - bfab2a30 by Sebastian Graf at 2020-09-02T15:54:55-04:00 Turn on -XMonoLocalBinds by default (#18430) And fix the resulting type errors. Co-authored-by: Krzysztof Gogolewski <krz.gogolewski at gmail.com> Metric Decrease: parsing001 - - - - - c30cc0e9 by David Feuer at 2020-09-02T15:55:31-04:00 Remove potential space leak from Data.List.transpose Previously, `transpose` produced a list of heads and a list of tails independently. This meant that a function using only some heads, and only some tails, could potentially leak space. Use `unzip` to work around the problem by producing pairs and selector thunks instead. Time and allocation behavior will be worse, but there should be no more leak potential. - - - - - ffc3da47 by Sylvain Henry at 2020-09-02T15:56:11-04:00 Remove outdated note - - - - - 85e62123 by Sylvain Henry at 2020-09-02T15:56:48-04:00 Bignum: add missing compat import/export functions - - - - - 397c2b03 by Ben Gamari at 2020-09-03T17:31:47-04:00 configure: Work around Raspbian's silly packaging decisions See #17856. - - - - - 4891c18a by Kathryn Spiers at 2020-09-03T17:32:24-04:00 expected-undocumented-flags remove kill flags It looks like the flags were removed in https://gitlab.haskell.org/ghc/ghc/-/commit/3e27205a66b06a4501d87eb31e285eadbc693eb7 and can safely be removed here - - - - - 1d6d6488 by Sylvain Henry at 2020-09-04T16:24:20-04:00 Don't rely on CLabel's Outputable instance in CmmToC This is in preparation of the removal of sdocWithDynFlags (#10143), hence of the refactoring of CLabel's Outputable instance. - - - - - 89ce7cdf by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: use Platform in foldRegs* - - - - - 220ad8d6 by Sylvain Henry at 2020-09-04T16:24:59-04:00 DynFlags: don't pass DynFlags to cmmImplementSwitchPlans - - - - - c1e54439 by Ryan Scott at 2020-09-04T16:25:35-04:00 Introduce isBoxedTupleDataCon and use it to fix #18644 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. - - - - - 07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00 configure: Avoid hard-coded ld path on Windows 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). - - - - - 0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00 Documented the as of yet undocumented '--print-*' GHC flags, as well as `-split-objs`, since that is related to `--print-object-splitting-supported`. See #18641 - - - - - 4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00 Move Hadrian's wiki pages in tree (fix #16165) Only the debugging page contains interesting stuff. Some of this stuff looks old (e.g. recommending "cabal install")... - - - - - 7980ae23 by GHC GitLab CI at 2020-09-05T14:50:52-04:00 rts: Consistently use stgMallocBytes instead of malloc This can help in debugging RTS memory leaks since all allocations go through the same interface. - - - - - 67059893 by Ben Gamari at 2020-09-05T14:51:27-04:00 configure: Fix whitespace - - - - - be2cc0ad by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: More intelligent detection of locale availability Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607. - - - - - 15dca847 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Rename RELEASE variable to RELEASE_JOB This interfered with the autoconf variable of the same name, breaking pre-release builds. - - - - - bec0d170 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Bump Windows toolchain version This should have been done when we bumped the bootstrap compiler to 8.8.4. - - - - - 9fbaee21 by Ben Gamari at 2020-09-05T14:51:27-04:00 gitlab-ci: Drop Windows make job These are a significant burden on our CI resources and end up failing quite often due to #18274. Here I drop the make jobs during validaion; it is now run only during the nightly builds. - - - - - 869f6e19 by Ben Gamari at 2020-09-05T14:51:27-04:00 testsuite: Drop Windows-specific output for parseTree The normalise_slashes normaliser should handle this. - - - - - 2c9f743c by Ben Gamari at 2020-09-05T14:51:28-04:00 testsuite: Mark T5975[ab] as broken on Windows Due to #7305. - - - - - 643785e3 by Ben Gamari at 2020-09-05T14:51:28-04:00 gitlab-ci: Fix typo A small typo in a rule regular expression. - - - - - c5413fc6 by Wander Hillen at 2020-09-07T09:33:54-04:00 Add clarification regarding poll/kqueue flags - - - - - 10434d60 by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Configure bignum backend in Hadrian builds - - - - - d4bc9f0d by Ben Gamari at 2020-09-07T09:34:32-04:00 gitlab-ci: Use hadrian builds for Windows release artifacts - - - - - 4ff93292 by Moritz Angermann at 2020-09-07T21:18:39-04:00 [macOS] improved runpath handling 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) - - - - - df04b81e by Sylvain Henry at 2020-09-07T21:19:20-04:00 Move DynFlags test into updateModDetailsIdInfos's caller (#17957) - - - - - ea1cbb8f by Ben Gamari at 2020-09-08T15:42:02-04:00 rts: Add stg_copyArray_barrier to RtsSymbols list It's incredible that this wasn't noticed until now. - - - - - d7b2f799 by Daishi Nakajima at 2020-09-08T15:42:41-04:00 testsuite: Output performance test results in tabular format this was suggested in #18417. Change the print format of the values. * Shorten commit hash * Reduce precision of the "Value" field * Shorten metrics name * e.g. runtime/bytes allocated -> run/alloc * Shorten "MetricsChange" * e.g. unchanged -> unch, increased -> incr And, print the baseline environment if there are baselines that were measured in a different environment than the current environment. If all "Baseline commit" are the same, print it once. - - - - - 44472daf by Ryan Scott at 2020-09-08T15:43:16-04:00 Make the forall-or-nothing rule only apply to invisible foralls (#18660) 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. - - - - - 0c61cbff by Ben Gamari at 2020-09-08T15:43:54-04:00 gitlab-ci: Handle distributions without locales Previously we would assume that the `locale` utility exists. However, this is not so on Alpine as musl's locale support is essentially non-existent. (cherry picked from commit 17cdb7ac3b557a245fee1686e066f9f770ddc21e) - - - - - d989c842 by Ben Gamari at 2020-09-08T15:43:55-04:00 gitlab-ci: Accept Centos 7 C.utf8 locale Centos apparently has C.utf8 rather than C.UTF-8. (cherry picked from commit d9f85dd25a26a04d3485470afb3395ee2dec6464) - - - - - e5a2899c by John Ericson at 2020-09-09T00:46:05-04:00 Use "to" instead of "2" in internal names of conversion ops 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. - - - - - 822f1057 by Ryan Scott at 2020-09-09T00:46:41-04:00 Postpone associated tyfam default checks until after typechecking 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. - - - - - 8c892689 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add OptCoercionOpts Use OptCoercionOpts to avoid threading DynFlags all the way down to GHC.Core.Coercion.Opt - - - - - 3f32a9c0 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add UnfoldingOpts and SimpleOpts Milestone: after this patch, we only use 'unsafeGlobalDynFlags' for the state hack and for debug in Outputable. - - - - - b3df72a6 by Sylvain Henry at 2020-09-09T11:19:24-04:00 DynFlags: add sm_pre_inline field into SimplMode (#17957) It avoids passing and querying DynFlags down in the simplifier. - - - - - ffae5792 by Sylvain Henry at 2020-09-09T11:19:24-04:00 Add comments about sm_dflags and simpleOptExpr - - - - - 7911d0d9 by Alan Zimmerman at 2020-09-09T11:20:03-04:00 Remove GENERATED pragma, as it is not being used @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 - - - - - 5aae5b32 by Ben Gamari at 2020-09-09T18:31:40-04:00 gitlab-ci: Bump Docker images We now generate our Docker images via Dhall definitions, as described in ghc/ci-images!52. Additionally, we are far more careful about where tools come from, using the ALEX, HAPPY, HSCOLOR, and GHC environment variables (set in the Dockerfiles) to find bootstrapping tools. - - - - - 4ce9fe88 by Ben Gamari at 2020-09-09T18:31:40-04:00 hadrian: Fix leakage of GHC in PATH into build Previously hadrian would use GHC on PATH when configuring packages (or fail if there is no such GHC). Fix this. Unfortunately this runs into another bug in Cabal which we workaround. - - - - - 291a15dd by Ben Gamari at 2020-09-09T18:31:40-04:00 utils: Bump cabal-version of hp2ps and unlit - - - - - 4798caa0 by David Himmelstrup at 2020-09-09T18:32:16-04:00 rts comment: RTS_TICKY_SYMBOLS moved from rts/Linker.c to rts/RtsSymbols.c - - - - - 67ce72da by Sebastian Graf at 2020-09-10T10:35:33-04:00 Add long-distance info for pattern bindings (#18572) 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. - - - - - 1207576a by Sebastian Graf at 2020-09-10T10:35:33-04:00 PmCheck: Big refactor using guard tree variants more closely following 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. - - - - - 95455982 by GHC GitLab CI at 2020-09-10T10:36:09-04:00 hadrian: Don't include -fdiagnostics-color in argument hash Otherwise the input hash will vary with whether colors are requested, which changed with `isatty`. Fixes #18672. - - - - - 6abe4a1c by Sebastian Graf at 2020-09-10T17:02:00+02:00 .gitignore *.hiedb files - - - - - 3777be14 by Sebastian Graf at 2020-09-10T17:03:12+02:00 PmCheck: Handle ⊥ and strict fields correctly (#18341) 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 - - - - - 1bd28931 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Define TICKY_TICKY when compiling cmm RTS files. - - - - - 15e67801 by David Himmelstrup at 2020-09-11T09:59:43-04:00 Fix typos in TICKY_TICKY symbol names. - - - - - 8a5a91cb by David Himmelstrup at 2020-09-11T09:59:43-04:00 Enable TICKY_TICKY for debug builds when building with makefiles. - - - - - fc965c09 by Sandy Maguire at 2020-09-12T00:31:36-04:00 Add clamp function to Data.Ord - - - - - fb6e29e8 by Sandy Maguire at 2020-09-12T00:31:37-04:00 Add tests - - - - - 2a942285 by Sebastian Graf at 2020-09-12T00:32:13-04:00 PmCheck: Disattach COMPLETE pragma lookup from TyCons By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478 - - - - - 389a6683 by Ben Gamari at 2020-09-12T00:32:49-04:00 hadrian: Pass input file to makeindex Strangely I find that on Alpine (and apparently only on Alpine) the latex makeindex command expects to be given a filename, lest it reads from stdin. - - - - - 853d121a by Ryan Scott at 2020-09-12T00:33:25-04:00 Don't quote argument to Hadrian's test-env flag (#18656) Doing so causes the name of the test environment to gain an extra set of double quotes, which changes the name entirely. Fixes #18656. - - - - - 8440b5fa by Krzysztof Gogolewski at 2020-09-12T00:33:25-04:00 Make sure we can read past perf notes See #18656. - - - - - 2157be52 by theobat at 2020-09-12T21:27:04-04:00 Avoid iterating twice in `zipTyEnv` (#18535) zipToUFM is a new function to replace `listToUFM (zipEqual ks vs)`. An explicit recursion is preferred due to the sensible nature of fusion. T12227 -6.0% T12545 -12.3% T5030 -9.0% T9872a -1.6% T9872b -1.6% T9872c -2.0% ------------------------- Metric Decrease: T12227 T12545 T5030 T9872a T9872b T9872c ------------------------- - - - - - 69ea2fee by Sebastian Graf at 2020-09-12T21:27:40-04:00 Make `tcCheckSatisfiability` incremental (#18645) By taking and returning an `InertSet`. Every new `TcS` session can then pick up where a prior session left with `setTcSInerts`. Since we don't want to unflatten the Givens (and because it leads to infinite loops, see !3971), we introduced a new variant of `runTcS`, `runTcSInerts`, that takes and returns the `InertSet` and makes sure not to unflatten the Givens after running the `TcS` action. Fixes #18645 and #17836. Metric Decrease: T17977 T18478 - - - - - a77e48d2 by Sebastian Graf at 2020-09-12T21:27:40-04:00 Extract definition of DsM into GHC.HsToCore.Types `DsM` was previously defined in `GHC.Tc.Types`, along with `TcM`. But `GHC.Tc.Types` is in the set of transitive dependencies of `GHC.Parser`, a set which we aim to minimise. Test case `CountParserDeps` checks for that. Having `DsM` in that set means the parser also depends on the innards of the pattern-match checker in `GHC.HsToCore.PmCheck.Types`, which is the reason we have that module in the first place. In the previous commit, we represented the `TyState` by an `InertSet`, but that pulls the constraint solver as well as 250 more modules into the set of dependencies, triggering failure of `CountParserDeps`. Clearly, we want to evolve the pattern-match checker (and the desugarer) without being concerned by this test, so this patch includes a small refactor that puts `DsM` into its own module. - - - - - fd5d622a by Sebastian Graf at 2020-09-12T21:27:40-04:00 Hackily decouple the parser from the desugarer In a hopefully temporary hack, I re-used the idea from !1957 of using a nullary type family to break the dependency from GHC.Driver.Hooks on the definition of DsM ("Abstract Data"). This in turn broke the last dependency from the parser to the desugarer. More details in `Note [The Decoupling Abstract Data Hack]`. In the future, we hope to undo this hack again in favour of breaking the dependency from the parser to DynFlags altogether. - - - - - 35a7b7ec by Adam Sandberg Eriksson at 2020-09-14T17:46:16-04:00 docs: -B rts option sounds the bell on every GC (#18351) - - - - - 5ae8212c by Wander Hillen at 2020-09-14T17:46:54-04:00 Populate gitlab cache after building - - - - - a5ffb39a by Wander Hillen at 2020-09-14T17:46:54-04:00 Move ahead cabal cache restoration to before use of cabal - - - - - e8b37c21 by Wander Hillen at 2020-09-14T17:46:54-04:00 Do the hadrian rebuild multicore - - - - - 07762eb5 by Wander Hillen at 2020-09-14T17:46:54-04:00 Also cache other hadrian builds - - - - - 8610bcbe by DenisFrezzato at 2020-09-15T15:19:08-04:00 Fix rtsopts documentation - - - - - c7182a5c by Simon Peyton Jones at 2020-09-15T15:19:44-04:00 Care with implicit-parameter superclasses Two bugs, #18627 and #18649, had the same cause: we were not account for the fact that a constaint tuple might hide an implicit parameter. The solution is not hard: look for implicit parameters in superclasses. See Note [Local implicit parameters] in GHC.Core.Predicate. Then we use this new function in two places * The "short-cut solver" in GHC.Tc.Solver.Interact.shortCutSolver which simply didn't handle implicit parameters properly at all. This fixes #18627 * The specialiser, which should not specialise on implicit parameters This fixes #18649 There are some lingering worries (see Note [Local implicit parameters]) but things are much better. - - - - - 0f3884b0 by Zubin Duggal at 2020-09-15T15:20:23-04:00 Export enrichHie from GHC.Iface.Ext.Ast This is useful for `ghcide` - - - - - b3143f5a by Sylvain Henry at 2020-09-15T15:21:06-04:00 Enhance metrics output - - - - - 4283feaa by Ryan Scott at 2020-09-15T15:21:43-04:00 Introduce and use DerivClauseTys (#18662) This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662. - - - - - 90229c4b by Ryan Scott at 2020-09-16T04:53:22-04:00 Include -f{write,validate}-ide-info in the User's Guide flag reference Previously, these were omitted from the flag reference due to a layout oversight in `docs/users_guide/flags.{rst,py}`. Fixes #18426. - - - - - ce42e187 by Ben Gamari at 2020-09-16T04:53:59-04:00 rts: Fix erroneous usage of vsnprintf As pointed out in #18685, this should be snprintf not vsnprintf. This appears to be due to a cut-and-paste error. Fixes #18658. - - - - - b695e7d7 by Sylvain Henry at 2020-09-16T04:54:38-04:00 Rename ghci flag into internal-interpreter "ghci" as a flag name was confusing because it really enables the internal-interpreter. Even the ghci library had a "ghci" flag... - - - - - 8af954d2 by Sylvain Henry at 2020-09-16T04:55:17-04:00 Make ghc-boot reexport modules from ghc-boot-th Packages don't have to import both ghc-boot and ghc-boot-th. It makes the dependency graph easier to understand and to refactor. - - - - - 6baa67f5 by Adam Sandberg Eriksson at 2020-09-16T07:45:47-04:00 docs: correct haddock reference [skip ci] - - - - - 7cf09ab0 by Simon Peyton Jones at 2020-09-17T01:27:25-04:00 Do absence analysis on stable unfoldings Ticket #18638 showed that Very Bad Things happen if we fail to do absence analysis on stable unfoldings. It's all described in Note [Absence analysis for stable unfoldings and RULES]. I'm a bit surprised this hasn't bitten us before. Fortunately the fix is pretty simple. - - - - - 76d3bcbc by Leif Metcalf at 2020-09-17T01:28:01-04:00 Replace deprecated git --recursive The --recursive flag of git-clone has been replaced by the --recurse-submodules flag since git 1.7.4, released in 2011. - - - - - da8f4ddd by Richard Eisenberg at 2020-09-17T01:28:38-04:00 Document IfaceTupleTy - - - - - 3c94c816 by HaskellMouse at 2020-09-17T08:49:51-04:00 Added explicit fixity to (~). Solves #18252 - - - - - b612e396 by Cary Robbins at 2020-09-17T08:50:30-04:00 Make the 'IsString (Const a b)' instance polykinded on 'b' - - - - - 8d0c26c4 by Ben Gamari at 2020-09-17T08:51:08-04:00 rts/win32: Fix missing #include's These slipped through CI. - - - - - 76009ec8 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump Win32 submodule to 2.9.0.0 Also bumps Cabal, directory - - - - - 147bb598 by Ben Gamari at 2020-09-17T08:51:08-04:00 Bump version to 9.0 Bumps haskeline and haddock submodules. (cherry picked from commit f218cfc92f7b1a1e01190851972bb9a0e0f3c682) - - - - - 5c7387f6 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Make Z-encoding comment into a note - - - - - c12b3041 by Leif Metcalf at 2020-09-17T08:51:43-04:00 Cosmetic - - - - - 4f461e1a by Vladislav Zavialov at 2020-09-17T08:52:19-04:00 Parser.y: clarify treatment of @{-# UNPACK #-} Before this patch, we had this parser production: ftype : ... | ftype PREFIX_AT tyarg { ... } And 'tyarg' is defined as follows: tyarg : atype { ... } | unpackedness atype { ... } So one might get the (false) impression that that parser production is intended to parse things like: F @{-# UNPACK #-} X However, the lexer wouldn't produce PREFIX_AT followed by 'unpackedness', as the '@' operator followed by '{-' is not considered prefix. Thus there's no point using 'tyarg' after PREFIX_AT, and a simple 'atype' will suffice: ftype : ... | ftype PREFIX_AT atype { ... } This change has no user-facing consequences. It just makes the grammar a bit more clear. - - - - - 9dec8600 by Benjamin Maurer at 2020-09-17T08:52:56-04:00 Documented '-m' flags for machine specific instruction extensions. See #18641 'Documenting the Expected Undocumented Flags' - - - - - ca48076a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Introduce OutputableP Some types need a Platform value to be pretty-printed: CLabel, Cmm types, instructions, etc. Before this patch they had an Outputable instance and the Platform value was obtained via sdocWithDynFlags. It meant that the *renderer* of the SDoc was responsible of passing the appropriate Platform value (e.g. via the DynFlags given to showSDoc). It put the burden of passing the Platform value on the renderer while the generator of the SDoc knows the Platform it is generating the SDoc for and there is no point passing a different Platform at rendering time. With this patch, we introduce a new OutputableP class: class OutputableP a where pdoc :: Platform -> a -> SDoc With this class we still have some polymorphism as we have with `ppr` (i.e. we can use `pdoc` on a variety of types instead of having a dedicated `pprXXX` function for each XXX type). One step closer removing `sdocWithDynFlags` (#10143) and supporting several platforms (#14335). - - - - - e45c8544 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Generalize OutputableP Add a type parameter for the environment required by OutputableP. It avoids tying Platform with OutputableP. - - - - - 37aa224a by Sylvain Henry at 2020-09-17T20:04:08-04:00 Add note about OutputableP - - - - - 7f2785f2 by Sylvain Henry at 2020-09-17T20:04:08-04:00 Remove pprPrec from Outputable (unused) - - - - - b689f3db by Sylvain Henry at 2020-09-17T20:04:46-04:00 Bignum: add clamping naturalToWord (fix #18697) - - - - - 0799b3de by Ben Gamari at 2020-09-18T15:55:50-04:00 rts/nonmoving: Add missing STM write barrier When updating a TRec for a TVar already part of a transaction we previously neglected to add the old value to the update remembered set. I suspect this was the cause of #18587. - - - - - c4921349 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor foreign export tracking This avoids calling `libc` in the initializers which are responsible for registering foreign exports. We believe this should avoid the corruption observed in #18548. See Note [Tracking foreign exports] in rts/ForeignExports.c for an overview of the new scheme. - - - - - 40dc9106 by Ben Gamari at 2020-09-18T15:56:25-04:00 rts: Refactor unloading of foreign export StablePtrs Previously we would allocate a linked list cell for each foreign export. Now we can avoid this by taking advantage of the fact that they are already broken into groups. - - - - - 45fa8218 by Simon Jakobi at 2020-09-19T06:57:36-04:00 Deprecate Data.Semigroup.Option Libraries email: https://mail.haskell.org/pipermail/libraries/2018-April/028724.html GHC issue: https://gitlab.haskell.org/ghc/ghc/issues/15028 Corresponding PRs for deepseq: * https://github.com/haskell/deepseq/pull/55 * https://github.com/haskell/deepseq/pull/57 Bumps the deepseq submodule. - - - - - 2229d570 by Vladislav Zavialov at 2020-09-19T15:47:24-04:00 Require happy >=1.20 - - - - - a89c2fba by Ben Gamari at 2020-09-19T15:47:24-04:00 ci.sh: Enforce minimum happy/alex versions Also, always invoke cabal-install to ensure that happy/alex symlinks are up-to-date. - - - - - 2f7ef2fb by Ben Gamari at 2020-09-19T15:47:24-04:00 gitlab-ci: Ensure that cabal-install overwrites existing executables Previously cabal-install wouldn't overwrite toolchain executables if they already existed (as they likely would due to caching). - - - - - ac213d26 by Ryan Scott at 2020-09-19T15:48:01-04:00 Wire in constraint tuples This wires in the definitions of the constraint tuple classes. The key changes are in: * `GHC.Builtin.Types`, where the `mk_ctuple` function is used to define constraint tuple type constructors, data constructors, and superclass selector functions, and * `GHC.Builtin.Uniques`. In addition to wiring in the `Unique`s for constraint tuple type and data constructors, we now must wire in the superclass selector functions. Luckily, this proves to be not that challenging. See the newly added comments. Historical note: constraint tuples used to be wired-in until about five years ago, when commit 130e93aab220bdf14d08028771f83df210da340b turned them into known-key names. This was done as part of a larger refactor to reduce the number of special cases for constraint tuples, but the commit message notes that the main reason that constraint tuples were made known-key (as opposed to boxed/unboxed tuples, which are wired in) is because it was awkward to wire in the superclass selectors. This commit solves the problem of wiring in superclass selectors. Fixes #18635. ------------------------- Metric Decrease: T10421 T12150 T12227 T12234 T12425 T13056 T13253-spj T18282 T18304 T5321FD T5321Fun T5837 T9961 Metric Decrease (test_env='x86_64-linux-deb9-unreg-hadrian'): T12707 Metric Decrease (test_env='x86_64-darwin'): T4029 ------------------------- - - - - - e195dae6 by Wander Hillen at 2020-09-19T15:48:41-04:00 Export singleton function from Data.List Data.OldList exports a monomorphized singleton function but it is not re-exported by Data.List. Adding the export to Data.List causes a conflict with a 14-year old function of the same name and type by SPJ in GHC.Utils.Misc. We can't just remove this function because that leads to a problems when building GHC with a stage0 compiler that does not have singleton in Data.List yet. We also can't hide the function in GHC.Utils.Misc since it is not possible to hide a function from a module if the module does not export the function. To work around this, all places where the Utils.Misc singleton was used now use a qualified version like Utils.singleton and in GHC.Utils.Misc we are very specific about which version we export. - - - - - 9c1b8ad9 by Sylvain Henry at 2020-09-19T15:49:19-04:00 Bump Stack resolver - - - - - d05d13ce by John Ericson at 2020-09-19T15:49:57-04:00 Cinch -fno-warn-name-shadowing down to specific GHCi module - - - - - f1accd00 by Sylvain Henry at 2020-09-19T15:49:57-04:00 Add quick-validate Hadrian flavour (quick + -Werror) - - - - - 8f8d51f1 by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix docs who misstated how the RTS treats size suffixes. They are parsed as multiples of 1024. Not 1000. The docs used to imply otherwise. See decodeSize in rts/RtsFlags.c for the logic for this. - - - - - 2ae0edbd by Andreas Klebinger at 2020-09-19T15:50:33-04:00 Fix a codeblock in ghci.rst - - - - - 4df3aa95 by Ben Gamari at 2020-09-19T15:51:07-04:00 users guide: Fix various documentation issues - - - - - 885ecd18 by Ben Gamari at 2020-09-19T15:51:07-04:00 hadrian: Fail on Sphinx syntax errors Specifically the "Inline literal start-string without end-string" warning, which typically means that the user neglected to separate an inline code block from suffix text with a backslash. - - - - - b26cd867 by David Feuer at 2020-09-19T15:51:44-04:00 Unpack the MVar in Compact The `MVar` lock in `Compact` was unnecessarily lazy, creating an extra indirection and wasting two words. Make it strict. - - - - - 760307cf by Artyom Kuznetsov at 2020-09-19T15:52:21-04:00 Remove GADT self-reference check (#11554, #12081, #12174, fixes #15942) Reverts 430f5c84dac1eab550110d543831a70516b5cac8 - - - - - 057db94c by Ben Gamari at 2020-09-19T15:52:56-04:00 rts: Drop field initializer on thread_basic_info_data_t This struct has a number of fields and we only care that the value is initialized with zeros. This eliminates the warnings noted in #17905. - - - - - 87e2e2b1 by Vladislav Zavialov at 2020-09-19T23:55:30+03:00 Resolve shift/reduce conflicts with %shift (#17232) - - - - - 66cba46e by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T12971 as broken on Windows It's unclear why, but this no longer seems to fail. Closes #17945. - - - - - 816811d4 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Unmark T5975[ab] as broken on Windows Sadly it's unclear *why* they have suddenly started working. Closes #7305. - - - - - 43a43d39 by Ben Gamari at 2020-09-20T20:30:57-04:00 base/testsuite: Add missing LANGUAGE pragma in ThreadDelay001 Only affected the Windows codepath. - - - - - ced8f113 by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Update expected output for outofmem on Windows The error originates from osCommitMemory rather than getMBlocks. - - - - - ea08aead by Ben Gamari at 2020-09-20T20:30:57-04:00 testsuite: Mark some GHCi/Makefile tests as broken on Windows See #18718. - - - - - caf6a5a3 by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Fix WinIO error message normalization This wasn't being applied to stderr. - - - - - 93ab3e8d by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark tempfiles as broken on Win32 without WinIO The old POSIX emulation appears to ignore the user-requested prefix. - - - - - 9df77fed by GHC GitLab CI at 2020-09-20T20:30:57-04:00 testsuite: Mark TH_spliceE5_prof as broken on Windows Due to #18721. - - - - - 1a0f8243 by Ryan Scott at 2020-09-21T16:45:47-04:00 Remove unused ThBrackCtxt and ResSigCtxt Fixes #18715. - - - - - 2f222b12 by Ryan Scott at 2020-09-21T16:45:47-04:00 Disallow constraints in KindSigCtxt This patch cleans up how `GHC.Tc.Validity` classifies `UserTypeCtxt`s that can only refer to kind-level positions, which is important for rejecting certain classes of programs. In particular, this patch: * Introduces a new `TypeOrKindCtxt` data type and `typeOrKindCtxt :: UserTypeCtxt -> TypeOrKindCtxt` function, which determines whether a `UserTypeCtxt` can refer to type-level contexts, kind-level contexts, or both. * Defines the existing `allConstraintsAllowed` and `vdqAllowed` functions in terms of `typeOrKindCtxt`, which avoids code duplication and ensures that they stay in sync in the future. The net effect of this patch is that it fixes #18714, in which it was discovered that `allConstraintsAllowed` incorrectly returned `True` for `KindSigCtxt`. Because `typeOrKindCtxt` now correctly classifies `KindSigCtxt` as a kind-level context, this bug no longer occurs. - - - - - aaa51dcf by Ben Gamari at 2020-09-21T16:46:22-04:00 hadrian: Add extra-deps: happy-1.20 to stack.yaml GHC now requires happy-1.20, which isn't available in LTS-16.14. Fixes #18726. - - - - - 6de40f83 by Simon Peyton Jones at 2020-09-22T05:37:24-04:00 Better eta-expansion (again) and don't specilise DFuns This patch fixes #18223, which made GHC generate an exponential amount of code. There are three quite separate changes in here 1. Re-engineer eta-expansion (again). The eta-expander was generating lots of intermediate stuff, which could be optimised away, but which choked the simplifier meanwhile. Relatively easy to kill it off at source. See Note [The EtaInfo mechanism] in GHC.Core.Opt.Arity. The main new thing is the use of pushCoArg in getArg_maybe. 2. Stop Specialise specalising DFuns. This is the cause of a huge (and utterly unnecessary) blowup in program size in #18223. See Note [Do not specialise DFuns] in GHC.Core.Opt.Specialise. I also refactored the Specialise monad a bit... it was silly, because it passed on unchanging values as if they were mutable state. 3. Do an extra Simplifer run, after SpecConstra and before late-Specialise. I found (investigating perf/compiler/T16473) that failing to do this was crippling *both* SpecConstr *and* Specialise. See Note [Simplify after SpecConstr] in GHC.Core.Opt.Pipeline. This change does mean an extra run of the Simplifier, but only with -O2, and I think that's acceptable. T16473 allocates *three* times less with this change. (I changed it to check runtime rather than compile time.) Some smaller consequences * I moved pushCoercion, pushCoArg and friends from SimpleOpt to Arity, because it was needed by the new etaInfoApp. And pushCoValArg now returns a MCoercion rather than Coercion for the argument Coercion. * A minor, incidental improvement to Core pretty-printing This does fix #18223, (which was otherwise uncompilable. Hooray. But there is still a big intermediate because there are some very deeply nested types in that program. Modest reductions in compile-time allocation on a couple of benchmarks T12425 -2.0% T13253 -10.3% Metric increase with -O2, due to extra simplifier run T9233 +5.8% T12227 +1.8% T15630 +5.0% There is a spurious apparent increase on heap residency on T9630, on some architectures at least. I tried it with -G1 and the residency is essentially unchanged. Metric Increase T9233 T12227 T9630 Metric Decrease T12425 T13253 - - - - - 416bd50e by Simon Peyton Jones at 2020-09-22T05:37:59-04:00 Fix the occurrence analyser Ticket #18603 demonstrated that the occurrence analyser's handling of local RULES for imported Ids (which I now call IMP-RULES) was inadequate. It led the simplifier into an infnite loop by failing to label a binder as a loop breaker. The main change in this commit is to treat IMP-RULES in a simple and uniform way: as extra rules for the local binder. See Note [IMP-RULES: local rules for imported functions] This led to quite a bit of refactoring. The result is still tricky, but it's much better than before, and better documented I think. Oh, and it fixes the bug. - - - - - 6fe8a0c7 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck - Comments only: Replace /~ by ≁ - - - - - e9501547 by Sebastian Graf at 2020-09-22T05:38:35-04:00 PmCheck: Rewrite inhabitation test We used to produce inhabitants of a pattern-match refinement type Nabla in the checker in at least two different and mostly redundant ways: 1. There was `provideEvidence` (now called `generateInhabitingPatterns`) which is used by `GHC.HsToCore.PmCheck` to produce non-exhaustive patterns, which produces inhabitants of a Nabla as a sub-refinement type where all match variables are instantiated. 2. There also was `ensure{,All}Inhabited` (now called `inhabitationTest`) which worked slightly different, but was whenever new type constraints or negative term constraints were added. See below why `provideEvidence` and `ensureAllInhabited` can't be the same function, the main reason being performance. 3. And last but not least there was the `nonVoid` test, which tested that a given type was inhabited. We did use this for strict fields and -XEmptyCase in the past. The overlap of (3) with (2) was always a major pet peeve of mine. The latter was quite efficient and proven to work for recursive data types, etc, but could not handle negative constraints well (e.g. we often want to know if a *refined* type is empty, such as `{ x:[a] | x /= [] }`). Lower Your Guards suggested that we could get by with just one, by replacing both functions with `inhabitationTest` in this patch. That was only possible by implementing the structure of φ constraints as in the paper, namely the semantics of φ constructor constraints. This has a number of benefits: a. Proper handling of unlifted types and strict fields, fixing #18249, without any code duplication between `GHC.HsToCore.PmCheck.Oracle.instCon` (was `mkOneConFull`) and `GHC.HsToCore.PmCheck.checkGrd`. b. `instCon` can perform the `nonVoid` test (3) simply by emitting unliftedness constraints for strict fields. c. `nonVoid` (3) is thus simply expressed by a call to `inhabitationTest`. d. Similarly, `ensureAllInhabited` (2), which we called after adding type info, now can similarly be expressed as the fuel-based `inhabitationTest`. See the new `Note [Why inhabitationTest doesn't call generateInhabitingPatterns]` why we still have tests (1) and (2). Fixes #18249 and brings nice metric decreases for `T17836` (-76%) and `T17836b` (-46%), as well as `T18478` (-8%) at the cost of a few very minor regressions (< +2%), potentially due to the fact that `generateInhabitingPatterns` does more work to suggest the minimal COMPLETE set. Metric Decrease: T17836 T17836b - - - - - 086ef018 by Hécate at 2020-09-23T06:52:08-04:00 Remove the list of loaded modules from the ghci prompt - - - - - d7385f70 by Ben Gamari at 2020-09-23T06:52:44-04:00 Bump submodules * Bump bytestring to 0.10.12.0 * Bump Cabal to 3.4.0.0-rc3 * Bump Win32 to 2.10.0.0 - - - - - 667d6355 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Refactor CLabel pretty-printing * Don't depend on the selected backend to know if we print Asm or C labels: we already have PprStyle to determine this. Moreover even when a native backend is used (NCG, LLVM) we may want to C headers containing pretty-printed labels, so it wasn't a good predicate anyway. * Make pretty-printing code clearer and avoid partiality - - - - - a584366b by Sylvain Henry at 2020-09-23T20:43:48-04:00 Remove sdocWithDynFlags (fix #10143) - - - - - a997fa01 by Sylvain Henry at 2020-09-23T20:43:48-04:00 Preliminary work towards removing DynFlags -> Driver.Ppr dependency - - - - - 31fea307 by Hécate at 2020-09-23T20:44:24-04:00 Remove redundant "do", "return" and language extensions from base - - - - - 04d64331 by syd at cs-syd.eu at 2020-09-24T13:15:54-04:00 Update Lock.hs with more documentation to make sure that the Boolean return value is clear. [skip ci] - - - - - 97cff919 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Implement Quick Look impredicativity This patch implements Quick Look impredicativity (#18126), sticking very closely to the design in A quick look at impredicativity, Serrano et al, ICFP 2020 The main change is that a big chunk of GHC.Tc.Gen.Expr has been extracted to two new modules GHC.Tc.Gen.App GHC.Tc.Gen.Head which deal with typechecking n-ary applications, and the head of such applications, respectively. Both contain a good deal of documentation. Three other loosely-related changes are in this patch: * I implemented (partly by accident) points (2,3)) of the accepted GHC proposal "Clean up printing of foralls", namely https://github.com/ghc-proposals/ghc-proposals/blob/ master/proposals/0179-printing-foralls.rst (see #16320). In particular, see Note [TcRnExprMode] in GHC.Tc.Module - :type instantiates /inferred/, but not /specified/, quantifiers - :type +d instantiates /all/ quantifiers - :type +v is killed off That completes the implementation of the proposal, since point (1) was done in commit df08468113ab46832b7ac0a7311b608d1b418c4d Author: Krzysztof Gogolewski <krzysztof.gogolewski at tweag.io> Date: Mon Feb 3 21:17:11 2020 +0100 Always display inferred variables using braces * HsRecFld (which the renamer introduces for record field selectors), is now preserved by the typechecker, rather than being rewritten back to HsVar. This is more uniform, and turned out to be more convenient in the new scheme of things. * The GHCi debugger uses a non-standard unification that allows the unification variables to unify with polytypes. We used to hack this by using ImpredicativeTypes, but that doesn't work anymore so I introduces RuntimeUnkTv. See Note [RuntimeUnkTv] in GHC.Runtime.Heap.Inspect Updates haddock submodule. WARNING: this patch won't validate on its own. It was too hard to fully disentangle it from the following patch, on type errors and kind generalisation. Changes to tests * Fixes #9730 (test added) * Fixes #7026 (test added) * Fixes most of #8808, except function `g2'` which uses a section (which doesn't play with QL yet -- see #18126) Test added * Fixes #1330. NB Church1.hs subsumes Church2.hs, which is now deleted * Fixes #17332 (test added) * Fixes #4295 * This patch makes typecheck/should_run/T7861 fail. But that turns out to be a pre-existing bug: #18467. So I have just made T7861 into expect_broken(18467) - - - - - 9fa26aa1 by Simon Peyton Jones at 2020-09-24T13:16:32-04:00 Improve kind generalisation, error messages This patch does two things: * It refactors GHC.Tc.Errors a bit. In debugging Quick Look I was forced to look in detail at error messages, and ended up doing a bit of refactoring, esp in mkTyVarEqErr'. It's still quite a mess, but a bit better, I think. * It makes a significant improvement to the kind checking of type and class declarations. Specifically, we now ensure that if kind checking fails with an unsolved constraint, all the skolems are in scope. That wasn't the case before, which led to some obscure error messages; and occasional failures with "no skolem info" (eg #16245). Both of these, and the main Quick Look patch itself, affect a /lot/ of error messages, as you can see from the number of files changed. I've checked them all; I think they are as good or better than before. Smaller things * I documented the various instances of VarBndr better. See Note [The VarBndr tyep and its uses] in GHC.Types.Var * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds * A bit of refactoring in bindExplicitTKTele, to avoid the footwork with Either. Simpler now. * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType Fixes #16245 (comment 211369), memorialised as typecheck/polykinds/T16245a Also fixes the three bugs in #18640 - - - - - 6d0ce0eb by Sebastian Graf at 2020-09-24T13:17:07-04:00 PmCheck: Desugar string literal patterns with -XRebindableSyntax correctly (#18708) Fixes #18708. - - - - - 007940d2 by Hécate at 2020-09-24T13:17:44-04:00 Namespace the Hadrian linting rule for base - - - - - 5b727189 by Andreas Klebinger at 2020-09-25T21:10:20-04:00 Make sizeExpr strict in the size threshold to facilitate WW. - - - - - dd664031 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci.sh: Factor out common utilities - - - - - 5b78e865 by Ben Gamari at 2020-09-25T21:10:56-04:00 ci: Add ad-hoc performance testing rule - - - - - 29885f07 by Zubin Duggal at 2020-09-25T21:11:32-04:00 Stop removing definitions of record fields in GHC.Iface.Ext.Ast - - - - - 0d6519d9 by Ben Gamari at 2020-09-25T21:12:08-04:00 gitlab-ci: Drop Darwin cleanup job We now have a proper periodic clean-up script installed on the runners. - - - - - 277d20af by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add regression tests for #18371 They have been fixed by !3959, I believe. Fixes #18371. - - - - - 8edf6056 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Add a regression test for #18609 The egregious performance hits are gone since !4050. So we fix #18609. - - - - - 4a1b89a4 by Sebastian Graf at 2020-09-25T21:12:44-04:00 Accept new test output for #17218 The expected test output was plain wrong. It has been fixed for a long time. Thus we can close #17218. - - - - - 51606236 by Sven Tennie at 2020-09-25T21:13:19-04:00 Print RET_BIG stack closures A RET_BIG closure has a large bitmap that describes it's payload and can be printed with printLargeBitmap(). Additionally, the output for payload closures of small and big bitmaps is changed: printObj() is used to print a bit more information about what's on the stack. - - - - - 2707c4ea by Arnaud Spiwack at 2020-09-25T21:13:58-04:00 Pattern guards BindStmt always use multiplicity Many Fixes #18439 . The rhs of the pattern guard was consumed with multiplicity one, while the pattern assumed it was Many. We use Many everywhere instead. This is behaviour consistent with that of `case` expression. See #18738. - - - - - 92daad24 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: refactor backend modules * move backends into GHC.Num.Backend.* * split backend selection into GHC.Num.Backend and GHC.Num.Backend.Selected to avoid duplication with the Check backend - - - - - 04bc50b3 by Sylvain Henry at 2020-09-25T21:14:36-04:00 Bignum: implement extended GCD (#18427) - - - - - 6a7dae4b by Krzysztof Gogolewski at 2020-09-25T21:15:14-04:00 Fix typed holes causing linearity errors (#18491) - - - - - 83407ffc by Krzysztof Gogolewski at 2020-09-25T21:15:53-04:00 Various documentation fixes * Remove UnliftedFFITypes from conf. Some time ago, this extension was undocumented and we had to silence a warning. This is no longer needed. * Use r'' in conf.py. This fixes a Sphinx warning: WARNING: Support for evaluating Python 2 syntax is deprecated and will be removed in Sphinx 4.0. Convert docs/users_guide/conf.py to Python 3 syntax. * Mark GHCForeignImportPrim as documented * Fix formatting in template_haskell.rst * Remove 'recursive do' from the list of unsupported items in TH - - - - - af1e84e7 by Sebastian Graf at 2020-09-26T05:36:46-04:00 PmCheck: Big refactor of module structure * Move everything from `GHC.HsToCore.PmCheck.*` to `GHC.HsToCore.Pmc.*` in analogy to `GHC.Tc`, rename exported `covCheck*` functions to `pmc*` * Rename `Pmc.Oracle` to `Pmc.Solver` * Split off the LYG desugaring and checking steps into their own modules (`Pmc.Desugar` and `Pmc.Check` respectively) * Split off a `Pmc.Utils` module with stuff shared by `Pmc.{,Desugar,Check,Solver}` * Move `Pmc.Types` to `Pmc.Solver.Types`, add a new `Pmc.Types` module with all the LYG types, which form the interfaces between `Pmc.{Desugar,Check,Solver,}`. - - - - - f08f98e8 by Sebastian Graf at 2020-09-26T05:36:46-04:00 Extract SharedIdEnv into its own module It's now named `GHC.Types.Unique.SDFM.UniqSDFM`. The implementation is more clear about its stated goals and supported operations. - - - - - 1cde295c by Sylvain Henry at 2020-09-26T05:37:23-04:00 Bignum: add bigNatFromWordArray Reimplementation of integer-gmp's byteArrayToBigNat# - - - - - bda55fa0 by Krzysztof Gogolewski at 2020-09-26T13:18:22-04:00 Make 'undefined x' linear in 'x' (#18731) - - - - - 160fba4a by Krzysztof Gogolewski at 2020-09-26T13:19:00-04:00 Disallow linear types in FFI (#18472) - - - - - e124f2a7 by Krzysztof Gogolewski at 2020-09-26T13:19:36-04:00 Fix handling of function coercions (#18747) This was broken when we added multiplicity to the function type. - - - - - 7ff43382 by Vladislav Zavialov at 2020-09-27T03:01:31+03:00 Comments: change outdated reference to mergeOps As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip] - - - - - 4edf5527 by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Don't rearrange (->) in the renamer The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn. - - - - - a9ce159b by Vladislav Zavialov at 2020-09-27T10:04:12-04:00 Remove outdated comment in rnHsTyKi This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore. - - - - - 583a2070 by Richard Eisenberg at 2020-09-29T00:31:27-04:00 Optimize NthCo (FunCo ...) in coercion opt We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun - - - - - b31a3360 by Krzysztof Gogolewski at 2020-09-29T00:32:05-04:00 Linear types: fix kind inference when checking datacons - - - - - 5830a12c by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 New linear types syntax: a %p -> b (#18459) Implements GHC Proposal #356 Updates the haddock submodule. - - - - - bca4d36d by Vladislav Zavialov at 2020-09-29T00:32:05-04:00 Improve error messages for (a %m) without LinearTypes Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead. - - - - - b9635d0a by Benjamin Maurer at 2020-09-29T00:32:43-04:00 Description of flag `-H` was in 'verbosity options', moved to 'misc'. Fixes #18699 - - - - - 74c797f6 by Benjamin Maurer at 2020-09-29T00:33:20-04:00 Workaround for #18623: GHC crashes bc. under rlimit for vmem it will reserve _all_ of it, leaving nothing for, e.g., thread stacks. Fix will only allocate 2/3rds and check whether remainder is at least large enough for minimum amount of thread stacks. - - - - - 4365d77a by Ryan Scott at 2020-09-29T00:33:57-04:00 Add regression test #18501 ghc/ghc!3220 ended up fixing #18501. This patch adds a regression test for #18501 to ensure that it stays fixed. - - - - - 8e3f00dd by Sylvain Henry at 2020-09-29T17:24:03+02:00 Make the parser module less dependent on DynFlags Bump haddock submodule - - - - - 3ab0d8f7 by Sebastian Graf at 2020-09-30T02:48:27-04:00 PmCheck: Long-distance information for LocalBinds (#18626) Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626. - - - - - f8f60efc by Ben Gamari at 2020-09-30T02:49:03-04:00 testsuite: Mark T12971 as broken on Windows Due to #17945. - - - - - 6527fc57 by Ben Gamari at 2020-09-30T02:49:03-04:00 Bump Cabal, hsc2hs, directory, process submodules Necessary for recent Win32 bump. - - - - - df3f5880 by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unsafeGlobalDynFlags (#17957, #14597) There are still global variables but only 3 booleans instead of a single DynFlags. - - - - - 9befd94d by Sylvain Henry at 2020-09-30T02:49:41-04:00 Remove unused global variables Some removed globals variables were still declared in the RTS. They were removed in the following commits: * 4fc6524a2a4a0003495a96c8b84783286f65c198 * 0dc7985663efa1739aafb480759e2e2e7fca2a36 * bbd3c399939311ec3e308721ab87ca6b9443f358 - - - - - 7c98699f by Richard Eisenberg at 2020-09-30T02:50:17-04:00 Omit redundant kind equality check in solver See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753. - - - - - 39549826 by Sebastian Graf at 2020-09-30T02:50:54-04:00 Pmc: Don't call exprType on type arguments (#18767) Fixes #18767. - - - - - 235e410f by Richard Eisenberg at 2020-09-30T02:51:29-04:00 Regression test for #10709. Close #10709 - - - - - 5c32655f by Ben Gamari at 2020-09-30T22:31:55-04:00 hadrian/doc: Clarify documentation of key-value configuration - - - - - 0bb02873 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Add test for T18574 - - - - - e393f213 by Sylvain Henry at 2020-10-01T18:34:53-04:00 Allow fusion with catMaybes (#18574) Metric Decrease: T18574 - - - - - d2cfad96 by Fendor at 2020-10-01T18:35:33-04:00 Add mainModuleNameIs and demote mainModIs Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from. - - - - - fc351ab8 by Fendor at 2020-10-01T18:35:33-04:00 Use HomeUnit for main module without module declaration - - - - - dca1cb22 by Fendor at 2020-10-01T18:35:33-04:00 Remove mAIN completely - - - - - a5aaceec by Sylvain Henry at 2020-10-01T18:36:11-04:00 Use ADTs for parser errors/warnings Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001 - - - - - a946c7ef by Sylvain Henry at 2020-10-01T18:36:11-04:00 Less DynFlags in Header parsing - - - - - dafe7943 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Parser: remove some unused imports These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-} - - - - - 93d5de16 by Sylvain Henry at 2020-10-01T18:36:11-04:00 Don't import GHC.Unit to reduce the number of dependencies - - - - - e3655f81 by Sebastian Graf at 2020-10-01T18:36:47-04:00 Don't attach CPR signatures to NOINLINE data structures (#18154) Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected. - - - - - ba5965eb by Richard Eisenberg at 2020-10-01T18:37:23-04:00 Add regression test for #18755. Close #18755 - - - - - a8018c17 by Vladislav Zavialov at 2020-10-01T18:37:58-04:00 Fix pretty-printing of the mult-polymorphic arrow A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04) - - - - - e5523324 by Sylvain Henry at 2020-10-01T18:38:35-04:00 Bignum: add integerNegate RULE - - - - - 1edd6d21 by Vladislav Zavialov at 2020-10-01T18:39:10-04:00 Refactor: remove rnHsDoc It did not do any useful work. - - - - - a9ae83af by Krzysztof Gogolewski at 2020-10-02T08:00:25-04:00 Fix typos in comments [skip ci] - - - - - b81350bb by Icelandjack at 2020-10-02T08:01:01-04:00 Replaced MkT1 with T1 in type signatures. - - - - - 3c9beab7 by Vladislav Zavialov at 2020-10-02T13:51:58-04:00 Minor TTG clean-up: comments, unused families, bottom 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt' - - - - - 12c06927 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerRecipMod (#18427) - - - - - 8dd4f405 by Sylvain Henry at 2020-10-02T13:52:38-04:00 Bignum: implement integerPowMod (#18427) Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing. - - - - - 1033a720 by Krzysztof Gogolewski at 2020-10-02T13:53:23-04:00 Reject linearity in kinds in checkValidType (#18780) Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673 - - - - - b0ccba66 by Krzysztof Gogolewski at 2020-10-03T19:33:02-04:00 Small documentation fixes - Fix formatting of code blocks and a few sphinx warnings - Move the Void# change to 9.2, it was done right after the branch was cut - Fix typo in linear types documentation - Note that -Wincomplete-uni-patterns affects lazy patterns [skip ci] - - - - - 70dc2f09 by Karel Gardas at 2020-10-03T19:33:06-04:00 fix rts.cabal to use real arch names and not aliasses (fixes #18654) - - - - - bc5de347 by Sebastian Graf at 2020-10-05T13:59:24-04:00 Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` instead Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359 - - - - - 802b5e6f by Krzysztof Gogolewski at 2020-10-05T13:59:33-04:00 Fix linear types in TH splices (#18465) - - - - - 18a3ddf7 by Ben Gamari at 2020-10-05T13:59:33-04:00 rts: Fix integer width in TICK_BUMP_BY Previously `TICK_BUMP_BY` was defined as ```c #define TICK_BUMP_BY(ctr,n) CLong[ctr] = CLong[ctr] + n ``` Yet the tickers themselves were defined as `StgInt`s. This happened to work out correctly on Linux, where `CLong` is 64-bits. However, it failed on Windows, where `CLong` is 32-bits, resulting in #18782. Fixes #18783. - - - - - 5fc4243b by Rachel at 2020-10-07T14:59:45-04:00 Document profiling flags, warning flags, and no-pie - - - - - b41f7c38 by Andreas Klebinger at 2020-10-07T15:00:20-04:00 WinIO: Small changes related to atomic request swaps. Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things. - - - - - 948a14e1 by Ben Gamari at 2020-10-07T15:00:55-04:00 gitlab-ci: Fix name of Ubuntu 20.04 image - - - - - 74d4017b by Sylvain Henry at 2020-10-07T15:01:35-04:00 Fix -flink-rts (#18651) Before this patch -flink-rts could link with GHC's rts instead of the selected one. - - - - - 0e8b923d by Sylvain Henry at 2020-10-07T15:01:35-04:00 Apply suggestion to compiler/GHC/SysTools.hs - - - - - d6dff830 by Alan Zimmerman at 2020-10-07T15:02:10-04:00 Preserve as-parsed arrow type for HsUnrestrictedArrow When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791 - - - - - 030c5ce0 by Karel Gardas at 2020-10-07T15:02:48-04:00 hadrian: use stage0 linker to merge objects when done during the stage0 Fixes #18800. - - - - - a94db588 by Ben Gamari at 2020-10-07T15:03:23-04:00 testsuite: Allow whitespace before "Metric (in|de)crease" Several people have struggled with metric change annotations in their commit messages not being recognized due to the fact that GitLab's job log inserts a space at the beginning of each line. Teach the regular expression to accept this whitespace. - - - - - e91ddddd by Krzysztof Gogolewski at 2020-10-07T15:04:07-04:00 Misc cleanup * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732) - - - - - 386c2d7f by Sylvain Henry at 2020-10-09T08:40:33-04:00 Use UnitId in the backend instead of Unit In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm. - - - - - a566c83d by Simon Jakobi at 2020-10-09T08:41:09-04:00 Update containers to v0.6.4.1 Updates containers submodule. - - - - - fd984d68 by Tamar Christina at 2020-10-09T08:41:50-04:00 rts: fix race condition in StgCRun On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601. - - - - - accdb24a by Sylvain Henry at 2020-10-09T08:42:31-04:00 Expose RTS-only ways (#18651) Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself. - - - - - d360f343 by MaxGabriel at 2020-10-09T08:43:11-04:00 Document -Wderiving-typeable Tracking: #18641 - - - - - e48cab2a by Krzysztof Gogolewski at 2020-10-09T08:43:49-04:00 Add a flag to indicate that gcc supports -no-pie Fixes #17919. - - - - - f7e2fff9 by Hécate at 2020-10-09T08:44:26-04:00 Add linting of `base` to the CI - - - - - 45a1d493 by Andreas Klebinger at 2020-10-09T08:45:05-04:00 Use proper RTS flags when collecting residency in perf tests. Replace options like collect_stats(['peak_megabytes_allocated'],4) with collect_runtime_residency(4) and so forth. Reason being that the later also supplies some default RTS arguments which make sure residency does not fluctuate too much. The new flags mean we get new (hopefully more accurate) baselines so accept the stat changes. ------------------------- Metric Decrease: T4029 T4334 T7850 Metric Increase: T13218 T7436 ------------------------- - - - - - ef65b154 by Andreas Klebinger at 2020-10-09T08:45:42-04:00 testsuite/timeout: Fix windows specific errors. We now seem to use -Werror there. Which caused some long standing warnings to become errors. I applied changes to remove the warnings allowing the testsuite to run on windows as well. - - - - - e691a5a0 by Sylvain Henry at 2020-10-09T08:46:22-04:00 Hadrian: add quick-debug flavour - - - - - 12191a99 by Sylvain Henry at 2020-10-09T08:47:00-04:00 Bignum: match on small Integer/Natural Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test). - - - - - 36787bba by Alan Zimmerman at 2020-10-09T08:47:36-04:00 ApiAnnotations : preserve parens in GADTs A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT. - - - - - 32dc7698 by Krzysztof Gogolewski at 2020-10-09T08:48:15-04:00 Linear types: fix roles in GADTs (#18799) - - - - - 9657f6f3 by Ben Gamari at 2020-10-09T08:48:52-04:00 sdist: Include hadrian sources in source distribution Previously the make build system's source distribution rules neglected to include Hadrian's sources. Fixes #18794. - - - - - c832f7e2 by Tamar Christina at 2020-10-09T08:49:33-04:00 winio: fixed timeouts non-threaded. - - - - - 6f0243ae by Tamar Christina at 2020-10-09T08:50:13-04:00 winio: fix array splat - - - - - 0fd3d360 by Tamar Christina at 2020-10-09T08:50:51-04:00 winio: fixed bytestring reading interface. - - - - - dfaef1ca by Tamar Christina at 2020-10-09T08:51:30-04:00 winio: fixed more data error. - - - - - bfdccac6 by Simon Peyton Jones at 2020-10-09T08:52:07-04:00 Fix desugaring of record updates on data families This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners. - - - - - e5c7c9c8 by Ben Gamari at 2020-10-09T08:52:43-04:00 Bump win32-tarballs version to 0.3 This should fix #18774. - - - - - ef950b19 by Andreas Klebinger at 2020-10-09T08:53:21-04:00 Add TyCon Set/Env and use them in a few places. Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles. - - - - - fd302e93 by Krzysztof Gogolewski at 2020-10-09T08:54:02-04:00 Add -pgmlm and -optlm flags !3798 added documentation and semantics for the flags, but not parsing. - - - - - db236ffc by Sylvain Henry at 2020-10-09T08:54:41-04:00 Testsuite: increase timeout for T18223 (#18795) - - - - - 6a243e9d by Sylvain Henry at 2020-10-09T08:55:21-04:00 Cache HomeUnit in HscEnv (#17957) Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv. - - - - - 5884fd32 by Fendor at 2020-10-09T19:46:28+02:00 Move File Target parser to library #18596 - - - - - ea59fd4d by Hécate at 2020-10-10T14:49:59-04:00 Lint the compiler for extraneous LANGUAGE pragmas - - - - - 22f218b7 by Krzysztof Gogolewski at 2020-10-10T14:50:42-04:00 Linear types: fix quantification in GADTs (#18790) - - - - - 74ee1237 by Sylvain Henry at 2020-10-10T14:51:20-04:00 Bignum: fix bigNatCompareWord# bug (#18813) - - - - - 274e21f0 by Hécate at 2020-10-11T10:55:56+02:00 Remove the dependency on the ghc-linters stage - - - - - 990ea991 by Daniel Rogozin at 2020-10-11T22:20:04+03:00 Fall back to types when looking up data constructors (#18740) Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables. - - - - - 9bbc84d2 by Sylvain Henry at 2020-10-12T18:21:51-04:00 DynFlags: refactor DmdAnal Make demand analysis usable without having to provide DynFlags. - - - - - 7fdcce6d by Wander Hillen at 2020-10-13T00:12:47-04:00 Initial ShortText code and conversion of package db code Metric Decrease: Naperian T10421 T10421a T10547 T12150 T12234 T12425 T13035 T18140 T18304 T5837 T6048 T13253-spj T18282 T18223 T3064 T9961 Metric Increase T13701 HFSKJH - - - - - 0a5f2918 by Sylvain Henry at 2020-10-13T00:13:28-04:00 Parser: don't require the HomeUnitId The HomeUnitId is only used by the Cmm parser and this one has access to the DynFlags, so it can grab the UnitId of the HomeUnit from them. Bump haddock submodule - - - - - 8f4f5794 by HaskellMouse at 2020-10-13T13:05:49+03:00 Unification of Nat and Naturals This commit removes the separate kind 'Nat' and enables promotion of type 'Natural' for using as type literal. It partially solves #10776 Now the following code will be successfully typechecked: data C = MkC Natural type CC = MkC 1 Before this change we had to create the separate type for promotion data C = MkC Natural data CP = MkCP Nat type CC = MkCP 1 But CP is uninhabited in terms. For backward compatibility type synonym `Nat` has been made: type Nat = Natural The user's documentation and tests have been updated. The haddock submodule also have been updated. - - - - - 0fc1cb54 by Ben Gamari at 2020-10-14T03:42:50-04:00 gitlab-ci: Verify that Hadrian builds with Stack As noted in #18726, this regularly breaks. Let's test it. Note that we don't actually perform a build of GHC itself; we merely test that the Hadrian executable builds and works (by invoking `hadrian --version`). - - - - - 89f4d8e9 by Ben Gamari at 2020-10-14T12:03:57-04:00 Bump LLVM version to 10.0 Fixes #18267. - - - - - 716385c9 by Ryan Scott at 2020-10-14T12:04:34-04:00 Make DataKinds the sole arbiter of kind-level literals (and friends) Previously, the use of kind-level literals, promoted tuples, and promoted lists required enabling both `DataKinds` and `PolyKinds`. This made sense back in a `TypeInType` world, but not so much now that `TypeInType`'s role has been superseded. Nowadays, `PolyKinds` only controls kind polymorphism, so let's make `DataKinds` the thing that controls the other aspects of `TypeInType`, which include literals, promoted tuples and promoted lists. There are some other things that overzealously required `PolyKinds`, which this patch fixes as well: * Previously, using constraints in kinds (e.g., `data T :: () -> Type`) required `PolyKinds`, despite the fact that this is orthogonal to kind polymorphism. This now requires `DataKinds` instead. * Previously, using kind annotations in kinds (e.g., `data T :: (Type :: Type) -> Type`) required both `KindSignatures` and `PolyKinds`. This doesn't make much sense, so it only requires `KindSignatures` now. Fixes #18831. - - - - - ac300a0d by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Remove "Operator sections" from docs/users_guide/bugs.rst The issue described in that section was fixed by 2b89ca5b850b4097447cc4908cbb0631011ce979 - - - - - bf2411a3 by Vladislav Zavialov at 2020-10-14T12:05:11-04:00 Fix PostfixOperators (#18151) This fixes a regression introduced in 2b89ca5b850b4097447cc4908cbb0631011ce979 See the new T18151x test case. - - - - - e60ae8a3 by Fumiaki Kinoshita at 2020-10-14T18:06:12-04:00 Add -Wnoncanonical-{monad,monoid}-instances to standardWarnings ------------------------- Metric Decrease: T12425 Metric Increase: T17516 ------------------------- - - - - - 15d2340c by Simon Peyton Jones at 2020-10-14T18:06:48-04:00 Fix some missed opportunities for preInlineUnconditionally There are two signficant changes here: * Ticket #18815 showed that we were missing some opportunities for preInlineUnconditionally. The one-line fix is in the code for GHC.Core.Opt.Simplify.Utils.preInlineUnconditionally, which now switches off only for INLINE pragmas. I expanded Note [Stable unfoldings and preInlineUnconditionally] to explain. * When doing this I discovered a way in which preInlineUnconditionally was occasionally /too/ eager. It's all explained in Note [Occurrences in stable unfoldings] in GHC.Core.Opt.OccurAnal, and the one-line change adding markAllMany to occAnalUnfolding. I also got confused about what NoUserInline meant, so I've renamed it to NoUserInlinePrag, and changed its pretty-printing slightly. That led to soem error messate wibbling, and touches quite a few files, but there is no change in functionality. I did a nofib run. As expected, no significant changes. Program Size Allocs ---------------------------------------- sphere -0.0% -0.4% ---------------------------------------- Min -0.0% -0.4% Max -0.0% +0.0% Geometric Mean -0.0% -0.0% I'm allowing a max-residency increase for T10370, which seems very irreproducible. (See comments on !4241.) There is always sampling error for max-residency measurements; and in any case the change shows up on some platforms but not others. Metric Increase: T10370 - - - - - 0c4bfed8 by Ben Gamari at 2020-10-14T18:07:25-04:00 users-guide: Add missing :ghc-flag: directive - - - - - 51c4b851 by Krzysztof Gogolewski at 2020-10-15T04:30:27-04:00 Remove Proxy# argument in Data.Typeable.Internal No longer neccessary - TypeRep is now indexed, there is no ambiguity. Also fix a comment in Evidence.hs, IsLabel no longer takes a Proxy#. - - - - - 809f09e8 by Sylvain Henry at 2020-10-15T04:31:07-04:00 Fix parsing of PIE flags -fPIE and -fno-PIE flags were (un)setting Opt_PIC instead of Opt_PIE. Original commit: 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a - - - - - 3d7db148 by Ben Gamari at 2020-10-15T04:31:42-04:00 testsuite: Add missing #include on <stdlib.h> This otherwise fails on newer Clangs, which warn more aggressively on undeclared symbols. - - - - - 998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00 Add flags for annotating Generic{,1} methods INLINE[1] (#11068) Makes it possible for GHC to optimize away intermediate Generic representation for more types. Metric Increase: T12227 - - - - - 6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00 Extend mAX_TUPLE_SIZE to 64 As well a ctuples and sums. - - - - - d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00 rts: Clean-up whitespace in Interpreter - - - - - cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Use strict Maps in bytecode assembler - - - - - ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Make LocalLabel a newtype - - - - - cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00 compiler/ByteCode: Allow 2^32 local labels This widens LocalLabel to 2^16, avoiding the crash observed in #14334. Closes #14334. - - - - - 1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00 mingw: Extract zst toolchain archives This should have been done when the toolchain was bumped. - - - - - bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00 base: Reintroduce necessary LANGUAGE pragmas These were incorrectly removed in a recent cleanup commit. - - - - - c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Sort metrics by metric type Closes #18838. - - - - - c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00 testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows - - - - - 330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00 rts: Add __mingw_vfprintf to RtsSymbols.c Following the model of the other printf symbols. See Note [Symbols for MinGW's printf]. - - - - - c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Remove allow_failure from Windows jobs - - - - - 9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00 gitlab-ci: Fix Hadrian bindist names - - - - - 07b0db86 by f-a at 2020-10-16T10:14:39-04:00 Clarify Eq documentation #18713 - - - - - aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00 gitlab-ci: Allow doc-tarball job to fail Currently the Hadrian build appears not to package documentation correctly, causing doc-tarball to fail due to the Windows build. - - - - - b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00 gitlab-ci: s/allow_newer/allow_failure Silly mistake on my part. - - - - - 59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00 Skip type family defaults with hs-boot and hsig files Works around #17190, possible resolution for #17224. New design is is according to accepted [GHC Propoal 320]. Instances in signatures currently unconditionally opt into associated family defaults if no explicit instance is given. This is bad for two reasons: 1. It constrains possible instantiations to use the default, rather than possibly define the associated family differently. 2. It breaks compilation as type families are unsupported in signatures. This PR simply turns off the filling in of defaults in those cases. Additionally, it squelches a missing definition warning for hs-boot too that was only squelched for hsig before. The downsides are: 1. There is no way to opt into the default, other than copying its definition. 2. If we fixed type classes in signatures, and wanted instances to have to explicitly *out of* rather than into the default, that would now be a breaking change. The change that is most unambiguously goood is harmonizing the warning squelching between hs-boot or hsig. Maybe they should have the warning (opt out of default) maybe they shouldn't (opt in to default), but surely it should be the same for both. Add hs-boot version of a backpack test regarding class-specified defaults in instances that appear in an hs-boot file. The metrics increase is very slight and makes no sense --- at least no one has figured anything out after this languishing for a while, so I'm just going to accept it. Metric Increase: T10421a [GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320 - - - - - 7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity Arity analysis used to propagate optimistic arity types during fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field, which is like `GHC.Core.Utils.exprIsCheap`, but also considers the current iteration's optimistic arity, for the binder in question only. In #18793, we have seen that this is a problematic design, because it doesn't allow us to look through PAP bindings of that binder. Hence this patch refactors to a more traditional form with an explicit signature environment, in which we record the optimistic `ArityType` of the binder in question (and at the moment is the *only* binder that is recorded in the arity environment). - - - - - 6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00 Arity: Record arity types for non-recursive lets In #18793, we saw a compelling example which requires us to look at non-recursive let-bindings during arity analysis and unleash their arity types at use sites. After the refactoring in the previous patch, the needed change is quite simple and very local to `arityType`'s defn for non-recurisve `Let`. Apart from that, we had to get rid of the second item of `Note [Dealing with bottoms]`, which was entirely a safety measure and hindered optimistic fixed-point iteration. Fixes #18793. The following metric increases are all caused by this commit and a result of the fact that we just do more work now: Metric Increase: T3294 T12545 T12707 - - - - - 451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00 Testsuite: Add dead arity analysis tests We didn't seem to test these old tests at all, judging from their expected output. - - - - - 50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00 When using rts_setInCallCapability, lock incall threads This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked. If the thread is not locked, the thread might end up being scheduled to a different capability. While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used. This commit also adds a test to make sure things stay on the correct capability. - - - - - 0b995759 by DylanZA at 2020-10-17T22:02:50-04:00 Apply suggestion to testsuite/tests/ffi/should_run/all.T - - - - - a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00 Don't get host RTS ways via settings (#18651) To correctly perform a linking hack for Windows we need to link with the RTS GHC is currently using. We used to query the RTS ways via the "settings" file but it is fragile (#18651). The hack hasn't been fixed to take into account all the ways (Tracing) and it makes linking of GHC with another RTS more difficult (we need to link with another RTS and to regenerate the settings file). So this patch uses the ways reported by the RTS itself (GHC.Platform.Ways.hostWays) instead of the "settings" file. - - - - - d858a3ae by Hécate at 2020-10-17T22:04:38-04:00 Linting corrections * Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows * Exclude some modules that are wrongfully reported - - - - - b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00 Implement -Woperator-whitespace (#18834) This patch implements two related warnings: -Woperator-whitespace-ext-conflict warns on uses of infix operators that would be parsed differently were a particular GHC extension enabled -Woperator-whitespace warns on prefix, suffix, and tight infix uses of infix operators Updates submodules: haddock, containers. - - - - - 9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00 Remove pdocPrec pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove it. OutputableP becomes a one-function class which might be better for performance. - - - - - ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00 testsuite: Add test for #18346 This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20. - - - - - 6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00 Minor comments, update linear types docs - Update comments: placeHolderTypeTc no longer exists "another level check problem" was a temporary comment from linear types - Use Mult type synonym (reported in #18676) - Mention multiplicity-polymorphic fields in linear types docs - - - - - 58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00 Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042) The documentation states that when using :add and :load, the `*` prefix forces a module to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been enabled. In that case, the compiled code is always used, regardless of whether the *-form is used. The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If the flag for given module is set, then patch up DynFlags and select compilation backend accordingly. This would require a linear scan of course, but that shouldn't be too costly. - - - - - 59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00 gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR Previously the Hadrian jobs used the `FLAVOUR` environment variable to communicate which flavour `ci.sh` should build whereas `make` used `BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these two. - - - - - ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00 API Annotations: Keep track of unicode for linear arrow notation The linear arrow can be parsed as `%1 ->` or a direct single token unicode equivalent. Make sure that this distinction is captured in the parsed AST by using IsUnicodeSyntax where it appears, and introduce a new API Annotation, AnnMult to represent its location when unicode is not used. Updated haddock submodule - - - - - cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00 testsuite: Mark T12971 as fragile on Windows Due to #17945. - - - - - e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00 Parser regression tests, close #12862 #12446 These issues were fixed by earlier parser changes, most likely related to whitespace-sensitive parsing. - - - - - 711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00 Fix error message location in tcCheckPatSynDecl Ticket #18856 showed that we were failing to set the right location for an error message. Easy to fix, happily. Turns out that this also improves the error location in test T11010, which was bogus before but we had never noticed. - - - - - 730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00 cmm: Add Note reference to ForeignHint - - - - - 9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00 Fix `instance Bounded a => Bounded (Down a)` (#18716) * Flip `minBound` and `maxBound` to respect the change in ordering * Remove awkward `Enum` (and hence `Integral`) instances for `Data.Ord.Down` * Update changelog - - - - - eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00 Version bump: base-4.16 (#18712) Also bumps upper bounds on base in boot libraries (incl. submodules). - - - - - 412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00 winio: simplify logic remove optimization step. - - - - - 4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00 hadrian: Suppress xelatex output unless it fails As noted in #18835, xelatex produces an absurd amount of output, nearly all of which is meaningless. Silence this. Fixes #18835. - - - - - f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00 build system: Clean mingw tarballs Tamar noticed in !4293 that the build systems fail to clean up the mingw tarballs directory (`ghc-tarballs`). Fix this in both the make build system and Hadrian. - - - - - 0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00 Fix two constraint solving problems This patch fixes two problems in the constraint solver. * An actual bug #18555: we were floating out a constraint to eagerly, and that was ultimately fatal. It's explained in Note [Do not float blocked constraints] in GHC.Core.Constraint. This is all very delicate, but it's all going to become irrelevant when we stop floating constraints (#17656). * A major performance infelicity in the flattener. When flattening (ty |> co) we *never* generated Refl, even when there was nothing at all to do. Result: we would gratuitously rewrite the constraint to exactly the same thing, wasting work. Described in #18413, and came up again in #18855. Solution: exploit the special case by calling the new function castCoercionKind1. See Note [castCoercionKind1] in GHC.Core.Coercion - - - - - f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00 ghc.mk: amend 'make sdist' Noticed 'make sdist' failure seen as: ``` "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/ /bin/sh: -c: line 0: syntax error near unexpected token `(' ``` commit 9657f6f34 ("sdist: Include hadrian sources in source distribution") added a new cleanup path without a variable expantion. The change adds variable reference. While at it move directory cleanup to a separate statement. Amends #18794 Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00 Use config.run_ways for multi_compile_and_run tests - - - - - e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00 Api Annotations: Introduce AnnPercent for HsExplicitMult For the case foo :: a %p -> b The location of the '%' is captured, separate from the 'p' - - - - - d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00 gitlab-ci: Bump ci-images Bumps bootstrap compiler to 8.10.1. - - - - - 28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00 DmdAnal: Kill `is_thunk` case in `splitFV` The `splitFV` function implements the highly dubious hack described in `Note [Lazy und unleashable free variables]` in GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only carry strictness info on free variables. Usage info is released through other means, see the Note. It's purely for analysis performance reasons. It turns out that `splitFV` has a quite involved case for thunks that produces slightly different usage signatures and it's not clear why we need it: `splitFV` is only relevant in the LetDown case and the only time we call it on thunks is for top-level or local recursive thunks. Since usage signatures of top-level thunks can only reference other top-level bindings and we completely discard demand info we have on top-level things (see the lack of `setIdDemandInfo` in `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here. For local, recursive thunks, the added benefit of the `is_thunk` test is marginal: We get used-multiple-times in some cases where previously we had used-once if a recursive thunk has multiple call sites. It's very unlikely and not a case to optimise for. So we kill the `is_thunk` case and inline `splitFV` at its call site, exposing `isWeakDmd` from `GHC.Types.Demand` instead. The NoFib summary supports this decision: ``` Min 0.0% -0.0% Max 0.0% +0.0% Geometric Mean -0.0% -0.0% ``` - - - - - 60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00 hadrian: Don't quote metric baseline argument Previously this was quoted inappropriately. - - - - - c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00 API Annotations: put constructors in alphabetical order - - - - - 795908dc by John Ericson at 2020-10-29T03:53:14-04:00 Widen acceptance threshold for T10421a Progress towards #18842. As @sgraf812 points out, widening the window is dangerous until the exponential described in #17658 is fixed. But this test has caused enough misery and is low stakes enough that we and @bgamari think it's worth it in this one case for the time being. - - - - - 0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00 Split GHC.Driver.Types I was working on making DynFlags stateless (#17957), especially by storing loaded plugins into HscEnv instead of DynFlags. It turned out to be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I didn't feel like introducing yet another hs-boot file to break the loop. Additionally I remember that while we introduced the module hierarchy (#13009) we talked about splitting GHC.Driver.Types because it contained various unrelated types and functions, but we never executed. I didn't feel like making GHC.Driver.Types bigger with more unrelated Plugins related types, so finally I bit the bullet and split GHC.Driver.Types. As a consequence this patch moves a lot of things. I've tried to put them into appropriate modules but nothing is set in stone. Several other things moved to avoid loops. * Removed Binary instances from GHC.Utils.Binary for random compiler things * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they import a lot of things that users of GHC.Utils.Binary don't want to depend on. * put everything related to Units/Modules under GHC.Unit: GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.} * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText, etc. * Split GHC.Utils.Error (into GHC.Types.Error) * Finally removed GHC.Driver.Types Note that this patch doesn't put loaded plugins into HscEnv. It's left for another patch. Bump haddock submodule - - - - - 22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00 GC: Avoid data race (#18717, #17964) - - - - - 2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00 Check for large tuples more thoroughly This fixes #18723 by: * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity check to `GHC.Rename.Utils.checkCTupSize` for consistency with `GHC.Rename.Utils.checkTupSize`, and * Using `check(C)TupSize` when checking tuple _types_, in addition to checking names, expressions, and patterns. Note that I put as many of these checks as possible in the typechecker so that GHC can properly distinguish between boxed and constraint tuples. The exception to this rule is checking names, which I perform in the renamer (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and `''(,, ... ,,)` alike in one fell swoop. While I was in town, I also removed the `HsConstraintTuple` and `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally unused. This requires a `haddock` submodule bump. - - - - - 7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00 Remove unnecessary gender from comments/docs While, say, alternating "he" and "she" in sequential writing may be nicer than always using "they", reading code/documentation is almost never sequential. If this small change makes individuals feel more welcome in GHC's codebase, that's a good thing. - - - - - 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - b2fb38bc by Ben Gamari at 2020-10-31T19:51:53-04:00 gitlab-ci: Only deploy GitLab Pages in ghc/ghc> The deployments are quite large and yet are currently only served for the ghc/ghc> project. - - - - - 23 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/common.sh - .gitlab/linters/check-cpp.py - .gitlab/test-metrics.sh - CODEOWNERS - Makefile - README.md - aclocal.m4 - + compiler/.hlint.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Names/TH.hs - compiler/GHC/Builtin/PrimOps.hs - + compiler/GHC/Builtin/RebindableNames.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/Uniques.hs-boot - compiler/GHC/Builtin/Utils.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c1c6a367ce760fe13d07612dbe3d7e88dcf042e...b2fb38bcdbc9dbe3f46e9aa6cff1be04106f93f3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c1c6a367ce760fe13d07612dbe3d7e88dcf042e...b2fb38bcdbc9dbe3f46e9aa6cff1be04106f93f3 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gitlab at gitlab.haskell.org Sat Oct 31 23:55:53 2020 From: gitlab at gitlab.haskell.org (Ben Gamari) Date: Sat, 31 Oct 2020 19:55:53 -0400 Subject: [Git][ghc/ghc][wip/T18857] 14 commits: [skip ci] Fix typo in `callocBytes` haddock. Message-ID: <5f9df9898723a_785eef046c175691@gitlab.haskell.org.mail> Ben Gamari pushed to branch wip/T18857 at Glasgow Haskell Compiler / GHC Commits: 9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00 [skip ci] Fix typo in `callocBytes` haddock. - - - - - 31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00 Split HsConDecl{H98,GADT}Details Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes `InfixCon`. But `InfixCon` is never used for GADT constructors, which results in an awkward unrepresentable state. This removes the unrepresentable state by: * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`, which emphasizes the fact that it is now only used for Haskell98-style data constructors, and * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon` in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails` lacks any way to represent infix constructors. The rest of the patch is refactoring to accommodate the new structure of `HsConDecl{H98,GADT}Details`. Some highlights: * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as there is no way to implement these functions uniformly for all `ConDecl`s. For the most part, their previous call sites now pattern match on the `ConDecl`s directly and do different things for `ConDeclH98`s and `ConDeclGADT`s. I did introduce one new function to make the transition easier: `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`. This is still possible since `RecCon(GADT)`s still use the same representation in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the pattern that `getRecConArgs_maybe` implements is used in several places, I thought it worthwhile to factor it out into its own function. * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were both of type `HsConDeclDetails`. Now, the former is of type `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`, which are distinct types. As a result, I had to rename the `con_args` field in `ConDeclGADT` to `con_g_args` to make it typecheck. A consequence of all this is that the `con_args` field is now partial, so using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock was using `con_args` at the top-level, which caused it to crash at runtime before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1 release notes to advertise this pitfall. Fixes #18844. Bumps the `haddock` submodule. - - - - - 57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00 Make typechecker equality consider visibility in ForAllTys Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix this, `can_eq_nc'` now uses the `sameVis` function to first check if the `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s implementation to match this behavior. For more explanation on the "modulo specificity" part, see the new `Note [ForAllTy and typechecker equality]` in `GHC.Tc.Solver.Canonical`. While I was in town, I fixed some related documentation issues: * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement typechecker equality) from `eqType` (which implements definitional equality, which does not care about the `ArgFlags` of `ForAllTy`s at all). * The User's Guide had some outdated prose on the specified/inferred distinction being different for types and kinds, a holdover from #15079. This is no longer the case on today's GHC, so I removed this prose, added some new prose to take its place, and added a regression test for the programs in #15079. * The User's Guide had some _more_ outdated prose on inferred type variables not being allowed in `default` type signatures for class methods, which is no longer true as of the resolution of #18432. * The related `Note [Deferred Unification]` was being referenced as `Note [Deferred unification]` elsewhere, which made it harder to `grep` for. I decided to change the name of the Note to `Deferred unification` for consistency with the capitalization style used for most other Notes. Fixes #18863. - - - - - a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00 Refactor numeric constant folding rules Avoid the use of global pattern synonyms. 1) I think it's going to be helpful to implement constant folding for other numeric types, especially Natural which doesn't have a wrapping behavior. We'll have to refactor these rules even more so we'd better make them less cryptic. 2) It should also be slightly faster because global pattern synonyms matched operations for every numeric types instead of the current one: e.g., ":**:" pattern was matching multiplication for both Int# and Word# types. As we will probably want to implement constant folding for other numeric types (Int8#, Int16#, etc.), it is more efficient to only match primops for a given type as we do now. - - - - - 730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00 Simplify constant-folding (#18032) See #18032 for the details. * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does more work but that is not needed for constant-folding * Don't export `GHC.Types.Literal.isLitValue_maybe` * Kill `GHC.Types.Literal.isLitValue` which isn't used - - - - - d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00 primops.txt.pp: Move ByteArray# primops to separate file This file will be generated. - - - - - b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00 primops: Generate ByteArray# index/read/write primops Previously these were mostly undocumented and was ripe for potential inconsistencies. - - - - - 08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00 Move loadDecl into IfaceToCore - - - - - cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00 winio: Fix unused variables warnings - - - - - eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00 Add testcase for #816 - - - - - 143b1da0 by Ben Gamari at 2020-10-31T19:55:45-04:00 CmmToLlvm: Declare signature for memcmp Otherwise `opt` fails with: error: use of undefined value '@memcmp$def' Fixes #18857. - - - - - 50617897 by Ben Gamari at 2020-10-31T19:55:45-04:00 gitlab-ci: Run LLVM job on appropriately-labelled MRs Namely, those marked with the ~"LLVM backend" label - - - - - 92e6ecbf by Ben Gamari at 2020-10-31T19:55:45-04:00 gitlab-ci: Run LLVM builds on Debian 10 The current Debian 9 image doesn't provide LLVM 7. - - - - - 801fc156 by Ben Gamari at 2020-10-31T19:55:45-04:00 hadrian: Don't use -fllvm to bootstrap under LLVM flavour Previously Hadrian's LLVM build flavours would use `-fllvm` for all invocations, even those to stage0 GHC. This meant that we needed to keep two LLVM versions around in all of the CI images. Moreover, it differed from the behavior of the old make build system's llvm flavours. Change this to reflect the behavior of the `make` build system, using `-fllvm` only with the stage1 and stage2 compilers. - - - - - 30 changed files: - .gitlab-ci.yml - + compiler/GHC/Builtin/bytearray-ops.txt.pp - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Hs/Decls.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Hs/Type.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Load.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/IfaceToCore.hs-boot - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Utils/Unify.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Types/Literal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e08ea0e232257d1957de9f9fae0bd6f985186f...801fc15669bc0b59cca24078d7f547172224db92 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e08ea0e232257d1957de9f9fae0bd6f985186f...801fc15669bc0b59cca24078d7f547172224db92 You're receiving this email because of your account on gitlab.haskell.org. -------------- next part -------------- An HTML attachment was scrubbed... URL: